SQLite VDBE opcode

SCopy

Make a shallow copy of register P1 into register P2.

An example

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

INSERT OR REPLACE INTO genres VALUES ('Jazz', 'Swing')
addropcodep1p2p3p4p5
0Init01200
1OpenWrite190k(1,)0
2String8020Jazz0
3String8030Swing0
4Null0100
5HaltIfNull129922genres.name1
6Affinity220BB0
7SCopy2500
8SCopy3600
9MakeRecord5240
10IdxInsert145117
11Halt0000
12Transaction01101
13Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Affinity, Goto, Halt, HaltIfNull, IdxInsert, Init, MakeRecord, Null, OpenWrite, String8, Transaction.

What the SQLite documentation says

Make a shallow copy of register P1 into register P2.

This instruction makes a shallow copy of the value. If the value is a string or blob, then the copy is only a pointer to the original and hence if the original changes so will the copy. Worse, if the original is deallocated, the copy becomes invalid. Thus the program must guarantee that the original will not change during the lifetime of the copy. Use Copy to make a complete copy.

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.

← Savepoint · SeekEnd →