OpenRead
Open a read-only cursor for the database table whose root page is P2 in a database file.
An example
117 of the 178 statements we compiled against the sample database use OpenRead. This is the one with the shortest program; the rows that use OpenRead are highlighted.
SELECT count(*) FROM tracks
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 7 | 0 | 0 | |
| 1 | OpenRead | 1 | 19 | 0 | k(2,,) | 0 |
| 2 | Count | 1 | 1 | 0 | 0 | |
| 3 | Close | 1 | 0 | 0 | 0 | |
| 4 | Copy | 1 | 2 | 0 | 0 | |
| 5 | ResultRow | 2 | 1 | 0 | 0 | |
| 6 | Halt | 0 | 0 | 0 | 0 | |
| 7 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 8 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Close, Copy, Count, Goto, Halt, Init, ResultRow, Transaction.
What the SQLite documentation says
Open a read-only cursor for the database table whose root page is P2 in a database file. The database file is determined by P3. P3==0 means the main database, P3==1 means the database used for temporary tables, and P3>1 means used the corresponding attached database. Give the new cursor an identifier of P1. The P1 values need not be contiguous but all P1 values should be small integers. It is an error for P1 to be negative.
Allowed P5 bits:
- 0x02 OPFLAG_SEEKEQ: This cursor will only be used for equality lookups (implemented as a pair of opcodes SeekGE/IdxGT of SeekLE/IdxLT)
The P4 value may be either an integer (P4_INT32) or a pointer to a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo object, then table being opened must be an index b-tree where the KeyInfo object defines the content and collating sequence of that index b-tree. Otherwise, if P4 is an integer value, then the table being opened must be a table b-tree with a number of columns no less than the value of P4.
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.
← OpenPseudo · OpenWrite →