SQLite VDBE opcode

Rewind

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.

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

101 of the 178 statements we compiled against the sample database use Rewind. This is the one with the shortest program; the rows that use Rewind are highlighted.

SELECT id IS TRUE FROM tracks
addropcodep1p2p3p4p5
0Init0800
1OpenRead1190k(2,,)0
2Rewind17100
3IdxRowid1200
4IsTrue21000
5ResultRow1100
6Next1301
7Halt0000
8Transaction00101
9Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Goto, Halt, IdxRowid, Init, IsTrue, Next, OpenRead, ResultRow, Transaction.

What the SQLite documentation says

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, jump immediately to P2. If the table or index is not empty, fall through to the following instruction.

If P2 is zero, that is an assertion that the P1 table is never empty and hence the jump will never be taken.

This opcode leaves the cursor configured to move in forward order, from the beginning toward the end. In other words, the cursor is configured to use Next, not Prev.

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.

← Return · RowCell →