SQLite VDBE opcode

Eq

Compare the values in register P1 and P3.

Jumps: P2 is an instruction address. In the listings here, a jump is drawn as an arc and the address is a link.

An example

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

DROP VIEW album_lengths
addropcodep1p2p3p4p5
0Init01400
1Null0100
2OpenWrite01050
3Rewind01100
4Column0220
5Ne3102BINARY-882
6Column0020
7Eq4102BINARY-882
8Rowid0500
9Delete0002
10Next0401
11DropTable000album_lengths0
12SetCookie0120
13Halt0000
14Transaction01101
15String8030album_lengths0
16String8040trigger0
17Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Delete, DropTable, Goto, Halt, Init, Ne, Next, Null, OpenWrite, Rewind, Rowid, SetCookie, String8, Transaction.

What the SQLite documentation says

Compare the values in register P1 and P3. If reg(P3)==reg(P1) then jump to address P2.

The SQLITE_AFF_MASK portion of P5 must be an affinity character - SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made to coerce both inputs according to this affinity before the comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric affinity is used. Note that the affinity conversions are stored back into the input registers P1 and P3. So this opcode can cause persistent changes to registers P1 and P3.

Once any conversions have taken place, and neither value is NULL, the values are compared. If both values are blobs then memcmp() is used to determine the results of the comparison. If both values are text, then the appropriate collating function specified in P4 is used to do the comparison. If P4 is not specified then memcmp() is used to compare text string. If both values are numeric, then a numeric comparison is used. If the two values are of different types, then numbers are considered less than strings and strings are considered less than blobs.

If SQLITE_NULLEQ is set in P5 then the result of comparison is always either true or false and is never NULL. If both operands are NULL then the result of comparison is true. If either operand is NULL then the result is false. If neither operand is NULL the result is the same as it would be if the SQLITE_NULLEQ flag were omitted from P5.

This opcode saves the result of comparison for use by the new Jump opcode.

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.

← EndCoroutine · Expire →