Skip to main content

Opcode

Enum Opcode 

Source
#[repr(u8)]
pub enum Opcode {
Show 197 variants Goto = 1, Gosub = 2, Return = 3, InitCoroutine = 4, EndCoroutine = 5, Yield = 6, HaltIfNull = 7, Halt = 8, Integer = 9, Int64 = 10, Real = 11, String8 = 12, String = 13, BeginSubrtn = 14, Null = 15, SoftNull = 16, Blob = 17, Variable = 18, Move = 19, Copy = 20, SCopy = 21, IntCopy = 22, FkCheck = 23, ResultRow = 24, Concat = 25, Add = 26, Subtract = 27, Multiply = 28, Divide = 29, Remainder = 30, CollSeq = 31, BitAnd = 32, BitOr = 33, ShiftLeft = 34, ShiftRight = 35, AddImm = 36, MustBeInt = 37, RealAffinity = 38, Cast = 39, Eq = 40, Ne = 41, Lt = 42, Le = 43, Gt = 44, Ge = 45, ElseEq = 46, Permutation = 47, Compare = 48, Jump = 49, And = 50, Or = 51, IsTrue = 52, Not = 53, BitNot = 54, Once = 55, If = 56, IfNot = 57, IsNull = 58, IsType = 59, ZeroOrNull = 60, NotNull = 61, IfNullRow = 62, Offset = 63, Column = 64, TypeCheck = 65, Affinity = 66, MakeRecord = 67, Count = 68, Savepoint = 69, AutoCommit = 70, Transaction = 71, ReadCookie = 72, SetCookie = 73, ReopenIdx = 74, OpenRead = 75, OpenWrite = 76, OpenDup = 77, OpenEphemeral = 78, OpenAutoindex = 79, SorterOpen = 80, SequenceTest = 81, OpenPseudo = 82, Close = 83, ColumnsUsed = 84, SeekLT = 85, SeekLE = 86, SeekGE = 87, SeekGT = 88, SeekScan = 89, SeekHit = 90, IfNotOpen = 91, IfNoHope = 92, NoConflict = 93, NotFound = 94, Found = 95, SeekRowid = 96, NotExists = 97, Sequence = 98, NewRowid = 99, Insert = 100, RowCell = 101, Delete = 102, ResetCount = 103, SorterCompare = 104, SorterData = 105, RowData = 106, Rowid = 107, NullRow = 108, SeekEnd = 109, Last = 110, IfSizeBetween = 111, SorterSort = 112, Sort = 113, Rewind = 114, IfEmpty = 115, SorterNext = 116, Prev = 117, Next = 118, IdxInsert = 119, SorterInsert = 120, IdxDelete = 121, DeferredSeek = 122, IdxRowid = 123, FinishSeek = 124, IdxLE = 125, IdxGT = 126, IdxLT = 127, IdxGE = 128, Destroy = 129, Clear = 130, ResetSorter = 131, CreateBtree = 132, SqlExec = 133, ParseSchema = 134, LoadAnalysis = 135, DropTable = 136, DropIndex = 137, DropTrigger = 138, IntegrityCk = 139, RowSetAdd = 140, RowSetRead = 141, RowSetTest = 142, Program = 143, Param = 144, FkCounter = 145, FkIfZero = 146, MemMax = 147, IfPos = 148, OffsetLimit = 149, IfNotZero = 150, DecrJumpZero = 151, AggInverse = 152, AggStep = 153, AggStep1 = 154, AggValue = 155, AggFinal = 156, Checkpoint = 157, JournalMode = 158, Vacuum = 159, IncrVacuum = 160, Expire = 161, CursorLock = 162, CursorUnlock = 163, TableLock = 164, VBegin = 165, VCreate = 166, VDestroy = 167, VOpen = 168, VCheck = 169, VInitIn = 170, VFilter = 171, VColumn = 172, VNext = 173, VRename = 174, VUpdate = 175, Pagecount = 176, MaxPgcnt = 177, PureFunc = 178, Function = 179, ClrSubtype = 180, GetSubtype = 181, SetSubtype = 182, FilterAdd = 183, Filter = 184, Trace = 185, Init = 186, CursorHint = 187, Abortable = 188, ReleaseReg = 189, SetSnapshot = 190, Noop = 191, LikeConstFast = 192, CountIndexEqRun = 193, FusedAppendInsert = 194, FusedOpenWriteLast = 195, FusedLiteralResultRow = 196, ColumnSubstrPrefix = 197,
}
Expand description

