SQLite VDBE opcode

Concat

Add the text in register P1 onto the end of the text in register P2 and store the result in register P3.

An example

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

SELECT name || ' (' || country || ')' FROM artists
addropcodep1p2p3p4p5
0Init01100
1OpenRead02030
2Rewind01000
3Column0140
4Concat5430
5Column0240
6Concat4320
7Concat6210
8ResultRow1100
9Next0301
10Halt0000
11Transaction00101
12String8050 (0
13String8060)0
14Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Goto, Halt, Init, Next, OpenRead, ResultRow, Rewind, String8, Transaction.

What the SQLite documentation says

Add the text in register P1 onto the end of the text in register P2 and store the result in register P3. If either the P1 or P2 text are NULL then store NULL in P3.

P3 = P2 || P1

It is illegal for P1 and P3 to be the same register. Sometimes, if P3 is the same register as P2, the implementation is able to avoid a memcpy().

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.

← Compare · Copy →