IfNullRow
Check the cursor P1 to see if it is currently pointing at a NULL row.
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
5 of the 178 statements we compiled against the sample database use IfNullRow. This is the one with the shortest program; the rows that use IfNullRow are highlighted.
SELECT total FROM sales
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 12 | 0 | 0 | |
| 1 | OpenRead | 0 | 17 | 0 | 4 | 0 |
| 2 | Rewind | 0 | 11 | 0 | 0 | |
| 3 | IfNullRow | 0 | 9 | 1 | 0 | |
| 4 | Column | 0 | 2 | 2 | 0 | |
| 5 | Column | 0 | 3 | 3 | 0 | |
| 6 | RealAffinity | 3 | 0 | 0 | 0 | |
| 7 | Multiply | 3 | 2 | 1 | 0 | |
| 8 | TypeCheck | 1 | 1 | 6 | sales | 0 |
| 9 | ResultRow | 1 | 1 | 0 | 0 | |
| 10 | Next | 0 | 3 | 0 | 1 | |
| 11 | Halt | 0 | 0 | 0 | 0 | |
| 12 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 13 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Column, Goto, Halt, Init, Multiply, Next, OpenRead, RealAffinity, ResultRow, Rewind, Transaction, TypeCheck.
What the SQLite documentation says
Check the cursor P1 to see if it is currently pointing at a NULL row. If it is, then set register P3 to NULL and jump immediately to P2. If P1 is not on a NULL row, then fall through without making any changes.
If P1 is not an open cursor, then this opcode is a no-op.
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.