SQLite VDBE opcode

Function

Invoke a user function (P4 is a pointer to an sqlite3_context object that contains a pointer to the function to be run) with arguments taken from register P2 and successors.

An example

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

SELECT random()
addropcodep1p2p3p4p5
0Init0400
1Function001random(0)0
2ResultRow1100
3Halt0000
4Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Goto, Halt, Init, ResultRow.

What the SQLite documentation says

Invoke a user function (P4 is a pointer to an sqlite3_context object that contains a pointer to the function to be run) with arguments taken from register P2 and successors. The number of arguments is in the sqlite3_context object that P4 points to. The result of the function is stored in register P3. Register P3 must not be one of the function inputs.

P1 is a 32-bit bitmask indicating whether or not each argument to the function was determined to be constant at compile time. If the first argument was constant then bit 0 of P1 is set. This is used to determine whether meta data associated with a user function argument using the sqlite3_set_auxdata() API may be safely retained until the next invocation of this opcode.

See also: AggStep, AggFinal, PureFunc

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.

← Found · Ge →