Once
Fall through to the next instruction the first time this opcode is encountered on each invocation of the byte-code program.
Jumps: P2 is an instruction address. In the listings here, a jump is drawn as an arc and the address is a link.
An example
21 of the 178 statements we compiled against the sample database use Once. This is the one with the shortest program; the rows that use Once are highlighted.
SELECT sqlite_version()
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 6 | 0 | 0 | |
| 1 | Once | 0 | 3 | 0 | 0 | |
| 2 | Function | 0 | 0 | 2 | sqlite_version(0) | 0 |
| 3 | Copy | 2 | 1 | 0 | 0 | |
| 4 | ResultRow | 1 | 1 | 0 | 0 | |
| 5 | Halt | 0 | 0 | 0 | 0 | |
| 6 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Copy, Function, Goto, Halt, Init, ResultRow.
What the SQLite documentation says
Fall through to the next instruction the first time this opcode is encountered on each invocation of the byte-code program. Jump to P2 on the second and all subsequent encounters during the same invocation.
Top-level programs determine first invocation by comparing the P1 operand against the P1 operand on the Init opcode at the beginning of the program. If the P1 values differ, then fall through and make the P1 of this opcode equal to the P1 of Init. If P1 values are the same then take the jump.
For subprograms, there is a bitmask in the VdbeFrame that determines whether or not the jump should be taken. The bitmask is necessary because the self-altering code trick does not work for recursive triggers.
The P3 operand is not used directly by this opcode. However P3 is used by the code generator as follows: If this opcode is the start of a subroutine and that subroutine uses a Bloom filter, then P3 will be the register that holds that Bloom filter. See tag-202407032019 in the source code for implementation details.
From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.
← OffsetLimit · OpenAutoindex →