Opcode Name | Description |
AbsValue
|
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. |
Add
|
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. |
AddImm
|
Add the value P1 to whatever is on top of the stack. The result
is always an integer.
To force the top of the stack to be an integer, just add 0. |
AggContextPop
|
Restore the aggregator to the state it was in when AggContextPush
was last called. Any data in the current aggregator is deleted. |
AggContextPush
|
Save the state of the current aggregator. It is restored an
AggContextPop opcode.
|
AggFocus
|
Pop the top of the stack and use that as an aggregator key. If
an aggregator with that same key already exists, then make the
aggregator the current aggregator and jump to P2. If no aggregator
with the given key exists, create one and make it current but
do not jump.
The order of aggregator opcodes is important. The order is:
AggReset AggFocus AggNext. In other words, you must execute
AggReset first, then zero or more AggFocus operations, then
zero or more AggNext operations. You must not execute an AggFocus
in between an AggNext and an AggReset. |
AggFunc
|
Execute the step function for an aggregate. The
function has P2 arguments. P3 is a pointer to the FuncDef
structure that specifies the function.
The top of the stack must be an integer which is the index of
the aggregate column that corresponds to this aggregate function.
Ideally, this index would be another parameter, but there are
no free parameters left. The integer is popped from the stack. |
AggGet
|
Push a new entry onto the stack which is a copy of the P2-th field
of the current aggregate. Strings are not duplicated so
string values will be ephemeral.
If P1 is zero, then the value is pulled out of the current aggregate
in the current aggregate context. If P1 is greater than zero, then
the value is taken from the P1th outer aggregate context. (i.e. if
P1==1 then read from the aggregate context that will be restored
by the next OP_AggContextPop opcode). |
AggInit
|
Initialize the function parameters for an aggregate function.
The aggregate will operate out of aggregate column P2.
P3 is a pointer to the FuncDef structure for the function. |
AggNext
|
Make the next aggregate value the current aggregate. The prior
aggregate is deleted. If all aggregate values have been consumed,
jump to P2.
The order of aggregator opcodes is important. The order is:
AggReset AggFocus AggNext. In other words, you must execute
AggReset first, then zero or more AggFocus operations, then
zero or more AggNext operations. You must not execute an AggFocus
in between an AggNext and an AggReset. |
AggReset
|
Reset the current aggregator context so that it no longer contains any
data. Future aggregator elements will contain P2 values each and be sorted
using the KeyInfo structure pointed to by P3.
If P1 is non-zero, then only a single aggregator row is available (i.e.
there is no GROUP BY expression). In this case it is illegal to invoke
OP_AggFocus. |
AggSet
|
Move the top of the stack into the P2-th field of the current
aggregate. String values are duplicated into new memory. |
And
|
Pop two values off the stack. Take the logical AND of the
two values and push the resulting boolean value back onto the
stack. |
AutoCommit
|
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.
This instruction causes the VM to halt. |
BitAnd
|
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. |
BitNot
|
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. |
BitOr
|
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. |
Blob
|
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. |
Callback
|
Pop P1 values off the stack and form them into an array. Then
invoke the callback function using the newly formed array as the
3rd parameter. |
Clear
|
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.
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.
See also: Destroy |
Close
|
Close a cursor previously opened as P1. If P1 is not
currently open, this instruction is a no-op. |
CollSeq
|
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.
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. |
Column
|
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 the KeyAsData opcode has previously executed on this cursor, then the
field might be extracted from the key rather than the data.
If P1 is negative, then the record is stored on the stack rather than in
a table. For P1==-1, the top of the stack is used. For P1==-2, the
next on the stack is used. And so forth. The value pushed is always
just a pointer into the record which is stored further down on the
stack. The column value is not copied. The number of columns in the
record is stored on the stack just above the record itself. |
Concat
|
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.
When P1==1, this routine makes a copy of the top stack element
into memory obtained from sqliteMalloc(). |
ContextPop
|
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. |
ContextPush
|
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. |
CreateIndex
|
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.
See documentation on OP_CreateTable for additional information. |
CreateTable
|
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.
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.
See also: CreateIndex |
Delete
|
Delete the record at which the P1 cursor is currently pointing.
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.
If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
incremented (otherwise not).
If P1 is a pseudo-table, then this instruction is a no-op. |
Destroy
|
Delete an entire database table or index whose root page in the database
file is given by P1.
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.
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.
See also: Clear |
Distinct
|
Use the top of the stack as a string key. If a record with that key does
not exist in the table of cursor P1, then jump to P2. If the record
does already exist, then fall thru. The cursor is left pointing
at the record if it exists. The key is not popped from the stack.
This operation is similar to NotFound except that this operation
does not pop the key from the stack.
See also: Found, NotFound, MoveTo, IsUnique, NotExists |
Divide
|
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. |
DropIndex
|
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. |
DropTable
|
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. |
DropTrigger
|
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. |
Dup
|
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.
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.
Also see the Pull instruction. |
Eq
|
Pop the top two elements from the stack. If they are equal, then
jump to instruction P2. Otherwise, continue to the next instruction.
The least significant byte of P1 may be either 0x00 or 0x01. If either
operand is NULL (and thus if the result is unknown) then take the jump
only if the least significant byte of P1 is 0x01.
The second least significant byte of P1 must be an affinity character -
'n', 't', 'i' or 'o' - or 0x00. 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.
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.
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.
If P3 is not NULL it is a pointer to a collating sequence (a CollSeq
structure) that defines how to compare text. |
Expire
|
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()).
If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
then only the currently executing statement is affected. |
ForceInt
|
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. |
Found
|
Use the top of the stack as a string key. If a record with that key
does exist in table of P1, then jump to P2. If the record
does not exist, then fall thru. The cursor is left pointing
to the record if it exists. The key is popped from the stack.
See also: Distinct, NotFound, MoveTo, IsUnique, NotExists |
FullKey
|
Extract the complete key from the record that cursor P1 is currently
pointing to and push the key onto the stack as a string.
Compare this opcode to Recno. The Recno opcode extracts the first
4 bytes of the key and pushes those bytes onto the stack as an
integer. This instruction pushes the entire key as a string.
This opcode may not be used on a pseudo-table. |
Function
|
Invoke a user function (P3 is a pointer to a Function structure that
defines the function) with P1 arguments taken from the stack. Pop all
arguments from the stack and push back the result.
P2 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 P2 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.
See also: AggFunc |
Ge
|
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. |
Gosub
|
Push the current address plus 1 onto the return address stack
and then jump to address P2.
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. |
Goto
|
An unconditional jump to address P2.
The next instruction executed will be
the one at index P2 from the beginning of
the program. |
Gt
|
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. |
Halt
|
Exit immediately. All open cursors, Lists, Sorts, etc are closed
automatically.
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.
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. |
HexBlob
|
P3 is an UTF-8 SQL hex encoding of a blob. The blob is pushed onto the
vdbe stack.
The first time this instruction executes, in transforms itself into a
'Blob' opcode with a binary blob as P3. |
IdxDelete
|
The top of the stack is an index key built using the MakeIdxKey opcode.
This opcode removes that entry from the index. |
IdxGE
|
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.
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.
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. |
IdxGT
|
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.
The top of the stack might have fewer columns that P1.
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. |
IdxIsNull
|
The top of the stack contains an index entry such as might be generated
by the MakeIdxKey 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.
The index entry is always popped from the stack. |
IdxLT
|
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.
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.
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. |
IdxPut
|
The top of the stack holds a SQL index key made using the
MakeIdxKey instruction. This opcode writes that key into the
index P1. Data for the entry is nil.
If P2==1, then the key must be unique. If the key is not unique,
the program aborts with a SQLITE_CONSTRAINT error and the database
is rolled back. If P3 is not null, then it becomes part of the
error message returned with the SQLITE_CONSTRAINT. |
IdxRecno
|
Push onto the stack an integer which is the varint located at the
end of the index key pointed to by cursor P1. This integer should be
the record number of the table entry to which this index entry points.
See also: Recno, MakeIdxKey. |
If
|
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.
If the value popped of the stack is NULL, then take the jump if P1
is true and fall through if P1 is false. |
IfMemPos
|
If the value of memory cell P1 is 1 or greater, jump to P2. This
opcode assumes that memory cell P1 holds an integer value. |
IfNot
|
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.
If the value popped of the stack is NULL, then take the jump if P1
is true and fall through if P1 is false. |
Integer
|
The integer value P1 is pushed onto the stack. If P3 is not zero
then it is assumed to be a string representation of the same integer.
If P1 is zero and P3 is not zero, then the value is derived from P3.
If the value cannot be represented as a 32-bits then its value
will be in P3. |
IntegrityCk
|
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.
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.
If P2 is not zero, the check is done on the auxiliary database
file, not the main database file.
This opcode is used for testing purposes only. |
IsNull
|
If any of the top abs(P1) values on the stack are NULL, then jump
to P2. Pop the stack P1 times if P1>0. If P1<0 leave the stack
unchanged. |
IsUnique
|
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 MakeIdxKey. Call it K. This instruction pops R from the
stack but it leaves K unchanged.
P1 is an index. So it has no data and its key consists of a
record generated by OP_MakeIdxKey. This key contains one or more
fields followed by a ROWID field.
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.
See also: Distinct, NotFound, NotExists, Found |
KeyAsData
|
Turn the key-as-data mode for cursor P1 either on (if P2==1) or
off (if P2==0). In key-as-data mode, the OP_Column opcode pulls
data off of the key rather than the data. This is used for
processing compound selects. |
Last
|
The next use of the Recno 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>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. |
Le
|
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. |
ListRead
|
Attempt to read an integer from the temporary storage buffer
and push it onto the stack. If the storage buffer is empty,
push nothing but instead jump to P2. |
ListReset
|
Reset the temporary storage buffer so that it holds nothing. |
ListRewind
|
Rewind the temporary buffer back to the beginning. |
ListWrite
|
Write the integer on the top of the stack
into the temporary storage list. |
Lt
|
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. |
MakeRecord
|
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.
The original stack entries are popped from the stack if P1>0 but
remain on the stack if P1<0.
The P2 argument is divided into two 16-bit words before it is processed.
If the hi-word is non-zero, then an extra integer is read from the stack
and appended to the record as a varint. If the low-word of P2 is not
zero and one or more of the entries are NULL, then jump to the value of
the low-word of P2. This feature can be used to skip a uniqueness test
on indices.
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).
The mapping from character to affinity is as follows:
'n' = NUMERIC.
'i' = INTEGER.
't' = TEXT.
'o' = NONE.
If P3 is NULL then all index fields have the affinity NONE. |
MemIncr
|
Increment the integer valued memory cell P1 by 1. If P2 is not zero
and the result after the increment is exactly 1, then jump
to P2.
This instruction throws an error if the memory cell is not initially
an integer. |
MemLoad
|
Push a copy of the value in memory location P1 onto the stack.
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. |
MemMax
|
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.
This instruction throws an error if the memory cell is not initially
an integer. |
MemStore
|
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.
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. |
MoveGe
|
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.
See also: Found, NotFound, Distinct, MoveLt, MoveGt, MoveLe |
MoveGt
|
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.
See also: Found, NotFound, Distinct, MoveLt, MoveGe, MoveLe |
MoveLe
|
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.
See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLt |
MoveLt
|
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.
See also: Found, NotFound, Distinct, MoveGt, MoveGe, MoveLe |
Multiply
|
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. |
MustBeInt
|
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.
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. |
Ne
|
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. |
Negative
|
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. |
NewRecno
|
Get a new integer record number 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.
If P2>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. |
Next
|
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.
See also: Prev |
Noop
|
Do nothing. This instruction is often useful as a jump
destination. |
Not
|
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. |
NotExists
|
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.
The difference between this operation and NotFound is that this
operation assumes the key is an integer and NotFound assumes it
is a string.
See also: Distinct, Found, MoveTo, NotFound, IsUnique |
NotFound
|
Use the top of the stack as a string 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 key is popped from the stack.
The difference between this operation and Distinct is that
Distinct does not pop the key from the stack.
See also: Distinct, Found, MoveTo, NotExists, IsUnique |
NotNull
|
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. |
NullRow
|
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. |
OpenPseudo
|
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.
A pseudo-table created by this opcode is useful for holding the
NEW or OLD tables in a trigger. |
OpenRead
|
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.
If P2==0 then take the root page number from the next of the stack.
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.
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.
See also OpenWrite. |
OpenTemp
|
Open a new cursor to a transient table.
The transient cursor is always opened read/write even if
the main database is read-only. The transient table is deleted
automatically when the cursor is closed.
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.
This opcode is used for tables that exist for the duration of a single
SQL statement only. Tables created using CREATE TEMPORARY TABLE
are opened using OP_OpenRead or OP_OpenWrite. "Temporary" in the
context of this opcode means for the duration of a single SQL statement
whereas "Temporary" in the context of CREATE TABLE means for the duration
of the connection to the database. Same word; different meanings. |
OpenWrite
|
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.
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.
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.
See also OpenRead. |
Or
|
Pop two values off the stack. Take the logical OR of the
two values and push the resulting boolean value back onto the
stack. |
ParseSchema
|
Read and parse all entries from the SQLITE_MASTER table of database P1
that match the WHERE clause P3.
This opcode invokes the parser to create a new virtual machine,
then runs the new virtual machine. It is thus a reentrant opcode. |
Pop
|
P1 elements are popped off of the top of stack and discarded. |
Prev
|
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. |
Pull
|
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.
See also the Dup instruction. |
Push
|
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. |
PutIntKey
|
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.
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). |
PutStrKey
|
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 a string. The stack is popped twice by this instruction.
P1 may not be a pseudo-table opened using the OpenPseudo opcode. |
ReadCookie
|
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.
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. |
Real
|
The string value P3 is converted to a real and pushed on to the stack. |
Recno
|
Push onto the stack an integer which is the first 4 bytes of the
the key to the current entry in a sequential scan of the database
file P1. The sequential scan should have been started using the
Next opcode. |
Remainder
|
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. |
ResetCount
|
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. |
Return
|
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. |
Rewind
|
The next use of the Recno 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>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. |
RowData
|
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.
If the cursor is not pointing to a valid row, a NULL is pushed
onto the stack. |
RowKey
|
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.
If the cursor is not pointing to a valid row, a NULL is pushed
onto the stack. |
SetCookie
|
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.
A transaction must be started before executing this opcode. |
SetNumColumns
|
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.
This opcode sets the number of columns for cursor P1 to P2.
If OP_KeyAsData is to be applied to cursor P1, it must be executed
before this op-code. |
ShiftLeft
|
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. |
ShiftRight
|
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. |
Sort
|
Sort all elements on the sorter. The algorithm is a
mergesort. The P3 argument is a pointer to a KeyInfo structure
that describes the keys to be sorted. |
SortNext
|
Push the data for the topmost element in the sorter onto the
stack, then remove the element from the sorter. If the sorter
is empty, push nothing on the stack and instead jump immediately
to instruction P2. |
SortPut
|
The TOS is the key and the NOS is the data. Pop both from the stack
and put them on the sorter. The key and data should have been
made using the MakeRecord opcode. |
SortReset
|
Remove any elements that remain on the sorter. |
Statement
|
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.
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. |
String
|
The string value P3 is pushed onto the stack. If P3==0 then a
NULL is pushed onto the stack. P3 is assumed to be a nul terminated
string encoded with the database native encoding. |
String8
|
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. |
Subtract
|
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. |
Transaction
|
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.
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.
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.
If P2 is zero, then a read-lock is obtained on the database file. |
Vacuum
|
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. |
Variable
|
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. |
VerifyCookie
|
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.
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.
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. |