MemMax
P1 is a register in the root frame of this VM (the root frame is different from the current frame if this instruction is being executed within a sub-program).
An example
2 of the 178 statements we compiled against the sample database use MemMax. This is the one with the shortest program; the rows that use MemMax are highlighted.
INSERT INTO playlists (name) VALUES ('workout')| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 25 | 0 | 0 | |
| 1 | OpenWrite | 0 | 13 | 0 | 3 | 0 |
| 2 | OpenWrite | 1 | 14 | 0 | k(1,) | 0 |
| 3 | SoftNull | 6 | 0 | 0 | 0 | |
| 4 | String8 | 0 | 7 | 0 | workout | 0 |
| 5 | NewRowid | 0 | 5 | 2 | 0 | |
| 6 | MemMax | 2 | 5 | 0 | 0 | |
| 7 | HaltIfNull | 1299 | 2 | 7 | playlists.name | 1 |
| 8 | Affinity | 6 | 3 | 0 | DBB | 0 |
| 9 | SCopy | 7 | 10 | 0 | 0 | |
| 10 | IntCopy | 5 | 11 | 0 | 0 | |
| 11 | MakeRecord | 10 | 2 | 9 | 0 | |
| 12 | NoConflict | 1 | 14 | 10 | 1 | 0 |
| 13 | Halt | 2067 | 2 | 0 | playlists.name | 2 |
| 14 | MakeRecord | 6 | 3 | 12 | 0 | |
| 15 | IdxInsert | 1 | 9 | 10 | 1 | 16 |
| 16 | Insert | 0 | 12 | 5 | playlists | 57 |
| 17 | Le | 4 | 24 | 2 | 0 | |
| 18 | OpenWrite | 0 | 15 | 0 | 2 | 0 |
| 19 | NotNull | 3 | 21 | 0 | 0 | |
| 20 | NewRowid | 0 | 3 | 0 | 0 | |
| 21 | MakeRecord | 1 | 2 | 13 | 0 | |
| 22 | Insert | 0 | 13 | 3 | 8 | |
| 23 | Close | 0 | 0 | 0 | 0 | |
| 24 | Halt | 0 | 0 | 0 | 0 | |
| 25 | Transaction | 0 | 1 | 1 | 0 | 1 |
| 26 | OpenRead | 0 | 15 | 0 | 2 | 0 |
| 27 | String8 | 0 | 1 | 0 | playlists | 0 |
| 28 | Null | 0 | 2 | 4 | 0 | |
| 29 | Rewind | 0 | 38 | 0 | 0 | |
| 30 | Column | 0 | 0 | 2 | 0 | |
| 31 | Ne | 1 | 37 | 2 | 16 | |
| 32 | Rowid | 0 | 3 | 0 | 0 | |
| 33 | Column | 0 | 1 | 2 | 0 | |
| 34 | AddImm | 2 | 0 | 0 | 0 | |
| 35 | Copy | 2 | 4 | 0 | 0 | |
| 36 | Goto | 0 | 39 | 0 | 0 | |
| 37 | Next | 0 | 30 | 0 | 0 | |
| 38 | Integer | 0 | 2 | 0 | 0 | |
| 39 | Close | 0 | 0 | 0 | 0 | |
| 40 | Function | 0 | 0 | 8 | current_timestamp(0) | 0 |
| 41 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: AddImm, Affinity, Close, Column, Copy, Function, Goto, Halt, HaltIfNull, IdxInsert, Init, Insert, IntCopy, Integer, Le, MakeRecord, Ne, NewRowid, Next, NoConflict, NotNull, Null, OpenRead, OpenWrite, Rewind, Rowid, SCopy, SoftNull, String8, Transaction.
What the SQLite documentation says
P1 is a register in the root frame of this VM (the root frame is different from the current frame if this instruction is being executed within a sub-program). Set the value of register P1 to the maximum of its current value and the value in register P2.
This instruction throws an error if the memory cell is not initially an integer.
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.