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: 5f 53 51 4c 49 54 45 5f 56 44 42 45 5f 48 5f 0a _SQLITE_VDBE_H_.
0290: 23 64 65 66 69 6e 65 20 5f 53 51 4c 49 54 45 5f #define _SQLITE_
02a0: 56 44 42 45 5f 48 5f 0a 23 69 6e 63 6c 75 64 65 VDBE_H_.#include
02b0: 20 3c 73 74 64 69 6f 2e 68 3e 0a 0a 2f 2a 0a 2a <stdio.h>../*.*
02c0: 2a 20 41 20 73 69 6e 67 6c 65 20 56 44 42 45 20 * A single VDBE
02d0: 69 73 20 61 6e 20 6f 70 61 71 75 65 20 73 74 72 is an opaque str
02e0: 75 63 74 75 72 65 20 6e 61 6d 65 64 20 22 56 64 ucture named "Vd
02f0: 62 65 22 2e 20 20 4f 6e 6c 79 20 72 6f 75 74 69 be". Only routi
0300: 6e 65 73 0a 2a 2a 20 69 6e 20 74 68 65 20 73 6f nes.** in the so
0310: 75 72 63 65 20 66 69 6c 65 20 73 71 6c 69 74 65 urce file sqlite
0320: 56 64 62 65 2e 63 20 61 72 65 20 61 6c 6c 6f 77 Vdbe.c are allow
0330: 65 64 20 74 6f 20 73 65 65 20 74 68 65 20 69 6e ed to see the in
0340: 73 69 64 65 73 0a 2a 2a 20 6f 66 20 74 68 69 73 sides.** of this
0350: 20 73 74 72 75 63 74 75 72 65 2e 0a 2a 2f 0a 74 structure..*/.t
0360: 79 70 65 64 65 66 20 73 74 72 75 63 74 20 56 64 ypedef struct Vd
0370: 62 65 20 56 64 62 65 3b 0a 0a 2f 2a 0a 2a 2a 20 be Vdbe;../*.**
0380: 54 68 65 20 6e 61 6d 65 73 20 6f 66 20 74 68 65 The names of the
0390: 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 79 70 65 73 following types
03a0: 20 64 65 63 6c 61 72 65 64 20 69 6e 20 76 64 62 declared in vdb
03b0: 65 49 6e 74 2e 68 20 61 72 65 20 72 65 71 75 69 eInt.h are requi
03c0: 72 65 64 0a 2a 2a 20 66 6f 72 20 74 68 65 20 56 red.** for the V
03d0: 64 62 65 4f 70 20 64 65 66 69 6e 69 74 69 6f 6e dbeOp definition
03e0: 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 20 73 74 72 ..*/.typedef str
03f0: 75 63 74 20 4d 65 6d 20 4d 65 6d 3b 0a 74 79 70 uct Mem Mem;.typ
0400: 65 64 65 66 20 73 74 72 75 63 74 20 53 75 62 50 edef struct SubP
0410: 72 6f 67 72 61 6d 20 53 75 62 50 72 6f 67 72 61 rogram SubProgra
0420: 6d 3b 0a 0a 2f 2a 0a 2a 2a 20 41 20 73 69 6e 67 m;../*.** A sing
0430: 6c 65 20 69 6e 73 74 72 75 63 74 69 6f 6e 20 6f le instruction o
0440: 66 20 74 68 65 20 76 69 72 74 75 61 6c 20 6d 61 f the virtual ma
0450: 63 68 69 6e 65 20 68 61 73 20 61 6e 20 6f 70 63 chine has an opc
0460: 6f 64 65 0a 2a 2a 20 61 6e 64 20 61 73 20 6d 61 ode.** and as ma
0470: 6e 79 20 61 73 20 74 68 72 65 65 20 6f 70 65 72 ny as three oper
0480: 61 6e 64 73 2e 20 20 54 68 65 20 69 6e 73 74 72 ands. The instr
0490: 75 63 74 69 6f 6e 20 69 73 20 72 65 63 6f 72 64 uction is record
04a0: 65 64 0a 2a 2a 20 61 73 20 61 6e 20 69 6e 73 74 ed.** as an inst
04b0: 61 6e 63 65 20 6f 66 20 74 68 65 20 66 6f 6c 6c ance of the foll
04c0: 6f 77 69 6e 67 20 73 74 72 75 63 74 75 72 65 3a owing structure:
04d0: 0a 2a 2f 0a 73 74 72 75 63 74 20 56 64 62 65 4f .*/.struct VdbeO
04e0: 70 20 7b 0a 20 20 75 38 20 6f 70 63 6f 64 65 3b p {. u8 opcode;
04f0: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 57 68 61 /* Wha
0500: 74 20 6f 70 65 72 61 74 69 6f 6e 20 74 6f 20 70 t operation to p
0510: 65 72 66 6f 72 6d 20 2a 2f 0a 20 20 73 69 67 6e erform */. sign
0520: 65 64 20 63 68 61 72 20 70 34 74 79 70 65 3b 20 ed char p4type;
0530: 2f 2a 20 4f 6e 65 20 6f 66 20 74 68 65 20 50 34 /* One of the P4
0540: 5f 78 78 78 20 63 6f 6e 73 74 61 6e 74 73 20 66 _xxx constants f
0550: 6f 72 20 70 34 20 2a 2f 0a 20 20 75 38 20 6f 70 or p4 */. u8 op
0560: 66 6c 61 67 73 3b 20 20 20 20 20 20 20 20 20 2f flags; /
0570: 2a 20 4d 61 73 6b 20 6f 66 20 74 68 65 20 4f 50 * Mask of the OP
0580: 46 4c 47 5f 2a 20 66 6c 61 67 73 20 69 6e 20 6f FLG_* flags in o
0590: 70 63 6f 64 65 73 2e 68 20 2a 2f 0a 20 20 75 38 pcodes.h */. u8
05a0: 20 70 35 3b 20 20 20 20 20 20 20 20 20 20 20 20 p5;
05b0: 20 20 2f 2a 20 46 69 66 74 68 20 70 61 72 61 6d /* Fifth param
05c0: 65 74 65 72 20 69 73 20 61 6e 20 75 6e 73 69 67 eter is an unsig
05d0: 6e 65 64 20 63 68 61 72 61 63 74 65 72 20 2a 2f ned character */
05e0: 0a 20 20 69 6e 74 20 70 31 3b 20 20 20 20 20 20 . int p1;
05f0: 20 20 20 20 20 20 20 2f 2a 20 46 69 72 73 74 20 /* First
0600: 6f 70 65 72 61 6e 64 20 2a 2f 0a 20 20 69 6e 74 operand */. int
0610: 20 70 32 3b 20 20 20 20 20 20 20 20 20 20 20 20 p2;
0620: 20 2f 2a 20 53 65 63 6f 6e 64 20 70 61 72 61 6d /* Second param
0630: 65 74 65 72 20 28 6f 66 74 65 6e 20 74 68 65 20 eter (often the
0640: 6a 75 6d 70 20 64 65 73 74 69 6e 61 74 69 6f 6e jump destination
0650: 29 20 2a 2f 0a 20 20 69 6e 74 20 70 33 3b 20 20 ) */. int p3;
0660: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 68 /* Th
0670: 65 20 74 68 69 72 64 20 70 61 72 61 6d 65 74 65 e third paramete
0680: 72 20 2a 2f 0a 20 20 75 6e 69 6f 6e 20 7b 20 20 r */. union {
0690: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 66 6f /* fo
06a0: 75 72 74 68 20 70 61 72 61 6d 65 74 65 72 20 2a urth parameter *
06b0: 2f 0a 20 20 20 20 69 6e 74 20 69 3b 20 20 20 20 /. int i;
06c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
06d0: 49 6e 74 65 67 65 72 20 76 61 6c 75 65 20 69 66 Integer value if
06e0: 20 70 34 74 79 70 65 3d 3d 50 34 5f 49 4e 54 33 p4type==P4_INT3
06f0: 32 20 2a 2f 0a 20 20 20 20 76 6f 69 64 20 2a 70 2 */. void *p
0700: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
0710: 2f 2a 20 47 65 6e 65 72 69 63 20 70 6f 69 6e 74 /* Generic point
0720: 65 72 20 2a 2f 0a 20 20 20 20 63 68 61 72 20 2a er */. char *
0730: 7a 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 z;
0740: 20 2f 2a 20 50 6f 69 6e 74 65 72 20 74 6f 20 64 /* Pointer to d
0750: 61 74 61 20 66 6f 72 20 73 74 72 69 6e 67 20 28 ata for string (
0760: 63 68 61 72 20 61 72 72 61 79 29 20 74 79 70 65 char array) type
0770: 73 20 2a 2f 0a 20 20 20 20 69 36 34 20 2a 70 49 s */. i64 *pI
0780: 36 34 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 64;
0790: 2f 2a 20 55 73 65 64 20 77 68 65 6e 20 70 34 74 /* Used when p4t
07a0: 79 70 65 20 69 73 20 50 34 5f 49 4e 54 36 34 20 ype is P4_INT64
07b0: 2a 2f 0a 20 20 20 20 64 6f 75 62 6c 65 20 2a 70 */. double *p
07c0: 52 65 61 6c 3b 20 20 20 20 20 20 20 20 20 2f 2a Real; /*
07d0: 20 55 73 65 64 20 77 68 65 6e 20 70 34 74 79 70 Used when p4typ
07e0: 65 20 69 73 20 50 34 5f 52 45 41 4c 20 2a 2f 0a e is P4_REAL */.
07f0: 20 20 20 20 46 75 6e 63 44 65 66 20 2a 70 46 75 FuncDef *pFu
0800: 6e 63 3b 20 20 20 20 20 20 20 20 2f 2a 20 55 73 nc; /* Us
0810: 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 20 69 ed when p4type i
0820: 73 20 50 34 5f 46 55 4e 43 44 45 46 20 2a 2f 0a s P4_FUNCDEF */.
0830: 20 20 20 20 43 6f 6c 6c 53 65 71 20 2a 70 43 6f CollSeq *pCo
0840: 6c 6c 3b 20 20 20 20 20 20 20 20 2f 2a 20 55 73 ll; /* Us
0850: 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 20 69 ed when p4type i
0860: 73 20 50 34 5f 43 4f 4c 4c 53 45 51 20 2a 2f 0a s P4_COLLSEQ */.
0870: 20 20 20 20 4d 65 6d 20 2a 70 4d 65 6d 3b 20 20 Mem *pMem;
0880: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 55 73 /* Us
0890: 65 64 20 77 68 65 6e 20 70 34 74 79 70 65 20 69 ed when p4type i
08a0: 73 20 50 34 5f 4d 45 4d 20 2a 2f 0a 20 20 20 20 s P4_MEM */.
08b0: 56 54 61 62 6c 65 20 2a 70 56 74 61 62 3b 20 20 VTable *pVtab;
08c0: 20 20 20 20 20 20 20 2f 2a 20 55 73 65 64 20 77 /* Used w
08d0: 68 65 6e 20 70 34 74 79 70 65 20 69 73 20 50 34 hen p4type is P4
08e0: 5f 56 54 41 42 20 2a 2f 0a 20 20 20 20 4b 65 79 _VTAB */. Key
08f0: 49 6e 66 6f 20 2a 70 4b 65 79 49 6e 66 6f 3b 20 Info *pKeyInfo;
0900: 20 20 20 20 2f 2a 20 55 73 65 64 20 77 68 65 6e /* Used when
0910: 20 70 34 74 79 70 65 20 69 73 20 50 34 5f 4b 45 p4type is P4_KE
0920: 59 49 4e 46 4f 20 2a 2f 0a 20 20 20 20 69 6e 74 YINFO */. int
0930: 20 2a 61 69 3b 20 20 20 20 20 20 20 20 20 20 20 *ai;
0940: 20 20 20 20 2f 2a 20 55 73 65 64 20 77 68 65 6e /* Used when
0950: 20 70 34 74 79 70 65 20 69 73 20 50 34 5f 49 4e p4type is P4_IN
0960: 54 41 52 52 41 59 20 2a 2f 0a 20 20 20 20 53 75 TARRAY */. Su
0970: 62 50 72 6f 67 72 61 6d 20 2a 70 50 72 6f 67 72 bProgram *pProgr
0980: 61 6d 3b 20 20 2f 2a 20 55 73 65 64 20 77 68 65 am; /* Used whe
0990: 6e 20 70 34 74 79 70 65 20 69 73 20 50 34 5f 53 n p4type is P4_S
09a0: 55 42 50 52 4f 47 52 41 4d 20 2a 2f 0a 20 20 20 UBPROGRAM */.
09b0: 20 69 6e 74 20 28 2a 78 41 64 76 61 6e 63 65 29 int (*xAdvance)
09c0: 28 42 74 43 75 72 73 6f 72 20 2a 2c 20 69 6e 74 (BtCursor *, int
09d0: 20 2a 29 3b 0a 20 20 7d 20 70 34 3b 0a 23 69 66 *);. } p4;.#if
09e0: 64 65 66 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c def SQLITE_ENABL
09f0: 45 5f 45 58 50 4c 41 49 4e 5f 43 4f 4d 4d 45 4e E_EXPLAIN_COMMEN
0a00: 54 53 0a 20 20 63 68 61 72 20 2a 7a 43 6f 6d 6d TS. char *zComm
0a10: 65 6e 74 3b 20 20 20 20 20 20 20 20 20 20 2f 2a ent; /*
0a20: 20 43 6f 6d 6d 65 6e 74 20 74 6f 20 69 6d 70 72 Comment to impr
0a30: 6f 76 65 20 72 65 61 64 61 62 69 6c 69 74 79 20 ove readability
0a40: 2a 2f 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 */.#endif.#ifdef
0a50: 20 56 44 42 45 5f 50 52 4f 46 49 4c 45 0a 20 20 VDBE_PROFILE.
0a60: 75 33 32 20 63 6e 74 3b 20 20 20 20 20 20 20 20 u32 cnt;
0a70: 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 /* Numb
0a80: 65 72 20 6f 66 20 74 69 6d 65 73 20 74 68 69 73 er of times this
0a90: 20 69 6e 73 74 72 75 63 74 69 6f 6e 20 77 61 73 instruction was
0aa0: 20 65 78 65 63 75 74 65 64 20 2a 2f 0a 20 20 75 executed */. u
0ab0: 36 34 20 63 79 63 6c 65 73 3b 20 20 20 20 20 20 64 cycles;
0ac0: 20 20 20 20 20 20 20 20 2f 2a 20 54 6f 74 61 6c /* Total
0ad0: 20 74 69 6d 65 20 73 70 65 6e 74 20 65 78 65 63 time spent exec
0ae0: 75 74 69 6e 67 20 74 68 69 73 20 69 6e 73 74 72 uting this instr
0af0: 75 63 74 69 6f 6e 20 2a 2f 0a 23 65 6e 64 69 66 uction */.#endif
0b00: 0a 23 69 66 64 65 66 20 53 51 4c 49 54 45 5f 56 .#ifdef SQLITE_V
0b10: 44 42 45 5f 43 4f 56 45 52 41 47 45 0a 20 20 69 DBE_COVERAGE. i
0b20: 6e 74 20 69 53 72 63 4c 69 6e 65 3b 20 20 20 20 nt iSrcLine;
0b30: 20 20 20 20 20 20 20 20 2f 2a 20 53 6f 75 72 63 /* Sourc
0b40: 65 2d 63 6f 64 65 20 6c 69 6e 65 20 74 68 61 74 e-code line that
0b50: 20 67 65 6e 65 72 61 74 65 64 20 74 68 69 73 20 generated this
0b60: 6f 70 63 6f 64 65 20 2a 2f 0a 23 65 6e 64 69 66 opcode */.#endif
0b70: 0a 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 .};.typedef stru
0b80: 63 74 20 56 64 62 65 4f 70 20 56 64 62 65 4f 70 ct VdbeOp VdbeOp
0b90: 3b 0a 0a 0a 2f 2a 0a 2a 2a 20 41 20 73 75 62 2d ;.../*.** A sub-
0ba0: 72 6f 75 74 69 6e 65 20 75 73 65 64 20 74 6f 20 routine used to
0bb0: 69 6d 70 6c 65 6d 65 6e 74 20 61 20 74 72 69 67 implement a trig
0bc0: 67 65 72 20 70 72 6f 67 72 61 6d 2e 0a 2a 2f 0a ger program..*/.
0bd0: 73 74 72 75 63 74 20 53 75 62 50 72 6f 67 72 61 struct SubProgra
0be0: 6d 20 7b 0a 20 20 56 64 62 65 4f 70 20 2a 61 4f m {. VdbeOp *aO
0bf0: 70 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 p;
0c00: 20 20 20 20 2f 2a 20 41 72 72 61 79 20 6f 66 20 /* Array of
0c10: 6f 70 63 6f 64 65 73 20 66 6f 72 20 73 75 62 2d opcodes for sub-
0c20: 70 72 6f 67 72 61 6d 20 2a 2f 0a 20 20 69 6e 74 program */. int
0c30: 20 6e 4f 70 3b 20 20 20 20 20 20 20 20 20 20 20 nOp;
0c40: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 45 6c /* El
0c50: 65 6d 65 6e 74 73 20 69 6e 20 61 4f 70 5b 5d 20 ements in aOp[]
0c60: 2a 2f 0a 20 20 69 6e 74 20 6e 4d 65 6d 3b 20 20 */. int nMem;
0c70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0c80: 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 /* Number of
0c90: 6d 65 6d 6f 72 79 20 63 65 6c 6c 73 20 72 65 71 memory cells req
0ca0: 75 69 72 65 64 20 2a 2f 0a 20 20 69 6e 74 20 6e uired */. int n
0cb0: 43 73 72 3b 20 20 20 20 20 20 20 20 20 20 20 20 Csr;
0cc0: 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 /* Numb
0cd0: 65 72 20 6f 66 20 63 75 72 73 6f 72 73 20 72 65 er of cursors re
0ce0: 71 75 69 72 65 64 20 2a 2f 0a 20 20 69 6e 74 20 quired */. int
0cf0: 6e 4f 6e 63 65 3b 20 20 20 20 20 20 20 20 20 20 nOnce;
0d00: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d /* Num
0d10: 62 65 72 20 6f 66 20 4f 50 5f 4f 6e 63 65 20 69 ber of OP_Once i
0d20: 6e 73 74 72 75 63 74 69 6f 6e 73 20 2a 2f 0a 20 nstructions */.
0d30: 20 76 6f 69 64 20 2a 74 6f 6b 65 6e 3b 20 20 20 void *token;
0d40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
0d50: 2a 20 69 64 20 74 68 61 74 20 6d 61 79 20 62 65 * id that may be
0d60: 20 75 73 65 64 20 74 6f 20 72 65 63 75 72 73 69 used to recursi
0d70: 76 65 20 74 72 69 67 67 65 72 73 20 2a 2f 0a 20 ve triggers */.
0d80: 20 53 75 62 50 72 6f 67 72 61 6d 20 2a 70 4e 65 SubProgram *pNe
0d90: 78 74 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f xt; /
0da0: 2a 20 4e 65 78 74 20 73 75 62 2d 70 72 6f 67 72 * Next sub-progr
0db0: 61 6d 20 61 6c 72 65 61 64 79 20 76 69 73 69 74 am already visit
0dc0: 65 64 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 ed */.};../*.**
0dd0: 41 20 73 6d 61 6c 6c 65 72 20 76 65 72 73 69 6f A smaller versio
0de0: 6e 20 6f 66 20 56 64 62 65 4f 70 20 75 73 65 64 n of VdbeOp used
0df0: 20 66 6f 72 20 74 68 65 20 56 64 62 65 41 64 64 for the VdbeAdd
0e00: 4f 70 4c 69 73 74 28 29 20 66 75 6e 63 74 69 6f OpList() functio
0e10: 6e 20 62 65 63 61 75 73 65 0a 2a 2a 20 69 74 20 n because.** it
0e20: 74 61 6b 65 73 20 75 70 20 6c 65 73 73 20 73 70 takes up less sp
0e30: 61 63 65 2e 0a 2a 2f 0a 73 74 72 75 63 74 20 56 ace..*/.struct V
0e40: 64 62 65 4f 70 4c 69 73 74 20 7b 0a 20 20 75 38 dbeOpList {. u8
0e50: 20 6f 70 63 6f 64 65 3b 20 20 20 20 20 20 20 20 opcode;
0e60: 20 20 2f 2a 20 57 68 61 74 20 6f 70 65 72 61 74 /* What operat
0e70: 69 6f 6e 20 74 6f 20 70 65 72 66 6f 72 6d 20 2a ion to perform *
0e80: 2f 0a 20 20 73 69 67 6e 65 64 20 63 68 61 72 20 /. signed char
0e90: 70 31 3b 20 20 20 20 20 2f 2a 20 46 69 72 73 74 p1; /* First
0ea0: 20 6f 70 65 72 61 6e 64 20 2a 2f 0a 20 20 73 69 operand */. si
0eb0: 67 6e 65 64 20 63 68 61 72 20 70 32 3b 20 20 20 gned char p2;
0ec0: 20 20 2f 2a 20 53 65 63 6f 6e 64 20 70 61 72 61 /* Second para
0ed0: 6d 65 74 65 72 20 28 6f 66 74 65 6e 20 74 68 65 meter (often the
0ee0: 20 6a 75 6d 70 20 64 65 73 74 69 6e 61 74 69 6f jump destinatio
0ef0: 6e 29 20 2a 2f 0a 20 20 73 69 67 6e 65 64 20 63 n) */. signed c
0f00: 68 61 72 20 70 33 3b 20 20 20 20 20 2f 2a 20 54 har p3; /* T
0f10: 68 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 2a hird parameter *
0f20: 2f 0a 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 /.};.typedef str
0f30: 75 63 74 20 56 64 62 65 4f 70 4c 69 73 74 20 56 uct VdbeOpList V
0f40: 64 62 65 4f 70 4c 69 73 74 3b 0a 0a 2f 2a 0a 2a dbeOpList;../*.*
0f50: 2a 20 41 6c 6c 6f 77 65 64 20 76 61 6c 75 65 73 * Allowed values
0f60: 20 6f 66 20 56 64 62 65 4f 70 2e 70 34 74 79 70 of VdbeOp.p4typ
0f70: 65 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f e.*/.#define P4_
0f80: 4e 4f 54 55 53 45 44 20 20 20 20 30 20 20 20 2f NOTUSED 0 /
0f90: 2a 20 54 68 65 20 50 34 20 70 61 72 61 6d 65 74 * The P4 paramet
0fa0: 65 72 20 69 73 20 6e 6f 74 20 75 73 65 64 20 2a er is not used *
0fb0: 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 44 59 4e /.#define P4_DYN
0fc0: 41 4d 49 43 20 20 28 2d 31 29 20 20 2f 2a 20 50 AMIC (-1) /* P
0fd0: 6f 69 6e 74 65 72 20 74 6f 20 61 20 73 74 72 69 ointer to a stri
0fe0: 6e 67 20 6f 62 74 61 69 6e 65 64 20 66 72 6f 6d ng obtained from
0ff0: 20 73 71 6c 69 74 65 4d 61 6c 6c 6f 63 28 29 20 sqliteMalloc()
1000: 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 53 54 */.#define P4_ST
1010: 41 54 49 43 20 20 20 28 2d 32 29 20 20 2f 2a 20 ATIC (-2) /*
1020: 50 6f 69 6e 74 65 72 20 74 6f 20 61 20 73 74 61 Pointer to a sta
1030: 74 69 63 20 73 74 72 69 6e 67 20 2a 2f 0a 23 64 tic string */.#d
1040: 65 66 69 6e 65 20 50 34 5f 43 4f 4c 4c 53 45 51 efine P4_COLLSEQ
1050: 20 20 28 2d 34 29 20 20 2f 2a 20 50 34 20 69 73 (-4) /* P4 is
1060: 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 a pointer to a
1070: 43 6f 6c 6c 53 65 71 20 73 74 72 75 63 74 75 72 CollSeq structur
1080: 65 20 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f e */.#define P4_
1090: 46 55 4e 43 44 45 46 20 20 28 2d 35 29 20 20 2f FUNCDEF (-5) /
10a0: 2a 20 50 34 20 69 73 20 61 20 70 6f 69 6e 74 65 * P4 is a pointe
10b0: 72 20 74 6f 20 61 20 46 75 6e 63 44 65 66 20 73 r to a FuncDef s
10c0: 74 72 75 63 74 75 72 65 20 2a 2f 0a 23 64 65 66 tructure */.#def
10d0: 69 6e 65 20 50 34 5f 4b 45 59 49 4e 46 4f 20 20 ine P4_KEYINFO
10e0: 28 2d 36 29 20 20 2f 2a 20 50 34 20 69 73 20 61 (-6) /* P4 is a
10f0: 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 4b 65 pointer to a Ke
1100: 79 49 6e 66 6f 20 73 74 72 75 63 74 75 72 65 20 yInfo structure
1110: 2a 2f 0a 23 64 65 66 69 6e 65 20 50 34 5f 4d 45 */.#define P4_ME
1120: 4d 20 20 20 20 20 20 28 2d 38 29 20 20 2f 2a 20 M (-8) /*
1130: 50 34 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 P4 is a pointer
1140: 74 6f 20 61 20 4d 65 6d 2a 20 20 20 20 73 74 72 to a Mem* str
1150: 75 63 74 75 72 65 20 2a 2f 0a 23 64 65 66 69 6e ucture */.#defin
1160: 65 20 50 34 5f 54 52 41 4e 53 49 45 4e 54 20 20 e P4_TRANSIENT
1170: 30 20 20 20 2f 2a 20 50 34 20 69 73 20 61 20 70 0 /* P4 is a p
1180: 6f 69 6e 74 65 72 20 74 6f 20 61 20 74 72 61 6e ointer to a tran
1190: 73 69 65 6e 74 20 73 74 72 69 6e 67 20 2a 2f 0a sient string */.
11a0: 23 64 65 66 69 6e 65 20 50 34 5f 56 54 41 42 20 #define P4_VTAB
11b0: 20 20 20 20 28 2d 31 30 29 20 2f 2a 20 50 34 20 (-10) /* P4
11c0: 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 is a pointer to
11d0: 61 6e 20 73 71 6c 69 74 65 33 5f 76 74 61 62 20 an sqlite3_vtab
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 4d 50 52 49 4e 54 46 20 fine P4_MPRINTF
1200: 20 28 2d 31 31 29 20 2f 2a 20 50 34 20 69 73 20 (-11) /* P4 is
1210: 61 20 73 74 72 69 6e 67 20 6f 62 74 61 69 6e 65 a string obtaine
1220: 64 20 66 72 6f 6d 20 73 71 6c 69 74 65 33 5f 6d d from sqlite3_m
1230: 70 72 69 6e 74 66 28 29 20 2a 2f 0a 23 64 65 66 printf() */.#def
1240: 69 6e 65 20 50 34 5f 52 45 41 4c 20 20 20 20 20 ine P4_REAL
1250: 28 2d 31 32 29 20 2f 2a 20 50 34 20 69 73 20 61 (-12) /* P4 is a
1260: 20 36 34 2d 62 69 74 20 66 6c 6f 61 74 69 6e 67 64-bit floating
1270: 20 70 6f 69 6e 74 20 76 61 6c 75 65 20 2a 2f 0a point value */.
1280: 23 64 65 66 69 6e 65 20 50 34 5f 49 4e 54 36 34 #define P4_INT64
1290: 20 20 20 20 28 2d 31 33 29 20 2f 2a 20 50 34 20 (-13) /* P4
12a0: 69 73 20 61 20 36 34 2d 62 69 74 20 73 69 67 6e is a 64-bit sign
12b0: 65 64 20 69 6e 74 65 67 65 72 20 2a 2f 0a 23 64 ed integer */.#d
12c0: 65 66 69 6e 65 20 50 34 5f 49 4e 54 33 32 20 20 efine P4_INT32
12d0: 20 20 28 2d 31 34 29 20 2f 2a 20 50 34 20 69 73 (-14) /* P4 is
12e0: 20 61 20 33 32 2d 62 69 74 20 73 69 67 6e 65 64 a 32-bit signed
12f0: 20 69 6e 74 65 67 65 72 20 2a 2f 0a 23 64 65 66 integer */.#def
1300: 69 6e 65 20 50 34 5f 49 4e 54 41 52 52 41 59 20 ine P4_INTARRAY
1310: 28 2d 31 35 29 20 2f 2a 20 50 34 20 69 73 20 61 (-15) /* P4 is a
1320: 20 76 65 63 74 6f 72 20 6f 66 20 33 32 2d 62 69 vector of 32-bi
1330: 74 20 69 6e 74 65 67 65 72 73 20 2a 2f 0a 23 64 t integers */.#d
1340: 65 66 69 6e 65 20 50 34 5f 53 55 42 50 52 4f 47 efine P4_SUBPROG
1350: 52 41 4d 20 20 28 2d 31 38 29 20 2f 2a 20 50 34 RAM (-18) /* P4
1360: 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f is a pointer to
1370: 20 61 20 53 75 62 50 72 6f 67 72 61 6d 20 73 74 a SubProgram st
1380: 72 75 63 74 75 72 65 20 2a 2f 0a 23 64 65 66 69 ructure */.#defi
1390: 6e 65 20 50 34 5f 41 44 56 41 4e 43 45 20 20 28 ne P4_ADVANCE (
13a0: 2d 31 39 29 20 2f 2a 20 50 34 20 69 73 20 61 20 -19) /* P4 is a
13b0: 70 6f 69 6e 74 65 72 20 74 6f 20 42 74 72 65 65 pointer to Btree
13c0: 4e 65 78 74 28 29 20 6f 72 20 42 74 72 65 65 50 Next() or BtreeP
13d0: 72 65 76 28 29 20 2a 2f 0a 0a 2f 2a 20 45 72 72 rev() */../* Err
13e0: 6f 72 20 6d 65 73 73 61 67 65 20 63 6f 64 65 73 or message codes
13f0: 20 66 6f 72 20 4f 50 5f 48 61 6c 74 20 2a 2f 0a for OP_Halt */.
1400: 23 64 65 66 69 6e 65 20 50 35 5f 43 6f 6e 73 74 #define P5_Const
1410: 72 61 69 6e 74 4e 6f 74 4e 75 6c 6c 20 31 0a 23 raintNotNull 1.#
1420: 64 65 66 69 6e 65 20 50 35 5f 43 6f 6e 73 74 72 define P5_Constr
1430: 61 69 6e 74 55 6e 69 71 75 65 20 20 32 0a 23 64 aintUnique 2.#d
1440: 65 66 69 6e 65 20 50 35 5f 43 6f 6e 73 74 72 61 efine P5_Constra
1450: 69 6e 74 43 68 65 63 6b 20 20 20 33 0a 23 64 65 intCheck 3.#de
1460: 66 69 6e 65 20 50 35 5f 43 6f 6e 73 74 72 61 69 fine P5_Constrai
1470: 6e 74 46 4b 20 20 20 20 20 20 34 0a 0a 2f 2a 0a ntFK 4../*.
1480: 2a 2a 20 54 68 65 20 56 64 62 65 2e 61 43 6f 6c ** The Vdbe.aCol
1490: 4e 61 6d 65 20 61 72 72 61 79 20 63 6f 6e 74 61 Name array conta
14a0: 69 6e 73 20 35 6e 20 4d 65 6d 20 73 74 72 75 63 ins 5n Mem struc
14b0: 74 75 72 65 73 2c 20 77 68 65 72 65 20 6e 20 69 tures, where n i
14c0: 73 20 74 68 65 20 0a 2a 2a 20 6e 75 6d 62 65 72 s the .** number
14d0: 20 6f 66 20 63 6f 6c 75 6d 6e 73 20 6f 66 20 64 of columns of d
14e0: 61 74 61 20 72 65 74 75 72 6e 65 64 20 62 79 20 ata returned by
14f0: 74 68 65 20 73 74 61 74 65 6d 65 6e 74 2e 0a 2a the statement..*
1500: 2f 0a 23 64 65 66 69 6e 65 20 43 4f 4c 4e 41 4d /.#define COLNAM
1510: 45 5f 4e 41 4d 45 20 20 20 20 20 30 0a 23 64 65 E_NAME 0.#de
1520: 66 69 6e 65 20 43 4f 4c 4e 41 4d 45 5f 44 45 43 fine COLNAME_DEC
1530: 4c 54 59 50 45 20 31 0a 23 64 65 66 69 6e 65 20 LTYPE 1.#define
1540: 43 4f 4c 4e 41 4d 45 5f 44 41 54 41 42 41 53 45 COLNAME_DATABASE
1550: 20 32 0a 23 64 65 66 69 6e 65 20 43 4f 4c 4e 41 2.#define COLNA
1560: 4d 45 5f 54 41 42 4c 45 20 20 20 20 33 0a 23 64 ME_TABLE 3.#d
1570: 65 66 69 6e 65 20 43 4f 4c 4e 41 4d 45 5f 43 4f efine COLNAME_CO
1580: 4c 55 4d 4e 20 20 20 34 0a 23 69 66 64 65 66 20 LUMN 4.#ifdef
1590: 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 43 4f SQLITE_ENABLE_CO
15a0: 4c 55 4d 4e 5f 4d 45 54 41 44 41 54 41 0a 23 20 LUMN_METADATA.#
15b0: 64 65 66 69 6e 65 20 43 4f 4c 4e 41 4d 45 5f 4e define COLNAME_N
15c0: 20 20 20 20 20 20 20 20 35 20 20 20 20 20 20 2f 5 /
15d0: 2a 20 4e 75 6d 62 65 72 20 6f 66 20 43 4f 4c 4e * Number of COLN
15e0: 41 4d 45 5f 78 78 78 20 73 79 6d 62 6f 6c 73 20 AME_xxx symbols
15f0: 2a 2f 0a 23 65 6c 73 65 0a 23 20 69 66 64 65 66 */.#else.# ifdef
1600: 20 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 44 45 43 SQLITE_OMIT_DEC
1610: 4c 54 59 50 45 0a 23 20 20 20 64 65 66 69 6e 65 LTYPE.# define
1620: 20 43 4f 4c 4e 41 4d 45 5f 4e 20 20 20 20 20 20 COLNAME_N
1630: 31 20 20 20 20 20 20 2f 2a 20 53 74 6f 72 65 20 1 /* Store
1640: 6f 6e 6c 79 20 74 68 65 20 6e 61 6d 65 20 2a 2f only the name */
1650: 0a 23 20 65 6c 73 65 0a 23 20 20 20 64 65 66 69 .# else.# defi
1660: 6e 65 20 43 4f 4c 4e 41 4d 45 5f 4e 20 20 20 20 ne COLNAME_N
1670: 20 20 32 20 20 20 20 20 20 2f 2a 20 53 74 6f 72 2 /* Stor
1680: 65 20 74 68 65 20 6e 61 6d 65 20 61 6e 64 20 64 e the name and d
1690: 65 63 6c 74 79 70 65 20 2a 2f 0a 23 20 65 6e 64 ecltype */.# end
16a0: 69 66 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a if.#endif../*.**
16b0: 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6d The following m
16c0: 61 63 72 6f 20 63 6f 6e 76 65 72 74 73 20 61 20 acro converts a
16d0: 72 65 6c 61 74 69 76 65 20 61 64 64 72 65 73 73 relative address
16e0: 20 69 6e 20 74 68 65 20 70 32 20 66 69 65 6c 64 in the p2 field
16f0: 0a 2a 2a 20 6f 66 20 61 20 56 64 62 65 4f 70 20 .** of a VdbeOp
1700: 73 74 72 75 63 74 75 72 65 20 69 6e 74 6f 20 61 structure into a
1710: 20 6e 65 67 61 74 69 76 65 20 6e 75 6d 62 65 72 negative number
1720: 20 73 6f 20 74 68 61 74 20 0a 2a 2a 20 73 71 6c so that .** sql
1730: 69 74 65 33 56 64 62 65 41 64 64 4f 70 4c 69 73 ite3VdbeAddOpLis
1740: 74 28 29 20 6b 6e 6f 77 73 20 74 68 61 74 20 74 t() knows that t
1750: 68 65 20 61 64 64 72 65 73 73 20 69 73 20 72 65 he address is re
1760: 6c 61 74 69 76 65 2e 20 20 43 61 6c 6c 69 6e 67 lative. Calling
1770: 0a 2a 2a 20 74 68 65 20 6d 61 63 72 6f 20 61 67 .** the macro ag
1780: 61 69 6e 20 72 65 73 74 6f 72 65 73 20 74 68 65 ain restores the
1790: 20 61 64 64 72 65 73 73 2e 0a 2a 2f 0a 23 64 65 address..*/.#de
17a0: 66 69 6e 65 20 41 44 44 52 28 58 29 20 20 28 2d fine ADDR(X) (-
17b0: 31 2d 28 58 29 29 0a 0a 2f 2a 0a 2a 2a 20 54 68 1-(X))../*.** Th
17c0: 65 20 6d 61 6b 65 66 69 6c 65 20 73 63 61 6e 73 e makefile scans
17d0: 20 74 68 65 20 76 64 62 65 2e 63 20 73 6f 75 72 the vdbe.c sour
17e0: 63 65 20 66 69 6c 65 20 61 6e 64 20 63 72 65 61 ce file and crea
17f0: 74 65 73 20 74 68 65 20 22 6f 70 63 6f 64 65 73 tes the "opcodes
1800: 2e 68 22 0a 2a 2a 20 68 65 61 64 65 72 20 66 69 .h".** header fi
1810: 6c 65 20 74 68 61 74 20 64 65 66 69 6e 65 73 20 le that defines
1820: 61 20 6e 75 6d 62 65 72 20 66 6f 72 20 65 61 63 a number for eac
1830: 68 20 6f 70 63 6f 64 65 20 75 73 65 64 20 62 79 h opcode used by
1840: 20 74 68 65 20 56 44 42 45 2e 0a 2a 2f 0a 23 69 the VDBE..*/.#i
1850: 6e 63 6c 75 64 65 20 22 6f 70 63 6f 64 65 73 2e nclude "opcodes.
1860: 68 22 0a 0a 2f 2a 0a 2a 2a 20 50 72 6f 74 6f 74 h"../*.** Protot
1870: 79 70 65 73 20 66 6f 72 20 74 68 65 20 56 44 42 ypes for the VDB
1880: 45 20 69 6e 74 65 72 66 61 63 65 2e 20 20 53 65 E interface. Se
1890: 65 20 63 6f 6d 6d 65 6e 74 73 20 6f 6e 20 74 68 e comments on th
18a0: 65 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e e implementation
18b0: 0a 2a 2a 20 66 6f 72 20 61 20 64 65 73 63 72 69 .** for a descri
18c0: 70 74 69 6f 6e 20 6f 66 20 77 68 61 74 20 65 61 ption of what ea
18d0: 63 68 20 6f 66 20 74 68 65 73 65 20 72 6f 75 74 ch of these rout
18e0: 69 6e 65 73 20 64 6f 65 73 2e 0a 2a 2f 0a 56 64 ines does..*/.Vd
18f0: 62 65 20 2a 73 71 6c 69 74 65 33 56 64 62 65 43 be *sqlite3VdbeC
1900: 72 65 61 74 65 28 50 61 72 73 65 2a 29 3b 0a 69 reate(Parse*);.i
1910: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 41 64 nt sqlite3VdbeAd
1920: 64 4f 70 30 28 56 64 62 65 2a 2c 69 6e 74 29 3b dOp0(Vdbe*,int);
1930: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
1940: 41 64 64 4f 70 31 28 56 64 62 65 2a 2c 69 6e 74 AddOp1(Vdbe*,int
1950: 2c 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 ,int);.int sqlit
1960: 65 33 56 64 62 65 41 64 64 4f 70 32 28 56 64 62 e3VdbeAddOp2(Vdb
1970: 65 2a 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 29 3b e*,int,int,int);
1980: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
1990: 41 64 64 4f 70 33 28 56 64 62 65 2a 2c 69 6e 74 AddOp3(Vdbe*,int
19a0: 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 29 3b 0a 69 ,int,int,int);.i
19b0: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 41 64 nt sqlite3VdbeAd
19c0: 64 4f 70 34 28 56 64 62 65 2a 2c 69 6e 74 2c 69 dOp4(Vdbe*,int,i
19d0: 6e 74 2c 69 6e 74 2c 69 6e 74 2c 63 6f 6e 73 74 nt,int,int,const
19e0: 20 63 68 61 72 20 2a 7a 50 34 2c 69 6e 74 29 3b char *zP4,int);
19f0: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
1a00: 41 64 64 4f 70 34 49 6e 74 28 56 64 62 65 2a 2c AddOp4Int(Vdbe*,
1a10: 69 6e 74 2c 69 6e 74 2c 69 6e 74 2c 69 6e 74 2c int,int,int,int,
1a20: 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 int);.int sqlite
1a30: 33 56 64 62 65 41 64 64 4f 70 4c 69 73 74 28 56 3VdbeAddOpList(V
1a40: 64 62 65 2a 2c 20 69 6e 74 20 6e 4f 70 2c 20 56 dbe*, int nOp, V
1a50: 64 62 65 4f 70 4c 69 73 74 20 63 6f 6e 73 74 20 dbeOpList const
1a60: 2a 61 4f 70 2c 20 69 6e 74 20 69 4c 69 6e 65 6e *aOp, int iLinen
1a70: 6f 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 o);.void sqlite3
1a80: 56 64 62 65 41 64 64 50 61 72 73 65 53 63 68 65 VdbeAddParseSche
1a90: 6d 61 4f 70 28 56 64 62 65 2a 2c 69 6e 74 2c 63 maOp(Vdbe*,int,c
1aa0: 68 61 72 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 har*);.void sqli
1ab0: 74 65 33 56 64 62 65 43 68 61 6e 67 65 50 31 28 te3VdbeChangeP1(
1ac0: 56 64 62 65 2a 2c 20 75 33 32 20 61 64 64 72 2c Vdbe*, u32 addr,
1ad0: 20 69 6e 74 20 50 31 29 3b 0a 76 6f 69 64 20 73 int P1);.void s
1ae0: 71 6c 69 74 65 33 56 64 62 65 43 68 61 6e 67 65 qlite3VdbeChange
1af0: 50 32 28 56 64 62 65 2a 2c 20 75 33 32 20 61 64 P2(Vdbe*, u32 ad
1b00: 64 72 2c 20 69 6e 74 20 50 32 29 3b 0a 76 6f 69 dr, int P2);.voi
1b10: 64 20 73 71 6c 69 74 65 33 56 64 62 65 43 68 61 d sqlite3VdbeCha
1b20: 6e 67 65 50 33 28 56 64 62 65 2a 2c 20 75 33 32 ngeP3(Vdbe*, u32
1b30: 20 61 64 64 72 2c 20 69 6e 74 20 50 33 29 3b 0a addr, int P3);.
1b40: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
1b50: 43 68 61 6e 67 65 50 35 28 56 64 62 65 2a 2c 20 ChangeP5(Vdbe*,
1b60: 75 38 20 50 35 29 3b 0a 76 6f 69 64 20 73 71 6c u8 P5);.void sql
1b70: 69 74 65 33 56 64 62 65 4a 75 6d 70 48 65 72 65 ite3VdbeJumpHere
1b80: 28 56 64 62 65 2a 2c 20 69 6e 74 20 61 64 64 72 (Vdbe*, int addr
1b90: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
1ba0: 64 62 65 43 68 61 6e 67 65 54 6f 4e 6f 6f 70 28 dbeChangeToNoop(
1bb0: 56 64 62 65 2a 2c 20 69 6e 74 20 61 64 64 72 29 Vdbe*, int addr)
1bc0: 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 ;.int sqlite3Vdb
1bd0: 65 44 65 6c 65 74 65 50 72 69 6f 72 4f 70 63 6f eDeletePriorOpco
1be0: 64 65 28 56 64 62 65 2a 2c 20 75 38 20 6f 70 29 de(Vdbe*, u8 op)
1bf0: 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 ;.void sqlite3Vd
1c00: 62 65 4f 70 74 69 6d 69 7a 65 43 6f 6c 75 6d 6e beOptimizeColumn
1c10: 4f 70 63 6f 64 65 73 28 56 64 62 65 2a 29 3b 0a Opcodes(Vdbe*);.
1c20: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
1c30: 43 68 61 6e 67 65 50 34 28 56 64 62 65 2a 2c 20 ChangeP4(Vdbe*,
1c40: 69 6e 74 20 61 64 64 72 2c 20 63 6f 6e 73 74 20 int addr, const
1c50: 63 68 61 72 20 2a 7a 50 34 2c 20 69 6e 74 20 4e char *zP4, int N
1c60: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
1c70: 64 62 65 53 65 74 50 34 4b 65 79 49 6e 66 6f 28 dbeSetP4KeyInfo(
1c80: 50 61 72 73 65 2a 2c 20 49 6e 64 65 78 2a 29 3b Parse*, Index*);
1c90: 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 .void sqlite3Vdb
1ca0: 65 55 73 65 73 42 74 72 65 65 28 56 64 62 65 2a eUsesBtree(Vdbe*
1cb0: 2c 20 69 6e 74 29 3b 0a 56 64 62 65 4f 70 20 2a , int);.VdbeOp *
1cc0: 73 71 6c 69 74 65 33 56 64 62 65 47 65 74 4f 70 sqlite3VdbeGetOp
1cd0: 28 56 64 62 65 2a 2c 20 69 6e 74 29 3b 0a 69 6e (Vdbe*, int);.in
1ce0: 74 20 73 71 6c 69 74 65 33 56 64 62 65 4d 61 6b t sqlite3VdbeMak
1cf0: 65 4c 61 62 65 6c 28 56 64 62 65 2a 29 3b 0a 76 eLabel(Vdbe*);.v
1d00: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 52 oid sqlite3VdbeR
1d10: 75 6e 4f 6e 6c 79 4f 6e 63 65 28 56 64 62 65 2a unOnlyOnce(Vdbe*
1d20: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
1d30: 64 62 65 44 65 6c 65 74 65 28 56 64 62 65 2a 29 dbeDelete(Vdbe*)
1d40: 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 ;.void sqlite3Vd
1d50: 62 65 43 6c 65 61 72 4f 62 6a 65 63 74 28 73 71 beClearObject(sq
1d60: 6c 69 74 65 33 2a 2c 56 64 62 65 2a 29 3b 0a 76 lite3*,Vdbe*);.v
1d70: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d oid sqlite3VdbeM
1d80: 61 6b 65 52 65 61 64 79 28 56 64 62 65 2a 2c 50 akeReady(Vdbe*,P
1d90: 61 72 73 65 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 arse*);.int sqli
1da0: 74 65 33 56 64 62 65 46 69 6e 61 6c 69 7a 65 28 te3VdbeFinalize(
1db0: 56 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c Vdbe*);.void sql
1dc0: 69 74 65 33 56 64 62 65 52 65 73 6f 6c 76 65 4c ite3VdbeResolveL
1dd0: 61 62 65 6c 28 56 64 62 65 2a 2c 20 69 6e 74 29 abel(Vdbe*, int)
1de0: 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 ;.int sqlite3Vdb
1df0: 65 43 75 72 72 65 6e 74 41 64 64 72 28 56 64 62 eCurrentAddr(Vdb
1e00: 65 2a 29 3b 0a 23 69 66 64 65 66 20 53 51 4c 49 e*);.#ifdef SQLI
1e10: 54 45 5f 44 45 42 55 47 0a 20 20 69 6e 74 20 73 TE_DEBUG. int s
1e20: 71 6c 69 74 65 33 56 64 62 65 41 73 73 65 72 74 qlite3VdbeAssert
1e30: 4d 61 79 41 62 6f 72 74 28 56 64 62 65 20 2a 2c MayAbort(Vdbe *,
1e40: 20 69 6e 74 29 3b 0a 23 65 6e 64 69 66 0a 76 6f int);.#endif.vo
1e50: 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 52 65 id sqlite3VdbeRe
1e60: 73 65 74 53 74 65 70 52 65 73 75 6c 74 28 56 64 setStepResult(Vd
1e70: 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 be*);.void sqlit
1e80: 65 33 56 64 62 65 52 65 77 69 6e 64 28 56 64 62 e3VdbeRewind(Vdb
1e90: 65 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 e*);.int sqlite3
1ea0: 56 64 62 65 52 65 73 65 74 28 56 64 62 65 2a 29 VdbeReset(Vdbe*)
1eb0: 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 ;.void sqlite3Vd
1ec0: 62 65 53 65 74 4e 75 6d 43 6f 6c 73 28 56 64 62 beSetNumCols(Vdb
1ed0: 65 2a 2c 69 6e 74 29 3b 0a 69 6e 74 20 73 71 6c e*,int);.int sql
1ee0: 69 74 65 33 56 64 62 65 53 65 74 43 6f 6c 4e 61 ite3VdbeSetColNa
1ef0: 6d 65 28 56 64 62 65 2a 2c 20 69 6e 74 2c 20 69 me(Vdbe*, int, i
1f00: 6e 74 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a nt, const char *
1f10: 2c 20 76 6f 69 64 28 2a 29 28 76 6f 69 64 2a 29 , void(*)(void*)
1f20: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
1f30: 64 62 65 43 6f 75 6e 74 43 68 61 6e 67 65 73 28 dbeCountChanges(
1f40: 56 64 62 65 2a 29 3b 0a 73 71 6c 69 74 65 33 20 Vdbe*);.sqlite3
1f50: 2a 73 71 6c 69 74 65 33 56 64 62 65 44 62 28 56 *sqlite3VdbeDb(V
1f60: 64 62 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 dbe*);.void sqli
1f70: 74 65 33 56 64 62 65 53 65 74 53 71 6c 28 56 64 te3VdbeSetSql(Vd
1f80: 62 65 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 be*, const char
1f90: 2a 7a 2c 20 69 6e 74 20 6e 2c 20 69 6e 74 29 3b *z, int n, int);
1fa0: 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 .void sqlite3Vdb
1fb0: 65 53 77 61 70 28 56 64 62 65 2a 2c 56 64 62 65 eSwap(Vdbe*,Vdbe
1fc0: 2a 29 3b 0a 56 64 62 65 4f 70 20 2a 73 71 6c 69 *);.VdbeOp *sqli
1fd0: 74 65 33 56 64 62 65 54 61 6b 65 4f 70 41 72 72 te3VdbeTakeOpArr
1fe0: 61 79 28 56 64 62 65 2a 2c 20 69 6e 74 2a 2c 20 ay(Vdbe*, int*,
1ff0: 69 6e 74 2a 29 3b 0a 73 71 6c 69 74 65 33 5f 76 int*);.sqlite3_v
2000: 61 6c 75 65 20 2a 73 71 6c 69 74 65 33 56 64 62 alue *sqlite3Vdb
2010: 65 47 65 74 42 6f 75 6e 64 56 61 6c 75 65 28 56 eGetBoundValue(V
2020: 64 62 65 2a 2c 20 69 6e 74 2c 20 75 38 29 3b 0a dbe*, int, u8);.
2030: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
2040: 53 65 74 56 61 72 6d 61 73 6b 28 56 64 62 65 2a SetVarmask(Vdbe*
2050: 2c 20 69 6e 74 29 3b 0a 23 69 66 6e 64 65 66 20 , int);.#ifndef
2060: 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 54 52 41 43 SQLITE_OMIT_TRAC
2070: 45 0a 20 20 63 68 61 72 20 2a 73 71 6c 69 74 65 E. char *sqlite
2080: 33 56 64 62 65 45 78 70 61 6e 64 53 71 6c 28 56 3VdbeExpandSql(V
2090: 64 62 65 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 dbe*, const char
20a0: 2a 29 3b 0a 23 65 6e 64 69 66 0a 69 6e 74 20 73 *);.#endif.int s
20b0: 71 6c 69 74 65 33 4d 65 6d 43 6f 6d 70 61 72 65 qlite3MemCompare
20c0: 28 63 6f 6e 73 74 20 4d 65 6d 2a 2c 20 63 6f 6e (const Mem*, con
20d0: 73 74 20 4d 65 6d 2a 2c 20 63 6f 6e 73 74 20 43 st Mem*, const C
20e0: 6f 6c 6c 53 65 71 2a 29 3b 0a 0a 76 6f 69 64 20 ollSeq*);..void
20f0: 73 71 6c 69 74 65 33 56 64 62 65 52 65 63 6f 72 sqlite3VdbeRecor
2100: 64 55 6e 70 61 63 6b 28 4b 65 79 49 6e 66 6f 2a dUnpack(KeyInfo*
2110: 2c 69 6e 74 2c 63 6f 6e 73 74 20 76 6f 69 64 2a ,int,const void*
2120: 2c 55 6e 70 61 63 6b 65 64 52 65 63 6f 72 64 2a ,UnpackedRecord*
2130: 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 );.int sqlite3Vd
2140: 62 65 52 65 63 6f 72 64 43 6f 6d 70 61 72 65 28 beRecordCompare(
2150: 69 6e 74 2c 63 6f 6e 73 74 20 76 6f 69 64 2a 2c int,const void*,
2160: 55 6e 70 61 63 6b 65 64 52 65 63 6f 72 64 2a 29 UnpackedRecord*)
2170: 3b 0a 55 6e 70 61 63 6b 65 64 52 65 63 6f 72 64 ;.UnpackedRecord
2180: 20 2a 73 71 6c 69 74 65 33 56 64 62 65 41 6c 6c *sqlite3VdbeAll
2190: 6f 63 55 6e 70 61 63 6b 65 64 52 65 63 6f 72 64 ocUnpackedRecord
21a0: 28 4b 65 79 49 6e 66 6f 20 2a 2c 20 63 68 61 72 (KeyInfo *, char
21b0: 20 2a 2c 20 69 6e 74 2c 20 63 68 61 72 20 2a 2a *, int, char **
21c0: 29 3b 0a 0a 74 79 70 65 64 65 66 20 69 6e 74 20 );..typedef int
21d0: 28 2a 52 65 63 6f 72 64 43 6f 6d 70 61 72 65 29 (*RecordCompare)
21e0: 28 69 6e 74 2c 63 6f 6e 73 74 20 76 6f 69 64 2a (int,const void*
21f0: 2c 55 6e 70 61 63 6b 65 64 52 65 63 6f 72 64 2a ,UnpackedRecord*
2200: 29 3b 0a 52 65 63 6f 72 64 43 6f 6d 70 61 72 65 );.RecordCompare
2210: 20 73 71 6c 69 74 65 33 56 64 62 65 46 69 6e 64 sqlite3VdbeFind
2220: 43 6f 6d 70 61 72 65 28 55 6e 70 61 63 6b 65 64 Compare(Unpacked
2230: 52 65 63 6f 72 64 2a 29 3b 0a 0a 23 69 66 6e 64 Record*);..#ifnd
2240: 65 66 20 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 54 ef SQLITE_OMIT_T
2250: 52 49 47 47 45 52 0a 76 6f 69 64 20 73 71 6c 69 RIGGER.void sqli
2260: 74 65 33 56 64 62 65 4c 69 6e 6b 53 75 62 50 72 te3VdbeLinkSubPr
2270: 6f 67 72 61 6d 28 56 64 62 65 20 2a 2c 20 53 75 ogram(Vdbe *, Su
2280: 62 50 72 6f 67 72 61 6d 20 2a 29 3b 0a 23 65 6e bProgram *);.#en
2290: 64 69 66 0a 0a 2f 2a 20 55 73 65 20 53 51 4c 49 dif../* Use SQLI
22a0: 54 45 5f 45 4e 41 42 4c 45 5f 43 4f 4d 4d 45 4e TE_ENABLE_COMMEN
22b0: 54 53 20 74 6f 20 65 6e 61 62 6c 65 20 67 65 6e TS to enable gen
22c0: 65 72 61 74 69 6f 6e 20 6f 66 20 65 78 74 72 61 eration of extra
22d0: 20 63 6f 6d 6d 65 6e 74 73 20 6f 6e 0a 2a 2a 20 comments on.**
22e0: 65 61 63 68 20 56 44 42 45 20 6f 70 63 6f 64 65 each VDBE opcode
22f0: 2e 0a 2a 2a 0a 2a 2a 20 55 73 65 20 74 68 65 20 ..**.** Use the
2300: 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 4d 4f SQLITE_ENABLE_MO
2310: 44 55 4c 45 5f 43 4f 4d 4d 45 4e 54 53 20 6d 61 DULE_COMMENTS ma
2320: 63 72 6f 20 74 6f 20 73 65 65 20 73 6f 6d 65 20 cro to see some
2330: 65 78 74 72 61 20 6e 6f 2d 6f 70 0a 2a 2a 20 63 extra no-op.** c
2340: 6f 6d 6d 65 6e 74 73 20 69 6e 20 56 44 42 45 20 omments in VDBE
2350: 70 72 6f 67 72 61 6d 73 20 74 68 61 74 20 73 68 programs that sh
2360: 6f 77 20 6b 65 79 20 64 65 63 69 73 69 6f 6e 20 ow key decision
2370: 70 6f 69 6e 74 73 20 69 6e 20 74 68 65 20 63 6f points in the co
2380: 64 65 0a 2a 2a 20 67 65 6e 65 72 61 74 6f 72 2e de.** generator.
2390: 0a 2a 2f 0a 23 69 66 64 65 66 20 53 51 4c 49 54 .*/.#ifdef SQLIT
23a0: 45 5f 45 4e 41 42 4c 45 5f 45 58 50 4c 41 49 4e E_ENABLE_EXPLAIN
23b0: 5f 43 4f 4d 4d 45 4e 54 53 0a 20 20 76 6f 69 64 _COMMENTS. void
23c0: 20 73 71 6c 69 74 65 33 56 64 62 65 43 6f 6d 6d sqlite3VdbeComm
23d0: 65 6e 74 28 56 64 62 65 2a 2c 20 63 6f 6e 73 74 ent(Vdbe*, const
23e0: 20 63 68 61 72 2a 2c 20 2e 2e 2e 29 3b 0a 23 20 char*, ...);.#
23f0: 64 65 66 69 6e 65 20 56 64 62 65 43 6f 6d 6d 65 define VdbeComme
2400: 6e 74 28 58 29 20 20 73 71 6c 69 74 65 33 56 64 nt(X) sqlite3Vd
2410: 62 65 43 6f 6d 6d 65 6e 74 20 58 0a 20 20 76 6f beComment X. vo
2420: 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 4e 6f id sqlite3VdbeNo
2430: 6f 70 43 6f 6d 6d 65 6e 74 28 56 64 62 65 2a 2c opComment(Vdbe*,
2440: 20 63 6f 6e 73 74 20 63 68 61 72 2a 2c 20 2e 2e const char*, ..
2450: 2e 29 3b 0a 23 20 64 65 66 69 6e 65 20 56 64 62 .);.# define Vdb
2460: 65 4e 6f 6f 70 43 6f 6d 6d 65 6e 74 28 58 29 20 eNoopComment(X)
2470: 20 73 71 6c 69 74 65 33 56 64 62 65 4e 6f 6f 70 sqlite3VdbeNoop
2480: 43 6f 6d 6d 65 6e 74 20 58 0a 23 20 69 66 64 65 Comment X.# ifde
2490: 66 20 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f f SQLITE_ENABLE_
24a0: 4d 4f 44 55 4c 45 5f 43 4f 4d 4d 45 4e 54 53 0a MODULE_COMMENTS.
24b0: 23 20 20 20 64 65 66 69 6e 65 20 56 64 62 65 4d # define VdbeM
24c0: 6f 64 75 6c 65 43 6f 6d 6d 65 6e 74 28 58 29 20 oduleComment(X)
24d0: 20 73 71 6c 69 74 65 33 56 64 62 65 4e 6f 6f 70 sqlite3VdbeNoop
24e0: 43 6f 6d 6d 65 6e 74 20 58 0a 23 20 65 6c 73 65 Comment X.# else
24f0: 0a 23 20 20 20 64 65 66 69 6e 65 20 56 64 62 65 .# define Vdbe
2500: 4d 6f 64 75 6c 65 43 6f 6d 6d 65 6e 74 28 58 29 ModuleComment(X)
2510: 0a 23 20 65 6e 64 69 66 0a 23 65 6c 73 65 0a 23 .# endif.#else.#
2520: 20 64 65 66 69 6e 65 20 56 64 62 65 43 6f 6d 6d define VdbeComm
2530: 65 6e 74 28 58 29 0a 23 20 64 65 66 69 6e 65 20 ent(X).# define
2540: 56 64 62 65 4e 6f 6f 70 43 6f 6d 6d 65 6e 74 28 VdbeNoopComment(
2550: 58 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 X).# define Vdbe
2560: 4d 6f 64 75 6c 65 43 6f 6d 6d 65 6e 74 28 58 29 ModuleComment(X)
2570: 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 54 .#endif../*.** T
2580: 68 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 20 he VdbeCoverage
2590: 6d 61 63 72 6f 73 20 61 72 65 20 75 73 65 64 20 macros are used
25a0: 74 6f 20 73 65 74 20 61 20 63 6f 76 65 72 61 67 to set a coverag
25b0: 65 20 74 65 73 74 69 6e 67 20 70 6f 69 6e 74 0a e testing point.
25c0: 2a 2a 20 66 6f 72 20 56 44 42 45 20 62 72 61 6e ** for VDBE bran
25d0: 63 68 20 69 6e 73 74 72 75 63 74 69 6f 6e 73 2e ch instructions.
25e0: 20 20 54 68 65 20 63 6f 76 65 72 61 67 65 20 74 The coverage t
25f0: 65 73 74 69 6e 67 20 70 6f 69 6e 74 73 20 61 72 esting points ar
2600: 65 20 6c 69 6e 65 0a 2a 2a 20 6e 75 6d 62 65 72 e line.** number
2610: 73 20 69 6e 20 74 68 65 20 73 71 6c 69 74 65 33 s in the sqlite3
2620: 2e 63 20 73 6f 75 72 63 65 20 66 69 6c 65 2e 20 .c source file.
2630: 20 56 44 42 45 20 62 72 61 6e 63 68 20 63 6f 76 VDBE branch cov
2640: 65 72 61 67 65 20 74 65 73 74 69 6e 67 0a 2a 2a erage testing.**
2650: 20 6f 6e 6c 79 20 77 6f 72 6b 73 20 77 69 74 68 only works with
2660: 20 61 6e 20 61 6d 61 6c 61 67 6d 61 74 69 6f 6e an amalagmation
2670: 20 62 75 69 6c 64 2e 20 20 54 68 61 74 27 73 20 build. That's
2680: 6f 6b 20 73 69 6e 63 65 20 61 20 56 44 42 45 20 ok since a VDBE
2690: 62 72 61 6e 63 68 0a 2a 2a 20 63 6f 76 65 72 61 branch.** covera
26a0: 67 65 20 62 75 69 6c 64 20 64 65 73 69 67 6e 65 ge build designe
26b0: 64 20 66 6f 72 20 74 65 73 74 69 6e 67 20 74 68 d for testing th
26c0: 65 20 74 65 73 74 20 73 75 69 74 65 20 6f 6e 6c e test suite onl
26d0: 79 2e 20 20 4e 6f 20 61 70 70 6c 69 63 61 74 69 y. No applicati
26e0: 6f 6e 0a 2a 2a 20 73 68 6f 75 6c 64 20 65 76 65 on.** should eve
26f0: 72 20 73 68 69 70 20 77 69 74 68 20 56 44 42 45 r ship with VDBE
2700: 20 62 72 61 6e 63 68 20 63 6f 76 65 72 61 67 65 branch coverage
2710: 20 6d 65 61 73 75 72 69 6e 67 20 74 75 72 6e 65 measuring turne
2720: 64 20 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 20 20 20 56 d on..**.** V
2730: 64 62 65 43 6f 76 65 72 61 67 65 28 76 29 20 20 dbeCoverage(v)
2740: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2750: 2f 2f 20 4d 61 72 6b 20 74 68 65 20 70 72 65 76 // Mark the prev
2760: 69 6f 75 73 6c 79 20 63 6f 64 65 64 20 69 6e 73 iously coded ins
2770: 74 72 75 63 74 69 6f 6e 0a 2a 2a 20 20 20 20 20 truction.**
2780: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2790: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
27a0: 2f 2f 20 61 73 20 61 20 62 72 61 6e 63 68 0a 2a // as a branch.*
27b0: 2a 0a 2a 2a 20 20 20 20 56 64 62 65 43 6f 76 65 *.** VdbeCove
27c0: 72 61 67 65 49 66 28 76 2c 20 63 6f 6e 64 69 74 rageIf(v, condit
27d0: 69 6f 6e 61 6c 29 20 20 20 2f 2f 20 4d 61 72 6b ional) // Mark
27e0: 20 70 72 65 76 69 6f 75 73 20 69 66 20 63 6f 6e previous if con
27f0: 64 69 74 69 6f 6e 61 6c 20 74 72 75 65 0a 2a 2a ditional true.**
2800: 0a 2a 2a 20 20 20 20 56 64 62 65 43 6f 76 65 72 .** VdbeCover
2810: 61 67 65 41 6c 77 61 79 73 54 61 6b 65 6e 28 76 ageAlwaysTaken(v
2820: 29 20 20 20 20 20 20 20 2f 2f 20 50 72 65 76 69 ) // Previ
2830: 6f 75 73 20 62 72 61 6e 63 68 20 69 73 20 61 6c ous branch is al
2840: 77 61 79 73 20 74 61 6b 65 6e 0a 2a 2a 0a 2a 2a ways taken.**.**
2850: 20 20 20 20 56 64 62 65 43 6f 76 65 72 61 67 65 VdbeCoverage
2860: 4e 65 76 65 72 54 61 6b 65 6e 28 76 29 20 20 20 NeverTaken(v)
2870: 20 20 20 20 20 2f 2f 20 50 72 65 76 69 6f 75 73 // Previous
2880: 20 62 72 61 6e 63 68 20 69 73 20 6e 65 76 65 72 branch is never
2890: 20 74 61 6b 65 6e 0a 2a 2a 0a 2a 2a 20 45 76 65 taken.**.** Eve
28a0: 72 79 20 56 44 42 45 20 62 72 61 6e 63 68 20 6f ry VDBE branch o
28b0: 70 65 72 61 74 69 6f 6e 20 6d 75 73 74 20 62 65 peration must be
28c0: 20 74 61 67 67 65 64 20 77 69 74 68 20 6f 6e 65 tagged with one
28d0: 20 6f 66 20 74 68 65 20 6d 61 63 72 6f 73 20 61 of the macros a
28e0: 62 6f 76 65 2e 0a 2a 2a 20 49 66 20 6e 6f 74 2c bove..** If not,
28f0: 20 74 68 65 6e 20 77 68 65 6e 20 22 6d 61 6b 65 then when "make
2900: 20 74 65 73 74 22 20 69 73 20 72 75 6e 20 77 69 test" is run wi
2910: 74 68 20 2d 44 53 51 4c 49 54 45 5f 56 44 42 45 th -DSQLITE_VDBE
2920: 5f 43 4f 56 45 52 41 47 45 20 61 6e 64 0a 2a 2a _COVERAGE and.**
2930: 20 2d 44 53 51 4c 49 54 45 5f 44 45 42 55 47 20 -DSQLITE_DEBUG
2940: 74 68 65 6e 20 61 6e 20 41 4c 57 41 59 53 28 29 then an ALWAYS()
2950: 20 77 69 6c 6c 20 66 61 69 6c 20 69 6e 20 74 68 will fail in th
2960: 65 20 76 64 62 65 54 61 6b 65 42 72 61 6e 63 68 e vdbeTakeBranch
2970: 28 29 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 69 6e ().** routine in
2980: 20 76 64 62 65 2e 63 2c 20 61 6c 65 72 74 69 6e vdbe.c, alertin
2990: 67 20 74 68 65 20 64 65 76 65 6c 6f 70 65 72 20 g the developer
29a0: 74 6f 20 74 68 65 20 6d 69 73 73 65 64 20 74 61 to the missed ta
29b0: 67 2e 0a 2a 2f 0a 23 69 66 64 65 66 20 53 51 4c g..*/.#ifdef SQL
29c0: 49 54 45 5f 56 44 42 45 5f 43 4f 56 45 52 41 47 ITE_VDBE_COVERAG
29d0: 45 0a 20 20 76 6f 69 64 20 73 71 6c 69 74 65 33 E. void sqlite3
29e0: 56 64 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 VdbeSetLineNumbe
29f0: 72 28 56 64 62 65 2a 2c 69 6e 74 29 3b 0a 23 20 r(Vdbe*,int);.#
2a00: 64 65 66 69 6e 65 20 56 64 62 65 43 6f 76 65 72 define VdbeCover
2a10: 61 67 65 28 76 29 20 73 71 6c 69 74 65 33 56 64 age(v) sqlite3Vd
2a20: 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 72 28 beSetLineNumber(
2a30: 76 2c 5f 5f 4c 49 4e 45 5f 5f 29 0a 23 20 64 65 v,__LINE__).# de
2a40: 66 69 6e 65 20 56 64 62 65 43 6f 76 65 72 61 67 fine VdbeCoverag
2a50: 65 49 66 28 76 2c 78 29 20 69 66 28 78 29 73 71 eIf(v,x) if(x)sq
2a60: 6c 69 74 65 33 56 64 62 65 53 65 74 4c 69 6e 65 lite3VdbeSetLine
2a70: 4e 75 6d 62 65 72 28 76 2c 5f 5f 4c 49 4e 45 5f Number(v,__LINE_
2a80: 5f 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 _).# define Vdbe
2a90: 43 6f 76 65 72 61 67 65 41 6c 77 61 79 73 54 61 CoverageAlwaysTa
2aa0: 6b 65 6e 28 76 29 20 73 71 6c 69 74 65 33 56 64 ken(v) sqlite3Vd
2ab0: 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 72 28 beSetLineNumber(
2ac0: 76 2c 32 29 3b 0a 23 20 64 65 66 69 6e 65 20 56 v,2);.# define V
2ad0: 64 62 65 43 6f 76 65 72 61 67 65 4e 65 76 65 72 dbeCoverageNever
2ae0: 54 61 6b 65 6e 28 76 29 20 73 71 6c 69 74 65 33 Taken(v) sqlite3
2af0: 56 64 62 65 53 65 74 4c 69 6e 65 4e 75 6d 62 65 VdbeSetLineNumbe
2b00: 72 28 76 2c 31 29 3b 0a 23 20 64 65 66 69 6e 65 r(v,1);.# define
2b10: 20 56 44 42 45 5f 4f 46 46 53 45 54 5f 4c 49 4e VDBE_OFFSET_LIN
2b20: 45 4e 4f 28 78 29 20 28 5f 5f 4c 49 4e 45 5f 5f ENO(x) (__LINE__
2b30: 2b 78 29 0a 23 65 6c 73 65 0a 23 20 64 65 66 69 +x).#else.# defi
2b40: 6e 65 20 56 64 62 65 43 6f 76 65 72 61 67 65 28 ne VdbeCoverage(
2b50: 76 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 65 v).# define Vdbe
2b60: 43 6f 76 65 72 61 67 65 49 66 28 76 2c 78 29 0a CoverageIf(v,x).
2b70: 23 20 64 65 66 69 6e 65 20 56 64 62 65 43 6f 76 # define VdbeCov
2b80: 65 72 61 67 65 41 6c 77 61 79 73 54 61 6b 65 6e erageAlwaysTaken
2b90: 28 76 29 0a 23 20 64 65 66 69 6e 65 20 56 64 62 (v).# define Vdb
2ba0: 65 43 6f 76 65 72 61 67 65 4e 65 76 65 72 54 61 eCoverageNeverTa
2bb0: 6b 65 6e 28 76 29 0a 23 20 64 65 66 69 6e 65 20 ken(v).# define
2bc0: 56 44 42 45 5f 4f 46 46 53 45 54 5f 4c 49 4e 45 VDBE_OFFSET_LINE
2bd0: 4e 4f 28 78 29 20 30 0a 23 65 6e 64 69 66 0a 0a NO(x) 0.#endif..
2be0: 23 65 6e 64 69 66 0a #endif.