RowSetTest
Register P3 is assumed to hold a 64-bit integer value.
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
1 of the 178 statements we compiled against the sample database use RowSetTest. This is the one with the shortest program; the rows that use RowSetTest are highlighted.
SELECT * FROM tracks WHERE album_id = 3 OR id = 9
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 29 | 0 | 0 | |
| 1 | OpenRead | 0 | 4 | 0 | 6 | 0 |
| 2 | Null | 0 | 2 | 0 | 0 | |
| 3 | Integer | 18 | 1 | 0 | 0 | |
| 4 | ReopenIdx | 1 | 5 | 0 | k(2,,) | 2 |
| 5 | Integer | 3 | 4 | 0 | 0 | |
| 6 | SeekGE | 1 | 13 | 4 | 1 | 0 |
| 7 | IdxGT | 1 | 13 | 4 | 1 | 0 |
| 8 | DeferredSeek | 1 | 0 | 0 | [0,1,0,0,0,0] | 0 |
| 9 | IdxRowid | 1 | 3 | 0 | 0 | |
| 10 | RowSetTest | 2 | 12 | 3 | 0 | 0 |
| 11 | Gosub | 1 | 19 | 0 | 0 | |
| 12 | Next | 1 | 7 | 1 | 0 | |
| 13 | Integer | 9 | 5 | 0 | 0 | |
| 14 | SeekRowid | 0 | 18 | 5 | 0 | |
| 15 | Rowid | 0 | 3 | 0 | 0 | |
| 16 | RowSetTest | 2 | 18 | 3 | -1 | 0 |
| 17 | Gosub | 1 | 19 | 0 | 0 | |
| 18 | Goto | 0 | 28 | 0 | 0 | |
| 19 | Rowid | 0 | 6 | 0 | 0 | |
| 20 | Column | 0 | 1 | 7 | 0 | |
| 21 | Column | 0 | 2 | 8 | 0 | |
| 22 | Column | 0 | 3 | 9 | 0 | |
| 23 | Column | 0 | 4 | 10 | 0 | |
| 24 | Column | 0 | 5 | 11 | 0 | |
| 25 | RealAffinity | 11 | 0 | 0 | 0 | |
| 26 | ResultRow | 6 | 6 | 0 | 0 | |
| 27 | Return | 1 | 19 | 0 | 0 | |
| 28 | Halt | 0 | 0 | 0 | 0 | |
| 29 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 30 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Column, DeferredSeek, Gosub, Goto, Halt, IdxGT, IdxRowid, Init, Integer, Next, Null, OpenRead, RealAffinity, ReopenIdx, ResultRow, Return, Rowid, SeekGE, SeekRowid, Transaction.
What the SQLite documentation says
Register P3 is assumed to hold a 64-bit integer value. If register P1 contains a RowSet object and that RowSet object contains the value held in P3, jump to register P2. Otherwise, insert the integer in P3 into the RowSet and continue on to the next opcode.
The RowSet object is optimized for the case where sets of integers are inserted in distinct phases, which each set contains no duplicates. Each set is identified by a unique P4 value. The first set must have P4==0, the final set must have P4==-1, and for all other sets must have P4>0.
This allows optimizations: (a) when P4==0 there is no need to test the RowSet object for P3, as it is guaranteed not to contain it, (b) when P4==-1 there is no need to insert the value, as it will never be tested for, and (c) when a value that is part of set X is inserted, there is no need to search to see if the same value was previously inserted as part of set X (only if it was previously inserted as part of some other set).
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.
← RowSetRead · Savepoint →