ZeroOrNull
If both registers P1 and P3 are NOT NULL, then store a zero in register P2.
An example
4 of the 178 statements we compiled against the sample database use ZeroOrNull. This is the one with the shortest program; the rows that use ZeroOrNull are highlighted.
SELECT NOT (id > 5) FROM tracks
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 11 | 0 | 0 | |
| 1 | OpenRead | 1 | 19 | 0 | k(2,,) | 0 |
| 2 | Rewind | 1 | 10 | 1 | 0 | 0 |
| 3 | IdxRowid | 1 | 3 | 0 | 0 | |
| 4 | Integer | 1 | 2 | 0 | 0 | |
| 5 | Gt | 4 | 7 | 3 | 68 | |
| 6 | ZeroOrNull | 3 | 2 | 4 | 0 | |
| 7 | Not | 2 | 1 | 0 | 0 | |
| 8 | ResultRow | 1 | 1 | 0 | 0 | |
| 9 | Next | 1 | 3 | 0 | 1 | |
| 10 | Halt | 0 | 0 | 0 | 0 | |
| 11 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 12 | Integer | 5 | 4 | 0 | 0 | |
| 13 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Goto, Gt, Halt, IdxRowid, Init, Integer, Next, Not, OpenRead, ResultRow, Rewind, Transaction.
What the SQLite documentation says
If both registers P1 and P3 are NOT NULL, then store a zero in register P2. If either registers P1 or P3 are NULL then put a NULL in register P2.
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.
← Yield