MakeRecord
Convert P2 registers beginning with P1 into the record format use as a data record in a database table or as a key in an index.
An example
68 of the 178 statements we compiled against the sample database use MakeRecord. This is the one with the shortest program; the rows that use MakeRecord are highlighted.
SELECT DISTINCT country FROM artists
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 11 | 0 | 0 | |
| 1 | OpenEphemeral | 1 | 0 | 0 | k(1,B) | 8 |
| 2 | OpenRead | 0 | 2 | 0 | 3 | 0 |
| 3 | Rewind | 0 | 10 | 0 | 0 | |
| 4 | Column | 0 | 2 | 1 | 0 | |
| 5 | Found | 1 | 9 | 1 | 1 | 0 |
| 6 | MakeRecord | 1 | 1 | 2 | 0 | |
| 7 | IdxInsert | 1 | 2 | 1 | 1 | 16 |
| 8 | ResultRow | 1 | 1 | 0 | 0 | |
| 9 | Next | 0 | 4 | 0 | 1 | |
| 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, Found, Goto, Halt, IdxInsert, Init, Next, OpenEphemeral, OpenRead, ResultRow, Rewind, Transaction.
What the SQLite documentation says
Convert P2 registers beginning with P1 into the record format use as a data record in a database table or as a key in an index. The Column opcode can decode the record later.
P4 may be 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 field of the index key.
The mapping from character to affinity is given by the SQLITE_AFF_ macros defined in sqliteInt.h.
If P4 is NULL then all index fields have the affinity BLOB.
The meaning of P5 depends on whether or not the SQLITE_ENABLE_NULL_TRIM compile-time option is enabled:
* If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index of the right-most table that can be null-trimmed.
* If SQLITE_ENABLE_NULL_TRIM is omitted, then P5 has the value OPFLAG_NOCHNG_MAGIC if the MakeRecord opcode is allowed to accept no-change records with serial_type 10. This value is only used inside an assert() and does not affect the end result.
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.