VDBE (Virtual Database Engine) opcodes.

These correspond 1:1 to the upstream SQLite VDBE opcode set. Each opcode represents a single operation in the bytecode program that the VDBE executes. Opcodes are numbered sequentially; the specific numeric values match C SQLite for debugging/comparison purposes.

Reference: canonical upstream SQLite opcode definitions.

Variants§

§

Goto = 1

Jump to address P2.

§

Gosub = 2

Push return address, jump to P2.

§

Return = 3

Pop return address, jump to it.

§

InitCoroutine = 4

Initialize coroutine. P1=coroutine reg, P2=jump on first entry.

§

EndCoroutine = 5

End coroutine, jump to return address.

§

Yield = 6

Yield control to/from coroutine.

§

HaltIfNull = 7

Halt if register P3 is NULL.

§

Halt = 8

Halt execution (with optional error).

§

Integer = 9

Set register P2 to integer value P1.

§

Int64 = 10

Set register P2 to 64-bit integer from P4.

§

Real = 11

Set register P2 to real value from P4.

§

String8 = 12

Set register P2 to string P4 (zero-terminated).

§

String = 13

Set register P2 to string of length P1 from P4.

§

BeginSubrtn = 14

Begin subroutine / set register P2 to NULL.

§

Null = 15

Set registers P2..P2+P3-1 to NULL.

§

SoftNull = 16

Set register to soft NULL (for optimization).

§

Blob = 17

Set register P2 to blob of length P1 from P4.

§

Variable = 18

Set register P2 to the value of variable/parameter P1.

§

Move = 19

Move P3 registers from P1 to P2.

§

Copy = 20

Copy register P1 to P2 (and optionally more).

§

SCopy = 21

Shallow copy register P1 to P2.

§

IntCopy = 22

Copy integer value from P1 to P2.

§

FkCheck = 23

Check foreign key constraints.

§

ResultRow = 24

Output a row of P2 registers starting at P1.

§

Concat = 25

Concatenate P1 and P2, store in P3.

§

Add = 26

P3 = P2 + P1.

§

Subtract = 27

P3 = P2 - P1.

§

Multiply = 28

P3 = P2 * P1.

§

Divide = 29

P3 = P2 / P1.

§

Remainder = 30

P3 = P2 % P1.

§

CollSeq = 31

Set collation sequence for comparison.

§

BitAnd = 32

P3 = P1 & P2.

§

BitOr = 33

P3 = P1 | P2.

§

ShiftLeft = 34

P3 = P2 << P1.

§

ShiftRight = 35

P3 = P2 >> P1.

§

AddImm = 36

Add integer P2 to register P1.

§

MustBeInt = 37

Fail if P1 is not an integer; optionally jump to P2.

§

RealAffinity = 38

If P1 is integer, convert to real in-place.

§

Cast = 39

Cast register P1 to type P2.

§

Eq = 40

Jump to P2 if P1 == P3.

§

Ne = 41

Jump to P2 if P1 != P3.

§

Lt = 42

Jump to P2 if P3 < P1.

§

Le = 43

Jump to P2 if P3 <= P1.

§

Gt = 44

Jump to P2 if P3 > P1.

§

Ge = 45

Jump to P2 if P3 >= P1.

§

ElseEq = 46

Jump if the previous comparison was Eq (for multi-column indexes).

§

Permutation = 47

Set up permutation for subsequent Compare.

§

Compare = 48

Compare P1..P1+P3-1 with P2..P2+P3-1.

§

Jump = 49

Jump to one of P1, P2, or P3 based on comparison result.

§

And = 50

P3 = P1 AND P2 (three-valued logic).

§

Or = 51

P3 = P1 OR P2 (three-valued logic).

§

IsTrue = 52

Apply IS TRUE test.

§

Not = 53

P2 = NOT P1.

§

BitNot = 54

P2 = ~P1 (bitwise not).

§

Once = 55

