IfPos
Register P1 must contain an integer.
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
14 of the 178 statements we compiled against the sample database use IfPos. This is the one with the shortest program; the rows that use IfPos are highlighted.
PRAGMA incremental_vacuum
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 8 | 0 | 0 | |
| 1 | Expire | 1 | 1 | 0 | 0 | |
| 2 | Integer | 2147483647 | 1 | 0 | 0 | |
| 3 | IncrVacuum | 0 | 7 | 0 | 0 | |
| 4 | ResultRow | 1 | 0 | 0 | 0 | |
| 5 | AddImm | 1 | -1 | 0 | 0 | |
| 6 | IfPos | 1 | 3 | 0 | 0 | |
| 7 | Halt | 0 | 0 | 0 | 0 | |
| 8 | Transaction | 0 | 1 | 1 | 0 | 1 |
| 9 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: AddImm, Expire, Goto, Halt, IncrVacuum, Init, Integer, ResultRow, Transaction.
What the SQLite documentation says
Register P1 must contain an integer. If the value of register P1 is 1 or greater, subtract P3 from the value in P1 and jump to P2.
If the initial value of register P1 is less than 1, then the value is unchanged and control passes through to the next instruction.
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.
← IfNullRow · IfSizeBetween →