If
Jump to P2 if the value in register P1 is true.
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
17 of the 178 statements we compiled against the sample database use If. This is the one with the shortest program; the rows that use If are highlighted.
CREATE VIEW v AS SELECT 1
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 28 | 0 | 0 | |
| 1 | ReadCookie | 0 | 3 | 2 | 0 | |
| 2 | If | 3 | 5 | 0 | 0 | |
| 3 | SetCookie | 0 | 2 | 4 | 0 | |
| 4 | SetCookie | 0 | 5 | 1 | 0 | |
| 5 | Integer | 0 | 2 | 0 | 0 | |
| 6 | OpenWrite | 0 | 1 | 0 | 5 | 0 |
| 7 | NewRowid | 0 | 1 | 0 | 0 | |
| 8 | Blob | 6 | 3 | 0 | 0 | |
| 9 | Insert | 0 | 3 | 1 | 8 | |
| 10 | Close | 0 | 0 | 0 | 0 | |
| 11 | Close | 0 | 0 | 0 | 0 | |
| 12 | Null | 0 | 4 | 5 | 0 | |
| 13 | Noop | 2 | 0 | 4 | 0 | |
| 14 | OpenWrite | 1 | 1 | 0 | 5 | 0 |
| 15 | SeekRowid | 1 | 17 | 1 | 0 | |
| 16 | Rowid | 1 | 5 | 0 | 0 | |
| 17 | IsNull | 5 | 25 | 0 | 0 | |
| 18 | String8 | 0 | 6 | 0 | view | 0 |
| 19 | String8 | 0 | 7 | 0 | v | 0 |
| 20 | String8 | 0 | 8 | 0 | v | 0 |
| 21 | Copy | 2 | 9 | 0 | 0 | |
| 22 | String8 | 0 | 10 | 0 | CREATE VIEW v AS SELECT 1 | 0 |
| 23 | MakeRecord | 6 | 5 | 4 | BBBDB | 0 |
| 24 | Insert | 1 | 4 | 5 | 0 | |
| 25 | SetCookie | 0 | 1 | 2 | 0 | |
| 26 | ParseSchema | 0 | 0 | 0 | tbl_name='v' AND type!='trigger' | 0 |
| 27 | Halt | 0 | 0 | 0 | 0 | |
| 28 | Transaction | 0 | 1 | 1 | 0 | 1 |
| 29 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Blob, Close, Copy, Goto, Halt, Init, Insert, Integer, IsNull, MakeRecord, NewRowid, Noop, Null, OpenWrite, ParseSchema, ReadCookie, Rowid, SeekRowid, SetCookie, String8, Transaction.
What the SQLite documentation says
Jump to P2 if the value in register P1 is true. The value is considered true if it is numeric and non-zero. If the value in P1 is NULL then take the jump if and only if P3 is non-zero.
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.