Jump to P2 on first execution only.

§

If = 56

Jump to P2 if P1 is true (non-zero and non-NULL).

§

IfNot = 57

Jump to P2 if P1 is false (zero or NULL).

§

IsNull = 58

Jump to P2 if P1 is NULL.

§

IsType = 59

Type check against P5 type mask; jump to P2 on mismatch.

§

ZeroOrNull = 60

P2 = 0 if any of P1, P2, P3 is NULL.

§

NotNull = 61

Jump to P2 if P1 is not NULL.

§

IfNullRow = 62

Jump to P2 if the current row of cursor P1 is NULL.

§

Offset = 63

Extract byte offset of cursor.

§

Column = 64

Extract column P2 from cursor P1 into register P3.

§

TypeCheck = 65

Type-check columns against declared types.

§

Affinity = 66

Apply type affinity to P2 registers starting at P1.

§

MakeRecord = 67

Build a record from P1..P1+P2-1 registers into P3.

§

Count = 68

Store the number of rows in cursor P1 into register P2.

§

Savepoint = 69

Begin, release, or rollback a savepoint.

§

AutoCommit = 70

Set or clear auto-commit mode.

§

Transaction = 71

Begin a transaction on database P1.

§

ReadCookie = 72

Read database cookie P3 from database P1 into register P2.

§

SetCookie = 73

Write P3 to database cookie P2 of database P1.

§

ReopenIdx = 74

Reopen an index cursor (P1) if it’s on a different root page.

§

OpenRead = 75

Open a read cursor on table/index P2 in database P3.

§

OpenWrite = 76

Open a write cursor on table/index P2 in database P3.

§

OpenDup = 77

Open cursor P1 as a duplicate of cursor P2.

§

OpenEphemeral = 78

Open an ephemeral (temporary) table cursor.

§

OpenAutoindex = 79

Open an auto-index ephemeral cursor.

§

SorterOpen = 80

Open a sorter cursor.

§

SequenceTest = 81

Test if sequence number has been used.

§

OpenPseudo = 82

Open a pseudo-table cursor (reads from a register).

§

Close = 83

Close cursor P1.

§

ColumnsUsed = 84

Set the columns-used mask for cursor P1.

§

SeekLT = 85

Seek cursor P1 to the largest entry less than P3.

§

SeekLE = 86

Seek cursor P1 to the largest entry <= P3.

§

SeekGE = 87

Seek cursor P1 to the smallest entry >= P3.

§

SeekGT = 88

Seek cursor P1 to the smallest entry greater than P3.

§

SeekScan = 89

Optimized seek-scan for small result sets.

§

SeekHit = 90

Mark seek hit range for covering index optimization.

§

IfNotOpen = 91

Jump to P2 if cursor P1 is not open.

§

IfNoHope = 92

Like NotFound but with Bloom filter check.

§

NoConflict = 93

Jump to P2 if key P3 is NOT found (no conflict).

§

NotFound = 94

Jump to P2 if key P3 is NOT found in cursor P1.

§

Found = 95

Jump to P2 if key P3 IS found in cursor P1.

§

SeekRowid = 96

Seek cursor P1 to rowid P3; jump to P2 if not found.

§

NotExists = 97

Jump to P2 if rowid P3 does NOT exist in cursor P1.

§

Sequence = 98

Store next sequence value for cursor P1 into register P2.

§

NewRowid = 99

Generate a new unique rowid for cursor P1.

§

Insert = 100

Insert record from P2 with rowid P3 into cursor P1.

§

RowCell = 101

Copy a cell directly from one cursor to another.

§

Delete = 102

Delete the current row of cursor P1.

§

ResetCount = 103

Reset the change counter.

§

SorterCompare = 104

Compare sorter key.

§

SorterData = 105

Read data from the sorter.

§

RowData = 106

Copy the complete row data of cursor P1 into register P2.

§

Rowid = 107

Store the rowid of cursor P1 into register P2.

§

NullRow = 108

Set cursor P1 to a NULL row.

§

SeekEnd = 109

Seek to end of table (no-op for reading, positions for append).

§

Last = 110

Move cursor P1 to the last entry; jump to P2 if empty.

§

IfSizeBetween = 111

