SQLite VDBE opcode

FkCounter

Increment a "constraint counter" by P2 (P2 may be negative or positive).

An example

7 of the 178 statements we compiled against the sample database use FkCounter. This is the one with the shortest program; the rows that use FkCounter 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, Goto, Halt, IdxDelete, Init, Integer, Ne, Next, Null, OpenRead, OpenWrite, PureFunc, Rewind, Rowid, SeekRowid, Transaction.

What the SQLite documentation says

Increment a "constraint counter" by P2 (P2 may be negative or positive). If P1 is non-zero, the database constraint counter is incremented (deferred foreign key constraints). Otherwise, if P1 is zero, the statement counter is incremented (immediate foreign key constraints).

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.

← FkCheck · FkIfZero →