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
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 39 | 0 | 0 | |
| 1 | Noop | 1 | 2 | 0 | 0 | |
| 2 | Integer | 0 | 2 | 0 | 0 | |
| 3 | Null | 0 | 5 | 5 | 0 | |
| 4 | Gosub | 4 | 35 | 0 | 0 | |
| 5 | OpenRead | 0 | 4 | 0 | 4 | 0 |
| 6 | OpenRead | 2 | 5 | 0 | k(2,,) | 0 |
| 7 | Rewind | 2 | 23 | 7 | 0 | 0 |
| 8 | DeferredSeek | 2 | 0 | 0 | 0 | |
| 9 | Column | 2 | 0 | 6 | 0 | |
| 10 | Compare | 5 | 6 | 1 | k(1,B) | 0 |
| 11 | Jump | 12 | 16 | 12 | 0 | |
| 12 | Gosub | 3 | 27 | 0 | 0 | |
| 13 | Move | 6 | 5 | 1 | 0 | |
| 14 | IfPos | 2 | 38 | 0 | 0 | |
| 15 | Gosub | 4 | 35 | 0 | 0 | |
| 16 | AggStep | 0 | 0 | 9 | count(0) | 0 |
| 17 | Column | 0 | 3 | 11 | 0 | |
| 18 | AggStep | 0 | 11 | 10 | sum(1) | 1 |
| 19 | If | 1 | 21 | 0 | 0 | |
| 20 | Column | 2 | 0 | 7 | 0 | |
| 21 | Integer | 1 | 1 | 0 | 0 | |
| 22 | Next | 2 | 8 | 0 | 1 | |
| 23 | Gosub | 3 | 27 | 0 | 0 | |
| 24 | Goto | 0 | 38 | 0 | 0 | |
| 25 | Integer | 1 | 2 | 0 | 0 | |
| 26 | Return | 3 | 0 | 0 | 0 | |
| 27 | IfPos | 1 | 29 | 0 | 0 | |
| 28 | Return | 3 | 0 | 0 | 0 | |
| 29 | AggFinal | 9 | 0 | 0 | count(0) | 0 |
| 30 | AggFinal | 10 | 1 | 0 | sum(1) | 0 |
| 31 | Copy | 7 | 12 | 0 | 0 | |
| 32 | Copy | 9 | 13 | 1 | 0 | |
| 33 | ResultRow | 12 | 3 | 0 | 0 | |
| 34 | Return | 3 | 0 | 0 | 0 | |
| 35 | Null | 0 | 7 | 10 | 0 | |
| 36 | Integer | 0 | 1 | 0 | 0 | |
| 37 | Return | 4 | 0 | 0 | 0 | |
| 38 | Halt | 0 | 0 | 0 | 0 | |
| 39 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 40 | Null | 0 | 5 | 5 | 0 | |
| 41 | Goto | 0 | 1 | 0 | 0 |
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 →