InitCoroutine
Set up register P1 so that it will Yield to the coroutine located at address P3.
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
16 of the 178 statements we compiled against the sample database use InitCoroutine. This is the one with the shortest program; the rows that use InitCoroutine are highlighted.
WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i + 1 FROM n WHERE i < 10) SELECT i FROM n
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 29 | 0 | 0 | |
| 1 | InitCoroutine | 1 | 23 | 2 | 0 | |
| 2 | OpenPseudo | 1 | 2 | 1 | 0 | |
| 3 | OpenEphemeral | 2 | 1 | 0 | 0 | |
| 4 | Integer | 1 | 3 | 0 | 0 | |
| 5 | MakeRecord | 3 | 1 | 4 | 0 | |
| 6 | NewRowid | 2 | 5 | 0 | 0 | |
| 7 | Insert | 2 | 4 | 5 | 8 | |
| 8 | Rewind | 2 | 22 | 0 | 0 | |
| 9 | NullRow | 1 | 0 | 0 | 0 | |
| 10 | RowData | 2 | 2 | 0 | 0 | |
| 11 | Delete | 2 | 0 | 0 | 0 | |
| 12 | Column | 1 | 0 | 6 | 0 | |
| 13 | Yield | 1 | 0 | 0 | 0 | |
| 14 | Column | 1 | 0 | 4 | 0 | |
| 15 | Ge | 7 | 21 | 4 | BINARY-8 | 80 |
| 16 | Column | 1 | 0 | 4 | 0 | |
| 17 | Add | 8 | 4 | 3 | 0 | |
| 18 | MakeRecord | 3 | 1 | 4 | 0 | |
| 19 | NewRowid | 2 | 5 | 0 | 0 | |
| 20 | Insert | 2 | 4 | 5 | 8 | |
| 21 | Goto | 0 | 8 | 0 | 0 | |
| 22 | EndCoroutine | 1 | 0 | 0 | 0 | |
| 23 | InitCoroutine | 1 | 0 | 2 | 0 | |
| 24 | Yield | 1 | 28 | 0 | 0 | |
| 25 | Copy | 6 | 9 | 0 | 2 | |
| 26 | ResultRow | 9 | 1 | 0 | 0 | |
| 27 | Goto | 0 | 24 | 0 | 0 | |
| 28 | Halt | 0 | 0 | 0 | 0 | |
| 29 | Integer | 10 | 7 | 0 | 0 | |
| 30 | Integer | 1 | 8 | 0 | 0 | |
| 31 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: Add, Column, Copy, Delete, EndCoroutine, Ge, Goto, Halt, Init, Insert, Integer, MakeRecord, NewRowid, NullRow, OpenEphemeral, OpenPseudo, ResultRow, Rewind, RowData, Yield.
What the SQLite documentation says
Set up register P1 so that it will Yield to the coroutine located at address P3.
If P2!=0 then the coroutine implementation immediately follows this opcode. So jump over the coroutine implementation to address P2.
See also: EndCoroutine
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.