SQLite VDBE opcode

IdxDelete

The content of P5 registers starting at register P2 form an unpacked index key.

An example

5 of the 178 statements we compiled against the sample database use IdxDelete. This is the one with the shortest program; the rows that use IdxDelete are highlighted.

DELETE FROM artists WHERE id = 3
addropcodep1p2p3p4p5
0Init02300
1Null0100
2OpenWrite02030
3Integer3200
4SeekRowid02220
5Rowid0300
6OpenWrite170k(2,,)8
7OpenWrite260k(2,,)8
8Copy3400
9OpenRead33020
10Rewind31500
11Column3180
12Ne4148BINARY-883
13FkCounter0100
14Next31101
15Column0180
16PureFunc0810lower(1)32
17Rowid01100
18IdxDelete1100artists_lower2
19Column01100
20IdxDelete2100artists_name2
21Delete010artists0
22Halt0000
23Transaction01101
24Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Copy, Delete, FkCounter, Goto, Halt, Init, Integer, Ne, Next, Null, OpenRead, OpenWrite, PureFunc, Rewind, Rowid, SeekRowid, Transaction.

What the SQLite documentation says

The content of P5 registers starting at register P2 form an unpacked index key. This opcode removes that entry from the index opened by cursor P1.

P4 is a pointer to an Index structure.

If P3 is non-zero, it is the register number of a register holding a record that will be inserted into this index. If that record is identical to the one that would be deleted by this instruction, skip the delete and set register P3 to NULL.

Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found and not in writable_schema mode.

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.

← HaltIfNull · IdxGE →