Jump to P2 if table size is between P3 and P4.

§

SorterSort = 112

Sort (alias for SorterSort in some contexts).

§

Sort = 113

Sort cursor P1.

§

Rewind = 114

Rewind cursor P1 to the first entry; jump to P2 if empty.

§

IfEmpty = 115

Jump to P2 if cursor P1’s table is empty.

§

SorterNext = 116

Advance sorter to next entry.

§

Prev = 117

Move cursor P1 to the previous entry; jump to P2 if done.

§

Next = 118

Move cursor P1 to the next entry; jump to P2 if done.

§

IdxInsert = 119

Insert record P2 into index cursor P1.

§

SorterInsert = 120

Insert into sorter.

§

IdxDelete = 121

Delete from index cursor P1.

§

DeferredSeek = 122

Defer a seek on cursor P1 using the rowid from index cursor P2.

§

IdxRowid = 123

Extract rowid from index entry of cursor P1.

§

FinishSeek = 124

Complete a previously deferred seek.

§

IdxLE = 125

Jump to P2 if index key of P1 <= key.

§

IdxGT = 126

Jump to P2 if index key of P1 > key.

§

IdxLT = 127

Jump to P2 if index key of P1 < key.

§

IdxGE = 128

Jump to P2 if index key of P1 >= key.

§

Destroy = 129

Destroy (drop) a B-tree rooted at page P1.

§

Clear = 130

Clear (delete all rows from) a table or index.

§

ResetSorter = 131

Reset a sorter cursor.

§

CreateBtree = 132

Allocate a new B-tree, store root page number in P2.

§

SqlExec = 133

Execute an SQL statement stored in P4.

§

ParseSchema = 134

Parse the schema for database P1.

§

LoadAnalysis = 135

Load analysis data for database P1.

§

DropTable = 136

Drop a table.

§

DropIndex = 137

Drop an index.

§

DropTrigger = 138

Drop a trigger.

§

IntegrityCk = 139

Run integrity check on database P1.

§

RowSetAdd = 140

Add integer P2 to rowset P1.

§

RowSetRead = 141

Read next value from rowset P1 into P3; jump to P2 when empty.

§

RowSetTest = 142

Test if P3 exists in rowset P1; jump to P2 if found.

§

Program = 143

Call a trigger sub-program.

§

Param = 144

Copy trigger parameter into register P2.

§

FkCounter = 145

Increment or decrement FK counter.

§

FkIfZero = 146

Jump to P2 if FK counter is zero.

§

MemMax = 147

Set register P2 to max of P2 and register P1.

§

IfPos = 148

Jump to P2 if register P1 > 0; decrement by P3.

§

OffsetLimit = 149

Compute offset limit.

§

IfNotZero = 150

Jump to P2 if register P1 is not zero.

§

DecrJumpZero = 151

Decrement P1, jump to P2 if result is zero.

§

AggInverse = 152

Invoke aggregate inverse function.

§

AggStep = 153

Invoke aggregate step function.

§

AggStep1 = 154

Step variant with different init semantics.

§

AggValue = 155

Extract aggregate intermediate value.

§

AggFinal = 156

Finalize aggregate function.

§

Checkpoint = 157

Checkpoint the WAL for database P1.

§

JournalMode = 158

Set journal mode for database P1.

§

Vacuum = 159

Vacuum the database.

§

IncrVacuum = 160

Incremental vacuum step; jump to P2 if done.

§

Expire = 161

Mark prepared statement as expired.

§

CursorLock = 162

Lock cursor P1.

§

CursorUnlock = 163

Unlock cursor P1.

§

TableLock = 164

Lock table P2 in database P1.

§

VBegin = 165

Begin a virtual table transaction.

§

VCreate = 166

Create a virtual table.

§

VDestroy = 167

Destroy a virtual table.

§

VOpen = 168

Open a virtual table cursor.

§

VCheck = 169

Check virtual table integrity.

§

VInitIn = 170

Initialize IN constraint for virtual table.

§

VFilter = 171

Apply filter to virtual table cursor.

§

VColumn = 172

Read column from virtual table cursor.

§

VNext = 173

Advance virtual table cursor.

§

VRename = 174

Rename a virtual table.

§

