Yield
Swap the program counter with the value in register P1.
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 Yield. This is the one with the shortest program; the rows that use Yield 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, InitCoroutine, Insert, Integer, MakeRecord, NewRowid, NullRow, OpenEphemeral, OpenPseudo, ResultRow, Rewind, RowData.
What the SQLite documentation says
Swap the program counter with the value in register P1. This has the effect of yielding to a coroutine.
If the coroutine that is launched by this instruction ends with Yield or Return then continue to the next instruction. But if the coroutine launched by this instruction ends with EndCoroutine, then jump to P2 rather than continuing with the next instruction.
See also: InitCoroutine
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.
← VUpdate · ZeroOrNull →