SQLite VDBE opcode

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
addropcodep1p2p3p4p5
0Init02800
1ReadCookie0320
2If3500
3SetCookie0240
4SetCookie0510
5Integer0200
6OpenWrite01050
7NewRowid0100
8Blob6300
9Insert0318
10Close0000
11Close0000
12Null0450
13Noop2040
14OpenWrite11050
15SeekRowid11710
16Rowid1500
17IsNull52500
18String8060view0
19String8070v0
20String8080v0
21Copy2900
22String80100CREATE VIEW v AS SELECT 10
23MakeRecord654BBBDB0
24Insert1450
25SetCookie0120
26ParseSchema000tbl_name='v' AND type!='trigger'0
27Halt0000
28Transaction01101
29Goto0100

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.

← IdxRowid · IfEmpty →