Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > cf8bc8abd739a5374958491c4639c43d > files > 33

sqlite-devel-3.3.6-7.i386.rpm

<html><head><title>SQLite Virtual Machine Opcodes</title></head>
<body bgcolor="white" link="#50695f" vlink="#508896">
<table width="100%" border="0">
<tr><td valign="top">
<a href="index.html"><img src="sqlite.gif" border="none"></a></td>
<td width="100%"></td>
<td valign="bottom">
<ul>
<li><a href="http://www.sqlite.org/cvstrac/tktnew">bugs</a></li>
<li><a href="changes.html">changes</a></li>
<li><a href="contrib">contrib</a></li>
<li><a href="download.html#cvs">cvs&nbsp;repository</a></li>
<li><a href="docs.html">documentation</a></li>
</ul>
</td>
<td width="10"></td>
<td valign="bottom">
<ul>
<li><a href="download.html">download</a></li>
<li><a href="faq.html">faq</a></li>
<li><a href="index.html">home</a></li>
<li><a href="support.html">mailing&nbsp;list</a></li>
<li><a href="index.html">news</a></li>
</ul>
</td>
<td width="10"></td>
<td valign="bottom">
<ul>
<li><a href="quickstart.html">quick&nbsp;start</a></li>
<li><a href="support.html">support</a></li>
<li><a href="lang.html">syntax</a></li>
<li><a href="http://www.sqlite.org/cvstrac/timeline">timeline</a></li>
<li><a href="http://www.sqlite.org/cvstrac/wiki">wiki</a></li>
</ul>
</td>
</tr></table>
<table width="100%">
<tr><td bgcolor="#80a796"></td></tr>
</table>

<h2>SQLite Virtual Machine Opcodes</h2>


<h3>Introduction</h3>

<p>In order to execute an SQL statement, the SQLite library first parses
the SQL, analyzes the statement, then generates a short program to execute
the statement.  The program is generated for a "virtual machine" implemented
by the SQLite library.  This document describes the operation of that
virtual machine.</p>

<p>This document is intended as a reference, not a tutorial.
A separate <a href="vdbe.html">Virtual Machine Tutorial</a> is 
available.  If you are looking for a narrative description
of how the virtual machine works, you should read the tutorial
and not this document.  Once you have a basic idea of what the
virtual machine does, you can refer back to this document for
the details on a particular opcode.
Unfortunately, the virtual machine tutorial was written for
SQLite version 1.0.  There are substantial changes in the virtual
machine for version 2.0 and the document has not been updated.
</p>

<p>The source code to the virtual machine is in the <b>vdbe.c</b> source
file.  All of the opcode definitions further down in this document are
contained in comments in the source file.  In fact, the opcode table
in this document
was generated by scanning the <b>vdbe.c</b> source file 
and extracting the necessary information from comments.  So the 
source code comments are really the canonical source of information
about the virtual machine.  When in doubt, refer to the source code.</p>

<p>Each instruction in the virtual machine consists of an opcode and
up to three operands named P1, P2 and P3.  P1 may be an arbitrary
integer.  P2 must be a non-negative integer.  P2 is always the
jump destination in any operation that might cause a jump.
P3 is a null-terminated
string or NULL.  Some operators use all three operands.  Some use
one or two.  Some operators use none of the operands.<p>

<p>The virtual machine begins execution on instruction number 0.
Execution continues until (1) a Halt instruction is seen, or 
(2) the program counter becomes one greater than the address of
last instruction, or (3) there is an execution error.
When the virtual machine halts, all memory
that it allocated is released and all database cursors it may
have had open are closed.  If the execution stopped due to an
error, any pending transactions are terminated and changes made
to the database are rolled back.</p>

<p>The virtual machine also contains an operand stack of unlimited
depth.  Many of the opcodes use operands from the stack.  See the
individual opcode descriptions for details.</p>

<p>The virtual machine can have zero or more cursors.  Each cursor
is a pointer into a single table or index within the database.
There can be multiple cursors pointing at the same index or table.
All cursors operate independently, even cursors pointing to the same
indices or tables.
The only way for the virtual machine to interact with a database
file is through a cursor.
Instructions in the virtual
machine can create a new cursor (Open), read data from a cursor
(Column), advance the cursor to the next entry in the table
(Next) or index (NextIdx), and many other operations.
All cursors are automatically
closed when the virtual machine terminates.</p>

<p>The virtual machine contains an arbitrary number of fixed memory
locations with addresses beginning at zero and growing upward.
Each memory location can hold an arbitrary string.  The memory
cells are typically used to hold the result of a scalar SELECT
that is part of a larger expression.</p>

<p>The virtual machine contains a single sorter.
The sorter is able to accumulate records, sort those records,
then play the records back in sorted order.  The sorter is used
to implement the ORDER BY clause of a SELECT statement.</p>

<p>The virtual machine contains a single "List".
The list stores a list of integers.  The list is used to hold the
rowids for records of a database table that needs to be modified.
The WHERE clause of an UPDATE or DELETE statement scans through
the table and writes the rowid of every record to be modified
into the list.  Then the list is played back and the table is modified
in a separate step.</p>

<p>The virtual machine can contain an arbitrary number of "Sets".
Each set holds an arbitrary number of strings.  Sets are used to
implement the IN operator with a constant right-hand side.</p>

<p>The virtual machine can open a single external file for reading.
This external read file is used to implement the COPY command.</p>

<p>Finally, the virtual machine can have a single set of aggregators.
An aggregator is a device used to implement the GROUP BY clause
of a SELECT.  An aggregator has one or more slots that can hold
values being extracted by the select.  The number of slots is the
same for all aggregators and is defined by the AggReset operation.
At any point in time a single aggregator is current or "has focus".
There are operations to read or write to memory slots of the aggregator
in focus.  There are also operations to change the focus aggregator
and to scan through all aggregators.</p>

<h3>Viewing Programs Generated By SQLite</h3>

<p>Every SQL statement that SQLite interprets results in a program
for the virtual machine.  But if you precede the SQL statement with
the keyword "EXPLAIN" the virtual machine will not execute the
program.  Instead, the instructions of the program will be returned
like a query result.  This feature is useful for debugging and
for learning how the virtual machine operates.</p>

<p>You can use the <b>sqlite</b> command-line tool to see the
instructions generated by an SQL statement.  The following is
an example:</p>
<blockquote><tt>
$&nbsp;<b>sqlite&nbsp;ex1</b><br>
sqlite&gt;&nbsp;<b>.explain</b><br>
sqlite&gt;&nbsp;<b>explain&nbsp;delete&nbsp;from&nbsp;tbl1&nbsp;where&nbsp;two&lt;20;</b><br>
addr&nbsp;&nbsp;opcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>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;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
19&nbsp;&nbsp;&nbsp;&nbsp;ListClose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
20&nbsp;&nbsp;&nbsp;&nbsp;Commit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</tt></blockquote>

