RealAffinity
If register P1 holds an integer convert it to a real value.
An example
25 of the 178 statements we compiled against the sample database use RealAffinity. This is the one with the shortest program; the rows that use RealAffinity are highlighted.
SELECT typeof(price) FROM tracks
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 9 | 0 | 0 | |
| 1 | OpenRead | 0 | 4 | 0 | 6 | 0 |
| 2 | Rewind | 0 | 8 | 0 | 0 | |
| 3 | Column | 0 | 5 | 2 | 0 | |
| 4 | RealAffinity | 2 | 0 | 0 | 0 | |
| 5 | Function | 0 | 2 | 1 | typeof(1) | 0 |
| 6 | ResultRow | 1 | 1 | 0 | 0 | |
| 7 | Next | 0 | 3 | 0 | 1 | |
| 8 | Halt | 0 | 0 | 0 | 0 | |
| 9 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 10 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Column, Function, Goto, Halt, Init, Next, OpenRead, ResultRow, Rewind, Transaction.
What the SQLite documentation says
If register P1 holds an integer convert it to a real value.
This opcode is used when extracting information from a column that has REAL affinity. Such column values may still be stored as integers, for space efficiency, but after extraction we want them to have only a real value.
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.
← Real · ReleaseReg →