SQLite VDBE opcode

Jump

Jump to the instruction at address P1, P2, or P3 depending on whether in the most recent Compare instruction the P1 vector was less than, equal to, or greater than the P2 vector, respectively.

Jumps: P1, P2, P3 are an instruction address. In the listings here, a jump is drawn as an arc and the address is a link.

An example

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

SELECT album_id, count(*), sum(ms) FROM tracks GROUP BY album_id
addropcodep1p2p3p4p5
0Init03900
1Noop1200
2Integer0200
3Null0550
4Gosub43500
5OpenRead04040
6OpenRead250k(2,,)0
7Rewind223700
8DeferredSeek2000
9Column2060
10Compare561k(1,B)0
11Jump1216120
12Gosub32700
13Move6510
14IfPos23800
15Gosub43500
16AggStep009count(0)0
17Column03110
18AggStep01110sum(1)1
19If12100
20Column2070
21Integer1100
22Next2801
23Gosub32700
24Goto03800
25Integer1200
26Return3000
27IfPos12900
28Return3000
29AggFinal900count(0)0
30AggFinal1010sum(1)0
31Copy71200
32Copy91310
33ResultRow12300
34Return3000
35Null07100
36Integer0100
37Return4000
38Halt0000
39Transaction00101
40Null0550
41Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: AggFinal, AggStep, Column, Compare, Copy, DeferredSeek, Gosub, Goto, Halt, If, IfPos, Init, Integer, Move, Next, Noop, Null, OpenRead, ResultRow, Return, Rewind, Transaction.

What the SQLite documentation says

Jump to the instruction at address P1, P2, or P3 depending on whether in the most recent Compare instruction the P1 vector was less than, equal to, or greater than the P2 vector, respectively.

This opcode must immediately follow an Compare opcode.

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.

← JournalMode · Last →