📄 opcode.html
字号:
15 NotExists 0 17 1 00 <br>16 Delete 0 1 0 tbl 00 <br>17 Goto 0 14 0 00 <br>18 Close 0 0 0 00 <br>19 Halt 0 0 0 00 <br>20 Transaction 0 1 0 00 <br>21 VerifyCookie 0 1 0 00 <br>22 TableLock -1 2 0 tbl 00 <br>23 Goto 0 2 0 00</tt></blockquote><p>All you have to do is add the <a href="lang_explain.html">EXPLAIN</a> keyword to the front of theSQL statement. But if you use the ".explain" command in the CLI,it will set up the output mode to make the program more easilyviewable.</p><p>Depending on compile-time options, you can put the SQLite virtual machine in a mode where it will trace itsexecution by writing messages to standard output. The non-standardSQL "PRAGMA" comments can be used to turn tracing on and off. Toturn tracing on, enter:</p><blockquote><pre>PRAGMA vdbe_trace=on;</pre></blockquote><p>You can turn tracing back off by entering a similar statement butchanging the value "on" to "off".</p><h3>The Opcodes</h3><p>There are currently 135opcodes defined by the virtual machine.All currently defined opcodes are described in the table below.This table was generated automatically by scanning the source codefrom the file <b>vdbe.c</b>.</p><p><table cellspacing="1" border="1" cellpadding="10"><tr><th>Opcode Name</th><th>Description</th></tr><tr><td valign="top" align="center"><a name="Add"></a><p>Add</p><td><p>Add the value in register P1 to the value in register P2and store the result in register P3.If either input is NULL, the result is NULL.</td></tr><tr><td valign="top" align="center"><a name="AddImm"></a><p>AddImm</p><td><p>Add the constant P2 to the value in register P1.The result is always an integer.</p><p>To force any register to be an integer, just add 0.</td></tr><tr><td valign="top" align="center"><a name="Affinity"></a><p>Affinity</p><td><p>Apply affinities to a range of P2 registers starting with P1.</p><p>P4 is a string that is P2 characters long. The nth character of thestring indicates the column affinity that should be used for the nthmemory cell in the range.</td></tr><tr><td valign="top" align="center"><a name="AggFinal"></a><p>AggFinal</p><td><p>Execute the finalizer function for an aggregate. P1 isthe memory location that is the accumulator for the aggregate.</p><p>P2 is the number of arguments that the step function takes andP4 is a pointer to the FuncDef for this function. The P2argument is not used by this opcode. It is only there to disambiguatefunctions that can take varying numbers of arguments. TheP4 argument is only needed for the degenerate case wherethe step function was not previously called.</td></tr><tr><td valign="top" align="center"><a name="AggStep"></a><p>AggStep</p><td><p>Execute the step function for an aggregate. Thefunction has P5 arguments. P4 is a pointer to the FuncDefstructure that specifies the function. Use registerP3 as the accumulator.</p><p>The P5 arguments are taken from register P2 and itssuccessors.</td></tr><tr><td valign="top" align="center"><a name="And"></a><p>And</p><td><p>Take the logical AND of the values in registers P1 and P2 andwrite the result into register P3.</p><p>If either P1 or P2 is 0 (false) then the result is 0 even ifthe other input is NULL. A NULL and true or two NULLs givea NULL output.</td></tr><tr><td valign="top" align="center"><a name="AutoCommit"></a><p>AutoCommit</p><td><p>Set the database auto-commit flag to P1 (1 or 0). If P2 is true, rollback any currently active btree transactions. If there are any activeVMs (apart from this one), then the COMMIT or ROLLBACK statement fails.</p><p>This instruction causes the VM to halt.</td></tr><tr><td valign="top" align="center"><a name="BitAnd"></a><p>BitAnd</p><td><p>Take the bit-wise AND of the values in register P1 and P2 andstore the result in register P3.If either input is NULL, the result is NULL.</td></tr><tr><td valign="top" align="center"><a name="BitNot"></a><p>BitNot</p><td><p>Interpret the content of register P1 as an integer. Store theones-complement of the P1 value into register P2. If P1 holdsa NULL then store a NULL in P2.</td></tr><tr><td valign="top" align="center"><a name="BitOr"></a><p>BitOr</p><td><p>Take the bit-wise OR of the values in register P1 and P2 andstore the result in register P3.If either input is NULL, the result is NULL.</td></tr><tr><td valign="top" align="center"><a name="Blob"></a><p>Blob</p><td><p>P4 points to a blob of data P1 bytes long. Store thisblob in register P2. This instruction is not coded directlyby the compiler. Instead, the compiler layer specifiesan OP_HexBlob opcode, with the hex string representation ofthe blob as P4. This opcode is transformed to an OP_Blobthe first time it is executed.</td></tr><tr><td valign="top" align="center"><a name="Clear"></a><p>Clear</p><td><p>Delete all contents of the database table or index whose root pagein the database file is given by P1. But, unlike Destroy, do notremove the table or index from the database file.</p><p>The table being clear is in the main database file if P2==0. IfP2==1 then the table to be clear is in the auxiliary database filethat is used to store tables create using CREATE TEMPORARY TABLE.</p><p>If the P3 value is non-zero, then the table refered to must be anintkey table (an SQL table, not an index). In this case the row changecount is incremented by the number of rows in the table being cleared.If P3 is greater than zero, then the value stored in register P3 isalso incremented by the number of rows in the table being cleared.</p><p>See also: Destroy</td></tr><tr><td valign="top" align="center"><a name="Close"></a><p>Close</p><td><p>Close a cursor previously opened as P1. If P1 is notcurrently open, this instruction is a no-op.</td></tr><tr><td valign="top" align="center"><a name="CollSeq"></a><p>CollSeq</p><td><p>P4 is a pointer to a CollSeq struct. If the next call to a user functionor aggregate calls sqlite3GetFuncCollSeq(), this collation sequence willbe returned. This is used by the built-in min(), max() and nullif()functions.</p><p>The interface used by the implementation of the aforementioned functionsto retrieve the collation sequence set by this opcode is not availablepublicly, only to user functions defined in func.c.</td></tr><tr><td valign="top" align="center"><a name="Column"></a><p>Column</p><td><p>Interpret the data that cursor P1 points to as a structure built usingthe MakeRecord instruction. (See the MakeRecord opcode for additionalinformation about the format of the data.) Extract the P2-th columnfrom this record. If there are less that (P2+1)values in the record, extract a NULL.</p><p>The value extracted is stored in register P3.</p><p>If the column contains fewer than P2 fields, then extract a NULL. Or,if the P4 argument is a P4_MEM use the value of the P4 argument asthe result.</td></tr><tr><td valign="top" align="center"><a name="Compare"></a><p>Compare</p><td><p>Compare to vectors of registers in reg(P1)..reg(P1+P3-1) (all thisone "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result ofthe comparison for use by the next OP_Jump instruct.</p><p>P4 is a KeyInfo structure that defines collating sequences and sortorders for the comparison. The permutation applies to registersonly. The KeyInfo elements are used sequentially.</p><p>The comparison is a sort comparison, so NULLs compare equal,NULLs are less than numbers, numbers are less than strings,and strings are less than blobs.</td></tr><tr><td valign="top" align="center"><a name="Concat"></a><p>Concat</p><td><p>Add the text in register P1 onto the end of the text inregister P2 and store the result in register P3.If either the P1 or P2 text are NULL then store NULL in P3.</p><p>P3 = P2 || P1</p><p>It is illegal for P1 and P3 to be the same register. Sometimes,if P3 is the same register as P2, the implementation is ableto avoid a memcpy().</td></tr><tr><td valign="top" align="center"><a name="ContextPop"></a><p>ContextPop</p><td><p>Restore the Vdbe context to the state it was in when contextPush was lastexecuted. The context stores the last insert row id, the last statementchange count, and the current statement change count.</td></tr><tr><td valign="top" align="center"><a name="ContextPush"></a><p>ContextPush</p><td><p>Save the current Vdbe context such that it can be restored by a ContextPopopcode. The context stores the last insert row id, the last statement changecount, and the current statement change count.</td></tr><tr><td valign="top" align="center"><a name="Copy"></a><p>Copy</p><td><p>Make a copy of register P1 into register P2.</p><p>This instruction makes a deep copy of the value. A duplicateis made of any string or blob constant. See also OP_SCopy.</td></tr><tr><td valign="top" align="center"><a name="CreateIndex"></a><p>CreateIndex</p><td><p>Allocate a new index in the main database file if P1==0 or in theauxiliary database file if P1==1 or in an attached database ifP1>1. Write the root page number of the new table intoregister P2.</p><p>See documentation on OP_CreateTable for additional information.</td></tr><tr><td valign="top" align="center"><a name="CreateTable"></a><p>CreateTable</p><td><p>Allocate a new table in the main database file if P1==0 or in theauxiliary database file if P1==1 or in an attached database ifP1>1. Write the root page number of the new table intoregister P2</p><p>The difference between a table and an index is this: A table musthave a 4-byte integer key and can have arbitrary data. An indexhas an arbitrary key but no data.</p><p>See also: CreateIndex</td></tr><tr><td valign="top" align="center"><a name="Delete"></a><p>Delete</p><td><p>Delete the record at which the P1 cursor is currently pointing.</p><p>The cursor will be left pointing at either the next or the previousrecord in the table. If it is left pointing at the next record, thenthe next Next instruction will be a no-op. Hence it is OK to deletea record from within an Next loop.</p><p>If the OPFLAG_NCHANGE flag of P2 is set, then the row change count isincremented (otherwise not).</p><p>P1 must not be pseudo-table. It has to be a real table withmultiple rows.</p><p>If P4 is not NULL, then it is the name of the table that P1 ispointing to. The update hook will be invoked, if it exists.If P4 is not NULL then the P1 cursor must have been positionedusing OP_NotFound prior to invoking this opcode.</td></tr><tr><td valign="top" align="center"><a name="Destroy"></a><p>Destroy</p><td><p>Delete an entire database table or index whose root page in the databasefile is given by P1.</p><p>The table being destroyed is in the main database file if P3==0. IfP3==1 then the table to be clear is in the auxiliary database filethat is used to store tables create using CREATE TEMPORARY TABLE.</p><p>If AUTOVACUUM is enabled then it is possible that another root pagemight be moved into the newly deleted root page in order to keep allroot pages contiguous at the beginning of the database. The formervalue of the root page that moved - its value before the move occurred -is stored in register P2. If no pagemovement was required (because the table being dropped was alreadythe last one in the database) then a zero is stored in register P2.If AUTOVACUUM is disabled then a zero is stored in register P2.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -