0000: 2f 2a 0a 2a 2a 20 32 30 30 31 20 53 65 70 74 65 /*.** 2001 Septe
0010: 6d 62 65 72 20 31 35 0a 2a 2a 0a 2a 2a 20 54 68 mber 15.**.** Th
0020: 65 20 61 75 74 68 6f 72 20 64 69 73 63 6c 61 69 e author disclai
0030: 6d 73 20 63 6f 70 79 72 69 67 68 74 20 74 6f 20 ms copyright to
0040: 74 68 69 73 20 73 6f 75 72 63 65 20 63 6f 64 65 this source code
0050: 2e 20 20 49 6e 20 70 6c 61 63 65 20 6f 66 0a 2a . In place of.*
0060: 2a 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69 63 65 * a legal notice
0070: 2c 20 68 65 72 65 20 69 73 20 61 20 62 6c 65 73 , here is a bles
0080: 73 69 6e 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 4d sing:.**.** M
0090: 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61 ay you do good a
00a0: 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 2a 2a 20 nd not evil..**
00b0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 May you find
00c0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 forgiveness for
00d0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 yourself and for
00e0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 2a 2a 20 give others..**
00f0: 20 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 May you share
0100: 20 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 freely, never t
0110: 61 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 aking more than
0120: 79 6f 75 20 67 69 76 65 2e 0a 2a 2a 0a 2a 2a 2a you give..**.***
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0170: 2a 2a 2a 2a 2a 2a 0a 2a 2a 20 48 65 61 64 65 72 ******.** Header
0180: 20 66 69 6c 65 20 66 6f 72 20 74 68 65 20 56 69 file for the Vi
0190: 72 74 75 61 6c 20 44 61 74 61 42 61 73 65 20 45 rtual DataBase E
01a0: 6e 67 69 6e 65 20 28 56 44 42 45 29 0a 2a 2a 0a ngine (VDBE).**.
01b0: 2a 2a 20 54 68 69 73 20 68 65 61 64 65 72 20 64 ** This header d
01c0: 65 66 69 6e 65 73 20 74 68 65 20 69 6e 74 65 72 efines the inter
01d0: 66 61 63 65 20 74 6f 20 74 68 65 20 76 69 72 74 face to the virt
01e0: 75 61 6c 20 64 61 74 61 62 61 73 65 20 65 6e 67 ual database eng
01f0: 69 6e 65 0a 2a 2a 20 6f 72 20 56 44 42 45 2e 20 ine.** or VDBE.
0200: 20 54 68 65 20 56 44 42 45 20 69 6d 70 6c 65 6d The VDBE implem
0210: 65 6e 74 73 20 61 6e 20 61 62 73 74 72 61 63 74 ents an abstract
0220: 20 6d 61 63 68 69 6e 65 20 74 68 61 74 20 72 75 machine that ru
0230: 6e 73 20 61 0a 2a 2a 20 73 69 6d 70 6c 65 20 70 ns a.** simple p
0240: 72 6f 67 72 61 6d 20 74 6f 20 61 63 63 65 73 73 rogram to access
0250: 20 61 6e 64 20 6d 6f 64 69 66 79 20 74 68 65 20 and modify the
0260: 75 6e 64 65 72 6c 79 69 6e 67 20 64 61 74 61 62 underlying datab
0270: 61 73 65 2e 0a 2a 2f 0a 23 69 66 6e 64 65 66 20 ase..*/.#ifndef
0280: 53 51 4c 49 54 45 5f 56 44 42 45 5f 48 0a 23 64 SQLITE_VDBE_H.#d
0290: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 56 44 42 efine SQLITE_VDB
02a0: 45 5f 48 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 E_H.#include <st
02b0: 64 69 6f 2e 68 3e 0a 0a 2f 2a 0a 2a 2a 20 41 20 dio.h>../*.** A
02c0: 73 69 6e 67 6c 65 20 56 44 42 45 20 69 73 20 61 single VDBE is a
02d0: 6e 20 6f 70 61 71 75 65 20 73 74 72 75 63 74 75 n opaque structu
02e0: 72 65 20 6e 61 6d 65 64 20 22 56 64 62 65 22 2e re named "Vdbe".
02f0: 20 20 4f 6e 6c 79 20 72 6f 75 74 69 6e 65 73 0a Only routines.
0300: 2a 2a 20 69 6e 20 74 68 65 20 73 6f 75 72 63 65 ** in the source
0310: 20 66 69 6c 65 20 73 71 6c 69 74 65 56 64 62 65 file sqliteVdbe
0320: 2e 63 20 61 72 65 20 61 6c 6c 6f 77 65 64 20 74 .c are allowed t
0330: 6f 20 73 65 65 20 74 68 65 20 69 6e 73 69 64 65 o see the inside
0340: 73 0a 2a 2a 20 6f 66 20 74 68 69 73 20 73 74 72 s.** of this str
0350: 75 63 74 75 72 65 2e 0a 2a 2f 0a 74 79 70 65 64 ucture..*/.typed
0360: 65 66 20 73 74 72 75 63 74 20 56 64 62 65 20 56 ef struct Vdbe V
0370: 64 62 65 3b 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 dbe;../*.** The
0380: 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 66 6f 6c names of the fol
0390: 6c 6f 77 69 6e 67 20 74 79 70 65 73 20 64 65 63 lowing types dec
03a0: 6c 61 72 65 64 20 69 6e 20 76 64 62 65 49 6e 74 lared in vdbeInt
03b0: 2e 68 20 61 72 65 20 72 65 71 75 69 72 65 64 0a .h are required.
03c0: 2a 2a 20 66 6f 72 20 74 68 65 20 56 64 62 65 4f ** for the VdbeO
03d0: 70 20 64 65 66 69 6e 69 74 69 6f 6e 2e 0a 2a 2f p definition..*/
03e0: 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 .typedef struct
03f0: 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 4d 65 sqlite3_value Me
0400: 6d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 m;.typedef struc
0410: 74 20 53 75 62 50 72 6f 67 72 61 6d 20 53 75 62 t SubProgram Sub
0420: 50 72 6f 67 72 61 6d 3b 0a 0a 2f 2a 0a 2a 2a 20 Program;../*.**
0430: 41 20 73 69 6e 67 6c 65 20 69 6e 73 74 72 75 63 A single instruc
0440: 74 69 6f 6e 20 6f 66 20 74 68 65 20 76 69 72 74 tion of the virt
0450: 75 61 6c 20 6d 61 63 68 69 6e 65 20 68 61 73 20 ual machine has
0460: 61 6e 20 6f 70 63 6f 64 65 0a 2a 2a 20 61 6e 64 an opcode.** and
0470: 20 61 73 20 6d 61 6e 79 20 61 73 20 74 68 72 65 as many as thre
0480: 65 20 6f 70 65 72 61 6e 64 73 2e 20 20 54 68 65 e operands. The
0490: 20 69 6e 73 74 72 75 63 74 69 6f 6e 20 69 73 20 instruction is
04a0: 72 65 63 6f 72 64 65 64 0a 2a 2a 20 61 73 20 61 recorded.** as a
04b0: 6e 20 69 6e 73 74 61 6e 63 65 20 6f 66 20 74 68 n instance of th
04c0: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 73 74 72 75 e following stru
04d0: 63 74 75 72 65 3a 0a 2a 2f 0a 73 74 72 75 63 74 cture:.*/.struct
04e0: 20 56 64 62 65 4f 70 20 7b 0a 20 20 75 38 20 6f VdbeOp {. u8 o
04f0: 70 63 6f 64 65 3b 20 20 20 20 20 20 20 20 20 20 pcode;
0500: 2f 2a 20 57 68 61 74 20 6f 70 65 72 61 74 69 6f /* What operatio
0510: 6e 20 74 6f 20 70 65 72 66 6f 72 6d 20 2a 2f 0a n to perform */.
0520: 20 20 73 69 67 6e 65 64 20 63 68 61 72 20 70 34 signed char p4
0530: 74 79 70 65 3b 20 2f 2a 20 4f 6e 65 20 6f 66 20 type; /* One of
0540: 74 68 65 20 50 34 5f 78 78 78 20 63 6f 6e 73 74 the P4_xxx const
0550: 61 6e 74 73 20 66 6f 72 20 70 34 20 2a 2f 0a 20 ants for p4 */.
0560: 20 75 31 36 20 70 35 3b 20 20 20 20 20 20 20 20 u16 p5;
0570: 20 20 20 20 20 2f 2a 20 46 69 66 74 68 20 70 61 /* Fifth pa
0580: 72 61 6d 65 74 65 72 20 69 73 20 61 6e 20 75 6e rameter is an un
0590: 73 69 67 6e 65 64 20 31 36 2d 62 69 74 20 69 6e signed 16-bit in
05a0: 74 65 67 65 72 20 2a 2f 0a 20 20 69 6e 74 20 70 teger */. int p
05b0: 31 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 1; /
05c0: 2a 20 46 69 72 73 74 20 6f 70 65 72 61 6e 64 20 * First operand
05d0: 2a 2f 0a 20 20 69 6e 74 20 70 32 3b 20 20 20 20 */. int p2;
05e0: 20 20 20 20 20 20 20 20 20 2f 2a 20 53 65 63 6f /* Seco
05f0: 6e 64 20 70 61 72 61 6d 65 74 65 72 20 28 6f 66 nd parameter (of
0600: 74 65 6e 20 74 68 65 20 6a 75 6d 70 20 64 65 73 ten the jump des
0610: 74 69 6e 61 74 69 6f 6e 29 20 2a 2f 0a 20 20 69 tination) */. i
0620: 6e 74 20 70 33 3b 20 20 20 20 20 20 20 20 20 20 nt p3;
0630: 20 20 20 2f 2a 20 54 68 65 20 74 68 69 72 64 20 /* The third
0640: 70 61 72 61 6d 65 74 65 72 20 2a 2f 0a 20 20 75 parameter */. u
0650: 6e 69 6f 6e 20 70 34 75 6e 69 6f 6e 20 7b 20 20 nion p4union {
0660: 20 20 20 2f 2a 20 66 6f 75 72 74 68 20 70 61 72 /* fourth par
0670: 61 6d 65 74 65 72 20 2a 2f 0a 20 20 20 20 69 6e ameter */. in
0680: 74 20 69 3b 20 20 20 20 20 20 20 20 20 20 20 20 t i;
0690: 20 20 20 20 20 2f 2a 20 49 6e 74 65 67 65 72 20 /* Integer
06a0: 76 61 6c 75 65 20 69 66 20 70 34 74 79 70 65 3d value if p4type=
06b0: 3d 50 34 5f 49 4e 54 33 32 20 2a 2f 0a 20 20 20 =P4_INT32 */.
06c0: 20 76 6f 69 64 20 2a 70 3b 20 20 20 20 20 20 20 void *p;
06d0: 20 20 20 20 20 20 20 20 2f 2a 20 47 65 6e 65 72 /* Gener
06e0: 69 63 20 70 6f 69 6e 74 65 72 20 2a 2f 0a 20 20 ic pointer */.
06f0: 20 20 63 68 61 72 20 2a 7a 3b 20 20 20 20 20 20 char *z;
0700: 20 20 20 20 20 20 20 20 20 2f 2a 20 50 6f 69 6e /* Poin
0710: 74 65 72 20 74 6f 20 64 61 74 61 20 66 6f 72 20 ter to data for
0720: 73 74 72 69 6e 67 20 28 63 68 61 72 20 61 72 72 string (char arr
0730: 61 79 29 20 74 79 70 65 73 20 2a 2f 0a 20 20 20 ay) types */.
0740: 20 69 36 34 20 2a 70 49 36 34 3b 20 20 20 20 20 i64 *pI64;
0750: 20 20 20 20 20 20 20 20 2f 2a 20 55 73 65 64 20 /* Used
0760: 77 68 65 6e 20 70 34 74 79 70 65 20 69 73 20 50 when p4type is P
0770: 34 5f 49 4e 54 36 34 20 2a 2f 0a 20 20 20 20 64 4_INT64 */. d
0780: 6f 75 62 6c 65 20 2a 70 52 65 61 6c 3b 20 20 20 ouble *pReal;
0790: 20 20 20 20 20 20 2f 2a 20 55 73 65 64 20 77 68 /* Used wh
07a0: 65 6e 20 70 34 74 79 70 65 20 69 73 20 50 34 5f en p4type is P4_
07b0: 52 45 41 4c 20 2a 2f 0a 20 20 20 20 46 75 6e 63 REAL */. Func
07c0: 44 65 66 20 2a 70 46 75 6e 63 3b 20 20 20 20 20 Def *pFunc;
07d0: 20 20 20 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 /* Used when
07e0: 70 34 74 79 70 65 20 69 73 20 50 34 5f 46 55 4e p4type is P4_FUN
07f0: 43 44 45 46 20 2a 2f 0a 20 20 20 20 73 71 6c 69 CDEF */. sqli
0800: 74 65 33 5f 63 6f 6e 74 65 78 74 20 2a 70 43 74 te3_context *pCt
0810: 78 3b 20 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 x; /* Used when
0820: 70 34 74 79 70 65 20 69 73 20 50 34 5f 46 55 4e p4type is P4_FUN
0830: 43 43 54 58 20 2a 2f 0a 20 20 20 20 43 6f 6c 6c CCTX */. Coll
0840: 53 65 71 20 2a 70 43 6f 6c 6c 3b 20 20 20 20 20 Seq *pColl;
0850: 20 20 20 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 /* Used when
0860: 70 34 74 79 70 65 20 69 73 20 50 34 5f 43 4f 4c p4type is P4_COL
0870: 4c 53 45 51 20 2a 2f 0a 20 20 20 20 4d 65 6d 20 LSEQ */. Mem
0880: 2a 70 4d 65 6d 3b 20 20 20 20 20 20 20 20 20 20 *pMem;
0890: 20 20 20 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 /* Used when
08a0: 70 34 74 79 70 65 20 69 73 20 50 34 5f 4d 45 4d p4type is P4_MEM
08b0: 20 2a 2f 0a 20 20 20 20 56 54 61 62 6c 65 20 2a */. VTable *
08c0: 70 56 74 61 62 3b 20 20 20 20 20 20 20 20 20 2f pVtab; /
08d0: 2a 20 55 73 65 64 20 77 68 65 6e 20 70 34 74 79 * Used when p4ty
08e0: 70 65 20 69 73 20 50 34 5f 56 54 41 42 20 2a 2f pe is P4_VTAB */
08f0: 0a 20 20 20 20 4b 65 79 49 6e 66 6f 20 2a 70 4b . KeyInfo *pK
0900: 65 79 49 6e 66 6f 3b 20 20 20 20 20 2f 2a 20 55 eyInfo; /* U
0910: 73 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 20 sed when p4type
0920: 69 73 20 50 34 5f 4b 45 59 49 4e 46 4f 20 2a 2f is P4_KEYINFO */
0930: 0a 20 20 20 20 69 6e 74 20 2a 61 69 3b 20 20 20 . int *ai;
0940: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 55 /* U
0950: 73 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 20 sed when p4type
0960: 69 73 20 50 34 5f 49 4e 54 41 52 52 41 59 20 2a is P4_INTARRAY *
0970: 2f 0a 20 20 20 20 53 75 62 50 72 6f 67 72 61 6d /. SubProgram
0980: 20 2a 70 50 72 6f 67 72 61 6d 3b 20 20 2f 2a 20 *pProgram; /*
0990: 55 73 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 Used when p4type
09a0: 20 69 73 20 50 34 5f 53 55 42 50 52 4f 47 52 41 is P4_SUBPROGRA
09b0: 4d 20 2a 2f 0a 20 20 20 20 54 61 62 6c 65 20 2a M */. Table *
09c0: 70 54 61 62 3b 20 20 20 20 20 20 20 20 20 20 20 pTab;
09d0: 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 70 34 74 /* Used when p4t
09e0: 79 70 65 20 69 73 20 50 34 5f 54 41 42 4c 45 20 ype is P4_TABLE
09f0: 2a 2f 0a 23 69 66 64 65 66 20 53 51 4c 49 54 45 */.#ifdef SQLITE
0a00: 5f 45 4e 41 42 4c 45 5f 43 55 52 53 4f 52 5f 48 _ENABLE_CURSOR_H
0a10: 49 4e 54 53 0a 20 20 20 20 45 78 70 72 20 2a 70 INTS. Expr *p
0a20: 45 78 70 72 3b 20 20 20 20 20 20 20 20 20 20 20 Expr;
0a30: 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 70 34 74 /* Used when p4t
0a40: 79 70 65 20 69 73 20 50 34 5f 45 58 50 52 20 2a ype is P4_EXPR *
0a50: 2f 0a 23 65 6e 64 69 66 0a 20 20 20 20 69 6e 74 /.#endif. int
0a60: 20 28 2a 78 41 64 76 61 6e 63 65 29 28 42 74 43 (*xAdvance)(BtC
0a70: 75 72 73 6f 72 20 2a 2c 20 69 6e 74 29 3b 0a 20 ursor *, int);.
0a80: 20 7d 20 70 34 3b 0a 23 69 66 64 65 66 20 53 51 } p4;.#ifdef SQ
0a90: 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 45 58 50 4c LITE_ENABLE_EXPL
0aa0: 41 49 4e 5f 43 4f 4d 4d 45 4e 54 53 0a 20 20 63 AIN_COMMENTS. c
0ab0: 68 61 72 20 2a 7a 43 6f 6d 6d 65 6e 74 3b 20 20 har *zComment;
0ac0: 20 20 20 20 20 20 20 20 2f 2a 20 43 6f 6d 6d 65 /* Comme
0ad0: 6e 74 20 74 6f 20 69 6d 70 72 6f 76 65 20 72 65 nt to improve re
0ae0: 61 64 61 62 69 6c 69 74 79 20 2a 2f 0a 23 65 6e adability */.#en
0af0: 64 69 66 0a 23 69 66 64 65 66 20 56 44 42 45 5f dif.#ifdef VDBE_
0b00: 50 52 4f 46 49 4c 45 0a 20 20 75 33 32 20 63 6e PROFILE. u32 cn
0b10: 74 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t;
0b20: 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 /* Number of
0b30: 74 69 6d 65 73 20 74 68 69 73 20 69 6e 73 74 72 times this instr
0b40: 75 63 74 69 6f 6e 20 77 61 73 20 65 78 65 63 75 uction was execu
0b50: 74 65 64 20 2a 2f 0a 20 20 75 36 34 20 63 79 63 ted */. u64 cyc
0b60: 6c 65 73 3b 20 20 20 20 20 20 20 20 20 20 20 20 les;
0b70: 20 20 2f 2a 20 54 6f 74 61 6c 20 74 69 6d 65 20 /* Total time
0b80: 73 70 65 6e 74 20 65 78 65 63 75 74 69 6e 67 20 spent executing
0b90: 74 68 69 73 20 69 6e 73 74 72 75 63 74 69 6f 6e this instruction
0ba0: 20 2a 2f 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 */.#endif.#ifde
0bb0: 66 20 53 51 4c 49 54 45 5f 56 44 42 45 5f 43 4f f SQLITE_VDBE_CO
0bc0: 56 45 52 41 47 45 0a 20 20 75 33 32 20 69 53 72 VERAGE. u32 iSr
0bd0: 63 4c 69 6e 65 3b 20 20 20 20 20 20 20 20 20 20 cLine;
0be0: 20 20 2f 2a 20 53 6f 75 72 63 65 2d 63 6f 64 65 /* Source-code
0bf0: 20 6c 69 6e 65 20 74 68 61 74 20 67 65 6e 65 72 line that gener
0c00: 61 74 65 64 20 74 68 69 73 20 6f 70 63 6f 64 65 ated this opcode
0c10: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
0c20: 20 20 20 20 20 20 20 20 20 20 20 20 2a 2a 20 77 ** w
0c30: 69 74 68 20 66 6c 61 67 73 20 69 6e 20 74 68 65 ith flags in the
0c40: 20 75 70 70 65 72 20 38 20 62 69 74 73 20 2a 2f upper 8 bits */
0c50: 0a 23 65 6e 64 69 66 0a 7d 3b 0a 74 79 70 65 64 .#endif.};.typed
0c60: 65 66 20 73 74 72 75 63 74 20 56 64 62 65 4f 70 ef struct VdbeOp
0c70: 20 56 64 62 65 4f 70 3b 0a 0a 0a 2f 2a 0a 2a 2a VdbeOp;.../*.**
0c80: 20 41 20 73 75 62 2d 72 6f 75 74 69 6e 65 20 75 A sub-routine u
0c90: 73 65 64 20 74 6f 20 69 6d 70 6c 65 6d 65 6e 74 sed to implement
0ca0: 20 61 20 74 72 69 67 67 65 72 20 70 72 6f 67 72 a trigger progr
0cb0: 61 6d 2e 0a 2a 2f 0a 73 74 72 75 63 74 20 53 75 am..*/.struct Su
0cc0: 62 50 72 6f 67 72 61 6d 20 7b 0a 20 20 56 64 62 bProgram {. Vdb
0cd0: 65 4f 70 20 2a 61 4f 70 3b 20 20 20 20 20 20 20 eOp *aOp;
0ce0: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 41 72 /* Ar
0cf0: 72 61 79 20 6f 66 20 6f 70 63 6f 64 65 73 20 66 ray of opcodes f
0d00: 6f 72 20 73 75 62 2d 70 72 6f 67 72 61 6d 20 2a or sub-program *
0d10: 2f 0a 20 20 69 6e 74 20 6e 4f 70 3b 20 20 20 20 /. int nOp;
0d20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0d30: 20 20 2f 2a 20 45 6c 65 6d 65 6e 74 73 20 69 6e /* Elements in
0d40: 20 61 4f 70 5b 5d 20 2a 2f 0a 20 20 69 6e 74 20 aOp[] */. int
0d50: 6e 4d 65 6d 3b 20 20 20 20 20 20 20 20 20 20 20 nMem;
0d60: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d /* Num
0d70: 62 65 72 20 6f 66 20 6d 65 6d 6f 72 79 20 63 65 ber of memory ce
0d80: 6c 6c 73 20 72 65 71 75 69 72 65 64 20 2a 2f 0a lls required */.
0d90: 20 20 69 6e 74 20 6e 43 73 72 3b 20 20 20 20 20 int nCsr;
0da0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0db0: 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 63 75 72 /* Number of cur
0dc0: 73 6f 72 73 20 72 65 71 75 69 72 65 64 20 2a 2f sors required */
0dd0: 0a 20 20 75 38 20 2a 61 4f 6e 63 65 3b 20 20 20 . u8 *aOnce;
0de0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0df0: 20 2f 2a 20 41 72 72 61 79 20 6f 66 20 4f 50 5f /* Array of OP_
0e00: 4f 6e 63 65 20 66 6c 61 67 73 20 2a 2f 0a 20 20 Once flags */.
0e10: 76 6f 69 64 20 2a 74 6f 6b 65 6e 3b 20 20 20 20 void *token;
0e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a /*
0e30: 20 69 64 20 74 68 61 74 20 6d 61 79 20 62 65 20 id that may be
0e40: 75 73 65 64 20 74 6f 20 72 65 63 75 72 73 69 76 used to recursiv
0e50: 65 20 74 72 69 67 67 65 72 73 20 2a 2f 0a 20 20 e triggers */.
0e60: 53 75 62 50 72 6f 67 72 61 6d 20 2a 70 4e 65 78 SubProgram *pNex
0e70: 74 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a t; /*
0e80: 20 4e 65 78 74 20 73 75 62 2d 70 72 6f 67 72 61 Next sub-progra
0e90: 6d 20 61 6c 72 65 61 64 79 20 76 69 73 69 74 65 m already visite
0ea0: 64 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 41 d */.};../*.** A
0eb0: 20 73 6d 61 6c 6c 65 72 20 76 65 72 73 69 6f 6e smaller version
0ec0: 20 6f 66 20 56 64 62 65 4f 70 20 75 73 65 64 20 of VdbeOp used
0ed0: 66 6f 72 20 74 68 65 20 56 64 62 65 41 64 64 4f for the VdbeAddO
0ee0: 70 4c 69 73 74 28 29 20 66 75 6e 63 74 69 6f 6e pList() function
0ef0: 20 62 65 63 61 75 73 65 0a 2a 2a 20 69 74 20 74 because.** it t
0f00: 61 6b 65 73 20 75 70 20 6c 65 73 73 20 73 70 61 akes up less spa
0f10: 63 65 2e 0a 2a 2f 0a 73 74 72 75 63 74 20 56 64 ce..*/.struct Vd
0f20: 62 65 4f 70 4c 69 73 74 20 7b 0a 20 20 75 38 20 beOpList {. u8
0f30: 6f 70 63 6f 64 65 3b 20 20 20 20 20 20 20 20 20 opcode;
0f40: 20 2f 2a 20 57 68 61 74 20 6f 70 65 72 61 74 69 /* What operati
0f50: 6f 6e 20 74 6f 20 70 65 72 66 6f 72 6d 20 2a 2f on to perform */
0f60: 0a 20 20 73 69 67 6e 65 64 20 63 68 61 72 20 70 . signed char p
0f70: 31 3b 20 20 20 20 20 2f 2a 20 46 69 72 73 74 20 1; /* First
0f80: 6f 70 65 72 61 6e 64 20 2a 2f 0a 20 20 73 69 67 operand */. sig
0f90: 6e 65 64 20 63 68 61 72 20 70 32 3b 20 20 20 20 ned char p2;
0fa0: 20 2f 2a 20 53 65 63 6f 6e 64 20 70 61 72 61 6d /* Second param
0fb0: 65 74 65 72 20 28 6f 66 74 65 6e 20 74 68 65 20 eter (often the
0fc0: 6a 75 6d 70 20 64 65 73 74 69 6e 61 74 69 6f 6e jump destination
0fd0: 29 20 2a 2f 0a 20 20 73 69 67 6e 65 64 20 63 68 ) */. signed ch
0fe0: 61 72 20 70 33 3b 20 20 20 20 20 2f 2a 20 54 68 ar p3; /* Th
0ff0: 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 2a 2f ird parameter */
1000: 0a 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 .};.typedef stru
1010: 63 74 20 56 64 62 65 4f 70 4c 69 73 74 20 56 64 ct VdbeOpList Vd
1020: 62 65 4f 70 4c 69 73 74 3b 0a 0a 2f 2a 0a 2a 2a beOpList;../*.**
1030: 20 41 6c 6c 6f 77 65 64 20 76 61 6c 75 65 73 20 Allowed values
1040: 6f 66 20 56 64 62 65 4f 70 2e 70 34 74 79 70 65 of VdbeOp.p4type
1050: 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 4e .*/.#define P4_N
1060: 4f 54 55 53 45 44 20 20 20 20 20 20 30 20 20 20 OTUSED 0
1070: 2f 2a 20 54 68 65 20 50 34 20 70 61 72 61 6d 65 /* The P4 parame
1080: 74 65 72 20 69 73 20 6e 6f 74 20 75 73 65 64 20 ter is not used
1090: 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 54 52 */.#define P4_TR
10a0: 41 4e 53 49 45 4e 54 20 20 20 20 30 20 20 20 2f ANSIENT 0 /
10b0: 2a 20 50 34 20 69 73 20 61 20 70 6f 69 6e 74 65 * P4 is a pointe
10c0: 72 20 74 6f 20 61 20 74 72 61 6e 73 69 65 6e 74 r to a transient
10d0: 20 73 74 72 69 6e 67 20 2a 2f 0a 23 64 65 66 69 string */.#defi
10e0: 6e 65 20 50 34 5f 53 54 41 54 49 43 20 20 20 20 ne P4_STATIC
10f0: 20 28 2d 31 29 20 20 2f 2a 20 50 6f 69 6e 74 65 (-1) /* Pointe
1100: 72 20 74 6f 20 61 20 73 74 61 74 69 63 20 73 74 r to a static st
1110: 72 69 6e 67 20 2a 2f 0a 23 64 65 66 69 6e 65 20 ring */.#define
1120: 50 34 5f 43 4f 4c 4c 53 45 51 20 20 20 20 28 2d P4_COLLSEQ (-
1130: 32 29 20 20 2f 2a 20 50 34 20 69 73 20 61 20 70 2) /* P4 is a p
1140: 6f 69 6e 74 65 72 20 74 6f 20 61 20 43 6f 6c 6c ointer to a Coll
1150: 53 65 71 20 73 74 72 75 63 74 75 72 65 20 2a 2f Seq structure */
1160: 0a 23 64 65 66 69 6e 65 20 50 34 5f 49 4e 54 33 .#define P4_INT3
1170: 32 20 20 20 20 20 20 28 2d 33 29 20 20 2f 2a 20 2 (-3) /*
1180: 50 34 20 69 73 20 61 20 33 32 2d 62 69 74 20 73 P4 is a 32-bit s
1190: 69 67 6e 65 64 20 69 6e 74 65 67 65 72 20 2a 2f igned integer */
11a0: 0a 23 64 65 66 69 6e 65 20 50 34 5f 53 55 42 50 .#define P4_SUBP
11b0: 52 4f 47 52 41 4d 20 28 2d 34 29 20 20 2f 2a 20 ROGRAM (-4) /*
11c0: 50 34 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 P4 is a pointer
11d0: 74 6f 20 61 20 53 75 62 50 72 6f 67 72 61 6d 20 to a SubProgram
11e0: 73 74 72 75 63 74 75 72 65 20 2a 2f 0a 23 64 65 structure */.#de
11f0: 66 69 6e 65 20 50 34 5f 41 44 56 41 4e 43 45 20 fine P4_ADVANCE
1200: 20 20 20 28 2d 35 29 20 20 2f 2a 20 50 34 20 69 (-5) /* P4 i
1210: 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 42 s a pointer to B
1220: 74 72 65 65 4e 65 78 74 28 29 20 6f 72 20 42 74 treeNext() or Bt
1230: 72 65 65 50 72 65 76 28 29 20 2a 2f 0a 23 64 65 reePrev() */.#de
1240: 66 69 6e 65 20 50 34 5f 54 41 42 4c 45 20 20 20 fine P4_TABLE
1250: 20 20 20 28 2d 36 29 20 20 2f 2a 20 50 34 20 69 (-6) /* P4 i
1260: 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 s a pointer to a
1270: 20 54 61 62 6c 65 20 73 74 72 75 63 74 75 72 65 Table structure
1280: 20 2a 2f 0a 2f 2a 20 41 62 6f 76 65 20 64 6f 20 */./* Above do
1290: 6e 6f 74 20 6f 77 6e 20 61 6e 79 20 72 65 73 6f not own any reso
12a0: 75 72 63 65 73 2e 20 20 4d 75 73 74 20 66 72 65 urces. Must fre
12b0: 65 20 74 68 6f 73 65 20 62 65 6c 6f 77 20 2a 2f e those below */
12c0: 0a 23 64 65 66 69 6e 65 20 50 34 5f 46 52 45 45 .#define P4_FREE
12d0: 5f 49 46 5f 4c 45 20 28 2d 37 29 0a 23 64 65 66 _IF_LE (-7).#def
12e0: 69 6e 65 20 50 34 5f 44 59 4e 41 4d 49 43 20 20 ine P4_DYNAMIC
12f0: 20 20 28 2d 37 29 20 20 2f 2a 20 50 6f 69 6e 74 (-7) /* Point
1300: 65 72 20 74 6f 20 6d 65 6d 6f 72 79 20 66 72 6f er to memory fro
1310: 6d 20 73 71 6c 69 74 65 4d 61 6c 6c 6f 63 28 29 m sqliteMalloc()
1320: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 46 */.#define P4_F
1330: 55 4e 43 44 45 46 20 20 20 20 28 2d 38 29 20 20 UNCDEF (-8)
1340: 2f 2a 20 50 34 20 69 73 20 61 20 70 6f 69 6e 74 /* P4 is a point
1350: 65 72 20 74 6f 20 61 20 46 75 6e 63 44 65 66 20 er to a FuncDef
1360: 73 74 72 75 63 74 75 72 65 20 2a 2f 0a 23 64 65 structure */.#de
1370: 66 69 6e 65 20 50 34 5f 4b 45 59 49 4e 46 4f 20 fine P4_KEYINFO
1380: 20 20 20 28 2d 39 29 20 20 2f 2a 20 50 34 20 69 (-9) /* P4 i
1390: 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 s a pointer to a
13a0: 20 4b 65 79 49 6e 66 6f 20 73 74 72 75 63 74 75 KeyInfo structu
13b0: 72 65 20 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 re */.#define P4
13c0: 5f 45 58 50 52 20 20 20 20 20 20 20 28 2d 31 30 _EXPR (-10
13d0: 29 20 2f 2a 20 50 34 20 69 73 20 61 20 70 6f 69 ) /* P4 is a poi
13e0: 6e 74 65 72 20 74 6f 20 61 6e 20 45 78 70 72 20 nter to an Expr
13f0: 74 72 65 65 20 2a 2f 0a 23 64 65 66 69 6e 65 20 tree */.#define
1400: 50 34 5f 4d 45 4d 20 20 20 20 20 20 20 20 28 2d P4_MEM (-
1410: 31 31 29 20 2f 2a 20 50 34 20 69 73 20 61 20 70 11) /* P4 is a p
1420: 6f 69 6e 74 65 72 20 74 6f 20 61 20 4d 65 6d 2a ointer to a Mem*
1430: 20 20 20 20 73 74 72 75 63 74 75 72 65 20 2a 2f structure */
1440: 0a 23 64 65 66 69 6e 65 20 50 34 5f 56 54 41 42 .#define P4_VTAB
1450: 20 20 20 20 20 20 20 28 2d 31 32 29 20 2f 2a 20 (-12) /*
1460: 50 34 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 P4 is a pointer
1470: 74 6f 20 61 6e 20 73 71 6c 69 74 65 33 5f 76 74 to an sqlite3_vt
1480: 61 62 20 73 74 72 75 63 74 75 72 65 20 2a 2f 0a ab structure */.
1490: 23 64 65 66 69 6e 65 20 50 34 5f 52 45 41 4c 20 #define P4_REAL
14a0: 20 20 20 20 20 20 28 2d 31 33 29 20 2f 2a 20 50 (-13) /* P
14b0: 34 20 69 73 20 61 20 36 34 2d 62 69 74 20 66 6c 4 is a 64-bit fl
14c0: 6f 61 74 69 6e 67 20 70 6f 69 6e 74 20 76 61 6c oating point val
14d0: 75 65 20 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 ue */.#define P4
14e0: 5f 49 4e 54 36 34 20 20 20 20 20 20 28 2d 31 34 _INT64 (-14
14f0: 29 20 2f 2a 20 50 34 20 69 73 20 61 20 36 34 2d ) /* P4 is a 64-
1500: 62 69 74 20 73 69 67 6e 65 64 20 69 6e 74 65 67 bit signed integ
1510: 65 72 20 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 er */.#define P4
1520: 5f 49 4e 54 41 52 52 41 59 20 20 20 28 2d 31 35 _INTARRAY (-15
1530: 29 20 2f 2a 20 50 34 20 69 73 20 61 20 76 65 63 ) /* P4 is a vec
1540: 74 6f 72 20 6f 66 20 33 32 2d 62 69 74 20 69 6e tor of 32-bit in
1550: 74 65 67 65 72 73 20 2a 2f 0a 23 64 65 66 69 6e tegers */.#defin
1560: 65 20 50 34 5f 46 55 4e 43 43 54 58 20 20 20 20 e P4_FUNCCTX
1570: 28 2d 31 36 29 20 2f 2a 20 50 34 20 69 73 20 61 (-16) /* P4 is a
1580: 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 73 pointer to an s
1590: 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 20 6f qlite3_context o
15a0: 62 6a 65 63 74 20 2a 2f 0a 23 64 65 66 69 6e 65 bject */.#define
15b0: 20 50 34 5f 44 59 4e 42 4c 4f 42 20 20 20 20 28 P4_DYNBLOB (
15c0: 2d 31 37 29 20 2f 2a 20 50 6f 69 6e 74 65 72 20 -17) /* Pointer
15d0: 74 6f 20 6d 65 6d 6f 72 79 20 66 72 6f 6d 20 73 to memory from s
15e0: 71 6c 69 74 65 4d 61 6c 6c 6f 63 28 29 20 2a 2f qliteMalloc() */
15f0: 0a 0a 2f 2a 20 45 72 72 6f 72 20 6d 65 73 73 61 ../* Error messa
1600: 67 65 20 63 6f 64 65 73 20 66 6f 72 20 4f 50 5f ge codes for OP_
1610: 48 61 6c 74 20 2a 2f 0a 23 64 65 66 69 6e 65 20 Halt */.#define
1620: 50 35 5f 43 6f 6e 73 74 72 61 69 6e 74 4e 6f 74 P5_ConstraintNot
1630: 4e 75 6c 6c 20 31 0a 23 64 65 66 69 6e 65 20 50 Null 1.#define P
1640: 35 5f 43 6f 6e 73 74 72 61 69 6e 74 55 6e 69 71 5_ConstraintUniq
1650: 75 65 20 20 32 0a 23 64 65 66 69 6e 65 20 50 35 ue 2.#define P5
1660: 5f 43 6f 6e 73 74 72 61 69 6e 74 43 68 65 63 6b _ConstraintCheck
1670: 20 20 20 33 0a 23 64 65 66 69 6e 65 20 50 35 5f 3.#define P5_
1680: 43 6f 6e 73 74 72 61 69 6e 74 46 4b 20 20 20 20 ConstraintFK
1690: 20 20 34 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 56 4../*.** The V
16a0: 64 62 65 2e 61 43 6f 6c 4e 61 6d 65 20 61 72 72 dbe.aColName arr
16b0: 61 79 20 63 6f 6e 74 61 69 6e 73 20 35 6e 20 4d ay contains 5n M
16c0: 65 6d 20 73 74 72 75 63 74 75 72 65 73 2c 20 77 em structures, w
16d0: 68 65 72 65 20 6e 20 69 73 20 74 68 65 20 0a 2a here n is the .*
16e0: 2a 20 6e 75 6d 62 65 72 20 6f 66 20 63 6f 6c 75 * number of colu
16f0: 6d 6e 73 20 6f 66 20 64 61 74 61 20 72 65 74 75 mns of data retu
1700: 72 6e 65 64 20 62 79 20 74 68 65 20 73 74 61 74 rned by the stat
1710: 65 6d 65 6e 74 2e 0a 2a 2f 0a 23 64 65 66 69 6e ement..*/.#defin
1720: 65 20 43 4f 4c 4e 41 4d 45 5f 4e 41 4d 45 20 20 e COLNAME_NAME
1730: 20 20 20 30 0a 23 64 65 66 69 6e 65 20 43 4f 4c 0.#define COL
1740: 4e 41 4d 45 5f 44 45 43 4c 54 59 50 45 20 31 0a NAME_DECLTYPE 1.
1750: 23 64 65 66 69 6e 65 20 43 4f 4c 4e 41 4d 45 5f #define COLNAME_
1760: 44 41 54 41 42 41 53 45 20 32 0a 23 64 65 66 69 DATABASE 2.#defi
1770: 6e 65 20 43 4f 4c 4e 41 4d 45 5f 54 41 42 4c 45 ne COLNAME_TABLE
1780: 20 20 20 20 33 0a 23 64 65 66 69 6e 65 20 43 4f 3.#define CO
1790: 4c 4e 41 4d 45 5f 43 4f 4c 55 4d 4e 20 20 20 34 LNAME_COLUMN 4
17a0: 0a 23 69 66 64 65 66 20 53 51 4c 49 54 45 5f 45 .#ifdef SQLITE_E
17b0: 4e 41 42 4c 45 5f 43 4f 4c 55 4d 4e 5f 4d 45 54 NABLE_COLUMN_MET
17c0: 41 44 41 54 41 0a 23 20 64 65 66 69 6e 65 20 43 ADATA.# define C
17d0: 4f 4c 4e 41 4d 45 5f 4e 20 20 20 20 20 20 20 20 OLNAME_N
17e0: 35 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 5 /* Number
17f0: 20 6f 66 20 43 4f 4c 4e 41 4d 45 5f 78 78 78 20 of COLNAME_xxx
1800: 73 79 6d 62 6f 6c 73 20 2a 2f 0a 23 65 6c 73 65 symbols */.#else
1810: 0a 23 20 69 66 64 65 66 20 53 51 4c 49 54 45 5f .# ifdef SQLITE_
1820: 4f 4d 49 54 5f 44 45 43 4c 54 59 50 45 0a 23 20 OMIT_DECLTYPE.#
1830: 20 20 64 65 66 69 6e 65 20 43 4f 4c 4e 41 4d 45 define COLNAME
1840: 5f 4e 20 20 20 20 20 20 31 20 20 20 20 20 20 2f _N 1 /
1850: 2a 20 53 74 6f 72 65 20 6f 6e 6c 79 20 74 68 65 * Store only the
1860: 20 6e 61 6d 65 20 2a 2f 0a 23 20 65 6c 73 65 0a name */.# else.
1870: 23 20 20 20 64 65 66 69 6e 65 20 43 4f 4c 4e 41 # define COLNA
1880: 4d 45 5f 4e 20 20 20 20 20 20 32 20 20 20 20 20 ME_N 2
1890: 20 2f 2a 20 53 74 6f 72 65 20 74 68 65 20 6e 61 /* Store the na
18a0: 6d 65 20 61 6e 64 20 64 65 63 6c 74 79 70 65 20 me and decltype
18b0: 2a 2f 0a 23 20 65 6e 64 69 66 0a 23 65 6e 64 69 */.# endif.#endi
18c0: 66 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 66 6f 6c f../*.** The fol
18d0: 6c 6f 77 69 6e 67 20 6d 61 63 72 6f 20 63 6f 6e lowing macro con
18e0: 76 65 72 74 73 20 61 20 72 65 6c 61 74 69 76 65 verts a relative
18f0: 20 61 64 64 72 65 73 73 20 69 6e 20 74 68 65 20 address in the
1900: 70 32 20 66 69 65 6c 64 0a 2a 2a 20 6f 66 20 61 p2 field.** of a
1910: 20 56 64 62 65 4f 70 20 73 74 72 75 63 74 75 72 VdbeOp structur
1920: 65 20 69 6e 74 6f 20 61 20 6e 65 67 61 74 69 76 e into a negativ
1930: 65 20 6e 75 6d 62 65 72 20 73 6f 20 74 68 61 74 e number so that
1940: 20 0a 2a 2a 20 73 71 6c 69 74 65 33 56 64 62 65 .** sqlite3Vdbe
1950: 41 64 64 4f 70 4c 69 73 74 28 29 20 6b 6e 6f 77 AddOpList() know
1960: 73 20 74 68 61 74 20 74 68 65 20 61 64 64 72 65 s that the addre
1970: 73 73 20 69 73 20 72 65 6c 61 74 69 76 65 2e 20 ss is relative.
1980: 20 43 61 6c 6c 69 6e 67 0a 2a 2a 20 74 68 65 20 Calling.** the
1990: 6d 61 63 72 6f 20 61 67 61 69 6e 20 72 65 73 74 macro again rest
19a0: 6f 72 65 73 20 74 68 65 20 61 64 64 72 65 73 73 ores the address
19b0: 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 41 44 44 ..*/.#define ADD
19c0: 52 28 58 29 20 20 28 2d 31 2d 28 58 29 29 0a 0a R(X) (-1-(X))..
19d0: 2f 2a 0a 2a 2a 20 54 68 65 20 6d 61 6b 65 66 69 /*.** The makefi
19e0: 6c 65 20 73 63 61 6e 73 20 74 68 65 20 76 64 62 le scans the vdb
19f0: 65 2e 63 20 73 6f 75 72 63 65 20 66 69 6c 65 20 e.c source file
1a00: 61 6e 64 20 63 72 65 61 74 65 73 20 74 68 65 20 and creates the
1a10: 22 6f 70 63 6f 64 65 73 2e 68 22 0a 2a 2a 20 68 "opcodes.h".** h
1a20: 65 61 64 65 72 20 66 69 6c 65 20 74 68 61 74 20 eader file that
1a30: 64 65 66 69 6e 65 73 20 61 20 6e 75 6d 62 65 72 defines a number
1a40: 20 66 6f 72 20 65 61 63 68 20 6f 70 63 6f 64 65 for each opcode
1a50: 20 75 73 65 64 20 62 79 20 74 68 65 20 56 44 42 used by the VDB
1a60: 45 2e 0a 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 22 E..*/.#include "
1a70: 6f 70 63 6f 64 65 73 2e 68 22 0a 0a 2f 2a 0a 2a opcodes.h"../*.*
1a80: 2a 20 41 64 64 69 74 69 6f 6e 61 6c 20 6e 6f 6e * Additional non
1a90: 2d 70 75 62 6c 69 63 20 53 51 4c 49 54 45 5f 50 -public SQLITE_P
1aa0: 52 45 50 41 52 45 5f 2a 20 66 6c 61 67 73 0a 2a REPARE_* flags.*
1ab0: 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
1ac0: 5f 50 52 45 50 41 52 45 5f 53 41 56 45 53 51 4c _PREPARE_SAVESQL
1ad0: 20 20 30 78 38 30 20 20 2f 2a 20 50 72 65 73 65 0x80 /* Prese
1ae0: 72 76 65 20 53 51 4c 20 74 65 78 74 20 2a 2f 0a rve SQL text */.
1af0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 50 #define SQLITE_P
1b00: 52 45 50 41 52 45 5f 4d 41 53 4b 20 20 20 20 20 REPARE_MASK
1b10: 30 78 30 66 20 20 2f 2a 20 4d 61 73 6b 20 6f 66 0x0f /* Mask of
1b20: 20 70 75 62 6c 69 63 20 66 6c 61 67 73 20 2a 2f public flags */
1b30: 0a 0a 2f 2a 0a 2a 2a 20 50 72 6f 74 6f 74 79 70 ../*.** Prototyp
1b40: 65 73 20 66 6f 72 20 74 68 65 20 56 44 42 45 20 es for the VDBE
1b50: 69 6e 74 65 72 66 61 63 65 2e 20 20 53 65 65 20 interface. See
1b60: 63 6f 6d 6d 65 6e 74 73 20 6f 6e 20 74 68 65 20 comments on the
1b70: 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 0a 2a implementation.*
1b80: 2a 20 66 6f 72 20 61 20 64 65 73 63 72 69 70 74 * for a descript
1b90: 69 6f 6e 20 6f 66 20 77 68 61 74 20 65 61 63 68 ion of what each
1ba0: 20 6f 66 20 74 68 65 73 65 20 72 6f 75 74 69 6e of these routin
1bb0: 65 73 20 64 6f 65 73 2e 0a 2a 2f 0a 56 64 62 65 es does..*/.Vdbe
1bc0: 20 2a 73 71 6c 69 74 65 33 56 64 62 65 43 72 65 *sqlite3VdbeCre
1bd0: 61 74 65 28 50 61 72 73 65 2a 29 3b 0a 69 6e 74 ate(Parse*);.int
1be0: 20 73 71 6c 69 74 65 33 56 64 62 65 41 64 64 4f sqlite3VdbeAddO
1bf0: 70 30 28 56 64 62 65 2a 2c 69 6e 74 29 3b 0a 69 p0(Vdbe*,int);.i
1c00: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 41 64 nt sqlite3VdbeAd
1c10: 64 4f 70 31 28 56 64 62 65 2a 2c 69 6e 74 2c 69 dOp1(Vdbe*,int,i
1c20: 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 nt);.int sqlite3
1c30: 56 64 62 65 41 64 64 4f 70 32 28 56 64 62 65 2a VdbeAddOp2(Vdbe*
1c40: 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 29 3b 0a 69 ,int,int,int);.i
1c50: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 47 6f nt sqlite3VdbeGo
1c60: 74 6f 28 56 64 62 65 2a 2c 69 6e 74 29 3b 0a 69 to(Vdbe*,int);.i
1c70: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 4c 6f nt sqlite3VdbeLo
1c80: 61 64 53 74 72 69 6e 67 28 56 64 62 65 2a 2c 69 adString(Vdbe*,i
1c90: 6e 74 2c 63 6f 6e 73 74 20 63 68 61 72 2a 29 3b nt,const char*);
1ca0: 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 .void sqlite3Vdb
1cb0: 65 4d 75 6c 74 69 4c 6f 61 64 28 56 64 62 65 2a eMultiLoad(Vdbe*
1cc0: 2c 69 6e 74 2c 63 6f 6e 73 74 20 63 68 61 72 2a ,int,const char*
1cd0: 2c 2e 2e 2e 29 3b 0a 69 6e 74 20 73 71 6c 69 74 ,...);.int sqlit
1ce0: 65 33 56 64 62 65 41 64 64 4f 70 33 28 56 64 62 e3VdbeAddOp3(Vdb
1cf0: 65 2a 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 2c 69 e*,int,int,int,i
1d00: 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 nt);.int sqlite3
1d10: 56 64 62 65 41 64 64 4f 70 34 28 56 64 62 65 2a VdbeAddOp4(Vdbe*
1d20: 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 ,int,int,int,int
1d30: 2c 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 50 34 ,const char *zP4
1d40: 2c 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 ,int);.int sqlit
1d50: 65 33 56 64 62 65 41 64 64 4f 70 34 44 75 70 38 e3VdbeAddOp4Dup8
1d60: 28 56 64 62 65 2a 2c 69 6e 74 2c 69 6e 74 2c 69 (Vdbe*,int,int,i
1d70: 6e 74 2c 69 6e 74 2c 63 6f 6e 73 74 20 75 38 2a nt,int,const u8*
1d80: 2c 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 ,int);.int sqlit
1d90: 65 33 56 64 62 65 41 64 64 4f 70 34 49 6e 74 28 e3VdbeAddOp4Int(
1da0: 56 64 62 65 2a 2c 69 6e 74 2c 69 6e 74 2c 69 6e Vdbe*,int,int,in
1db0: 74 2c 69 6e 74 2c 69 6e 74 29 3b 0a 76 6f 69 64 t,int,int);.void
1dc0: 20 73 71 6c 69 74 65 33 56 64 62 65 45 6e 64 43 sqlite3VdbeEndC
1dd0: 6f 72 6f 75 74 69 6e 65 28 56 64 62 65 2a 2c 69 oroutine(Vdbe*,i
1de0: 6e 74 29 3b 0a 23 69 66 20 64 65 66 69 6e 65 64 nt);.#if defined
1df0: 28 53 51 4c 49 54 45 5f 44 45 42 55 47 29 20 26 (SQLITE_DEBUG) &
1e00: 26 20 21 64 65 66 69 6e 65 64 28 53 51 4c 49 54 & !defined(SQLIT
1e10: 45 5f 54 45 53 54 5f 52 45 41 4c 4c 4f 43 5f 53 E_TEST_REALLOC_S
1e20: 54 52 45 53 53 29 0a 20 20 76 6f 69 64 20 73 71 TRESS). void sq
1e30: 6c 69 74 65 33 56 64 62 65 56 65 72 69 66 79 4e lite3VdbeVerifyN
1e40: 6f 4d 61 6c 6c 6f 63 52 65 71 75 69 72 65 64 28 oMallocRequired(
1e50: 56 64 62 65 20 2a 70 2c 20 69 6e 74 20 4e 29 3b Vdbe *p, int N);
1e60: 0a 20 20 76 6f 69 64 20 73 71 6c 69 74 65 33 56 . void sqlite3V
1e70: 64 62 65 56 65 72 69 66 79 4e 6f 52 65 73 75 6c dbeVerifyNoResul
1e80: 74 52 6f 77 28 56 64 62 65 20 2a 70 29 3b 0a 23 tRow(Vdbe *p);.#
1e90: 65 6c 73 65 0a 23 20 64 65 66 69 6e 65 20 73 71 else.# define sq
1ea0: 6c 69 74 65 33 56 64 62 65 56 65 72 69 66 79 4e lite3VdbeVerifyN
1eb0: 6f 4d 61 6c 6c 6f 63 52 65 71 75 69 72 65 64 28 oMallocRequired(
1ec0: 41 2c 42 29 0a 23 20 64 65 66 69 6e 65 20 73 71 A,B).# define sq
1ed0: 6c 69 74 65 33 56 64 62 65 56 65 72 69 66 79 4e lite3VdbeVerifyN
1ee0: 6f 52 65 73 75 6c 74 52 6f 77 28 41 29 0a 23 65 oResultRow(A).#e
1ef0: 6e 64 69 66 0a 23 69 66 20 64 65 66 69 6e 65 64 ndif.#if defined
1f00: 28 53 51 4c 49 54 45 5f 44 45 42 55 47 29 0a 20 (SQLITE_DEBUG).
1f10: 20 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 void sqlite3Vdb
1f20: 65 56 65 72 69 66 79 41 62 6f 72 74 61 62 6c 65 eVerifyAbortable
1f30: 28 56 64 62 65 20 2a 70 2c 20 69 6e 74 29 3b 0a (Vdbe *p, int);.
1f40: 23 65 6c 73 65 0a 23 20 64 65 66 69 6e 65 20 73 #else.# define s
1f50: 71 6c 69 74 65 33 56 64 62 65 56 65 72 69 66 79 qlite3VdbeVerify
1f60: 41 62 6f 72 74 61 62 6c 65 28 41 2c 42 29 0a 23 Abortable(A,B).#
1f70: 65 6e 64 69 66 0a 56 64 62 65 4f 70 20 2a 73 71 endif.VdbeOp *sq
1f80: 6c 69 74 65 33 56 64 62 65 41 64 64 4f 70 4c 69 lite3VdbeAddOpLi
1f90: 73 74 28 56 64 62 65 2a 2c 20 69 6e 74 20 6e 4f st(Vdbe*, int nO
1fa0: 70 2c 20 56 64 62 65 4f 70 4c 69 73 74 20 63 6f p, VdbeOpList co
1fb0: 6e 73 74 20 2a 61 4f 70 2c 69 6e 74 20 69 4c 69 nst *aOp,int iLi
1fc0: 6e 65 6e 6f 29 3b 0a 23 69 66 6e 64 65 66 20 53 neno);.#ifndef S
1fd0: 51 4c 49 54 45 5f 4f 4d 49 54 5f 45 58 50 4c 41 QLITE_OMIT_EXPLA
1fe0: 49 4e 0a 20 20 76 6f 69 64 20 73 71 6c 69 74 65 IN. void sqlite
1ff0: 33 56 64 62 65 45 78 70 6c 61 69 6e 28 50 61 72 3VdbeExplain(Par
2000: 73 65 2a 2c 75 38 2c 63 6f 6e 73 74 20 63 68 61 se*,u8,const cha
2010: 72 2a 2c 2e 2e 2e 29 3b 0a 20 20 76 6f 69 64 20 r*,...);. void
2020: 73 71 6c 69 74 65 33 56 64 62 65 45 78 70 6c 61 sqlite3VdbeExpla
2030: 69 6e 50 6f 70 28 50 61 72 73 65 2a 29 3b 0a 20 inPop(Parse*);.
2040: 20 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 int sqlite3Vdbe
2050: 45 78 70 6c 61 69 6e 50 61 72 65 6e 74 28 50 61 ExplainParent(Pa
2060: 72 73 65 2a 29 3b 0a 23 20 64 65 66 69 6e 65 20 rse*);.# define
2070: 45 78 70 6c 61 69 6e 51 75 65 72 79 50 6c 61 6e ExplainQueryPlan
2080: 28 50 29 20 20 20 20 20 20 20 20 73 71 6c 69 74 (P) sqlit
2090: 65 33 56 64 62 65 45 78 70 6c 61 69 6e 20 50 0a e3VdbeExplain P.
20a0: 23 20 64 65 66 69 6e 65 20 45 78 70 6c 61 69 6e # define Explain
20b0: 51 75 65 72 79 50 6c 61 6e 50 6f 70 28 50 29 20 QueryPlanPop(P)
20c0: 20 20 20 20 73 71 6c 69 74 65 33 56 64 62 65 45 sqlite3VdbeE
20d0: 78 70 6c 61 69 6e 50 6f 70 28 50 29 0a 23 20 64 xplainPop(P).# d
20e0: 65 66 69 6e 65 20 45 78 70 6c 61 69 6e 51 75 65 efine ExplainQue
20f0: 72 79 50 6c 61 6e 50 61 72 65 6e 74 28 50 29 20 ryPlanParent(P)
2100: 20 73 71 6c 69 74 65 33 56 64 62 65 45 78 70 6c sqlite3VdbeExpl
2110: 61 69 6e 50 61 72 65 6e 74 28 50 29 0a 23 65 6c ainParent(P).#el
2120: 73 65 0a 23 20 64 65 66 69 6e 65 20 45 78 70 6c se.# define Expl
2130: 61 69 6e 51 75 65 72 79 50 6c 61 6e 28 50 29 0a ainQueryPlan(P).
2140: 23 20 64 65 66 69 6e 65 20 45 78 70 6c 61 69 6e # define Explain
2150: 51 75 65 72 79 50 6c 61 6e 50 6f 70 28 50 29 0a QueryPlanPop(P).
2160: 23 20 64 65 66 69 6e 65 20 45 78 70 6c 61 69 6e # define Explain
2170: 51 75 65 72 79 50 6c 61 6e 50 61 72 65 6e 74 28 QueryPlanParent(
2180: 50 29 20 30 0a 23 65 6e 64 69 66 0a 76 6f 69 64 P) 0.#endif.void
2190: 20 73 71 6c 69 74 65 33 56 64 62 65 41 64 64 50 sqlite3VdbeAddP
21a0: 61 72 73 65 53 63 68 65 6d 61 4f 70 28 56 64 62 arseSchemaOp(Vdb
21b0: 65 2a 2c 69 6e 74 2c 63 68 61 72 2a 29 3b 0a 76 e*,int,char*);.v
21c0: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 43 oid sqlite3VdbeC
21d0: 68 61 6e 67 65 4f 70 63 6f 64 65 28 56 64 62 65 hangeOpcode(Vdbe
21e0: 2a 2c 20 75 33 32 20 61 64 64 72 2c 20 75 38 29 *, u32 addr, u8)
21f0: 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 ;.void sqlite3Vd
2200: 62 65 43 68 61 6e 67 65 50 31 28 56 64 62 65 2a beChangeP1(Vdbe*
2210: 2c 20 75 33 32 20 61 64 64 72 2c 20 69 6e 74 20 , u32 addr, int
2220: 50 31 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 P1);.void sqlite
2230: 33 56 64 62 65 43 68 61 6e 67 65 50 32 28 56 64 3VdbeChangeP2(Vd
2240: 62 65 2a 2c 20 75 33 32 20 61 64 64 72 2c 20 69 be*, u32 addr, i
2250: 6e 74 20 50 32 29 3b 0a 76 6f 69 64 20 73 71 6c nt P2);.void sql
2260: 69 74 65 33 56 64 62 65 43 68 61 6e 67 65 50 33 ite3VdbeChangeP3
2270: 28 56 64 62 65 2a 2c 20 75 33 32 20 61 64 64 72 (Vdbe*, u32 addr
2280: 2c 20 69 6e 74 20 50 33 29 3b 0a 76 6f 69 64 20 , int P3);.void
2290: 73 71 6c 69 74 65 33 56 64 62 65 43 68 61 6e 67 sqlite3VdbeChang
22a0: 65 50 35 28 56 64 62 65 2a 2c 20 75 31 36 20 50 eP5(Vdbe*, u16 P
22b0: 35 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 5);.void sqlite3
22c0: 56 64 62 65 4a 75 6d 70 48 65 72 65 28 56 64 62 VdbeJumpHere(Vdb
22d0: 65 2a 2c 20 69 6e 74 20 61 64 64 72 29 3b 0a 69 e*, int addr);.i
22e0: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 43 68 nt sqlite3VdbeCh
22f0: 61 6e 67 65 54 6f 4e 6f 6f 70 28 56 64 62 65 2a angeToNoop(Vdbe*
2300: 2c 20 69 6e 74 20 61 64 64 72 29 3b 0a 69 6e 74 , int addr);.int
2310: 20 73 71 6c 69 74 65 33 56 64 62 65 44 65 6c 65 sqlite3VdbeDele
2320: 74 65 50 72 69 6f 72 4f 70 63 6f 64 65 28 56 64 tePriorOpcode(Vd
2330: 62 65 2a 2c 20 75 38 20 6f 70 29 3b 0a 76 6f 69 be*, u8 op);.voi
2340: 64 20 73 71 6c 69 74 65 33 56 64 62 65 43 68 61 d sqlite3VdbeCha
2350: 6e 67 65 50 34 28 56 64 62 65 2a 2c 20 69 6e 74 ngeP4(Vdbe*, int
2360: 20 61 64 64 72 2c 20 63 6f 6e 73 74 20 63 68 61 addr, const cha
2370: 72 20 2a 7a 50 34 2c 20 69 6e 74 20 4e 29 3b 0a r *zP4, int N);.
2380: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
2390: 41 70 70 65 6e 64 50 34 28 56 64 62 65 2a 2c 20 AppendP4(Vdbe*,
23a0: 76 6f 69 64 20 2a 70 50 34 2c 20 69 6e 74 20 70 void *pP4, int p
23b0: 34 74 79 70 65 29 3b 0a 76 6f 69 64 20 73 71 6c 4type);.void sql
23c0: 69 74 65 33 56 64 62 65 53 65 74 50 34 4b 65 79 ite3VdbeSetP4Key
23d0: 49 6e 66 6f 28 50 61 72 73 65 2a 2c 20 49 6e 64 Info(Parse*, Ind
23e0: 65 78 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 ex*);.void sqlit
23f0: 65 33 56 64 62 65 55 73 65 73 42 74 72 65 65 28 e3VdbeUsesBtree(
2400: 56 64 62 65 2a 2c 20 69 6e 74 29 3b 0a 56 64 62 Vdbe*, int);.Vdb
2410: 65 4f 70 20 2a 73 71 6c 69 74 65 33 56 64 62 65 eOp *sqlite3Vdbe
2420: 47 65 74 4f 70 28 56 64 62 65 2a 2c 20 69 6e 74 GetOp(Vdbe*, int
2430: 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 );.int sqlite3Vd
2440: 62 65 4d 61 6b 65 4c 61 62 65 6c 28 56 64 62 65 beMakeLabel(Vdbe
2450: 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 *);.void sqlite3
2460: 56 64 62 65 52 75 6e 4f 6e 6c 79 4f 6e 63 65 28 VdbeRunOnlyOnce(
2470: 56 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c Vdbe*);.void sql
2480: 69 74 65 33 56 64 62 65 52 65 75 73 61 62 6c 65 ite3VdbeReusable
2490: 28 56 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 (Vdbe*);.void sq
24a0: 6c 69 74 65 33 56 64 62 65 44 65 6c 65 74 65 28 lite3VdbeDelete(
24b0: 56 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c Vdbe*);.void sql
24c0: 69 74 65 33 56 64 62 65 43 6c 65 61 72 4f 62 6a ite3VdbeClearObj
24d0: 65 63 74 28 73 71 6c 69 74 65 33 2a 2c 56 64 62 ect(sqlite3*,Vdb
24e0: 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 e*);.void sqlite
24f0: 33 56 64 62 65 4d 61 6b 65 52 65 61 64 79 28 56 3VdbeMakeReady(V
2500: 64 62 65 2a 2c 50 61 72 73 65 2a 29 3b 0a 69 6e dbe*,Parse*);.in
2510: 74 20 73 71 6c 69 74 65 33 56 64 62 65 46 69 6e t sqlite3VdbeFin
2520: 61 6c 69 7a 65 28 56 64 62 65 2a 29 3b 0a 76 6f alize(Vdbe*);.vo
2530: 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 52 65 id sqlite3VdbeRe
2540: 73 6f 6c 76 65 4c 61 62 65 6c 28 56 64 62 65 2a solveLabel(Vdbe*
2550: 2c 20 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 , int);.int sqli
2560: 74 65 33 56 64 62 65 43 75 72 72 65 6e 74 41 64 te3VdbeCurrentAd
2570: 64 72 28 56 64 62 65 2a 29 3b 0a 23 69 66 64 65 dr(Vdbe*);.#ifde
2580: 66 20 53 51 4c 49 54 45 5f 44 45 42 55 47 0a 20 f SQLITE_DEBUG.
2590: 20 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 int sqlite3Vdbe
25a0: 41 73 73 65 72 74 4d 61 79 41 62 6f 72 74 28 56 AssertMayAbort(V
25b0: 64 62 65 20 2a 2c 20 69 6e 74 29 3b 0a 23 65 6e dbe *, int);.#en
25c0: 64 69 66 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 dif.void sqlite3
25d0: 56 64 62 65 52 65 73 65 74 53 74 65 70 52 65 73 VdbeResetStepRes
25e0: 75 6c 74 28 56 64 62 65 2a 29 3b 0a 76 6f 69 64 ult(Vdbe*);.void
25f0: 20 73 71 6c 69 74 65 33 56 64 62 65 52 65 77 69 sqlite3VdbeRewi
2600: 6e 64 28 56 64 62 65 2a 29 3b 0a 69 6e 74 20 73 nd(Vdbe*);.int s
2610: 71 6c 69 74 65 33 56 64 62 65 52 65 73 65 74 28 qlite3VdbeReset(
2620: 56 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c Vdbe*);.void sql
2630: 69 74 65 33 56 64 62 65 53 65 74 4e 75 6d 43 6f ite3VdbeSetNumCo
2640: 6c 73 28 56 64 62 65 2a 2c 69 6e 74 29 3b 0a 69 ls(Vdbe*,int);.i
2650: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 53 65 nt sqlite3VdbeSe
2660: 74 43 6f 6c 4e 61 6d 65 28 56 64 62 65 2a 2c 20 tColName(Vdbe*,
2670: 69 6e 74 2c 20 69 6e 74 2c 20 63 6f 6e 73 74 20 int, int, const
2680: 63 68 61 72 20 2a 2c 20 76 6f 69 64 28 2a 29 28 char *, void(*)(
2690: 76 6f 69 64 2a 29 29 3b 0a 76 6f 69 64 20 73 71 void*));.void sq
26a0: 6c 69 74 65 33 56 64 62 65 43 6f 75 6e 74 43 68 lite3VdbeCountCh
26b0: 61 6e 67 65 73 28 56 64 62 65 2a 29 3b 0a 73 71 anges(Vdbe*);.sq
26c0: 6c 69 74 65 33 20 2a 73 71 6c 69 74 65 33 56 64 lite3 *sqlite3Vd
26d0: 62 65 44 62 28 56 64 62 65 2a 29 3b 0a 75 38 20 beDb(Vdbe*);.u8
26e0: 73 71 6c 69 74 65 33 56 64 62 65 50 72 65 70 61 sqlite3VdbePrepa
26f0: 72 65 46 6c 61 67 73 28 56 64 62 65 2a 29 3b 0a reFlags(Vdbe*);.
2700: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
2710: 53 65 74 53 71 6c 28 56 64 62 65 2a 2c 20 63 6f SetSql(Vdbe*, co
2720: 6e 73 74 20 63 68 61 72 20 2a 7a 2c 20 69 6e 74 nst char *z, int
2730: 20 6e 2c 20 75 38 29 3b 0a 23 69 66 64 65 66 20 n, u8);.#ifdef
2740: 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 4e 4f SQLITE_ENABLE_NO
2750: 52 4d 41 4c 49 5a 45 0a 76 6f 69 64 20 73 71 6c RMALIZE.void sql
2760: 69 74 65 33 56 64 62 65 41 64 64 44 62 6c 71 75 ite3VdbeAddDblqu
2770: 6f 74 65 53 74 72 28 73 71 6c 69 74 65 33 2a 2c oteStr(sqlite3*,
2780: 56 64 62 65 2a 2c 63 6f 6e 73 74 20 63 68 61 72 Vdbe*,const char
2790: 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 *);.int sqlite3V
27a0: 64 62 65 55 73 65 73 44 6f 75 62 6c 65 51 75 6f dbeUsesDoubleQuo
27b0: 74 65 64 53 74 72 69 6e 67 28 56 64 62 65 2a 2c tedString(Vdbe*,
27c0: 63 6f 6e 73 74 20 63 68 61 72 2a 29 3b 0a 23 65 const char*);.#e
27d0: 6e 64 69 66 0a 76 6f 69 64 20 73 71 6c 69 74 65 ndif.void sqlite
27e0: 33 56 64 62 65 53 77 61 70 28 56 64 62 65 2a 2c 3VdbeSwap(Vdbe*,
27f0: 56 64 62 65 2a 29 3b 0a 56 64 62 65 4f 70 20 2a Vdbe*);.VdbeOp *
2800: 73 71 6c 69 74 65 33 56 64 62 65 54 61 6b 65 4f sqlite3VdbeTakeO
2810: 70 41 72 72 61 79 28 56 64 62 65 2a 2c 20 69 6e pArray(Vdbe*, in
2820: 74 2a 2c 20 69 6e 74 2a 29 3b 0a 73 71 6c 69 74 t*, int*);.sqlit
2830: 65 33 5f 76 61 6c 75 65 20 2a 73 71 6c 69 74 65 e3_value *sqlite
2840: 33 56 64 62 65 47 65 74 42 6f 75 6e 64 56 61 6c 3VdbeGetBoundVal
2850: 75 65 28 56 64 62 65 2a 2c 20 69 6e 74 2c 20 75 ue(Vdbe*, int, u
2860: 38 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 8);.void sqlite3
2870: 56 64 62 65 53 65 74 56 61 72 6d 61 73 6b 28 56 VdbeSetVarmask(V
2880: 64 62 65 2a 2c 20 69 6e 74 29 3b 0a 23 69 66 6e dbe*, int);.#ifn
2890: 64 65 66 20 53 51 4c 49 54 45 5f 4f 4d 49 54 5f def SQLITE_OMIT_
28a0: 54 52 41 43 45 0a 20 20 63 68 61 72 20 2a 73 71 TRACE. char *sq
28b0: 6c 69 74 65 33 56 64 62 65 45 78 70 61 6e 64 53 lite3VdbeExpandS
28c0: 71 6c 28 56 64 62 65 2a 2c 20 63 6f 6e 73 74 20 ql(Vdbe*, const
28d0: 63 68 61 72 2a 29 3b 0a 23 65 6e 64 69 66 0a 69 char*);.#endif.i
28e0: 6e 74 20 73 71 6c 69 74 65 33 4d 65 6d 43 6f 6d nt sqlite3MemCom
28f0: 70 61 72 65 28 63 6f 6e 73 74 20 4d 65 6d 2a 2c pare(const Mem*,
2900: 20 63 6f 6e 73 74 20 4d 65 6d 2a 2c 20 63 6f 6e const Mem*, con
2910: 73 74 20 43 6f 6c 6c 53 65 71 2a 29 3b 0a 69 6e st CollSeq*);.in
2920: 74 20 73 71 6c 69 74 65 33 42 6c 6f 62 43 6f 6d t sqlite3BlobCom
2930: 70 61 72 65 28 63 6f 6e 73 74 20 4d 65 6d 2a 2c pare(const Mem*,
2940: 20 63 6f 6e 73 74 20 4d 65 6d 2a 29 3b 0a 0a 76 const Mem*);..v
2950: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 52 oid sqlite3VdbeR
2960: 65 63 6f 72 64 55 6e 70 61 63 6b 28 4b 65 79 49 ecordUnpack(KeyI
2970: 6e 66 6f 2a 2c 69 6e 74 2c 63 6f 6e 73 74 20 76 nfo*,int,const v
2980: 6f 69 64 2a 2c 55 6e 70 61 63 6b 65 64 52 65 63 oid*,UnpackedRec
2990: 6f 72 64 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 ord*);.int sqlit
29a0: 65 33 56 64 62 65 52 65 63 6f 72 64 43 6f 6d 70 e3VdbeRecordComp
29b0: 61 72 65 28 69 6e 74 2c 63 6f 6e 73 74 20 76 6f are(int,const vo
29c0: 69 64 2a 2c 55 6e 70 61 63 6b 65 64 52 65 63 6f id*,UnpackedReco
29d0: 72 64 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 rd*);.int sqlite
29e0: 33 56 64 62 65 52 65 63 6f 72 64 43 6f 6d 70 61 3VdbeRecordCompa
29f0: 72 65 57 69 74 68 53 6b 69 70 28 69 6e 74 2c 20 reWithSkip(int,
2a00: 63 6f 6e 73 74 20 76 6f 69 64 20 2a 2c 20 55 6e const void *, Un
2a10: 70 61 63 6b 65 64 52 65 63 6f 72 64 20 2a 2c 20 packedRecord *,
2a20: 69 6e 74 29 3b 0a 55 6e 70 61 63 6b 65 64 52 65 int);.UnpackedRe
2a30: 63 6f 72 64 20 2a 73 71 6c 69 74 65 33 56 64 62 cord *sqlite3Vdb
2a40: 65 41 6c 6c 6f 63 55 6e 70 61 63 6b 65 64 52 65 eAllocUnpackedRe
2a50: 63 6f 72 64 28 4b 65 79 49 6e 66 6f 2a 29 3b 0a cord(KeyInfo*);.
2a60: 0a 74 79 70 65 64 65 66 20 69 6e 74 20 28 2a 52 .typedef int (*R
2a70: 65 63 6f 72 64 43 6f 6d 70 61 72 65 29 28 69 6e ecordCompare)(in
2a80: 74 2c 63 6f 6e 73 74 20 76 6f 69 64 2a 2c 55 6e t,const void*,Un
2a90: 70 61 63 6b 65 64 52 65 63 6f 72 64 2a 29 3b 0a packedRecord*);.
2aa0: 52 65 63 6f 72 64 43 6f 6d 70 61 72 65 20 73 71 RecordCompare sq
2ab0: 6c 69 74 65 33 56 64 62 65 46 69 6e 64 43 6f 6d lite3VdbeFindCom
2ac0: 70 61 72 65 28 55 6e 70 61 63 6b 65 64 52 65 63 pare(UnpackedRec
2ad0: 6f 72 64 2a 29 3b 0a 0a 23 69 66 6e 64 65 66 20 ord*);..#ifndef
2ae0: 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 54 52 49 47 SQLITE_OMIT_TRIG
2af0: 47 45 52 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 GER.void sqlite3
2b00: 56 64 62 65 4c 69 6e 6b 53 75 62 50 72 6f 67 72 VdbeLinkSubProgr
2b10: 61 6d 28 56 64 62 65 20 2a 2c 20 53 75 62 50 72 am(Vdbe *, SubPr
2b20: 6f 67 72 61 6d 20 2a 29 3b 0a 23 65 6e 64 69 66 ogram *);.#endif
2b30: 0a 0a 69 6e 74 20 73 71 6c 69 74 65 33 4e 6f 74 ..int sqlite3Not
2b40: 50 75 72 65 46 75 6e 63 28 73 71 6c 69 74 65 33 PureFunc(sqlite3
2b50: 5f 63 6f 6e 74 65 78 74 2a 29 3b 0a 0a 2f 2a 20 _context*);../*
2b60: 55 73 65 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c Use SQLITE_ENABL
2b70: 45 5f 43 4f 4d 4d 45 4e 54 53 20 74 6f 20 65 6e E_COMMENTS to en
2b80: 61 62 6c 65 20 67 65 6e 65 72 61 74 69 6f 6e 20 able generation
2b90: 6f 66 20 65 78 74 72 61 20 63 6f 6d 6d 65 6e 74 of extra comment
2ba0: 73 20 6f 6e 0a 2a 2a 20 65 61 63 68 20 56 44 42 s on.** each VDB
2bb0: 45 20 6f 70 63 6f 64 65 2e 0a 2a 2a 0a 2a 2a 20 E opcode..**.**
2bc0: 55 73 65 20 74 68 65 20 53 51 4c 49 54 45 5f 45 Use the SQLITE_E
2bd0: 4e 41 42 4c 45 5f 4d 4f 44 55 4c 45 5f 43 4f 4d NABLE_MODULE_COM
2be0: 4d 45 4e 54 53 20 6d 61 63 72 6f 20 74 6f 20 73 MENTS macro to s
2bf0: 65 65 20 73 6f 6d 65 20 65 78 74 72 61 20 6e 6f ee some extra no
2c00: 2d 6f 70 0a 2a 2a 20 63 6f 6d 6d 65 6e 74 73 20 -op.** comments
2c10: 69 6e 20 56 44 42 45 20 70 72 6f 67 72 61 6d 73 in VDBE programs
2c20: 20 74 68 61 74 20 73 68 6f 77 20 6b 65 79 20 64 that show key d
2c30: 65 63 69 73 69 6f 6e 20 70 6f 69 6e 74 73 20 69 ecision points i
2c40: 6e 20 74 68 65 20 63 6f 64 65 0a 2a 2a 20 67 65 n the code.** ge
2c50: 6e 65 72 61 74 6f 72 2e 0a 2a 2f 0a 23 69 66 64 nerator..*/.#ifd
2c60: 65 66 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 ef SQLITE_ENABLE
2c70: 5f 45 58 50 4c 41 49 4e 5f 43 4f 4d 4d 45 4e 54 _EXPLAIN_COMMENT
2c80: 53 0a 20 20 76 6f 69 64 20 73 71 6c 69 74 65 33 S. void sqlite3
2c90: 56 64 62 65 43 6f 6d 6d 65 6e 74 28 56 64 62 65 VdbeComment(Vdbe
2ca0: 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 2a 2c 20 *, const char*,
2cb0: 2e 2e 2e 29 3b 0a 23 20 64 65 66 69 6e 65 20 56 ...);.# define V
2cc0: 64 62 65 43 6f 6d 6d 65 6e 74 28 58 29 20 20 73 dbeComment(X) s
2cd0: 71 6c 69 74 65 33 56 64 62 65 43 6f 6d 6d 65 6e qlite3VdbeCommen
2ce0: 74 20 58 0a 20 20 76 6f 69 64 20 73 71 6c 69 74 t X. void sqlit
2cf0: 65 33 56 64 62 65 4e 6f 6f 70 43 6f 6d 6d 65 6e e3VdbeNoopCommen
2d00: 74 28 56 64 62 65 2a 2c 20 63 6f 6e 73 74 20 63 t(Vdbe*, const c
2d10: 68 61 72 2a 2c 20 2e 2e 2e 29 3b 0a 23 20 64 65 har*, ...);.# de
2d20: 66 69 6e 65 20 56 64 62 65 4e 6f 6f 70 43 6f 6d fine VdbeNoopCom
2d30: 6d 65 6e 74 28 58 29 20 20 73 71 6c 69 74 65 33 ment(X) sqlite3
2d40: 56 64 62 65 4e 6f 6f 70 43 6f 6d 6d 65 6e 74 20 VdbeNoopComment
2d50: 58 0a 23 20 69 66 64 65 66 20 53 51 4c 49 54 45 X.# ifdef SQLITE
2d60: 5f 45 4e 41 42 4c 45 5f 4d 4f 44 55 4c 45 5f 43 _ENABLE_MODULE_C
2d70: 4f 4d 4d 45 4e 54 53 0a 23 20 20 20 64 65 66 69 OMMENTS.# defi
2d80: 6e 65 20 56 64 62 65 4d 6f 64 75 6c 65 43 6f 6d ne VdbeModuleCom
2d90: 6d 65 6e 74 28 58 29 20 20 73 71 6c 69 74 65 33 ment(X) sqlite3
2da0: 56 64 62 65 4e 6f 6f 70 43 6f 6d 6d 65 6e 74 20 VdbeNoopComment
2db0: 58 0a 23 20 65 6c 73 65 0a 23 20 20 20 64 65 66 X.# else.# def
2dc0: 69 6e 65 20 56 64 62 65 4d 6f 64 75 6c 65 43 6f ine VdbeModuleCo
2dd0: 6d 6d 65 6e 74 28 58 29 0a 23 20 65 6e 64 69 66 mment(X).# endif
2de0: 0a 23 65 6c 73 65 0a 23 20 64 65 66 69 6e 65 20 .#else.# define
2df0: 56 64 62 65 43 6f 6d 6d 65 6e 74 28 58 29 0a 23 VdbeComment(X).#
2e00: 20 64 65 66 69 6e 65 20 56 64 62 65 4e 6f 6f 70 define VdbeNoop
2e10: 43 6f 6d 6d 65 6e 74 28 58 29 0a 23 20 64 65 66 Comment(X).# def
2e20: 69 6e 65 20 56 64 62 65 4d 6f 64 75 6c 65 43 6f ine VdbeModuleCo
2e30: 6d 6d 65 6e 74 28 58 29 0a 23 65 6e 64 69 66 0a mment(X).#endif.
2e40: 0a 2f 2a 0a 2a 2a 20 54 68 65 20 56 64 62 65 43 ./*.** The VdbeC
2e50: 6f 76 65 72 61 67 65 20 6d 61 63 72 6f 73 20 61 overage macros a
2e60: 72 65 20 75 73 65 64 20 74 6f 20 73 65 74 20 61 re used to set a
2e70: 20 63 6f 76 65 72 61 67 65 20 74 65 73 74 69 6e coverage testin
2e80: 67 20 70 6f 69 6e 74 0a 2a 2a 20 66 6f 72 20 56 g point.** for V
2e90: 44 42 45 20 62 72 61 6e 63 68 20 69 6e 73 74 72 DBE branch instr
2ea0: 75 63 74 69 6f 6e 73 2e 20 20 54 68 65 20 63 6f uctions. The co
2eb0: 76 65 72 61 67 65 20 74 65 73 74 69 6e 67 20 70 verage testing p
2ec0: 6f 69 6e 74 73 20 61 72 65 20 6c 69 6e 65 0a 2a oints are line.*
2ed0: 2a 20 6e 75 6d 62 65 72 73 20 69 6e 20 74 68 65 * numbers in the
2ee0: 20 73 71 6c 69 74 65 33 2e 63 20 73 6f 75 72 63 sqlite3.c sourc
2ef0: 65 20 66 69 6c 65 2e 20 20 56 44 42 45 20 62 72 e file. VDBE br
2f00: 61 6e 63 68 20 63 6f 76 65 72 61 67 65 20 74 65 anch coverage te
2f10: 73 74 69 6e 67 0a 2a 2a 20 6f 6e 6c 79 20 77 6f sting.** only wo
2f20: 72 6b 73 20 77 69 74 68 20 61 6e 20 61 6d 61 6c rks with an amal
2f30: 61 67 6d 61 74 69 6f 6e 20 62 75 69 6c 64 2e 20 agmation build.
2f40: 20 54 68 61 74 27 73 20 6f 6b 20 73 69 6e 63 65 That's ok since
2f50: 20 61 20 56 44 42 45 20 62 72 61 6e 63 68 0a 2a a VDBE branch.*
2f60: 2a 20 63 6f 76 65 72 61 67 65 20 62 75 69 6c 64 * coverage build
2f70: 20 64 65 73 69 67 6e 65 64 20 66 6f 72 20 74 65 designed for te
2f80: 73 74 69 6e 67 20 74 68 65 20 74 65 73 74 20 73 sting the test s
2f90: 75 69 74 65 20 6f 6e 6c 79 2e 20 20 4e 6f 20 61 uite only. No a
2fa0: 70 70 6c 69 63 61 74 69 6f 6e 0a 2a 2a 20 73 68 pplication.** sh
2fb0: 6f 75 6c 64 20 65 76 65 72 20 73 68 69 70 20 77 ould ever ship w
2fc0: 69 74 68 20 56 44 42 45 20 62 72 61 6e 63 68 20 ith VDBE branch
2fd0: 63 6f 76 65 72 61 67 65 20 6d 65 61 73 75 72 69 coverage measuri
2fe0: 6e 67 20 74 75 72 6e 65 64 20 6f 6e 2e 0a 2a 2a ng turned on..**
2ff0: 0a 2a 2a 20 20 20 20 56 64 62 65 43 6f 76 65 72 .** VdbeCover
3000: 61 67 65 28 76 29 20 20 20 20 20 20 20 20 20 20 age(v)
3010: 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 72 6b 20 // Mark
3020: 74 68 65 20 70 72 65 76 69 6f 75 73 6c 79 20 63 the previously c
3030: 6f 64 65 64 20 69 6e 73 74 72 75 63 74 69 6f 6e oded instruction
3040: 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 .**
3050: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3060: 20 20 20 20 20 20 20 20 2f 2f 20 61 73 20 61 20 // as a
3070: 62 72 61 6e 63 68 0a 2a 2a 0a 2a 2a 20 20 20 20 branch.**.**
3080: 56 64 62 65 43 6f 76 65 72 61 67 65 49 66 28 76 VdbeCoverageIf(v
3090: 2c 20 63 6f 6e 64 69 74 69 6f 6e 61 6c 29 20 20 , conditional)
30a0: 20 2f 2f 20 4d 61 72 6b 20 70 72 65 76 69 6f 75 // Mark previou
30b0: 73 20 69 66 20 63 6f 6e 64 69 74 69 6f 6e 61 6c s if conditional
30c0: 20 74 72 75 65 0a 2a 2a 0a 2a 2a 20 20 20 20 56 true.**.** V
30d0: 64 62 65 43 6f 76 65 72 61 67 65 41 6c 77 61 79 dbeCoverageAlway
30e0: 73 54 61 6b 65 6e 28 76 29 20 20 20 20 20 20 20 sTaken(v)
30f0: 2f 2f 20 50 72 65 76 69 6f 75 73 20 62 72 61 6e // Previous bran
3100: 63 68 20 69 73 20 61 6c 77 61 79 73 20 74 61 6b ch is always tak
3110: 65 6e 0a 2a 2a 0a 2a 2a 20 20 20 20 56 64 62 65 en.**.** Vdbe
3120: 43 6f 76 65 72 61 67 65 4e 65 76 65 72 54 61 6b CoverageNeverTak
3130: 65 6e 28 76 29 20 20 20 20 20 20 20 20 2f 2f 20 en(v) //
3140: 50 72 65 76 69 6f 75 73 20 62 72 61 6e 63 68 20 Previous branch
3150: 69 73 20 6e 65 76 65 72 20 74 61 6b 65 6e 0a 2a is never taken.*
3160: 2a 0a 2a 2a 20 20 20 20 56 64 62 65 43 6f 76 65 *.** VdbeCove
3170: 72 61 67 65 4e 65 76 65 72 4e 75 6c 6c 28 76 29 rageNeverNull(v)
3180: 20 20 20 20 20 20 20 20 20 2f 2f 20 50 72 65 76 // Prev
3190: 69 6f 75 73 20 74 68 72 65 65 2d 77 61 79 20 62 ious three-way b
31a0: 72 61 6e 63 68 20 69 73 20 6f 6e 6c 79 0a 2a 2a ranch is only.**
31b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
31c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
31d0: 20 20 20 20 20 2f 2f 20 74 61 6b 65 6e 20 6f 6e // taken on
31e0: 20 74 68 65 20 66 69 72 73 74 20 74 77 6f 20 77 the first two w
31f0: 61 79 73 2e 20 20 54 68 65 0a 2a 2a 20 20 20 20 ays. The.**
3200: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3220: 20 2f 2f 20 4e 55 4c 4c 20 6f 70 74 69 6f 6e 20 // NULL option
3230: 69 73 20 6e 6f 74 20 70 6f 73 73 69 62 6c 65 0a is not possible.
3240: 2a 2a 0a 2a 2a 20 20 20 20 56 64 62 65 43 6f 76 **.** VdbeCov
3250: 65 72 61 67 65 45 71 4e 65 28 76 29 20 20 20 20 erageEqNe(v)
3260: 20 20 20 20 20 20 20 20 20 20 2f 2f 20 50 72 65 // Pre
3270: 76 69 6f 75 73 20 4f 50 5f 4a 75 6d 70 20 69 73 vious OP_Jump is
3280: 20 6f 6e 6c 79 20 69 6e 74 65 72 65 73 74 65 64 only interested
3290: 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 .**
32a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
32b0: 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 20 64 69 // in di
32c0: 73 74 69 6e 67 69 73 68 69 6e 67 20 65 71 75 61 stingishing equa
32d0: 6c 20 61 6e 64 20 6e 6f 74 2d 65 71 75 61 6c 2e l and not-equal.
32e0: 0a 2a 2a 0a 2a 2a 20 45 76 65 72 79 20 56 44 42 .**.** Every VDB
32f0: 45 20 62 72 61 6e 63 68 20 6f 70 65 72 61 74 69 E branch operati
3300: 6f 6e 20 6d 75 73 74 20 62 65 20 74 61 67 67 65 on must be tagge
3310: 64 20 77 69 74 68 20 6f 6e 65 20 6f 66 20 74 68 d with one of th
3320: 65 20 6d 61 63 72 6f 73 20 61 62 6f 76 65 2e 0a e macros above..
3330: 2a 2a 20 49 66 20 6e 6f 74 2c 20 74 68 65 6e 20 ** If not, then
3340: 77 68 65 6e 20 22 6d 61 6b 65 20 74 65 73 74 22 when "make test"
3350: 20 69 73 20 72 75 6e 20 77 69 74 68 20 2d 44 53 is run with -DS
3360: 51 4c 49 54 45 5f 56 44 42 45 5f 43 4f 56 45 52 QLITE_VDBE_COVER
3370: 41 47 45 20 61 6e 64 0a 2a 2a 20 2d 44 53 51 4c AGE and.** -DSQL
3380: 49 54 45 5f 44 45 42 55 47 20 74 68 65 6e 20 61 ITE_DEBUG then a
3390: 6e 20 41 4c 57 41 59 53 28 29 20 77 69 6c 6c 20 n ALWAYS() will
33a0: 66 61 69 6c 20 69 6e 20 74 68 65 20 76 64 62 65 fail in the vdbe
33b0: 54 61 6b 65 42 72 61 6e 63 68 28 29 0a 2a 2a 20 TakeBranch().**
33c0: 72 6f 75 74 69 6e 65 20 69 6e 20 76 64 62 65 2e routine in vdbe.
33d0: 63 2c 20 61 6c 65 72 74 69 6e 67 20 74 68 65 20 c, alerting the
33e0: 64 65 76 65 6c 6f 70 65 72 20 74 6f 20 74 68 65 developer to the
33f0: 20 6d 69 73 73 65 64 20 74 61 67 2e 0a 2a 2a 0a missed tag..**.
3400: 2a 2a 20 44 75 72 69 6e 67 20 74 65 73 74 69 6e ** During testin
3410: 67 2c 20 74 68 65 20 74 65 73 74 20 61 70 70 6c g, the test appl
3420: 69 63 61 74 69 6f 6e 20 77 69 6c 6c 20 69 6e 76 ication will inv
3430: 6f 6b 65 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 74 oke.** sqlite3_t
3440: 65 73 74 5f 63 6f 6e 74 72 6f 6c 28 53 51 4c 49 est_control(SQLI
3450: 54 45 5f 54 45 53 54 43 54 52 4c 5f 56 44 42 45 TE_TESTCTRL_VDBE
3460: 5f 43 4f 56 45 52 41 47 45 2c 2e 2e 2e 29 20 74 _COVERAGE,...) t
3470: 6f 20 73 65 74 20 61 20 63 61 6c 6c 62 61 63 6b o set a callback
3480: 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 74 68 61 74 .** routine that
3490: 20 69 73 20 69 6e 76 6f 6b 65 64 20 61 73 20 65 is invoked as e
34a0: 61 63 68 20 62 79 74 65 63 6f 64 65 20 62 72 61 ach bytecode bra
34b0: 6e 63 68 20 69 73 20 74 61 6b 65 6e 2e 20 20 54 nch is taken. T
34c0: 68 65 20 63 61 6c 6c 62 61 63 6b 0a 2a 2a 20 63 he callback.** c
34d0: 6f 6e 74 61 69 6e 73 20 74 68 65 20 73 71 6c 69 ontains the sqli
34e0: 74 65 33 2e 63 20 73 6f 75 72 63 65 20 6c 69 6e te3.c source lin
34f0: 65 20 6e 75 6d 62 65 72 20 6f 76 20 74 68 65 20 e number ov the
3500: 56 64 62 65 43 6f 76 65 72 61 67 65 20 6d 61 63 VdbeCoverage mac
3510: 72 6f 20 61 6e 64 0a 2a 2a 20 66 6c 61 67 73 20 ro and.** flags
3520: 74 6f 20 69 6e 64 69 63 61 74 65 20 77 68 65 74 to indicate whet
3530: 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 65 20 62 her or not the b
3540: 72 61 6e 63 68 20 77 61 73 20 74 61 6b 65 6e 2e ranch was taken.
3550: 20 20 54 68 65 20 74 65 73 74 20 61 70 70 6c 69 The test appli
3560: 63 61 74 69 6f 6e 0a 2a 2a 20 69 73 20 72 65 73 cation.** is res
3570: 70 6f 6e 73 69 62 6c 65 20 66 6f 72 20 6b 65 65 ponsible for kee
3580: 70 69 6e 67 20 74 72 61 63 6b 20 6f 66 20 74 68 ping track of th
3590: 69 73 20 61 6e 64 20 72 65 70 6f 72 74 69 6e 67 is and reporting
35a0: 20 62 79 74 65 2d 63 6f 64 65 20 62 72 61 6e 63 byte-code branc
35b0: 68 65 73 0a 2a 2a 20 74 68 61 74 20 61 72 65 20 hes.** that are
35c0: 6e 65 76 65 72 20 74 61 6b 65 6e 2e 0a 2a 2a 0a never taken..**.
35d0: 2a 2a 20 53 65 65 20 74 68 65 20 56 64 62 65 42 ** See the VdbeB
35e0: 72 61 6e 63 68 54 61 6b 65 6e 28 29 20 6d 61 63 ranchTaken() mac
35f0: 72 6f 20 61 6e 64 20 76 64 62 65 54 61 6b 65 42 ro and vdbeTakeB
3600: 72 61 6e 63 68 28 29 20 66 75 6e 63 74 69 6f 6e ranch() function
3610: 20 69 6e 20 74 68 65 0a 2a 2a 20 76 64 62 65 2e in the.** vdbe.
3620: 63 20 73 6f 75 72 63 65 20 66 69 6c 65 20 66 6f c source file fo
3630: 72 20 61 64 64 69 74 69 6f 6e 61 6c 20 69 6e 66 r additional inf
3640: 6f 72 6d 61 74 69 6f 6e 2e 0a 2a 2f 0a 23 69 66 ormation..*/.#if
3650: 64 65 66 20 53 51 4c 49 54 45 5f 56 44 42 45 5f def SQLITE_VDBE_
3660: 43 4f 56 45 52 41 47 45 0a 20 20 76 6f 69 64 20 COVERAGE. void
3670: 73 71 6c 69 74 65 33 56 64 62 65 53 65 74 4c 69 sqlite3VdbeSetLi
3680: 6e 65 4e 75 6d 62 65 72 28 56 64 62 65 2a 2c 69 neNumber(Vdbe*,i
3690: 6e 74 29 3b 0a 23 20 64 65 66 69 6e 65 20 56 64 nt);.# define Vd
36a0: 62 65 43 6f 76 65 72 61 67 65 28 76 29 20 73 71 beCoverage(v) sq
36b0: 6c 69 74 65 33 56 64 62 65 53 65 74 4c 69 6e 65 lite3VdbeSetLine
36c0: 4e 75 6d 62 65 72 28 76 2c 5f 5f 4c 49 4e 45 5f Number(v,__LINE_
36d0: 5f 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 _).# define Vdbe
36e0: 43 6f 76 65 72 61 67 65 49 66 28 76 2c 78 29 20 CoverageIf(v,x)
36f0: 69 66 28 78 29 73 71 6c 69 74 65 33 56 64 62 65 if(x)sqlite3Vdbe
3700: 53 65 74 4c 69 6e 65 4e 75 6d 62 65 72 28 76 2c SetLineNumber(v,
3710: 5f 5f 4c 49 4e 45 5f 5f 29 0a 23 20 64 65 66 69 __LINE__).# defi
3720: 6e 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 41 ne VdbeCoverageA
3730: 6c 77 61 79 73 54 61 6b 65 6e 28 76 29 20 5c 0a lwaysTaken(v) \.
3740: 20 20 20 20 20 20 20 20 20 73 71 6c 69 74 65 33 sqlite3
3750: 56 64 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 VdbeSetLineNumbe
3760: 72 28 76 2c 5f 5f 4c 49 4e 45 5f 5f 7c 30 78 35 r(v,__LINE__|0x5
3770: 30 30 30 30 30 30 29 3b 0a 23 20 64 65 66 69 6e 000000);.# defin
3780: 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 4e 65 e VdbeCoverageNe
3790: 76 65 72 54 61 6b 65 6e 28 76 29 20 5c 0a 20 20 verTaken(v) \.
37a0: 20 20 20 20 20 20 20 73 71 6c 69 74 65 33 56 64 sqlite3Vd
37b0: 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 72 28 beSetLineNumber(
37c0: 76 2c 5f 5f 4c 49 4e 45 5f 5f 7c 30 78 36 30 30 v,__LINE__|0x600
37d0: 30 30 30 30 29 3b 0a 23 20 64 65 66 69 6e 65 20 0000);.# define
37e0: 56 64 62 65 43 6f 76 65 72 61 67 65 4e 65 76 65 VdbeCoverageNeve
37f0: 72 4e 75 6c 6c 28 76 29 20 5c 0a 20 20 20 20 20 rNull(v) \.
3800: 20 20 20 20 73 71 6c 69 74 65 33 56 64 62 65 53 sqlite3VdbeS
3810: 65 74 4c 69 6e 65 4e 75 6d 62 65 72 28 76 2c 5f etLineNumber(v,_
3820: 5f 4c 49 4e 45 5f 5f 7c 30 78 34 30 30 30 30 30 _LINE__|0x400000
3830: 30 29 3b 0a 23 20 64 65 66 69 6e 65 20 56 64 62 0);.# define Vdb
3840: 65 43 6f 76 65 72 61 67 65 4e 65 76 65 72 4e 75 eCoverageNeverNu
3850: 6c 6c 49 66 28 76 2c 78 29 20 5c 0a 20 20 20 20 llIf(v,x) \.
3860: 20 20 20 20 20 69 66 28 78 29 73 71 6c 69 74 65 if(x)sqlite
3870: 33 56 64 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 3VdbeSetLineNumb
3880: 65 72 28 76 2c 5f 5f 4c 49 4e 45 5f 5f 7c 30 78 er(v,__LINE__|0x
3890: 34 30 30 30 30 30 30 29 3b 0a 23 20 64 65 66 69 4000000);.# defi
38a0: 6e 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 45 ne VdbeCoverageE
38b0: 71 4e 65 28 76 29 20 5c 0a 20 20 20 20 20 20 20 qNe(v) \.
38c0: 20 20 73 71 6c 69 74 65 33 56 64 62 65 53 65 74 sqlite3VdbeSet
38d0: 4c 69 6e 65 4e 75 6d 62 65 72 28 76 2c 5f 5f 4c LineNumber(v,__L
38e0: 49 4e 45 5f 5f 7c 30 78 38 30 30 30 30 30 30 29 INE__|0x8000000)
38f0: 3b 0a 23 20 64 65 66 69 6e 65 20 56 44 42 45 5f ;.# define VDBE_
3900: 4f 46 46 53 45 54 5f 4c 49 4e 45 4e 4f 28 78 29 OFFSET_LINENO(x)
3910: 20 28 5f 5f 4c 49 4e 45 5f 5f 2b 78 29 0a 23 65 (__LINE__+x).#e
3920: 6c 73 65 0a 23 20 64 65 66 69 6e 65 20 56 64 62 lse.# define Vdb
3930: 65 43 6f 76 65 72 61 67 65 28 76 29 0a 23 20 64 eCoverage(v).# d
3940: 65 66 69 6e 65 20 56 64 62 65 43 6f 76 65 72 61 efine VdbeCovera
3950: 67 65 49 66 28 76 2c 78 29 0a 23 20 64 65 66 69 geIf(v,x).# defi
3960: 6e 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 41 ne VdbeCoverageA
3970: 6c 77 61 79 73 54 61 6b 65 6e 28 76 29 0a 23 20 lwaysTaken(v).#
3980: 64 65 66 69 6e 65 20 56 64 62 65 43 6f 76 65 72 define VdbeCover
3990: 61 67 65 4e 65 76 65 72 54 61 6b 65 6e 28 76 29 ageNeverTaken(v)
39a0: 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 43 6f .# define VdbeCo
39b0: 76 65 72 61 67 65 4e 65 76 65 72 4e 75 6c 6c 28 verageNeverNull(
39c0: 76 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 v).# define Vdbe
39d0: 43 6f 76 65 72 61 67 65 4e 65 76 65 72 4e 75 6c CoverageNeverNul
39e0: 6c 49 66 28 76 2c 78 29 0a 23 20 64 65 66 69 6e lIf(v,x).# defin
39f0: 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 45 71 e VdbeCoverageEq
3a00: 4e 65 28 76 29 0a 23 20 64 65 66 69 6e 65 20 56 Ne(v).# define V
3a10: 44 42 45 5f 4f 46 46 53 45 54 5f 4c 49 4e 45 4e DBE_OFFSET_LINEN
3a20: 4f 28 78 29 20 30 0a 23 65 6e 64 69 66 0a 0a 23 O(x) 0.#endif..#
3a30: 69 66 64 65 66 20 53 51 4c 49 54 45 5f 45 4e 41 ifdef SQLITE_ENA
3a40: 42 4c 45 5f 53 54 4d 54 5f 53 43 41 4e 53 54 41 BLE_STMT_SCANSTA
3a50: 54 55 53 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 TUS.void sqlite3
3a60: 56 64 62 65 53 63 61 6e 53 74 61 74 75 73 28 56 VdbeScanStatus(V
3a70: 64 62 65 2a 2c 20 69 6e 74 2c 20 69 6e 74 2c 20 dbe*, int, int,
3a80: 69 6e 74 2c 20 4c 6f 67 45 73 74 2c 20 63 6f 6e int, LogEst, con
3a90: 73 74 20 63 68 61 72 2a 29 3b 0a 23 65 6c 73 65 st char*);.#else
3aa0: 0a 23 20 64 65 66 69 6e 65 20 73 71 6c 69 74 65 .# define sqlite
3ab0: 33 56 64 62 65 53 63 61 6e 53 74 61 74 75 73 28 3VdbeScanStatus(
3ac0: 61 2c 62 2c 63 2c 64 2c 65 29 0a 23 65 6e 64 69 a,b,c,d,e).#endi
3ad0: 66 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 28 53 f..#if defined(S
3ae0: 51 4c 49 54 45 5f 44 45 42 55 47 29 20 7c 7c 20 QLITE_DEBUG) ||
3af0: 64 65 66 69 6e 65 64 28 56 44 42 45 5f 50 52 4f defined(VDBE_PRO
3b00: 46 49 4c 45 29 0a 76 6f 69 64 20 73 71 6c 69 74 FILE).void sqlit
3b10: 65 33 56 64 62 65 50 72 69 6e 74 4f 70 28 46 49 e3VdbePrintOp(FI
3b20: 4c 45 2a 2c 20 69 6e 74 2c 20 56 64 62 65 4f 70 LE*, int, VdbeOp
3b30: 2a 29 3b 0a 23 65 6e 64 69 66 0a 0a 23 65 6e 64 *);.#endif..#end
3b40: 69 66 20 2f 2a 20 53 51 4c 49 54 45 5f 56 44 42 if /* SQLITE_VDB
3b50: 45 5f 48 20 2a 2f 0a E_H */.