Affinity
Apply affinities to a range of P2 registers starting with P1.
An example
29 of the 178 statements we compiled against the sample database use Affinity. This is the one with the shortest program; the rows that use Affinity are highlighted.
SELECT * FROM genres WHERE name = ?
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 11 | 0 | 0 | |
| 1 | OpenRead | 1 | 9 | 0 | k(1,) | 2 |
| 2 | Variable | 1 | 1 | 0 | 0 | |
| 3 | IsNull | 1 | 10 | 0 | 0 | |
| 4 | Affinity | 1 | 1 | 0 | B | 0 |
| 5 | SeekGE | 1 | 10 | 1 | 1 | 0 |
| 6 | IdxGT | 1 | 10 | 1 | 1 | 0 |
| 7 | Column | 1 | 0 | 2 | 0 | |
| 8 | Column | 1 | 1 | 3 | 0 | |
| 9 | ResultRow | 2 | 2 | 0 | 0 | |
| 10 | Halt | 0 | 0 | 0 | 0 | |
| 11 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 12 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Column, Goto, Halt, IdxGT, Init, IsNull, OpenRead, ResultRow, SeekGE, Transaction, Variable.
What the SQLite documentation says
Apply affinities to a range of P2 registers starting with P1.
P4 is a string that is P2 characters long. The N-th character of the string indicates the column affinity that should be used for the N-th memory cell in the range.
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.