<p>All you have to do is add the "EXPLAIN" keyword to the front of the
SQL statement.  But if you use the ".explain" command to <b>sqlite</b>
first, it will set up the output mode to make the program more easily
viewable.</p>

<p>If <b>sqlite</b> has been compiled without the "-DNDEBUG=1" option
(that is, with the NDEBUG preprocessor macro not defined) then you
can put the SQLite virtual machine in a mode where it will trace its
execution by writing messages to standard output.  The non-standard
SQL "PRAGMA" comments can be used to turn tracing on and off.  To
turn tracing on, enter:
</p>

<blockquote><pre>
PRAGMA vdbe_trace=on;
</pre></blockquote>

<p>
You can turn tracing back off by entering a similar statement but
changing the value "on" to "off".</p>

<h3>The Opcodes</h3>

<p>There are currently 130 opcodes defined by
the virtual machine.
All currently defined opcodes are described in the table below.
This table was generated automatically by scanning the source code
from the file <b>vdbe.c</b>.</p>

<p><table cellspacing="1" border="1" cellpadding="10">
<tr><th>Opcode&nbsp;Name</th><th>Description</th></tr>
<tr><td valign="top" align="center">
<a name="AbsValue">AbsValue</a>
<td><p>
Treat the top of the stack as a numeric quantity.  Replace it
with its absolute value. If the top of the stack is NULL
its value is unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="Add">Add</a>
<td><p>
Pop the top two elements from the stack, add them together,
and push the result back onto the stack.  If either element
is a string then it is converted to a double using the atof()
function before the addition.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="AddImm">AddImm</a>
<td><p>
Add the value P1 to whatever is on top of the stack.  The result
is always an integer.
<p>
To force the top of the stack to be an integer, just add 0.</td></tr>
<tr><td valign="top" align="center">
<a name="AggFinal">AggFinal</a>
<td><p>
Execute the finalizer function for an aggregate.  P1 is
the memory location that is the accumulator for the aggregate.
<p>
P2 is the number of arguments that the step function takes and
P3 is a pointer to the FuncDef for this function.  The P2
argument is not used by this opcode.  It is only there to disambiguate
functions that can take varying numbers of arguments.  The
P3 argument is only needed for the degenerate case where
the step function was not previously called.</td></tr>
<tr><td valign="top" align="center">
<a name="AggStep">AggStep</a>
<td><p>
Execute the step function for an aggregate.  The
function has P2 arguments.  P3 is a pointer to the FuncDef
structure that specifies the function.  Use memory location
P1 as the accumulator.
<p>
The P2 arguments are popped from the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="And">And</a>
<td><p>
Pop two values off the stack.  Take the logical AND of the
two values and push the resulting boolean value back onto the
stack.</td></tr>
<tr><td valign="top" align="center">
<a name="AutoCommit">AutoCommit</a>
<td><p>
Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
back any currently active btree transactions. If there are any active
VMs (apart from this one), then the COMMIT or ROLLBACK statement fails.
<p>
This instruction causes the VM to halt.</td></tr>
<tr><td valign="top" align="center">
<a name="BitAnd">BitAnd</a>
<td><p>
Pop the top two elements from the stack.  Convert both elements
to integers.  Push back onto the stack the bit-wise AND of the
two elements.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="BitNot">BitNot</a>
<td><p>
Interpret the top of the stack as an value.  Replace it
with its ones-complement.  If the top of the stack is NULL its
value is unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="BitOr">BitOr</a>
<td><p>
Pop the top two elements from the stack.  Convert both elements
to integers.  Push back onto the stack the bit-wise OR of the
two elements.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Blob">Blob</a>
<td><p>
P3 points to a blob of data P1 bytes long. Push this
value onto the stack. This instruction is not coded directly
by the compiler. Instead, the compiler layer specifies
an OP_HexBlob opcode, with the hex string representation of
the blob as P3. This opcode is transformed to an OP_Blob
the first time it is executed.</td></tr>
<tr><td valign="top" align="center">
<a name="Callback">Callback</a>
<td><p>
The top P1 values on the stack represent a single result row from
a query.  This opcode causes the sqlite3_step() call to terminate
with an SQLITE_ROW return code and it sets up the sqlite3_stmt
structure to provide access to the top P1 values as the result
row.  When the sqlite3_step() function is run again, the top P1
values will be automatically popped from the stack before the next
instruction executes.</td></tr>
<tr><td valign="top" align="center">
<a name="Clear">Clear</a>
<td><p>
Delete all contents of the database table or index whose root page
in the database file is given by P1.  But, unlike Destroy, do not
remove the table or index from the database file.
<p>
The table being clear is in the main database file if P2==0.  If
P2==1 then the table to be clear is in the auxiliary database file
that is used to store tables create using CREATE TEMPORARY TABLE.
<p>
See also: Destroy</td></tr>
<tr><td valign="top" align="center">
<a name="Close">Close</a>
<td><p>
Close a cursor previously opened as P1.  If P1 is not
currently open, this instruction is a no-op.</td></tr>
<tr><td valign="top" align="center">
<a name="CollSeq">CollSeq</a>
<td><p>
P3 is a pointer to a CollSeq struct. If the next call to a user function
or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will
be returned. This is used by the built-in min(), max() and nullif()
functions.
<p>
The interface used by the implementation of the aforementioned functions
to retrieve the collation sequence set by this opcode is not available
publicly, only to user functions defined in func.c.</td></tr>
<tr><td valign="top" align="center">
<a name="Column">Column</a>
<td><p>
Interpret the data that cursor P1 points to as a structure built using
the MakeRecord instruction.  (See the MakeRecord opcode for additional
information about the format of the data.) Push onto the stack the value
of the P2-th column contained in the data. If there are less that (P2+1)
values in the record, push a NULL onto the stack.
<p>
If the KeyAsData opcode has previously executed on this cursor, then the
field might be extracted from the key rather than the data.
<p>
If the column contains fewer than P2 fields, then push a NULL.  Or
if P3 is of type P3_MEM, then push the P3 value.  The P3 value will
be default value for a column that has been added using the ALTER TABLE
ADD COLUMN command.  If P3 is an ordinary string, just push a NULL.
When P3 is a string it is really just a comment describing the value
to be pushed, not a default value.</td></tr>
<tr><td valign="top" align="center">
<a name="Concat">Concat</a>
<td><p>
Look at the first P1+2 elements of the stack.  Append them all
together with the lowest element first.  The original P1+2 elements
are popped from the stack if P2==0 and retained if P2==1.  If
any element of the stack is NULL, then the result is NULL.
<p>
When P1==1, this routine makes a copy of the top stack element
into memory obtained from sqliteMalloc().</td></tr>
<tr><td valign="top" align="center">
<a name="ContextPop">ContextPop</a>
<td><p>
Restore the Vdbe context to the state it was in when contextPush was last
executed. The context stores the last insert row id, the last statement
change count, and the current statement change count.</td></tr>
<tr><td valign="top" align="center">
<a name="ContextPush">ContextPush</a>
<td><p>
Save the current Vdbe context such that it can be restored by a ContextPop
opcode. The context stores the last insert row id, the last statement change
count, and the current statement change count.</td></tr>
<tr><td valign="top" align="center">
<a name="CreateIndex">CreateIndex</a>
<td><p>
Allocate a new index in the main database file if P2==0 or in the
auxiliary database file if P2==1.  Push the page number of the
root page of the new index onto the stack.
<p>
See documentation on OP_CreateTable for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="CreateTable">CreateTable</a>
<td><p>
Allocate a new table in the main database file if P2==0 or in the
auxiliary database file if P2==1.  Push the page number
for the root page of the new table onto the stack.
<p>
The difference between a table and an index is this:  A table must
have a 4-byte integer key and can have arbitrary data.  An index
has an arbitrary key but no data.
<p>
See also: CreateIndex</td></tr>
<tr><td valign="top" align="center">
<a name="Delete">Delete</a>
<td><p>
Delete the record at which the P1 cursor is currently pointing.
<p>
The cursor will be left pointing at either the next or the previous
record in the table. If it is left pointing at the next record, then
the next Next instruction will be a no-op.  Hence it is OK to delete
a record from within an Next loop.
<p>
If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
incremented (otherwise not).
<p>
If P1 is a pseudo-table, then this instruction is a no-op.</td></tr>
<tr><td valign="top" align="center">
<a name="Destroy">Destroy</a>
<td><p>
Delete an entire database table or index whose root page in the database
file is given by P1.
<p>
The table being destroyed is in the main database file if P2==0.  If
P2==1 then the table to be clear is in the auxiliary database file
that is used to store tables create using CREATE TEMPORARY TABLE.
<p>
If AUTOVACUUM is enabled then it is possible that another root page
might be moved into the newly deleted root page in order to keep all
root pages contiguous at the beginning of the database.  The former
value of the root page that moved - its value before the move occurred -
is pushed onto the stack.  If no page movement was required (because
the table being dropped was already the last one in the database) then
a zero is pushed onto the stack.  If AUTOVACUUM is disabled
then a zero is pushed onto the stack.
<p>
See also: Clear</td></tr>
<tr><td valign="top" align="center">
<a name="Distinct">Distinct</a>
<td><p>
Use the top of the stack as a record created using MakeRecord.  P1 is a
cursor on a table that declared as an index.  If that table contains an
entry that matches the top of the stack fall thru.  If the top of the stack
matches no entry in P1 then jump to P2.
<p>
The cursor is left pointing at the matching entry if it exists.  The
record on the top of the stack is not popped.
<p>
This instruction is similar to NotFound except that this operation
does not pop the key from the stack.
<p>
The instruction is used to implement the DISTINCT operator on SELECT
statements.  The P1 table is not a true index but rather a record of
all results that have produced so far.
<p>
See also: Found, NotFound, MoveTo, IsUnique, NotExists</td></tr>
<tr><td valign="top" align="center">
<a name="Divide">Divide</a>
<td><p>
Pop the top two elements from the stack, divide the
first (what was on top of the stack) from the second (the
next on stack)
and push the result back onto the stack.  If either element
is a string then it is converted to a double using the atof()
function before the division.  Division by zero returns NULL.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="DropIndex">DropIndex</a>
<td><p>
Remove the internal (in-memory) data structures that describe
the index named P3 in database P1.  This is called after an index
is dropped in order to keep the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="DropTable">DropTable</a>
<td><p>
Remove the internal (in-memory) data structures that describe
the table named P3 in database P1.  This is called after a table
is dropped in order to keep the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="DropTrigger">DropTrigger</a>
<td><p>
Remove the internal (in-memory) data structures that describe
the trigger named P3 in database P1.  This is called after a trigger
is dropped in order to keep the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="Dup">Dup</a>
<td><p>
A copy of the P1-th element of the stack
is made and pushed onto the top of the stack.
The top of the stack is element 0.  So the
instruction "Dup 0 0 0" will make a copy of the
top of the stack.
<p>
If the content of the P1-th element is a dynamically
allocated string, then a new copy of that string
is made if P2==0.  If P2!=0, then just a pointer
to the string is copied.
<p>
Also see the Pull instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Eq">Eq</a>
<td><p>
Pop the top two elements from the stack.  If they are equal, then
jump to instruction P2.  Otherwise, continue to the next instruction.
<p>
If the 0x100 bit of P1 is true and either operand is NULL then take the
jump.  If the 0x100 bit of P1 is clear then fall thru if either operand
is NULL.
<p>
If the 0x200 bit of P1 is set and either operand is NULL then
both operands are converted to integers prior to comparison.
NULL operands are converted to zero and non-NULL operands are
converted to 1.  Thus, for example, with 0x200 set,  NULL==NULL is true
whereas it would normally be NULL.  Similarly,  NULL==123 is false when
0x200 is set but is NULL when the 0x200 bit of P1 is clear.
<p>
The least significant byte of P1 (mask 0xff) must be an affinity character -
SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
to coerce both values
according to the affinity before the comparison is made. If the byte is
0x00, then numeric affinity is used.
<p>
Once any conversions have taken place, and neither value is NULL,
the values are compared. If both values are blobs, or both are text,
then memcmp() is used to determine the results of the comparison. If
both values are numeric, then a numeric comparison is used. If the
two values are of different types, then they are inequal.
<p>
If P2 is zero, do not jump.  Instead, push an integer 1 onto the
stack if the jump would have been taken, or a 0 if not.  Push a
NULL if either operand was NULL.
<p>
If P3 is not NULL it is a pointer to a collating sequence (a CollSeq
structure) that defines how to compare text.</td></tr>
<tr><td valign="top" align="center">
<a name="Expire">Expire</a>
<td><p>
Cause precompiled statements to become expired. An expired statement
fails with an error code of SQLITE_SCHEMA if it is ever executed
(via sqlite3_step()).
<p>
If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
then only the currently executing statement is affected.</td></tr>
<tr><td valign="top" align="center">
<a name="FifoRead">FifoRead</a>
<td><p>
Attempt to read a single integer from the Fifo
and push it onto the stack.  If the Fifo is empty
push nothing but instead jump to P2.</td></tr>
<tr><td valign="top" align="center">
<a name="FifoWrite">FifoWrite</a>
<td><p>
Write the integer on the top of the stack
into the Fifo.</td></tr>
<tr><td valign="top" align="center">
<a name="ForceInt">ForceInt</a>
<td><p>
Convert the top of the stack into an integer.  If the current top of
the stack is not numeric (meaning that is is a NULL or a string that
does not look like an integer or floating point number) then pop the
stack and jump to P2.  If the top of the stack is numeric then
convert it into the least integer that is greater than or equal to its
current value if P1==0, or to the least integer that is strictly
greater than its current value if P1==1.</td></tr>
<tr><td valign="top" align="center">
<a name="Found">Found</a>
<td><p>
Top of the stack holds a blob constructed by MakeRecord.  P1 is an index.
If an entry that matches the top of the stack exists in P1 then
jump to P2.  If the top of the stack does not match any entry in P1
then fall thru.  The P1 cursor is left pointing at the matching entry
if it exists.  The blob is popped off the top of the stack.
<p>
This instruction is used to implement the IN operator where the
left-hand side is a SELECT statement.  P1 is not a true index but
is instead a temporary index that holds the results of the SELECT
statement.  This instruction just checks to see if the left-hand side
of the IN operator (stored on the top of the stack) exists in the
result of the SELECT statement.
<p>
See also: Distinct, NotFound, MoveTo, IsUnique, NotExists</td></tr>
<tr><td valign="top" align="center">
<a name="Function">Function</a>
<td><p>
Invoke a user function (P3 is a pointer to a Function structure that
defines the function) with P2 arguments taken from the stack.  Pop all
arguments from the stack and push back the result.
<p>
P1 is a 32-bit bitmask indicating whether or not each argument to the
function was determined to be constant at compile time. If the first
argument was constant then bit 0 of P1 is set. This is used to determine
whether meta data associated with a user function argument using the
sqlite3_set_auxdata() API may be safely retained until the next
invocation of this opcode.
<p>
See also: AggStep and AggFinal</td></tr>
<tr><td valign="top" align="center">
<a name="Ge">Ge</a>
<td><p>
This works just like the Eq opcode except that the jump is taken if
the 2nd element down on the stack is greater than or equal to the
top of the stack.  See the Eq opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="Gosub">Gosub</a>
<td><p>
Push the current address plus 1 onto the return address stack
and then jump to address P2.
<p>
The return address stack is of limited depth.  If too many
OP_Gosub operations occur without intervening OP_Returns, then
the return address stack will fill up and processing will abort
with a fatal error.</td></tr>
<tr><td valign="top" align="center">
<a name="Goto">Goto</a>
<td><p>
An unconditional jump to address P2.
The next instruction executed will be
the one at index P2 from the beginning of
the program.</td></tr>
<tr><td valign="top" align="center">
<a name="Gt">Gt</a>
<td><p>
This works just like the Eq opcode except that the jump is taken if
the 2nd element down on the stack is greater than the top of the stack.
See the Eq opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="Halt">Halt</a>
<td><p>
Exit immediately.  All open cursors, Fifos, etc are closed
automatically.
<p>
P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),
or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).
For errors, it can be some other value.  If P1!=0 then P2 will determine
whether or not to rollback the current transaction.  Do not rollback
if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,
then back out all changes that have occurred during this execution of the
VDBE, but do not rollback the transaction.
<p>
If P3 is not null then it is an error message string.
<p>
There is an implied "Halt 0 0 0" instruction inserted at the very end of
every program.  So a jump past the last instruction of the program
is the same as executing Halt.</td></tr>
<tr><td valign="top" align="center">
<a name="HexBlob">HexBlob</a>
<td><p>
P3 is an UTF-8 SQL hex encoding of a blob. The blob is pushed onto the
vdbe stack.
<p>
The first time this instruction executes, in transforms itself into a
'Blob' opcode with a binary blob as P3.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxDelete">IdxDelete</a>
<td><p>
The top of the stack is an index key built using the either the
MakeIdxRec or MakeRecord opcodes.
This opcode removes that entry from the index.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxGE">IdxGE</a>
<td><p>
The top of the stack is an index entry that omits the ROWID.  Compare
the top of stack against the index that P1 is currently pointing to.
Ignore the ROWID on the P1 index.
<p>
If the P1 index entry is greater than or equal to the top of the stack
then jump to P2.  Otherwise fall through to the next instruction.
In either case, the stack is popped once.
<p>
If P3 is the "+" string (or any other non-NULL string) then the
index taken from the top of the stack is temporarily increased by
an epsilon prior to the comparison.  This make the opcode work
like IdxGT except that if the key from the stack is a prefix of
the key in the cursor, the result is false whereas it would be
true with IdxGT.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxGT">IdxGT</a>
<td><p>
The top of the stack is an index entry that omits the ROWID.  Compare
the top of stack against the index that P1 is currently pointing to.
Ignore the ROWID on the P1 index.
<p>
The top of the stack might have fewer columns that P1.
<p>
If the P1 index entry is greater than the top of the stack
then jump to P2.  Otherwise fall through to the next instruction.
In either case, the stack is popped once.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxInsert">IdxInsert</a>
<td><p>
The top of the stack holds a SQL index key made using either the
MakeIdxRec or MakeRecord instructions.  This opcode writes that key
into the index P1.  Data for the entry is nil.
<p>
This instruction only works for indices.  The equivalent instruction
for tables is OP_Insert.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxIsNull">IdxIsNull</a>
<td><p>
The top of the stack contains an index entry such as might be generated
by the MakeIdxRec opcode.  This routine looks at the first P1 fields of
that key.  If any of the first P1 fields are NULL, then a jump is made
to address P2.  Otherwise we fall straight through.
<p>
The index entry is always popped from the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxLT">IdxLT</a>
<td><p>
The top of the stack is an index entry that omits the ROWID.  Compare
the top of stack against the index that P1 is currently pointing to.
Ignore the ROWID on the P1 index.
<p>
If the P1 index entry is less than  the top of the stack
then jump to P2.  Otherwise fall through to the next instruction.
In either case, the stack is popped once.
<p>
If P3 is the "+" string (or any other non-NULL string) then the
index taken from the top of the stack is temporarily increased by
an epsilon prior to the comparison.  This makes the opcode work
like IdxLE.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxRowid">IdxRowid</a>
<td><p>
Push onto the stack an integer which is the last entry in the record at
the end of the index key pointed to by cursor P1.  This integer should be
the rowid of the table entry to which this index entry points.
<p>
See also: Rowid, MakeIdxRec.</td></tr>
<tr><td valign="top" align="center">
<a name="If">If</a>
<td><p>
Pop a single boolean from the stack.  If the boolean popped is
true, then jump to p2.  Otherwise continue to the next instruction.
An integer is false if zero and true otherwise.  A string is
false if it has zero length and true otherwise.
<p>
If the value popped of the stack is NULL, then take the jump if P1
is true and fall through if P1 is false.</td></tr>
<tr><td valign="top" align="center">
<a name="IfMemNeg">IfMemNeg</a>
<td><p>
If the value of memory cell P1 is less than zero, jump to P2.
<p>
It is illegal to use this instruction on a memory cell that does
not contain an integer.  An assertion fault will result if you try.</td></tr>
<tr><td valign="top" align="center">
<a name="IfMemPos">IfMemPos</a>
<td><p>
If the value of memory cell P1 is 1 or greater, jump to P2.
<p>
It is illegal to use this instruction on a memory cell that does
not contain an integer.  An assertion fault will result if you try.</td></tr>
<tr><td valign="top" align="center">
<a name="IfMemZero">IfMemZero</a>
<td><p>
If the value of memory cell P1 is exactly 0, jump to P2.
<p>
It is illegal to use this instruction on a memory cell that does
not contain an integer.  An assertion fault will result if you try.</td></tr>
<tr><td valign="top" align="center">
<a name="IfNot">IfNot</a>
<td><p>
Pop a single boolean from the stack.  If the boolean popped is
false, then jump to p2.  Otherwise continue to the next instruction.
An integer is false if zero and true otherwise.  A string is
false if it has zero length and true otherwise.
<p>
If the value popped of the stack is NULL, then take the jump if P1
is true and fall through if P1 is false.</td></tr>
<tr><td valign="top" align="center">
<a name="Insert">Insert</a>
<td><p>
Write an entry into the table of cursor P1.  A new entry is
created if it doesn't already exist or the data for an existing
entry is overwritten.  The data is the value on the top of the
stack.  The key is the next value down on the stack.  The key must
be an integer.  The stack is popped twice by this instruction.
<p>
If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
incremented (otherwise not).  If the OPFLAG_LASTROWID flag of P2 is set,
then rowid is stored for subsequent return by the
sqlite3_last_insert_rowid() function (otherwise it's unmodified).
<p>
This instruction only works on tables.  The equivalent instruction
for indices is OP_IdxInsert.</td></tr>
<tr><td valign="top" align="center">
<a name="Int64">Int64</a>
<td><p>
P3 is a string representation of an integer.  Convert that integer
to a 64-bit value and push it onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="Integer">Integer</a>
<td><p>
The 32-bit integer value P1 is pushed onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="IntegrityCk">IntegrityCk</a>
<td><p>
Do an analysis of the currently open database.  Push onto the
stack the text of an error message describing any problems.
If there are no errors, push a "ok" onto the stack.
<p>
The root page numbers of all tables in the database are integer
values on the stack.  This opcode pulls as many integers as it
can off of the stack and uses those numbers as the root pages.
<p>
If P2 is not zero, the check is done on the auxiliary database
file, not the main database file.
<p>
This opcode is used for testing purposes only.</td></tr>
<tr><td valign="top" align="center">
<a name="IsNull">IsNull</a>
<td><p>
If any of the top abs(P1) values on the stack are NULL, then jump
to P2.  Pop the stack P1 times if P1&gt;0.   If P1&lt;0 leave the stack
unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="IsUnique">IsUnique</a>
<td><p>
The top of the stack is an integer record number.  Call this
record number R.  The next on the stack is an index key created
using MakeIdxRec.  Call it K.  This instruction pops R from the
stack but it leaves K unchanged.
<p>
P1 is an index.  So it has no data and its key consists of a
record generated by OP_MakeRecord where the last field is the
rowid of the entry that the index refers to.
<p>
This instruction asks if there is an entry in P1 where the
fields matches K but the rowid is different from R.
If there is no such entry, then there is an immediate
jump to P2.  If any entry does exist where the index string
matches K but the record number is not R, then the record
number for that entry is pushed onto the stack and control
falls through to the next instruction.
<p>
See also: Distinct, NotFound, NotExists, Found</td></tr>
<tr><td valign="top" align="center">
<a name="Last">Last</a>
<td><p>
The next use of the Rowid or Column or Next instruction for P1
will refer to the last entry in the database table or index.
If the table or index is empty and P2&gt;0, then jump immediately to P2.
If P2 is 0 or if the table or index is not empty, fall through
to the following instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Le">Le</a>
<td><p>
This works just like the Eq opcode except that the jump is taken if
the 2nd element down on the stack is less than or equal to the
top of the stack.  See the Eq opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="LoadAnalysis">LoadAnalysis</a>
<td><p>
Read the sqlite_stat1 table for database P1 and load the content
of that table into the internal index hash table.  This will cause
the analysis to be used when preparing all subsequent queries.</td></tr>
<tr><td valign="top" align="center">
<a name="Lt">Lt</a>
<td><p>
This works just like the Eq opcode except that the jump is taken if
the 2nd element down on the stack is less than the top of the stack.
See the Eq opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="MakeIdxRec">MakeIdxRec</a>
<td><p>
This opcode works just OP_MakeRecord except that it reads an extra
integer from the stack (thus reading a total of abs(P1+1) entries)
and appends that extra integer to the end of the record as a varint.
This results in an index key.</td></tr>
<tr><td valign="top" align="center">
<a name="MakeRecord">MakeRecord</a>
<td><p>
Convert the top abs(P1) entries of the stack into a single entry
suitable for use as a data record in a database table or as a key
in an index.  The details of the format are irrelavant as long as
the OP_Column opcode can decode the record later and as long as the
sqlite3VdbeRecordCompare function will correctly compare two encoded
records.  Refer to source code comments for the details of the record
format.
<p>
The original stack entries are popped from the stack if P1&gt;0 but
remain on the stack if P1&lt;0.
<p>
If P2 is not zero and one or more of the entries are NULL, then jump
to the address given by P2.  This feature can be used to skip a
uniqueness test on indices.
<p>
P3 may be a string that is P1 characters long.  The nth character of the
string indicates the column affinity that should be used for the nth
field of the index key (i.e. the first character of P3 corresponds to the
lowest element on the stack).
<p>
The mapping from character to affinity is given by the SQLITE_AFF_
macros defined in sqliteInt.h.
<p>
If P3 is NULL then all index fields have the affinity NONE.
<p>
See also OP_MakeIdxRec</td></tr>
<tr><td valign="top" align="center">
<a name="MemIncr">MemIncr</a>
<td><p>
Increment the integer valued memory cell P2 by the value in P1.
<p>
It is illegal to use this instruction on a memory cell that does
not contain an integer.  An assertion fault will result if you try.</td></tr>
<tr><td valign="top" align="center">
<a name="MemInt">MemInt</a>
<td><p>
Store the integer value P1 in memory cell P2.</td></tr>
<tr><td valign="top" align="center">
<a name="MemLoad">MemLoad</a>
<td><p>
Push a copy of the value in memory location P1 onto the stack.
<p>
If the value is a string, then the value pushed is a pointer to
the string that is stored in the memory location.  If the memory
location is subsequently changed (using OP_MemStore) then the
value pushed onto the stack will change too.</td></tr>
<tr><td valign="top" align="center">
<a name="MemMax">MemMax</a>
<td><p>
Set the value of memory cell P1 to the maximum of its current value
and the value on the top of the stack.  The stack is unchanged.
<p>
This instruction throws an error if the memory cell is not initially
an integer.</td></tr>
<tr><td valign="top" align="center">
<a name="MemMove">MemMove</a>
<td><p>
Move the content of memory cell P2 over to memory cell P1.
Any prior content of P1 is erased.  Memory cell P2 is left
containing a NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="MemNull">MemNull</a>
<td><p>
Store a NULL in memory cell P1</td></tr>
<tr><td valign="top" align="center">
<a name="MemStore">MemStore</a>
<td><p>
Write the top of the stack into memory location P1.
P1 should be a small integer since space is allocated
for all memory locations between 0 and P1 inclusive.
<p>
After the data is stored in the memory location, the
stack is popped once if P2 is 1.  If P2 is zero, then
the original data remains on the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="MoveGe">MoveGe</a>
<td><p>
Pop the top of the stack and use its value as a key.  Reposition
cursor P1 so that it points to the smallest entry that is greater
than or equal to the key that was popped ffrom the stack.
If there are no records greater than or equal to the key and P2
is not zero, then jump to P2.
<p>
See also: Found, NotFound, Distinct, MoveLt, MoveGt, MoveLe</td></tr>
<tr><td valign="top" align="center">
<a name="MoveGt">MoveGt</a>
<td><p>
Pop the top of the stack and use its value as a key.  Reposition
cursor P1 so that it points to the smallest entry that is greater
than the key from the stack.
If there are no records greater than the key and P2 is not zero,
then jump to P2.
<p>
See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe</td></tr>
<tr><td valign="top" align="center">
<a name="MoveLe">MoveLe</a>
<td><p>
Pop the top of the stack and use its value as a key.  Reposition
cursor P1 so that it points to the largest entry that is less than
or equal to the key that was popped from the stack.
If there are no records less than or eqal to the key and P2 is not zero,
then jump to P2.
<p>
See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt</td></tr>
<tr><td valign="top" align="center">
<a name="MoveLt">MoveLt</a>
<td><p>
Pop the top of the stack and use its value as a key.  Reposition
cursor P1 so that it points to the largest entry that is less
than the key from the stack.
If there are no records less than the key and P2 is not zero,
then jump to P2.
<p>
See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe</td></tr>
<tr><td valign="top" align="center">
<a name="Multiply">Multiply</a>
<td><p>
Pop the top two elements from the stack, multiply them together,
and push the result back onto the stack.  If either element
is a string then it is converted to a double using the atof()
function before the multiplication.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="MustBeInt">MustBeInt</a>
<td><p>
Force the top of the stack to be an integer.  If the top of the
stack is not an integer and cannot be converted into an integer
with out data loss, then jump immediately to P2, or if P2==0
raise an SQLITE_MISMATCH exception.
<p>
If the top of the stack is not an integer and P2 is not zero and
P1 is 1, then the stack is popped.  In all other cases, the depth
of the stack is unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="Ne">Ne</a>
<td><p>
This works just like the Eq opcode except that the jump is taken if
the operands from the stack are not equal.  See the Eq opcode for
additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="Negative">Negative</a>
<td><p>
Treat the top of the stack as a numeric quantity.  Replace it
with its additive inverse.  If the top of the stack is NULL
its value is unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="NewRowid">NewRowid</a>
<td><p>
Get a new integer record number (a.k.a "rowid") used as the key to a table.
The record number is not previously used as a key in the database
table that cursor P1 points to.  The new record number is pushed
onto the stack.
<p>
If P2&gt;0 then P2 is a memory cell that holds the largest previously
generated record number.  No new record numbers are allowed to be less
than this value.  When this value reaches its maximum, a SQLITE_FULL
error is generated.  The P2 memory cell is updated with the generated
record number.  This P2 mechanism is used to help implement the
AUTOINCREMENT feature.</td></tr>
<tr><td valign="top" align="center">
<a name="Next">Next</a>
<td><p>
Advance cursor P1 so that it points to the next key/data pair in its
table or index.  If there are no more key/value pairs then fall through
to the following instruction.  But if the cursor advance was successful,
jump immediately to P2.
<p>
See also: Prev</td></tr>
<tr><td valign="top" align="center">
<a name="Noop">Noop</a>
<td><p>
Do nothing.  This instruction is often useful as a jump
destination.</td></tr>
<tr><td valign="top" align="center">
<a name="Not">Not</a>
<td><p>
Interpret the top of the stack as a boolean value.  Replace it
with its complement.  If the top of the stack is NULL its value
is unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="NotExists">NotExists</a>
<td><p>
Use the top of the stack as a integer key.  If a record with that key
does not exist in table of P1, then jump to P2.  If the record
does exist, then fall thru.  The cursor is left pointing to the
record if it exists.  The integer key is popped from the stack.
<p>
The difference between this operation and NotFound is that this
operation assumes the key is an integer and that P1 is a table whereas
NotFound assumes key is a blob constructed from MakeRecord and
P1 is an index.
<p>
See also: Distinct, Found, MoveTo, NotFound, IsUnique</td></tr>
<tr><td valign="top" align="center">
<a name="NotFound">NotFound</a>
<td><p>
The top of the stack holds a blob constructed by MakeRecord.  P1 is
an index.  If no entry exists in P1 that matches the blob then jump
to P1.  If an entry does existing, fall through.  The cursor is left
pointing to the entry that matches.  The blob is popped from the stack.
<p>
The difference between this operation and Distinct is that
Distinct does not pop the key from the stack.
<p>
See also: Distinct, Found, MoveTo, NotExists, IsUnique</td></tr>
<tr><td valign="top" align="center">
<a name="NotNull">NotNull</a>
<td><p>
Jump to P2 if the top P1 values on the stack are all not NULL.  Pop the
stack if P1 times if P1 is greater than zero.  If P1 is less than
zero then leave the stack unchanged.</td></tr>
<tr><td valign="top" align="center">
<a name="Null">Null</a>
<td><p>
Push a NULL onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="NullRow">NullRow</a>
<td><p>
Move the cursor P1 to a null row.  Any OP_Column operations
that occur while the cursor is on the null row will always push
a NULL onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenPseudo">OpenPseudo</a>
<td><p>
Open a new cursor that points to a fake table that contains a single
row of data.  Any attempt to write a second row of data causes the
first row to be deleted.  All data is deleted when the cursor is
closed.
<p>
A pseudo-table created by this opcode is useful for holding the
NEW or OLD tables in a trigger.  Also used to hold the a single
row output from the sorter so that the row can be decomposed into
individual columns using the OP_Column opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenRead">OpenRead</a>
<td><p>
Open a read-only cursor for the database table whose root page is
P2 in a database file.  The database file is determined by an
integer from the top of the stack.  0 means the main database and
1 means the database used for temporary tables.  Give the new
cursor an identifier of P1.  The P1 values need not be contiguous
but all P1 values should be small integers.  It is an error for
P1 to be negative.
<p>
If P2==0 then take the root page number from the next of the stack.
<p>
There will be a read lock on the database whenever there is an
open cursor.  If the database was unlocked prior to this instruction
then a read lock is acquired as part of this instruction.  A read
lock allows other processes to read the database but prohibits
any other process from modifying the database.  The read lock is
released when all cursors are closed.  If this instruction attempts
to get a read lock but fails, the script terminates with an
SQLITE_BUSY error code.
<p>
The P3 value is a pointer to a KeyInfo structure that defines the
content and collating sequence of indices.  P3 is NULL for cursors
that are not pointing to indices.
<p>
See also OpenWrite.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenVirtual">OpenVirtual</a>
<td><p>
Open a new cursor P1 to a transient or virtual table.
The cursor is always opened read/write even if
the main database is read-only.  The transient or virtual
table is deleted automatically when the cursor is closed.
<p>
P2 is the number of columns in the virtual table.
The cursor points to a BTree table if P3==0 and to a BTree index
if P3 is not 0.  If P3 is not NULL, it points to a KeyInfo structure
that defines the format of keys in the index.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenWrite">OpenWrite</a>
<td><p>
Open a read/write cursor named P1 on the table or index whose root
page is P2.  If P2==0 then take the root page number from the stack.
<p>
The P3 value is a pointer to a KeyInfo structure that defines the
content and collating sequence of indices.  P3 is NULL for cursors
that are not pointing to indices.
<p>
This instruction works just like OpenRead except that it opens the cursor
in read/write mode.  For a given table, there can be one or more read-only
cursors or a single read/write cursor but not both.
<p>
See also OpenRead.</td></tr>
<tr><td valign="top" align="center">
<a name="Or">Or</a>
<td><p>
Pop two values off the stack.  Take the logical OR of the
two values and push the resulting boolean value back onto the
stack.</td></tr>
<tr><td valign="top" align="center">
<a name="ParseSchema">ParseSchema</a>
<td><p>
Read and parse all entries from the SQLITE_MASTER table of database P1
that match the WHERE clause P3.
<p>
This opcode invokes the parser to create a new virtual machine,
then runs the new virtual machine.  It is thus a reentrant opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="Pop">Pop</a>
<td><p>
P1 elements are popped off of the top of stack and discarded.</td></tr>
<tr><td valign="top" align="center">
<a name="Prev">Prev</a>
<td><p>
Back up cursor P1 so that it points to the previous key/data pair in its
table or index.  If there is no previous key/value pairs then fall through
to the following instruction.  But if the cursor backup was successful,
jump immediately to P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Pull">Pull</a>
<td><p>
The P1-th element is removed from its current location on
the stack and pushed back on top of the stack.  The
top of the stack is element 0, so "Pull 0 0 0" is
a no-op.  "Pull 1 0 0" swaps the top two elements of
the stack.
<p>
See also the Dup instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Push">Push</a>
<td><p>
Overwrite the value of the P1-th element down on the
stack (P1==0 is the top of the stack) with the value
of the top of the stack.  Then pop the top of the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="ReadCookie">ReadCookie</a>
<td><p>
Read cookie number P2 from database P1 and push it onto the stack.
P2==0 is the schema version.  P2==1 is the database format.
P2==2 is the recommended pager cache size, and so forth.  P1==0 is
the main database file and P1==1 is the database file used to store
temporary tables.
<p>
There must be a read-lock on the database (either a transaction
must be started or there must be an open cursor) before
executing this instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Real">Real</a>
<td><p>
The string value P3 is converted to a real and pushed on to the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="RealAffinity">RealAffinity</a>
<td><p>
If the top of the stack is an integer, convert it to a real value.
<p>
This opcode is used when extracting information from a column that
has REAL affinity.  Such column values may still be stored as
integers, for space efficiency, but after extraction we want them
to have only a real value.</td></tr>
<tr><td valign="top" align="center">
<a name="Remainder">Remainder</a>
<td><p>
Pop the top two elements from the stack, divide the
first (what was on top of the stack) from the second (the
next on stack)
and push the remainder after division onto the stack.  If either element
is a string then it is converted to a double using the atof()
function before the division.  Division by zero returns NULL.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ResetCount">ResetCount</a>
<td><p>
This opcode resets the VMs internal change counter to 0. If P1 is true,
then the value of the change counter is copied to the database handle
change counter (returned by subsequent calls to sqlite3_changes())
before it is reset. This is used by trigger programs.</td></tr>
<tr><td valign="top" align="center">
<a name="Return">Return</a>
<td><p>
Jump immediately to the next instruction after the last unreturned
OP_Gosub.  If an OP_Return has occurred for all OP_Gosubs, then
processing aborts with a fatal error.</td></tr>
<tr><td valign="top" align="center">
<a name="Rewind">Rewind</a>
<td><p>
The next use of the Rowid or Column or Next instruction for P1
will refer to the first entry in the database table or index.
If the table or index is empty and P2&gt;0, then jump immediately to P2.
If P2 is 0 or if the table or index is not empty, fall through
to the following instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="RowData">RowData</a>
<td><p>
Push onto the stack the complete row data for cursor P1.
There is no interpretation of the data.  It is just copied
onto the stack exactly as it is found in the database file.
<p>
If the cursor is not pointing to a valid row, a NULL is pushed
onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="Rowid">Rowid</a>
<td><p>
Push onto the stack an integer which is the key of the table entry that
P1 is currently point to.</td></tr>
<tr><td valign="top" align="center">
<a name="RowKey">RowKey</a>
<td><p>
Push onto the stack the complete row key for cursor P1.
There is no interpretation of the key.  It is just copied
onto the stack exactly as it is found in the database file.
<p>
If the cursor is not pointing to a valid row, a NULL is pushed
onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="Sequence">Sequence</a>
<td><p>
Push an integer onto the stack which is the next available
sequence number for cursor P1.  The sequence number on the
cursor is incremented after the push.</td></tr>
<tr><td valign="top" align="center">
<a name="SetCookie">SetCookie</a>
<td><p>
Write the top of the stack into cookie number P2 of database P1.
P2==0 is the schema version.  P2==1 is the database format.
P2==2 is the recommended pager cache size, and so forth.  P1==0 is
the main database file and P1==1 is the database file used to store
temporary tables.
<p>
A transaction must be started before executing this opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="SetNumColumns">SetNumColumns</a>
<td><p>
Before the OP_Column opcode can be executed on a cursor, this
opcode must be called to set the number of fields in the table.
<p>
This opcode sets the number of columns for cursor P1 to P2.
<p>
If OP_KeyAsData is to be applied to cursor P1, it must be executed
before this op-code.</td></tr>
<tr><td valign="top" align="center">
<a name="ShiftLeft">ShiftLeft</a>
<td><p>
Pop the top two elements from the stack.  Convert both elements
to integers.  Push back onto the stack the second element shifted
left by N bits where N is the top element on the stack.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ShiftRight">ShiftRight</a>
<td><p>
Pop the top two elements from the stack.  Convert both elements
to integers.  Push back onto the stack the second element shifted
right by N bits where N is the top element on the stack.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Sort">Sort</a>
<td><p>
This opcode does exactly the same thing as OP_Rewind except that
it increments an undocumented global variable used for testing.
<p>
Sorting is accomplished by writing records into a sorting index,
then rewinding that index and playing it back from beginning to
end.  We use the OP_Sort opcode instead of OP_Rewind to do the
rewinding so that the global variable will be incremented and
regression tests can determine whether or not the optimizer is
correctly optimizing out sorts.</td></tr>
<tr><td valign="top" align="center">
<a name="Statement">Statement</a>
<td><p>
Begin an individual statement transaction which is part of a larger
BEGIN..COMMIT transaction.  This is needed so that the statement
can be rolled back after an error without having to roll back the
entire transaction.  The statement transaction will automatically
commit when the VDBE halts.
<p>
The statement is begun on the database file with index P1.  The main
database file has an index of 0 and the file used for temporary tables
has an index of 1.</td></tr>
<tr><td valign="top" align="center">
<a name="String">String</a>
<td><p>
The string value P3 of length P1 (bytes) is pushed onto the stack.</td></tr>
<tr><td valign="top" align="center">
<a name="String8">String8</a>
<td><p>
P3 points to a nul terminated UTF-8 string. This opcode is transformed
into an OP_String before it is executed for the first time.</td></tr>
<tr><td valign="top" align="center">
<a name="Subtract">Subtract</a>
<td><p>
Pop the top two elements from the stack, subtract the
first (what was on top of the stack) from the second (the
next on stack)
and push the result back onto the stack.  If either element
is a string then it is converted to a double using the atof()
function before the subtraction.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="TableLock">TableLock</a>
<td><p>
Obtain a lock on a particular table. This instruction is only used when
the shared-cache feature is enabled.
<p>
If P1 is not negative, then it is the index of the database
in sqlite3.aDb[] and a read-lock is required. If P1 is negative, a
write-lock is required. In this case the index of the database is the
absolute value of P1 minus one (iDb = abs(P1) - 1;) and a write-lock is
required.
<p>
P2 contains the root-page of the table to lock.
<p>
P3 contains a pointer to the name of the table being locked. This is only
used to generate an error message if the lock cannot be obtained.</td></tr>
<tr><td valign="top" align="center">
<a name="ToBlob">ToBlob</a>
<td><p>
Force the value on the top of the stack to be a BLOB.
If the value is numeric, convert it to a string first.
Strings are simply reinterpreted as blobs with no change
to the underlying data.
<p>
A NULL value is not changed by this routine.  It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ToInt">ToInt</a>
<td><p>
Force the value on the top of the stack to be an integer.  If
The value is currently a real number, drop its fractional part.
If the value is text or blob, try to convert it to an integer using the
equivalent of atoi() and store 0 if no such conversion is possible.
<p>
A NULL value is not changed by this routine.  It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ToNumeric">ToNumeric</a>
<td><p>
Force the value on the top of the stack to be numeric (either an
integer or a floating-point number.)
If the value is text or blob, try to convert it to an using the
equivalent of atoi() or atof() and store 0 if no such conversion
is possible.
<p>
A NULL value is not changed by this routine.  It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ToReal">ToReal</a>
<td><p>
Force the value on the top of the stack to be a floating point number.
If The value is currently an integer, convert it.
If the value is text or blob, try to convert it to an integer using the
equivalent of atoi() and store 0 if no such conversion is possible.
<p>
A NULL value is not changed by this routine.  It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ToText">ToText</a>
<td><p>
Force the value on the top of the stack to be text.
If the value is numeric, convert it to a string using the
equivalent of printf().  Blob values are unchanged and
are afterwards simply interpreted as text.
<p>
A NULL value is not changed by this routine.  It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Transaction">Transaction</a>
<td><p>
Begin a transaction.  The transaction ends when a Commit or Rollback
opcode is encountered.  Depending on the ON CONFLICT setting, the
transaction might also be rolled back if an error is encountered.
<p>
P1 is the index of the database file on which the transaction is
started.  Index 0 is the main database file and index 1 is the
file used for temporary tables.
<p>
If P2 is non-zero, then a write-transaction is started.  A RESERVED lock is
obtained on the database file when a write-transaction is started.  No
other process can start another write transaction while this transaction is
underway.  Starting a write transaction also creates a rollback journal. A
write transaction must be started before any changes can be made to the
database.  If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
on the file.
<p>
If P2 is zero, then a read-lock is obtained on the database file.</td></tr>
<tr><td valign="top" align="center">
<a name="Vacuum">Vacuum</a>
<td><p>
Vacuum the entire database.  This opcode will cause other virtual
machines to be created and run.  It may not be called from within
a transaction.</td></tr>
<tr><td valign="top" align="center">
<a name="Variable">Variable</a>
<td><p>
Push the value of variable P1 onto the stack.  A variable is
an unknown in the original SQL string as handed to sqlite3_compile().
Any occurance of the '?' character in the original SQL is considered
a variable.  Variables in the SQL string are number from left to
right beginning with 1.  The values of variables are set using the
sqlite3_bind() API.</td></tr>
<tr><td valign="top" align="center">
<a name="VerifyCookie">VerifyCookie</a>
<td><p>
Check the value of global database parameter number 0 (the
schema version) and make sure it is equal to P2.
P1 is the database number which is 0 for the main database file
and 1 for the file holding temporary tables and some higher number
for auxiliary databases.
<p>
The cookie changes its value whenever the database schema changes.
This operation is used to detect when that the cookie has changed
and that the current process needs to reread the schema.
<p>
Either a transaction needs to have been started or an OP_Open needs
to be executed (to establish a read lock) before this opcode is
invoked.</td></tr>
</table></p>

<table width="100%">
<tr><td bgcolor="#80a796"></td></tr>
</table>
<small><i>This page last modified on 2005/03/09 12:26:51</i></small>
</body></html>