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
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 23 | 0 | 0 | |
| 1 | Null | 0 | 1 | 0 | 0 | |
| 2 | OpenWrite | 0 | 2 | 0 | 3 | 0 |
| 3 | Integer | 3 | 2 | 0 | 0 | |
| 4 | SeekRowid | 0 | 22 | 2 | 0 | |
| 5 | Rowid | 0 | 3 | 0 | 0 | |
| 6 | OpenWrite | 1 | 7 | 0 | k(2,,) | 8 |
| 7 | OpenWrite | 2 | 6 | 0 | k(2,,) | 8 |
| 8 | Copy | 3 | 4 | 0 | 0 | |
| 9 | OpenRead | 3 | 3 | 0 | 2 | 0 |
| 10 | Rewind | 3 | 15 | 0 | 0 | |
| 11 | Column | 3 | 1 | 8 | 0 | |
| 12 | Ne | 4 | 14 | 8 | BINARY-8 | 83 |
| 13 | FkCounter | 0 | 1 | 0 | 0 | |
| 14 | Next | 3 | 11 | 0 | 1 | |
| 15 | Column | 0 | 1 | 8 | 0 | |
| 16 | PureFunc | 0 | 8 | 10 | lower(1) | 32 |
| 17 | Rowid | 0 | 11 | 0 | 0 | |
| 18 | IdxDelete | 1 | 10 | 0 | artists_lower | 2 |
| 19 | Column | 0 | 1 | 10 | 0 | |
| 20 | IdxDelete | 2 | 10 | 0 | artists_name | 2 |
| 21 | Delete | 0 | 1 | 0 | artists | 0 |
| 22 | Halt | 0 | 0 | 0 | 0 | |
| 23 | Transaction | 0 | 1 | 1 | 0 | 1 |
| 24 | Goto | 0 | 1 | 0 | 0 |
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 →