VUpdate = 175

Update/insert/delete on virtual table.

§

Pagecount = 176

Store database page count in register P2.

§

MaxPgcnt = 177

Set or read max page count.

§

PureFunc = 178

Call a pure (deterministic) function.

§

Function = 179

Call a function (possibly with side effects).

§

ClrSubtype = 180

Clear the subtype from register P1.

§

GetSubtype = 181

Get subtype of P1 into P2.

§

SetSubtype = 182

Set subtype of P2 from P1.

§

FilterAdd = 183

Add entry to Bloom filter.

§

Filter = 184

Test Bloom filter; jump to P2 if definitely not present.

§

Trace = 185

Trace/profile callback.

§

Init = 186

Initialize VDBE program; jump to P2.

§

CursorHint = 187

Provide cursor hint to storage engine.

§

Abortable = 188

Mark that this program can be aborted.

§

ReleaseReg = 189

Release register range.

§

SetSnapshot = 190

Set time-travel snapshot on cursor P1. P4 carries TimeTravelCommitSeq(n) or TimeTravelTimestamp(ts). Must immediately follow the OpenRead for the same cursor. The cursor becomes read-only; DML/DDL through it returns an error.

§

Noop = 191

No operation.

§

LikeConstFast = 192

Evaluate a literal-pattern LIKE fast path directly against a register.

§

CountIndexEqRun = 193

Count a run of equal first-column index keys, advancing the cursor.

§

FusedAppendInsert = 194

Fused NewRowid + MakeRecord + Insert for sequential append.

P1 = cursor number P2 = first register of column values (same as MakeRecord P1) P3 = number of columns (same as MakeRecord P2) P5 = Insert flags (OE_* conflict mode in low nibble)

Combines three opcodes into one dispatch:

  1. Allocate next sequential rowid (using cached last_alloc_rowid)
  2. Serialize column registers into record blob
  3. Append to B-tree via table_insert (prechecked absent, append mode)

Guard conditions (codegen must verify before emitting):

  • No secondary indexes on the table
  • No triggers
  • No foreign keys
  • Default ABORT conflict mode (OE_ABORT = 2 in low nibble)
  • No generated/stored columns
§

FusedOpenWriteLast = 195

Fused OpenWrite + Last for cursor setup in INSERT programs. P1 = cursor, P2 = root page number, P3 = column count, P5 = flags. Opens a write cursor and navigates to the last entry for append.

§

FusedLiteralResultRow = 196

Fused Integer(p1=lit, p2=reg) + ResultRow(p1=reg, p2=1) pair.

Emits a single-column result row whose only value is the literal integer p1, then clears register p2 (matching the post-ResultRow side effect of take_reg_range, which drains the source register).

P1 = integer literal value P2 = source register (written with the literal, then consumed) P3 = unused (reserved; must be 0) P4 = P4::None P5 = 0

Correctness contract: byte-equivalent to the unfused pair. Only the peephole codegen pass emits this opcode; it MUST verify that the immediately-following ResultRow consumes exactly the register written by Integer and outputs exactly one column.

§

ColumnSubstrPrefix = 197

Compute SUBSTR(column, 1, P4) directly from a table cursor column.

P1 = cursor number, P2 = logical column index, P3 = output register, P4 = Int(prefix_len), P5 = 0.

The engine may fast-path storage TEXT/BLOB payload prefixes without materializing the full column. Unsupported storage classes fall back to the equivalent scalar substr(value, 1, prefix_len) behavior.

Implementations§

Source§

impl Opcode

Source

pub const COUNT: usize = 198

Total number of opcodes defined.

Source

pub const fn name(self) -> &'static str

Get the opcode name as a static string slice.

Source

pub const fn from_byte(byte: u8) -> Option<Self>

Try to convert a u8 to an Opcode.

Source

pub const fn is_jump(self) -> bool

Whether this opcode is a jump instruction (has a P2 jump target).

Trait Implementations§

Source§

impl Clone for Opcode

Source§

fn clone(&self) -> Opcode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Opcode

Source§

impl Debug for Opcode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Opcode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Opcode

Source§

impl Hash for Opcode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Opcode

Source§

fn eq(&self, other: &Opcode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Opcode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more