SQLite VDBE opcode

Gosub

Write the current address onto register P1 and then jump to address P2.

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

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

SELECT * FROM tracks WHERE album_id = 3 OR id = 9
addropcodep1p2p3p4p5
0Init02900
1OpenRead04060
2Null0200
3Integer18100
4ReopenIdx150k(2,,)2
5Integer3400
6SeekGE113410
7IdxGT113410
8DeferredSeek100[0,1,0,0,0,0]0
9IdxRowid1300
10RowSetTest212300
11Gosub11900
12Next1710
13Integer9500
14SeekRowid01850
15Rowid0300
16RowSetTest2183-10
17Gosub11900
18Goto02800
19Rowid0600
20Column0170
21Column0280
22Column0390
23Column04100
24Column05110
25RealAffinity11000
26ResultRow6600
27Return11900
28Halt0000
29Transaction00101
30Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, DeferredSeek, Goto, Halt, IdxGT, IdxRowid, Init, Integer, Next, Null, OpenRead, RealAffinity, ReopenIdx, ResultRow, Return, RowSetTest, Rowid, SeekGE, SeekRowid, Transaction.

What the SQLite documentation says

Write the current address onto register P1 and then jump to address P2.

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.

← GetSubtype · Goto →