SQLite VDBE opcode

Sequence

Find the next available sequence number for cursor P1.

An example

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

SELECT * FROM tracks ORDER BY ms DESC LIMIT 10 OFFSET 20
addropcodep1p2p3p4p5
0Init03500
1OpenEphemeral180k(1,-B)0
2Integer10100
3Integer20200
4MustBeInt2000
5OffsetLimit1320
6OpenRead04060
7Rewind02300
8Column0340
9Sequence1500
10IfNotZero31400
11Last1000
12IdxLE122410
13Delete1000
14Rowid0600
15Column0170
16Column0280
17Column0490
18Column05100
19RealAffinity10000
20MakeRecord47120
21IdxInsert112470
22Next0801
23Sort13400
24IfPos23310
25AddImm1-100
26Column16110
27Column15100
28Column1090
29Column1480
30Column1370
31Column1260
32ResultRow6600
33Next12400
34Halt0000
35Transaction00101
36Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: AddImm, Column, Delete, Goto, Halt, IdxInsert, IdxLE, IfNotZero, IfPos, Init, Integer, Last, MakeRecord, MustBeInt, Next, OffsetLimit, OpenEphemeral, OpenRead, RealAffinity, ResultRow, Rewind, Rowid, Sort, Transaction.

What the SQLite documentation says

Find the next available sequence number for cursor P1. Write the sequence number into register P2. The sequence number on the cursor is incremented after this instruction.

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.

← SeekScan · SequenceTest →