SQLite VDBE opcode

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')
addropcodep1p2p3p4p5
0Init02500
1OpenWrite013030
2OpenWrite1140k(1,)0
3SoftNull6000
4String8070workout0
5NewRowid0520
6MemMax2500
7HaltIfNull129927playlists.name1
8Affinity630DBB0
9SCopy71000
10IntCopy51100
11MakeRecord10290
12NoConflict1141010
13Halt206720playlists.name2
14MakeRecord63120
15IdxInsert1910116
16Insert0125playlists57
17Le42420
18OpenWrite015020
19NotNull32100
20NewRowid0300
21MakeRecord12130
22Insert01338
23Close0000
24Halt0000
25Transaction01101
26OpenRead015020
27String8010playlists0
28Null0240
29Rewind03800
30Column0020
31Ne137216
32Rowid0300
33Column0120
34AddImm2000
35Copy2400
36Goto03900
37Next03000
38Integer0200
39Close0000
40Function008current_timestamp(0)0
41Goto0100

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.

← MaxPgcnt · Move →