SQLite VDBE opcode

AggValue

Invoke the xValue() function and store the result in register P3.

An example

4 of the 178 statements we compiled against the sample database use AggValue. This is the one with the shortest program; the rows that use AggValue are highlighted.

SELECT name, row_number() OVER (ORDER BY ms) FROM tracks
addropcodep1p2p3p4p5
0Init05900
1Null0100
2InitCoroutine31930
3SorterOpen640k(1,B)0
4OpenRead04040
5Rewind01100
6Column0250
7Column0340
8MakeRecord4270
9SorterInsert67420
10Next0601
11OpenPseudo7840
12SorterSort61800
13SorterData6870
14Column7060
15Column7150
16Yield3000
17SorterNext61300
18EndCoroutine3000
19OpenEphemeral1200
20OpenDup2100
21OpenDup3100
22OpenDup4100
23Integer1900
24InitCoroutine3030
25Yield34300
26Copy51102
27Copy61202
28MakeRecord112130
29NewRowid21400
30Insert213140
31Ne936140
32Null0100
33Rewind1000
34Rewind4000
35Goto04200
36AggStep0151row_number(0)0
37Next43800
38AggValue102row_number(0)0
39Gosub105400
40Delete1002
41Next14200
42Goto02500
43Rewind25200
44AggStep0151row_number(0)0
45Next44600
46AggValue102row_number(0)0
47Gosub105400
48Delete1002
49Next15100
50Goto05200
51Goto04600
52ResetSorter1000
53Goto05800
54Column10150
55Copy21600
56ResultRow15200
57Return10000
58Halt0000
59Transaction00101
60Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: AggStep, Column, Copy, Delete, EndCoroutine, Gosub, Goto, Halt, Init, InitCoroutine, Insert, Integer, MakeRecord, Ne, NewRowid, Next, Null, OpenDup, OpenEphemeral, OpenPseudo, OpenRead, ResetSorter, ResultRow, Return, Rewind, SorterData, SorterInsert, SorterNext, SorterOpen, SorterSort, Transaction, Yield.

What the SQLite documentation says

Invoke the xValue() function and store the result in register P3.

P2 is the number of arguments that the step function takes and P4 is a pointer to the FuncDef for this function. The P2 argument is not used by this opcode. It is only there to disambiguate functions that can take varying numbers of arguments. The P4 argument is only needed for the case where the step function was not previously called.

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.

← AggStep1 · And →