Return
Jump to the address stored in register P1.
An example
29 of the 178 statements we compiled against the sample database use Return. This is the one with the shortest program; the rows that use Return are highlighted.
SELECT title, (SELECT count(*) FROM tracks t WHERE t.album_id = a.id) FROM albums a
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 22 | 0 | 0 | |
| 1 | OpenRead | 0 | 3 | 0 | 3 | 0 |
| 2 | Rewind | 0 | 21 | 0 | 0 | |
| 3 | Column | 0 | 2 | 1 | 0 | |
| 4 | BeginSubrtn | 0 | 3 | 0 | 0 | |
| 5 | Null | 0 | 4 | 4 | 0 | |
| 6 | Integer | 1 | 5 | 0 | 0 | |
| 7 | Null | 0 | 6 | 6 | 0 | |
| 8 | OpenRead | 2 | 5 | 0 | k(2,,) | 2 |
| 9 | Rowid | 0 | 7 | 0 | 0 | |
| 10 | SeekGE | 2 | 14 | 7 | 1 | 0 |
| 11 | IdxGT | 2 | 14 | 7 | 1 | 0 |
| 12 | AggStep | 0 | 0 | 6 | count(0) | 0 |
| 13 | Next | 2 | 11 | 1 | 0 | |
| 14 | AggFinal | 6 | 0 | 0 | count(0) | 0 |
| 15 | Copy | 6 | 4 | 0 | 0 | |
| 16 | DecrJumpZero | 5 | 17 | 0 | 0 | |
| 17 | Return | 3 | 5 | 1 | 0 | |
| 18 | Copy | 4 | 2 | 0 | 0 | |
| 19 | ResultRow | 1 | 2 | 0 | 0 | |
| 20 | Next | 0 | 3 | 0 | 1 | |
| 21 | Halt | 0 | 0 | 0 | 0 | |
| 22 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 23 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: AggFinal, AggStep, BeginSubrtn, Column, Copy, DecrJumpZero, Goto, Halt, IdxGT, Init, Integer, Next, Null, OpenRead, ResultRow, Rewind, Rowid, SeekGE, Transaction.
What the SQLite documentation says
Jump to the address stored in register P1. If P1 is a return address register, then this accomplishes a return from a subroutine.
If P3 is 1, then the jump is only taken if register P1 holds an integer values, otherwise execution falls through to the next opcode, and the Return becomes a no-op. If P3 is 0, then register P1 must hold an integer or else an assert() is raised. P3 should be set to 1 when this opcode is used in combination with BeginSubrtn, and set to 0 otherwise.
The value in register P1 is unchanged by this opcode.
P2 is not used by the byte-code engine. However, if P2 is positive and also less than the current address, then the "EXPLAIN" output formatter in the CLI will indent all opcodes from the P2 opcode up to be not including the current Return. P2 should be the first opcode in the subroutine from which this opcode is returning. Thus the P2 value is a byte-code indentation hint. See tag-20220407a in wherecode.c and shell.c.
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.