SQLite VDBE opcode

SorterData

Write into register P2 the current sorter data for sorter cursor P1.

An example

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

SELECT name FROM artists ORDER BY name COLLATE NOCASE
addropcodep1p2p3p4p5
0Init01600
1SorterOpen130k(1,NOCASE)0
2OpenRead260k(2,,)0
3Rewind29100
4Column2020
5Column2010
6MakeRecord1230
7SorterInsert13120
8Next2401
9OpenPseudo3430
10SorterSort11500
11SorterData1430
12Column3120
13ResultRow2100
14SorterNext11100
15Halt0000
16Transaction00101
17Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Goto, Halt, Init, MakeRecord, Next, OpenPseudo, OpenRead, ResultRow, Rewind, SorterInsert, SorterNext, SorterOpen, SorterSort, Transaction.

What the SQLite documentation says

Write into register P2 the current sorter data for sorter cursor P1. Then clear the column header cache on cursor P3.

This opcode is normally used to move a record out of the sorter and into a register that is the source for a pseudo-table cursor created using OpenPseudo. That pseudo-table cursor is the one that is identified by parameter P3. Clearing the P3 column cache as part of this opcode saves us from having to issue a separate NullRow instruction to clear that cache.

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.

← SorterCompare · SorterInsert →