SQLite VDBE opcode

OpenPseudo

Open a new cursor that points to a fake table that contains a single row of data.

An example

13 of the 178 statements we compiled against the sample database use OpenPseudo. This is the one with the shortest program; the rows that use OpenPseudo 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, OpenRead, ResultRow, Rewind, SorterData, SorterInsert, SorterNext, SorterOpen, SorterSort, Transaction.

What the SQLite documentation says

Open a new cursor that points to a fake table that contains a single row of data. The content of that one row is the content of memory register P2. In other words, cursor P1 becomes an alias for the MEM_Blob content contained in register P2.

A pseudo-table created by this opcode is used to hold a single row output from the sorter so that the row can be decomposed into individual columns using the Column opcode. The Column opcode is the only cursor opcode that works with a pseudo-table.

P3 is the number of fields in the records that will be stored by the pseudo-table. If P2 is 0 or negative then the pseudo-cursor will return NULL for every column.

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.

← OpenEphemeral · OpenRead →