SQLite VDBE opcode

SetCookie

Write the integer value P3 into cookie number P2 of database P1.

An example

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

PRAGMA user_version = 3
addropcodep1p2p3p4p5
0Init0500
1Expire1100
2Transaction0100
3SetCookie0631
4Halt0000
5Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Expire, Goto, Halt, Init, Transaction.

What the SQLite documentation says

Write the integer value P3 into cookie number P2 of database P1. P2==1 is the schema version. P2==2 is the database format. P2==3 is the recommended pager cache size, and so forth. P1==0 is the main database file and P1==1 is the database file used to store temporary tables.

A transaction must be started before executing this opcode.

If P2 is the SCHEMA_VERSION cookie (cookie number 1) then the internal schema version is set to P3-P5. The "PRAGMA schema_version=N" statement has P5 set to 1, so that the internal schema version will be different from the database schema version, resulting in a schema reset.

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.

← SequenceTest · SetSubtype →