SQLite VDBE opcode

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
addropcodep1p2p3p4p5
0Init02900
1InitCoroutine12320
2OpenPseudo1210
3OpenEphemeral2100
4Integer1300
5MakeRecord3140
6NewRowid2500
7Insert2458
8Rewind22200
9NullRow1000
10RowData2200
11Delete2000
12Column1060
13Yield1000
14Column1040
15Ge7214BINARY-880
16Column1040
17Add8430
18MakeRecord3140
19NewRowid2500
20Insert2458
21Goto0800
22EndCoroutine1000
23InitCoroutine1020
24Yield12800
25Copy6902
26ResultRow9100
27Goto02400
28Halt0000
29Integer10700
30Integer1800
31Goto0100

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 →