SQLite VDBE opcode

SeekGT

If cursor P1 refers to an SQL table (B-Tree that uses integer keys), use the value in register P3 as a key.

Jumps: P2 is an instruction address. In the listings here, a jump is drawn as an arc and the address is a link.

An example

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

SELECT id FROM artists WHERE name > 'M'
addropcodep1p2p3p4p5
0Init0800
1OpenRead160k(2,,)0
2String8010M0
3SeekGT17110
4IdxRowid1200
5ResultRow2100
6Next1400
7Halt0000
8Transaction00101
9Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Goto, Halt, IdxRowid, Init, Next, OpenRead, ResultRow, String8, Transaction.

What the SQLite documentation says

If cursor P1 refers to an SQL table (B-Tree that uses integer keys), use the value in register P3 as a key. If cursor P1 refers to an SQL index, then P3 is the first in an array of P4 registers that are used as an unpacked index key.

Reposition cursor P1 so that it points to the smallest entry that is greater than the key value. If there are no records greater than the key and P2 is not zero, then jump to P2.

This opcode leaves the cursor configured to move in forward order, from the beginning toward the end. In other words, the cursor is configured to use Next, not Prev.

See also: Found, NotFound, SeekLt, SeekGe, SeekLe

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.

← SeekGE · SeekHit →