pub enum Op {
Show 51 variants
Integer {
value: i64,
dest: usize,
},
Real {
value: f64,
dest: usize,
},
Str {
value: String,
dest: usize,
},
Blob {
value: Vec<u8>,
dest: usize,
},
Null {
dest: usize,
},
Arith {
op: BinaryOp,
lhs: usize,
rhs: usize,
dest: usize,
},
Bitwise {
op: BinaryOp,
lhs: usize,
rhs: usize,
dest: usize,
},
Is {
is: bool,
lhs: usize,
rhs: usize,
dest: usize,
la: Option<Affinity>,
ra: Option<Affinity>,
},
Truthy {
want: bool,
not: bool,
operand: usize,
dest: usize,
},
Like {
glob: bool,
lhs: usize,
rhs: usize,
dest: usize,
},
Json {
as_text: bool,
lhs: usize,
rhs: usize,
dest: usize,
},
Func {
name: String,
arg_start: usize,
arg_count: usize,
dest: usize,
},
Concat {
lhs: usize,
rhs: usize,
dest: usize,
},
Compare {
op: BinaryOp,
lhs: usize,
rhs: usize,
dest: usize,
la: Option<Affinity>,
ra: Option<Affinity>,
coll: Collation,
},
And {
lhs: usize,
rhs: usize,
dest: usize,
},
Or {
lhs: usize,
rhs: usize,
dest: usize,
},
Not {
reg: usize,
dest: usize,
},
IsNull {
reg: usize,
negated: bool,
dest: usize,
},
Copy {
src: usize,
dest: usize,
},
Cast {
reg: usize,
type_name: String,
dest: usize,
},
Goto {
target: usize,
},
IfFalse {
reg: usize,
target: usize,
},
Rewind {
target: usize,
},
Column {
col: usize,
dest: usize,
},
Next {
target: usize,
},
RewindC {
cursor: usize,
target: usize,
},
ColumnC {
cursor: usize,
col: usize,
dest: usize,
},
NextC {
cursor: usize,
target: usize,
},
NullRow {
cursor: usize,
},
MarkMatched {
cursor: usize,
},
IfMatched {
cursor: usize,
target: usize,
},
DecrJumpZero {
reg: usize,
target: usize,
},
IfPosDecr {
reg: usize,
target: usize,
},
Negate {
reg: usize,
dest: usize,
},
BitNot {
reg: usize,
dest: usize,
},
ResultRow {
start: usize,
count: usize,
},
DistinctCheck {
start: usize,
count: usize,
target: usize,
},
SorterInsert {
row_start: usize,
row_count: usize,
key_start: usize,
key_count: usize,
},
SorterSort {
keys: Vec<SortKey>,
},
SorterRewind {
target: usize,
},
SorterRow {
start: usize,
count: usize,
},
SorterNext {
target: usize,
},
AggStep {
slot: usize,
kind: AggKind,
arg: Option<usize>,
distinct: bool,
filter: Option<usize>,
order: Vec<AggOrderKey>,
},
AggFinal {
slot: usize,
kind: AggKind,
dest: usize,
},
GroupStep {
key_start: usize,
key_count: usize,
aggs: Vec<AggSpec>,
},
GroupEmit {
outputs: Vec<GroupOut>,
agg_kinds: Vec<AggKind>,
},
GroupFinalize {
agg_kinds: Vec<AggKind>,
target: usize,
},
GroupKey {
key: usize,
dest: usize,
},
GroupAgg {
slot: usize,
dest: usize,
},
GroupNext {
target: usize,
},
Halt,
}Expand description
One VDBE instruction. Registers are addressed by index into the register file.
Variants§
Integer
Load an integer constant into dest.
Real
Load a real constant into dest.
Str
Load a text constant into dest.
Blob
Load a blob constant into dest.
Null
Load NULL into dest.
Arith
dest = lhs <op> rhs for an arithmetic BinaryOp (Add/Sub/Mul/Div/Mod).
Bitwise
dest = lhs <op> rhs for a bitwise BinaryOp (BitAnd/BitOr/LShift/RShift),
with SQLite’s NULL-yields-NULL semantics.
Is
dest = lhs IS rhs (is true) or lhs IS NOT rhs (is false); treats
NULL as comparable, always 1/0.
Fields
Truthy
dest = (truth(operand) == Some(want)) XOR not as 0/1 — the x IS [NOT] TRUE|FALSE truthiness test (a NULL operand is neither true nor false).
want is the boolean operand; not selects the IS NOT form.
Like
dest = lhs LIKE rhs (glob false) or lhs GLOB rhs (glob true);
NULL on either side yields NULL.
Json
dest = lhs -> rhs (as_text false) or lhs ->> rhs (as_text true):
the JSON extraction operators.
Func
dest = name(reg[arg_start], …, reg[arg_start+arg_count-1]): a pure,
context-free scalar function call, evaluated by re-using the tree-walker’s
func::eval_scalar over literal-reconstructed argument values.
Concat
dest = lhs || rhs (text concatenation).
Compare
dest = lhs <op> rhs for a comparison BinaryOp (Eq/NotEq/Lt/…), with
SQLite’s NULL-yields-NULL three-valued result (1/0/NULL). la/ra are the
operands’ comparison affinities (from their source expressions), applied
before comparing exactly as the tree-walker does.
Fields
And
dest = lhs AND rhs (three-valued).
Or
dest = lhs OR rhs (three-valued).
Not
dest = NOT reg (three-valued; NULL stays NULL).
IsNull
dest = reg IS [NOT] NULL (1/0).
Copy
Copy src into dest.
Cast
dest = CAST(reg AS type_name).
Goto
Unconditional jump to instruction index target.
IfFalse
Jump to target when reg is false or NULL (i.e. not true).
Rewind
Position the table cursor at the first row; jump to target (the loop
exit) when the table is empty.
Column
Load column col of the cursor’s current row into dest.
Next
Advance the cursor; jump back to target (the loop body) if a row remains,
else fall through.
RewindC
Multi-cursor Rewind (B5b nested-loop join): position cursor cursor at
its first row; jump to target when that cursor’s row-set is empty.
ColumnC
Multi-cursor Column: load column col of cursor cursor’s current row.
NextC
Multi-cursor Next: advance cursor cursor; jump back to target if a row
remains, else fall through.
NullRow
Mark cursor cursor as the NULL row (LEFT JOIN null-padding): every
subsequent ColumnC on it reads NULL until the next RewindC on that
cursor clears the mark.
MarkMatched
FULL JOIN bookkeeping: record that cursor cursor’s current row has been
matched, in a per-row bitmap that survives RewindC (unlike the NULL flag).
IfMatched
FULL JOIN anti-join pass: jump to target when cursor cursor’s current
row was already marked matched (so it is skipped in the second pass).
DecrJumpZero
Decrement reg; jump to target once it reaches zero (a LIMIT counter).
IfPosDecr
If reg is positive, decrement it and jump to target (an OFFSET skip).
Negate
dest = -reg (numeric negation).
BitNot
dest = ~reg (bitwise NOT; NULL stays NULL).
ResultRow
Emit registers [start, start+count) as one output row.
DistinctCheck
DISTINCT gate: if the row in [start, start+count) was already seen,
jump to target (skip it); otherwise record it and fall through.
SorterInsert
Append a row to the sorter: the output values in [row_start, row_start+ row_count) keyed by [key_start, key_start+key_count).
SorterSort
Sort the accumulated sorter rows by their keys (per keys, in order).
SorterRewind
Position the sorter cursor at the first sorted row; jump to target (the
emit-loop exit) when the sorter is empty.
SorterRow
Load the current sorter row’s stored output values into [start, start+ count).
SorterNext
Advance the sorter cursor; jump back to target if a row remains.
AggStep
Fold the current row into aggregate slot: for CountStar bump the row
counter, otherwise collect arg (when non-NULL). When distinct, a value
equal (BINARY) to one already collected for this slot is skipped, so the
slot folds only over distinct argument values. When filter is set, a row
whose predicate register is not true (FILTER (WHERE …)) contributes to
neither the count nor the collected values. When order is non-empty
(group_concat(x ORDER BY …)), each collected value also records its
ORDER BY key row so finalization can sort before concatenating.
Fields
order: Vec<AggOrderKey>AggFinal
Finalize aggregate slot into dest.
GroupStep
GROUP BY fold: find-or-create the group for the key in [key_start, key_start+key_count) (first-seen order, NULLs group together) and step
each per-group aggregate.
GroupEmit
Emit one row per group (in first-seen order): each output is either a group-key value or a finalized per-group aggregate.
GroupFinalize
Finalize the accumulated groups (computing each slot’s value per group)
into an emit list, then position the group cursor at the first group;
jump to target (the emit-loop exit) when there are no groups. Used by
the HAVING/ORDER BY grouped path, where each group’s keys and
aggregates are loaded into registers so arbitrary predicates / sort keys
can be computed by ordinary ops.
GroupKey
Load group-key value at index key of the current group into dest.
GroupAgg
Load the finalized aggregate at slot of the current group into dest.
GroupNext
Advance the group cursor; jump back to target if a group remains.
Halt
Stop execution.