SQLite VDBE opcode

AggInverse

Execute the xInverse function for an aggregate.

An example

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

SELECT percent_rank() OVER (ORDER BY ms) FROM tracks
addropcodep1p2p3p4p5
0Init08000
1Null0100
2InitCoroutine31730
3SorterOpen630k(1,B)0
4OpenRead04040
5Rewind01000
6Column0340
7MakeRecord4160
8SorterInsert66410
9Next0601
10OpenPseudo7730
11SorterSort61600
12SorterData6770
13Column7050
14Yield3000
15SorterNext61200
16EndCoroutine3000
17OpenEphemeral1100
18OpenDup2100
19OpenDup3100
20OpenDup4100
21Integer1800
22InitCoroutine3030
23Yield34900
24Copy51002
25MakeRecord101110
26NewRowid21200
27Insert211120
28Ne838120
29Null0100
30Rewind3000
31Rewind1000
32Rewind4000
33Copy101300
34Copy131400
35Copy131500
36Copy131600
37Goto04800
38Compare13101k(1,B)0
39Jump4048400
40Copy101300
41AggStep0171percent_rank(0)0
42Next44400
43Goto04800
44Column40170
45Compare16171k(1,B)0
46Jump4741470
47Copy171600
48Goto02300
49Rewind27400
50AggStep0171percent_rank(0)0
51Next45300
52Goto05700
53Column40170
54Compare16171k(1,B)0
55Jump5650560
56Copy171600
57AggValue102percent_rank(0)0
58Gosub97600
59Next16100
60Goto07400
61Column10170
62Compare15171k(1,B)0
63Jump6458640
64Copy171500
65AggInverse1171percent_rank(0)0
66Delete3002
67Next36900
68Goto07300
69Column30170
70Compare14171k(1,B)0
71Jump7265720
72Copy171400
73Goto05700
74ResetSorter1000
75Goto07900
76Copy21800
77ResultRow18100
78Return9000
79Halt0000
80Transaction00101
81Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: AggStep, AggValue, Column, Compare, Copy, Delete, EndCoroutine, Gosub, Goto, Halt, Init, InitCoroutine, Insert, Integer, Jump, 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

Execute the xInverse function for an aggregate. The function has P5 arguments. P4 is a pointer to the FuncDef structure that specifies the function. Register P3 is the accumulator.

The P5 arguments are taken from register P2 and its successors.

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.

← AggFinal · AggStep →