0000: 2f 2a 0a 2a 2a 20 32 30 30 33 20 53 65 70 74 65 /*.** 2003 Septe
0010: 6d 62 65 72 20 36 0a 2a 2a 0a 2a 2a 20 54 68 65 mber 6.**.** The
0020: 20 61 75 74 68 6f 72 20 64 69 73 63 6c 61 69 6d author disclaim
0030: 73 20 63 6f 70 79 72 69 67 68 74 20 74 6f 20 74 s copyright to t
0040: 68 69 73 20 73 6f 75 72 63 65 20 63 6f 64 65 2e his source code.
0050: 20 20 49 6e 20 70 6c 61 63 65 20 6f 66 0a 2a 2a In place of.**
0060: 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69 63 65 2c a legal notice,
0070: 20 68 65 72 65 20 69 73 20 61 20 62 6c 65 73 73 here is a bless
0080: 69 6e 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 4d 61 ing:.**.** Ma
0090: 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61 6e y you do good an
00a0: 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 2a 2a 20 20 d not evil..**
00b0: 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 66 May you find f
00c0: 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 79 orgiveness for y
00d0: 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 67 ourself and forg
00e0: 69 76 65 20 6f 74 68 65 72 73 2e 0a 2a 2a 20 20 ive others..**
00f0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 May you share
0100: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 freely, never ta
0110: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 king more than y
0120: 6f 75 20 67 69 76 65 2e 0a 2a 2a 0a 2a 2a 2a 2a ou 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 0a 2a 2a 20 54 68 69 73 20 69 73 *****.** This is
0180: 20 74 68 65 20 68 65 61 64 65 72 20 66 69 6c 65 the header file
0190: 20 66 6f 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e for information
01a0: 20 74 68 61 74 20 69 73 20 70 72 69 76 61 74 65 that is private
01b0: 20 74 6f 20 74 68 65 0a 2a 2a 20 56 44 42 45 2e to the.** VDBE.
01c0: 20 20 54 68 69 73 20 69 6e 66 6f 72 6d 61 74 69 This informati
01d0: 6f 6e 20 75 73 65 64 20 74 6f 20 61 6c 6c 20 62 on used to all b
01e0: 65 20 61 74 20 74 68 65 20 74 6f 70 20 6f 66 20 e at the top of
01f0: 74 68 65 20 73 69 6e 67 6c 65 0a 2a 2a 20 73 6f the single.** so
0200: 75 72 63 65 20 63 6f 64 65 20 66 69 6c 65 20 22 urce code file "
0210: 76 64 62 65 2e 63 22 2e 20 20 57 68 65 6e 20 74 vdbe.c". When t
0220: 68 61 74 20 66 69 6c 65 20 62 65 63 61 6d 65 20 hat file became
0230: 74 6f 6f 20 62 69 67 20 28 6f 76 65 72 0a 2a 2a too big (over.**
0240: 20 36 30 30 30 20 6c 69 6e 65 73 20 6c 6f 6e 67 6000 lines long
0250: 29 20 69 74 20 77 61 73 20 73 70 6c 69 74 20 75 ) it was split u
0260: 70 20 69 6e 74 6f 20 73 65 76 65 72 61 6c 20 73 p into several s
0270: 6d 61 6c 6c 65 72 20 66 69 6c 65 73 20 61 6e 64 maller files and
0280: 0a 2a 2a 20 74 68 69 73 20 68 65 61 64 65 72 20 .** this header
0290: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 77 61 73 20 information was
02a0: 66 61 63 74 6f 72 65 64 20 6f 75 74 2e 0a 2a 2a factored out..**
02b0: 0a 2a 2a 20 24 49 64 3a 20 76 64 62 65 49 6e 74 .** $Id: vdbeInt
02c0: 2e 68 2c 76 20 31 2e 31 37 34 20 32 30 30 39 2f .h,v 1.174 2009/
02d0: 30 36 2f 32 33 20 31 34 3a 31 35 3a 30 34 20 64 06/23 14:15:04 d
02e0: 72 68 20 45 78 70 20 24 0a 2a 2f 0a 23 69 66 6e rh Exp $.*/.#ifn
02f0: 64 65 66 20 5f 56 44 42 45 49 4e 54 5f 48 5f 0a def _VDBEINT_H_.
0300: 23 64 65 66 69 6e 65 20 5f 56 44 42 45 49 4e 54 #define _VDBEINT
0310: 5f 48 5f 0a 0a 2f 2a 0a 2a 2a 20 53 51 4c 20 69 _H_../*.** SQL i
0320: 73 20 74 72 61 6e 73 6c 61 74 65 64 20 69 6e 74 s translated int
0330: 6f 20 61 20 73 65 71 75 65 6e 63 65 20 6f 66 20 o a sequence of
0340: 69 6e 73 74 72 75 63 74 69 6f 6e 73 20 74 6f 20 instructions to
0350: 62 65 0a 2a 2a 20 65 78 65 63 75 74 65 64 20 62 be.** executed b
0360: 79 20 61 20 76 69 72 74 75 61 6c 20 6d 61 63 68 y a virtual mach
0370: 69 6e 65 2e 20 20 45 61 63 68 20 69 6e 73 74 72 ine. Each instr
0380: 75 63 74 69 6f 6e 20 69 73 20 61 6e 20 69 6e 73 uction is an ins
0390: 74 61 6e 63 65 0a 2a 2a 20 6f 66 20 74 68 65 20 tance.** of the
03a0: 66 6f 6c 6c 6f 77 69 6e 67 20 73 74 72 75 63 74 following struct
03b0: 75 72 65 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 20 ure..*/.typedef
03c0: 73 74 72 75 63 74 20 56 64 62 65 4f 70 20 4f 70 struct VdbeOp Op
03d0: 3b 0a 0a 2f 2a 0a 2a 2a 20 42 6f 6f 6c 65 61 6e ;../*.** Boolean
03e0: 20 76 61 6c 75 65 73 0a 2a 2f 0a 74 79 70 65 64 values.*/.typed
03f0: 65 66 20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 ef unsigned char
0400: 20 42 6f 6f 6c 3b 0a 0a 2f 2a 0a 2a 2a 20 41 20 Bool;../*.** A
0410: 63 75 72 73 6f 72 20 69 73 20 61 20 70 6f 69 6e cursor is a poin
0420: 74 65 72 20 69 6e 74 6f 20 61 20 73 69 6e 67 6c ter into a singl
0430: 65 20 42 54 72 65 65 20 77 69 74 68 69 6e 20 61 e BTree within a
0440: 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 2e 0a database file..
0450: 2a 2a 20 54 68 65 20 63 75 72 73 6f 72 20 63 61 ** The cursor ca
0460: 6e 20 73 65 65 6b 20 74 6f 20 61 20 42 54 72 65 n seek to a BTre
0470: 65 20 65 6e 74 72 79 20 77 69 74 68 20 61 20 70 e entry with a p
0480: 61 72 74 69 63 75 6c 61 72 20 6b 65 79 2c 20 6f articular key, o
0490: 72 0a 2a 2a 20 6c 6f 6f 70 20 6f 76 65 72 20 61 r.** loop over a
04a0: 6c 6c 20 65 6e 74 72 69 65 73 20 6f 66 20 74 68 ll entries of th
04b0: 65 20 42 74 72 65 65 2e 20 20 59 6f 75 20 63 61 e Btree. You ca
04c0: 6e 20 61 6c 73 6f 20 69 6e 73 65 72 74 20 6e 65 n also insert ne
04d0: 77 20 42 54 72 65 65 0a 2a 2a 20 65 6e 74 72 69 w BTree.** entri
04e0: 65 73 20 6f 72 20 72 65 74 72 69 65 76 65 20 74 es or retrieve t
04f0: 68 65 20 6b 65 79 20 6f 72 20 64 61 74 61 20 66 he key or data f
0500: 72 6f 6d 20 74 68 65 20 65 6e 74 72 79 20 74 68 rom the entry th
0510: 61 74 20 74 68 65 20 63 75 72 73 6f 72 0a 2a 2a at the cursor.**
0520: 20 69 73 20 63 75 72 72 65 6e 74 6c 79 20 70 6f is currently po
0530: 69 6e 74 69 6e 67 20 74 6f 2e 0a 2a 2a 20 0a 2a inting to..** .*
0540: 2a 20 45 76 65 72 79 20 63 75 72 73 6f 72 20 74 * Every cursor t
0550: 68 61 74 20 74 68 65 20 76 69 72 74 75 61 6c 20 hat the virtual
0560: 6d 61 63 68 69 6e 65 20 68 61 73 20 6f 70 65 6e machine has open
0570: 20 69 73 20 72 65 70 72 65 73 65 6e 74 65 64 20 is represented
0580: 62 79 20 61 6e 0a 2a 2a 20 69 6e 73 74 61 6e 63 by an.** instanc
0590: 65 20 6f 66 20 74 68 65 20 66 6f 6c 6c 6f 77 69 e of the followi
05a0: 6e 67 20 73 74 72 75 63 74 75 72 65 2e 0a 2a 2a ng structure..**
05b0: 0a 2a 2a 20 49 66 20 74 68 65 20 56 64 62 65 43 .** If the VdbeC
05c0: 75 72 73 6f 72 2e 69 73 54 72 69 67 67 65 72 52 ursor.isTriggerR
05d0: 6f 77 20 66 6c 61 67 20 69 73 20 73 65 74 20 69 ow flag is set i
05e0: 74 20 6d 65 61 6e 73 20 74 68 61 74 20 74 68 69 t means that thi
05f0: 73 20 63 75 72 73 6f 72 20 69 73 0a 2a 2a 20 72 s cursor is.** r
0600: 65 61 6c 6c 79 20 61 20 73 69 6e 67 6c 65 20 72 eally a single r
0610: 6f 77 20 74 68 61 74 20 72 65 70 72 65 73 65 6e ow that represen
0620: 74 73 20 74 68 65 20 4e 45 57 20 6f 72 20 4f 4c ts the NEW or OL
0630: 44 20 70 73 65 75 64 6f 2d 74 61 62 6c 65 20 6f D pseudo-table o
0640: 66 0a 2a 2a 20 61 20 72 6f 77 20 74 72 69 67 67 f.** a row trigg
0650: 65 72 2e 20 20 54 68 65 20 64 61 74 61 20 66 6f er. The data fo
0660: 72 20 74 68 65 20 72 6f 77 20 69 73 20 73 74 6f r the row is sto
0670: 72 65 64 20 69 6e 20 56 64 62 65 43 75 72 73 6f red in VdbeCurso
0680: 72 2e 70 44 61 74 61 20 61 6e 64 0a 2a 2a 20 74 r.pData and.** t
0690: 68 65 20 72 6f 77 69 64 20 69 73 20 69 6e 20 56 he rowid is in V
06a0: 64 62 65 43 75 72 73 6f 72 2e 69 4b 65 79 2e 0a dbeCursor.iKey..
06b0: 2a 2f 0a 73 74 72 75 63 74 20 56 64 62 65 43 75 */.struct VdbeCu
06c0: 72 73 6f 72 20 7b 0a 20 20 42 74 43 75 72 73 6f rsor {. BtCurso
06d0: 72 20 2a 70 43 75 72 73 6f 72 3b 20 20 20 20 2f r *pCursor; /
06e0: 2a 20 54 68 65 20 63 75 72 73 6f 72 20 73 74 72 * The cursor str
06f0: 75 63 74 75 72 65 20 6f 66 20 74 68 65 20 62 61 ucture of the ba
0700: 63 6b 65 6e 64 20 2a 2f 0a 20 20 69 6e 74 20 69 ckend */. int i
0710: 44 62 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 Db;
0720: 20 2f 2a 20 49 6e 64 65 78 20 6f 66 20 63 75 72 /* Index of cur
0730: 73 6f 72 20 64 61 74 61 62 61 73 65 20 69 6e 20 sor database in
0740: 64 62 2d 3e 61 44 62 5b 5d 20 28 6f 72 20 2d 31 db->aDb[] (or -1
0750: 29 20 2a 2f 0a 20 20 69 36 34 20 6c 61 73 74 52 ) */. i64 lastR
0760: 6f 77 69 64 3b 20 20 20 20 20 20 20 20 2f 2a 20 owid; /*
0770: 4c 61 73 74 20 72 6f 77 69 64 20 66 72 6f 6d 20 Last rowid from
0780: 61 20 4e 65 78 74 20 6f 72 20 4e 65 78 74 49 64 a Next or NextId
0790: 78 20 6f 70 65 72 61 74 69 6f 6e 20 2a 2f 0a 20 x operation */.
07a0: 20 42 6f 6f 6c 20 7a 65 72 6f 65 64 3b 20 20 20 Bool zeroed;
07b0: 20 20 20 20 20 20 20 2f 2a 20 54 72 75 65 20 69 /* True i
07c0: 66 20 7a 65 72 6f 65 64 20 6f 75 74 20 61 6e 64 f zeroed out and
07d0: 20 72 65 61 64 79 20 66 6f 72 20 72 65 75 73 65 ready for reuse
07e0: 20 2a 2f 0a 20 20 42 6f 6f 6c 20 72 6f 77 69 64 */. Bool rowid
07f0: 49 73 56 61 6c 69 64 3b 20 20 20 20 2f 2a 20 54 IsValid; /* T
0800: 72 75 65 20 69 66 20 6c 61 73 74 52 6f 77 69 64 rue if lastRowid
0810: 20 69 73 20 76 61 6c 69 64 20 2a 2f 0a 20 20 42 is valid */. B
0820: 6f 6f 6c 20 61 74 46 69 72 73 74 3b 20 20 20 20 ool atFirst;
0830: 20 20 20 20 20 2f 2a 20 54 72 75 65 20 69 66 20 /* True if
0840: 70 6f 69 6e 74 69 6e 67 20 74 6f 20 66 69 72 73 pointing to firs
0850: 74 20 65 6e 74 72 79 20 2a 2f 0a 20 20 42 6f 6f t entry */. Boo
0860: 6c 20 75 73 65 52 61 6e 64 6f 6d 52 6f 77 69 64 l useRandomRowid
0870: 3b 20 20 2f 2a 20 47 65 6e 65 72 61 74 65 20 6e ; /* Generate n
0880: 65 77 20 72 65 63 6f 72 64 20 6e 75 6d 62 65 72 ew record number
0890: 73 20 73 65 6d 69 2d 72 61 6e 64 6f 6d 6c 79 20 s semi-randomly
08a0: 2a 2f 0a 20 20 42 6f 6f 6c 20 6e 75 6c 6c 52 6f */. Bool nullRo
08b0: 77 3b 20 20 20 20 20 20 20 20 20 2f 2a 20 54 72 w; /* Tr
08c0: 75 65 20 69 66 20 70 6f 69 6e 74 69 6e 67 20 74 ue if pointing t
08d0: 6f 20 61 20 72 6f 77 20 77 69 74 68 20 6e 6f 20 o a row with no
08e0: 64 61 74 61 20 2a 2f 0a 20 20 42 6f 6f 6c 20 64 data */. Bool d
08f0: 65 66 65 72 72 65 64 4d 6f 76 65 74 6f 3b 20 20 eferredMoveto;
0900: 2f 2a 20 41 20 63 61 6c 6c 20 74 6f 20 73 71 6c /* A call to sql
0910: 69 74 65 33 42 74 72 65 65 4d 6f 76 65 74 6f 28 ite3BtreeMoveto(
0920: 29 20 69 73 20 6e 65 65 64 65 64 20 2a 2f 0a 20 ) is needed */.
0930: 20 42 6f 6f 6c 20 69 73 54 61 62 6c 65 3b 20 20 Bool isTable;
0940: 20 20 20 20 20 20 20 2f 2a 20 54 72 75 65 20 69 /* True i
0950: 66 20 61 20 74 61 62 6c 65 20 72 65 71 75 69 72 f a table requir
0960: 69 6e 67 20 69 6e 74 65 67 65 72 20 6b 65 79 73 ing integer keys
0970: 20 2a 2f 0a 20 20 42 6f 6f 6c 20 69 73 49 6e 64 */. Bool isInd
0980: 65 78 3b 20 20 20 20 20 20 20 20 20 2f 2a 20 54 ex; /* T
0990: 72 75 65 20 69 66 20 61 6e 20 69 6e 64 65 78 20 rue if an index
09a0: 63 6f 6e 74 61 69 6e 69 6e 67 20 6b 65 79 73 20 containing keys
09b0: 6f 6e 6c 79 20 2d 20 6e 6f 20 64 61 74 61 20 2a only - no data *
09c0: 2f 0a 20 20 69 36 34 20 6d 6f 76 65 74 6f 54 61 /. i64 movetoTa
09d0: 72 67 65 74 3b 20 20 20 20 20 2f 2a 20 41 72 67 rget; /* Arg
09e0: 75 6d 65 6e 74 20 74 6f 20 74 68 65 20 64 65 66 ument to the def
09f0: 65 72 72 65 64 20 73 71 6c 69 74 65 33 42 74 72 erred sqlite3Btr
0a00: 65 65 4d 6f 76 65 74 6f 28 29 20 2a 2f 0a 20 20 eeMoveto() */.
0a10: 42 74 72 65 65 20 2a 70 42 74 3b 20 20 20 20 20 Btree *pBt;
0a20: 20 20 20 20 20 20 2f 2a 20 53 65 70 61 72 61 74 /* Separat
0a30: 65 20 66 69 6c 65 20 68 6f 6c 64 69 6e 67 20 74 e file holding t
0a40: 65 6d 70 6f 72 61 72 79 20 74 61 62 6c 65 20 2a emporary table *
0a50: 2f 0a 20 20 69 6e 74 20 70 73 65 75 64 6f 54 61 /. int pseudoTa
0a60: 62 6c 65 52 65 67 3b 20 20 20 2f 2a 20 52 65 67 bleReg; /* Reg
0a70: 69 73 74 65 72 20 68 6f 6c 64 69 6e 67 20 70 73 ister holding ps
0a80: 65 75 64 6f 74 61 62 6c 65 20 63 6f 6e 74 65 6e eudotable conten
0a90: 74 2e 20 2a 2f 0a 20 20 4b 65 79 49 6e 66 6f 20 t. */. KeyInfo
0aa0: 2a 70 4b 65 79 49 6e 66 6f 3b 20 20 20 20 2f 2a *pKeyInfo; /*
0ab0: 20 49 6e 66 6f 20 61 62 6f 75 74 20 69 6e 64 65 Info about inde
0ac0: 78 20 6b 65 79 73 20 6e 65 65 64 65 64 20 62 79 x keys needed by
0ad0: 20 69 6e 64 65 78 20 63 75 72 73 6f 72 73 20 2a index cursors *
0ae0: 2f 0a 20 20 69 6e 74 20 6e 46 69 65 6c 64 3b 20 /. int nField;
0af0: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d /* Num
0b00: 62 65 72 20 6f 66 20 66 69 65 6c 64 73 20 69 6e ber of fields in
0b10: 20 74 68 65 20 68 65 61 64 65 72 20 2a 2f 0a 20 the header */.
0b20: 20 69 36 34 20 73 65 71 43 6f 75 6e 74 3b 20 20 i64 seqCount;
0b30: 20 20 20 20 20 20 20 2f 2a 20 53 65 71 75 65 6e /* Sequen
0b40: 63 65 20 63 6f 75 6e 74 65 72 20 2a 2f 0a 20 20 ce counter */.
0b50: 73 71 6c 69 74 65 33 5f 76 74 61 62 5f 63 75 72 sqlite3_vtab_cur
0b60: 73 6f 72 20 2a 70 56 74 61 62 43 75 72 73 6f 72 sor *pVtabCursor
0b70: 3b 20 20 2f 2a 20 54 68 65 20 63 75 72 73 6f 72 ; /* The cursor
0b80: 20 66 6f 72 20 61 20 76 69 72 74 75 61 6c 20 74 for a virtual t
0b90: 61 62 6c 65 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 able */. const
0ba0: 73 71 6c 69 74 65 33 5f 6d 6f 64 75 6c 65 20 2a sqlite3_module *
0bb0: 70 4d 6f 64 75 6c 65 3b 20 20 20 20 20 2f 2a 20 pModule; /*
0bc0: 4d 6f 64 75 6c 65 20 66 6f 72 20 63 75 72 73 6f Module for curso
0bd0: 72 20 70 56 74 61 62 43 75 72 73 6f 72 20 2a 2f r pVtabCursor */
0be0: 0a 0a 20 20 2f 2a 20 52 65 73 75 6c 74 20 6f 66 .. /* Result of
0bf0: 20 6c 61 73 74 20 73 71 6c 69 74 65 33 42 74 72 last sqlite3Btr
0c00: 65 65 4d 6f 76 65 74 6f 28 29 20 64 6f 6e 65 20 eeMoveto() done
0c10: 62 79 20 61 6e 20 4f 50 5f 4e 6f 74 45 78 69 73 by an OP_NotExis
0c20: 74 73 20 6f 72 20 0a 20 20 2a 2a 20 4f 50 5f 49 ts or . ** OP_I
0c30: 73 55 6e 69 71 75 65 20 6f 70 63 6f 64 65 20 6f sUnique opcode o
0c40: 6e 20 74 68 69 73 20 63 75 72 73 6f 72 2e 20 2a n this cursor. *
0c50: 2f 0a 20 20 69 6e 74 20 73 65 65 6b 52 65 73 75 /. int seekResu
0c60: 6c 74 3b 0a 0a 20 20 2f 2a 20 43 61 63 68 65 64 lt;.. /* Cached
0c70: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f information abo
0c80: 75 74 20 74 68 65 20 68 65 61 64 65 72 20 66 6f ut the header fo
0c90: 72 20 74 68 65 20 64 61 74 61 20 72 65 63 6f 72 r the data recor
0ca0: 64 20 74 68 61 74 20 74 68 65 0a 20 20 2a 2a 20 d that the. **
0cb0: 63 75 72 73 6f 72 20 69 73 20 63 75 72 72 65 6e cursor is curren
0cc0: 74 6c 79 20 70 6f 69 6e 74 69 6e 67 20 74 6f 2e tly pointing to.
0cd0: 20 20 4f 6e 6c 79 20 76 61 6c 69 64 20 69 66 20 Only valid if
0ce0: 63 61 63 68 65 53 74 61 74 75 73 20 6d 61 74 63 cacheStatus matc
0cf0: 68 65 73 0a 20 20 2a 2a 20 56 64 62 65 2e 63 61 hes. ** Vdbe.ca
0d00: 63 68 65 43 74 72 2e 20 20 56 64 62 65 2e 63 61 cheCtr. Vdbe.ca
0d10: 63 68 65 43 74 72 20 77 69 6c 6c 20 6e 65 76 65 cheCtr will neve
0d20: 72 20 74 61 6b 65 20 6f 6e 20 74 68 65 20 76 61 r take on the va
0d30: 6c 75 65 20 6f 66 0a 20 20 2a 2a 20 43 41 43 48 lue of. ** CACH
0d40: 45 5f 53 54 41 4c 45 20 61 6e 64 20 73 6f 20 73 E_STALE and so s
0d50: 65 74 74 69 6e 67 20 63 61 63 68 65 53 74 61 74 etting cacheStat
0d60: 75 73 3d 43 41 43 48 45 5f 53 54 41 4c 45 20 67 us=CACHE_STALE g
0d70: 75 61 72 61 6e 74 65 65 73 20 74 68 61 74 0a 20 uarantees that.
0d80: 20 2a 2a 20 74 68 65 20 63 61 63 68 65 20 69 73 ** the cache is
0d90: 20 6f 75 74 20 6f 66 20 64 61 74 65 2e 0a 20 20 out of date..
0da0: 2a 2a 0a 20 20 2a 2a 20 61 52 6f 77 20 6d 69 67 **. ** aRow mig
0db0: 68 74 20 70 6f 69 6e 74 20 74 6f 20 28 65 70 68 ht point to (eph
0dc0: 65 6d 65 72 61 6c 29 20 64 61 74 61 20 66 6f 72 emeral) data for
0dd0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 72 6f 77 the current row
0de0: 2c 20 6f 72 20 69 74 20 6d 69 67 68 74 0a 20 20 , or it might.
0df0: 2a 2a 20 62 65 20 4e 55 4c 4c 2e 0a 20 20 2a 2f ** be NULL.. */
0e00: 0a 20 20 75 33 32 20 63 61 63 68 65 53 74 61 74 . u32 cacheStat
0e10: 75 73 3b 20 20 20 20 20 20 2f 2a 20 43 61 63 68 us; /* Cach
0e20: 65 20 69 73 20 76 61 6c 69 64 20 69 66 20 74 68 e is valid if th
0e30: 69 73 20 6d 61 74 63 68 65 73 20 56 64 62 65 2e is matches Vdbe.
0e40: 63 61 63 68 65 43 74 72 20 2a 2f 0a 20 20 69 6e cacheCtr */. in
0e50: 74 20 70 61 79 6c 6f 61 64 53 69 7a 65 3b 20 20 t payloadSize;
0e60: 20 20 20 20 2f 2a 20 54 6f 74 61 6c 20 6e 75 6d /* Total num
0e70: 62 65 72 20 6f 66 20 62 79 74 65 73 20 69 6e 20 ber of bytes in
0e80: 74 68 65 20 72 65 63 6f 72 64 20 2a 2f 0a 20 20 the record */.
0e90: 75 33 32 20 2a 61 54 79 70 65 3b 20 20 20 20 20 u32 *aType;
0ea0: 20 20 20 20 20 20 2f 2a 20 54 79 70 65 20 76 61 /* Type va
0eb0: 6c 75 65 73 20 66 6f 72 20 61 6c 6c 20 65 6e 74 lues for all ent
0ec0: 72 69 65 73 20 69 6e 20 74 68 65 20 72 65 63 6f ries in the reco
0ed0: 72 64 20 2a 2f 0a 20 20 75 33 32 20 2a 61 4f 66 rd */. u32 *aOf
0ee0: 66 73 65 74 3b 20 20 20 20 20 20 20 20 20 2f 2a fset; /*
0ef0: 20 43 61 63 68 65 64 20 6f 66 66 73 65 74 73 20 Cached offsets
0f00: 74 6f 20 74 68 65 20 73 74 61 72 74 20 6f 66 20 to the start of
0f10: 65 61 63 68 20 63 6f 6c 75 6d 6e 73 20 64 61 74 each columns dat
0f20: 61 20 2a 2f 0a 20 20 75 38 20 2a 61 52 6f 77 3b a */. u8 *aRow;
0f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
0f40: 44 61 74 61 20 66 6f 72 20 74 68 65 20 63 75 72 Data for the cur
0f50: 72 65 6e 74 20 72 6f 77 2c 20 69 66 20 61 6c 6c rent row, if all
0f60: 20 6f 6e 20 6f 6e 65 20 70 61 67 65 20 2a 2f 0a on one page */.
0f70: 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 };.typedef struc
0f80: 74 20 56 64 62 65 43 75 72 73 6f 72 20 56 64 62 t VdbeCursor Vdb
0f90: 65 43 75 72 73 6f 72 3b 0a 0a 2f 2a 0a 2a 2a 20 eCursor;../*.**
0fa0: 57 68 65 6e 20 61 20 73 75 62 2d 70 72 6f 67 72 When a sub-progr
0fb0: 61 6d 20 69 73 20 65 78 65 63 75 74 65 64 20 28 am is executed (
0fc0: 4f 50 5f 50 72 6f 67 72 61 6d 29 2c 20 61 20 73 OP_Program), a s
0fd0: 74 72 75 63 74 75 72 65 20 6f 66 20 74 68 69 73 tructure of this
0fe0: 20 74 79 70 65 0a 2a 2a 20 69 73 20 61 6c 6c 6f type.** is allo
0ff0: 63 61 74 65 64 20 74 6f 20 73 74 6f 72 65 20 74 cated to store t
1000: 68 65 20 63 75 72 72 65 6e 74 20 76 61 6c 75 65 he current value
1010: 20 6f 66 20 74 68 65 20 70 72 6f 67 72 61 6d 20 of the program
1020: 63 6f 75 6e 74 65 72 2c 20 61 73 0a 2a 2a 20 77 counter, as.** w
1030: 65 6c 6c 20 61 73 20 74 68 65 20 63 75 72 72 65 ell as the curre
1040: 6e 74 20 6d 65 6d 6f 72 79 20 63 65 6c 6c 20 61 nt memory cell a
1050: 72 72 61 79 20 61 6e 64 20 76 61 72 69 6f 75 73 rray and various
1060: 20 6f 74 68 65 72 20 66 72 61 6d 65 20 73 70 65 other frame spe
1070: 63 69 66 69 63 0a 2a 2a 20 76 61 6c 75 65 73 20 cific.** values
1080: 73 74 6f 72 65 64 20 69 6e 20 74 68 65 20 56 64 stored in the Vd
1090: 62 65 20 73 74 72 75 63 74 2e 20 57 68 65 6e 20 be struct. When
10a0: 74 68 65 20 73 75 62 2d 70 72 6f 67 72 61 6d 20 the sub-program
10b0: 69 73 20 66 69 6e 69 73 68 65 64 2c 20 0a 2a 2a is finished, .**
10c0: 20 74 68 65 73 65 20 76 61 6c 75 65 73 20 61 72 these values ar
10d0: 65 20 63 6f 70 69 65 64 20 62 61 63 6b 20 74 6f e copied back to
10e0: 20 74 68 65 20 56 64 62 65 20 66 72 6f 6d 20 74 the Vdbe from t
10f0: 68 65 20 56 64 62 65 46 72 61 6d 65 20 73 74 72 he VdbeFrame str
1100: 75 63 74 75 72 65 2c 0a 2a 2a 20 72 65 73 74 6f ucture,.** resto
1110: 72 69 6e 67 20 74 68 65 20 73 74 61 74 65 20 6f ring the state o
1120: 66 20 74 68 65 20 56 4d 20 74 6f 20 61 73 20 69 f the VM to as i
1130: 74 20 77 61 73 20 62 65 66 6f 72 65 20 74 68 65 t was before the
1140: 20 73 75 62 2d 70 72 6f 67 72 61 6d 0a 2a 2a 20 sub-program.**
1150: 62 65 67 61 6e 20 65 78 65 63 75 74 69 6e 67 2e began executing.
1160: 0a 2a 2a 0a 2a 2a 20 46 72 61 6d 65 73 20 61 72 .**.** Frames ar
1170: 65 20 73 74 6f 72 65 64 20 69 6e 20 61 20 6c 69 e stored in a li
1180: 6e 6b 65 64 20 6c 69 73 74 20 68 65 61 64 65 64 nked list headed
1190: 20 61 74 20 56 64 62 65 2e 70 50 61 72 65 6e 74 at Vdbe.pParent
11a0: 2e 20 56 64 62 65 2e 70 50 61 72 65 6e 74 0a 2a . Vdbe.pParent.*
11b0: 2a 20 69 73 20 74 68 65 20 70 61 72 65 6e 74 20 * is the parent
11c0: 6f 66 20 74 68 65 20 63 75 72 72 65 6e 74 20 66 of the current f
11d0: 72 61 6d 65 2c 20 6f 72 20 7a 65 72 6f 20 69 66 rame, or zero if
11e0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 66 72 61 the current fra
11f0: 6d 65 0a 2a 2a 20 69 73 20 74 68 65 20 6d 61 69 me.** is the mai
1200: 6e 20 56 64 62 65 20 70 72 6f 67 72 61 6d 2e 0a n Vdbe program..
1210: 2a 2f 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 */.typedef struc
1220: 74 20 56 64 62 65 46 72 61 6d 65 20 56 64 62 65 t VdbeFrame Vdbe
1230: 46 72 61 6d 65 3b 0a 73 74 72 75 63 74 20 56 64 Frame;.struct Vd
1240: 62 65 46 72 61 6d 65 20 7b 0a 20 20 56 64 62 65 beFrame {. Vdbe
1250: 20 2a 76 3b 20 20 20 20 20 20 20 20 20 20 20 20 *v;
1260: 20 20 20 20 2f 2a 20 56 4d 20 74 68 69 73 20 66 /* VM this f
1270: 72 61 6d 65 20 62 65 6c 6f 6e 67 73 20 74 6f 20 rame belongs to
1280: 2a 2f 0a 20 20 69 6e 74 20 70 63 3b 20 20 20 20 */. int pc;
1290: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
12a0: 50 72 6f 67 72 61 6d 20 43 6f 75 6e 74 65 72 20 Program Counter
12b0: 2a 2f 0a 20 20 4f 70 20 2a 61 4f 70 3b 20 20 20 */. Op *aOp;
12c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
12d0: 50 72 6f 67 72 61 6d 20 69 6e 73 74 72 75 63 74 Program instruct
12e0: 69 6f 6e 73 20 2a 2f 0a 20 20 69 6e 74 20 6e 4f ions */. int nO
12f0: 70 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 p;
1300: 20 20 2f 2a 20 53 69 7a 65 20 6f 66 20 61 4f 70 /* Size of aOp
1310: 20 61 72 72 61 79 20 2a 2f 0a 20 20 4d 65 6d 20 array */. Mem
1320: 2a 61 4d 65 6d 3b 20 20 20 20 20 20 20 20 20 20 *aMem;
1330: 20 20 20 20 2f 2a 20 41 72 72 61 79 20 6f 66 20 /* Array of
1340: 6d 65 6d 6f 72 79 20 63 65 6c 6c 73 20 2a 2f 0a memory cells */.
1350: 20 20 69 6e 74 20 6e 4d 65 6d 3b 20 20 20 20 20 int nMem;
1360: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d /* Num
1370: 62 65 72 20 6f 66 20 65 6e 74 72 69 65 73 20 69 ber of entries i
1380: 6e 20 61 4d 65 6d 20 2a 2f 0a 20 20 56 64 62 65 n aMem */. Vdbe
1390: 43 75 72 73 6f 72 20 2a 2a 61 70 43 73 72 3b 20 Cursor **apCsr;
13a0: 20 20 20 20 2f 2a 20 45 6c 65 6d 65 6e 74 20 6f /* Element o
13b0: 66 20 56 64 62 65 20 63 75 72 73 6f 72 73 20 2a f Vdbe cursors *
13c0: 2f 0a 20 20 75 31 36 20 6e 43 75 72 73 6f 72 3b /. u16 nCursor;
13d0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e /* N
13e0: 75 6d 62 65 72 20 6f 66 20 65 6e 74 72 69 65 73 umber of entries
13f0: 20 69 6e 20 61 70 43 73 72 20 2a 2f 0a 20 20 76 in apCsr */. v
1400: 6f 69 64 20 2a 74 6f 6b 65 6e 3b 20 20 20 20 20 oid *token;
1410: 20 20 20 20 20 20 20 2f 2a 20 43 6f 70 79 20 6f /* Copy o
1420: 66 20 53 75 62 50 72 6f 67 72 61 6d 2e 74 6f 6b f SubProgram.tok
1430: 65 6e 20 2a 2f 0a 20 20 69 6e 74 20 6e 43 68 69 en */. int nChi
1440: 6c 64 4d 65 6d 3b 20 20 20 20 20 20 20 20 20 20 ldMem;
1450: 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 6d 65 6d /* Number of mem
1460: 6f 72 79 20 63 65 6c 6c 73 20 66 6f 72 20 63 68 ory cells for ch
1470: 69 6c 64 20 66 72 61 6d 65 20 2a 2f 0a 20 20 69 ild frame */. i
1480: 6e 74 20 6e 43 68 69 6c 64 43 73 72 3b 20 20 20 nt nChildCsr;
1490: 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 /* Number
14a0: 20 6f 66 20 63 75 72 73 6f 72 73 20 66 6f 72 20 of cursors for
14b0: 63 68 69 6c 64 20 66 72 61 6d 65 20 2a 2f 0a 20 child frame */.
14c0: 20 69 36 34 20 6c 61 73 74 52 6f 77 69 64 3b 20 i64 lastRowid;
14d0: 20 20 20 20 20 20 20 20 20 2f 2a 20 4c 61 73 74 /* Last
14e0: 20 69 6e 73 65 72 74 20 72 6f 77 69 64 20 28 73 insert rowid (s
14f0: 71 6c 69 74 65 33 2e 6c 61 73 74 52 6f 77 69 64 qlite3.lastRowid
1500: 29 20 2a 2f 0a 20 20 69 6e 74 20 6e 43 68 61 6e ) */. int nChan
1510: 67 65 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f ge; /
1520: 2a 20 53 74 61 74 65 6d 65 6e 74 20 63 68 61 6e * Statement chan
1530: 67 65 73 20 28 56 64 62 65 2e 6e 43 68 61 6e 67 ges (Vdbe.nChang
1540: 65 73 29 20 20 20 20 20 2a 2f 0a 20 20 56 64 62 es) */. Vdb
1550: 65 46 72 61 6d 65 20 2a 70 50 61 72 65 6e 74 3b eFrame *pParent;
1560: 20 20 20 20 20 2f 2a 20 50 61 72 65 6e 74 20 6f /* Parent o
1570: 66 20 74 68 69 73 20 66 72 61 6d 65 20 2a 2f 0a f this frame */.
1580: 7d 3b 0a 0a 23 64 65 66 69 6e 65 20 56 64 62 65 };..#define Vdbe
1590: 46 72 61 6d 65 4d 65 6d 28 70 29 20 28 28 4d 65 FrameMem(p) ((Me
15a0: 6d 20 2a 29 26 28 28 75 38 20 2a 29 70 29 5b 52 m *)&((u8 *)p)[R
15b0: 4f 55 4e 44 38 28 73 69 7a 65 6f 66 28 56 64 62 OUND8(sizeof(Vdb
15c0: 65 46 72 61 6d 65 29 29 5d 29 0a 0a 2f 2a 0a 2a eFrame))])../*.*
15d0: 2a 20 41 20 76 61 6c 75 65 20 66 6f 72 20 56 64 * A value for Vd
15e0: 62 65 43 75 72 73 6f 72 2e 63 61 63 68 65 56 61 beCursor.cacheVa
15f0: 6c 69 64 20 74 68 61 74 20 6d 65 61 6e 73 20 74 lid that means t
1600: 68 65 20 63 61 63 68 65 20 69 73 20 61 6c 77 61 he cache is alwa
1610: 79 73 20 69 6e 76 61 6c 69 64 2e 0a 2a 2f 0a 23 ys invalid..*/.#
1620: 64 65 66 69 6e 65 20 43 41 43 48 45 5f 53 54 41 define CACHE_STA
1630: 4c 45 20 30 0a 0a 2f 2a 0a 2a 2a 20 49 6e 74 65 LE 0../*.** Inte
1640: 72 6e 61 6c 6c 79 2c 20 74 68 65 20 76 64 62 65 rnally, the vdbe
1650: 20 6d 61 6e 69 70 75 6c 61 74 65 73 20 6e 65 61 manipulates nea
1660: 72 6c 79 20 61 6c 6c 20 53 51 4c 20 76 61 6c 75 rly all SQL valu
1670: 65 73 20 61 73 20 4d 65 6d 0a 2a 2a 20 73 74 72 es as Mem.** str
1680: 75 63 74 75 72 65 73 2e 20 45 61 63 68 20 4d 65 uctures. Each Me
1690: 6d 20 73 74 72 75 63 74 20 6d 61 79 20 63 61 63 m struct may cac
16a0: 68 65 20 6d 75 6c 74 69 70 6c 65 20 72 65 70 72 he multiple repr
16b0: 65 73 65 6e 74 61 74 69 6f 6e 73 20 28 73 74 72 esentations (str
16c0: 69 6e 67 2c 0a 2a 2a 20 69 6e 74 65 67 65 72 20 ing,.** integer
16d0: 65 74 63 2e 29 20 6f 66 20 74 68 65 20 73 61 6d etc.) of the sam
16e0: 65 20 76 61 6c 75 65 2e 20 20 41 20 76 61 6c 75 e value. A valu
16f0: 65 20 28 61 6e 64 20 74 68 65 72 65 66 6f 72 65 e (and therefore
1700: 20 4d 65 6d 20 73 74 72 75 63 74 75 72 65 29 0a Mem structure).
1710: 2a 2a 20 68 61 73 20 74 68 65 20 66 6f 6c 6c 6f ** has the follo
1720: 77 69 6e 67 20 70 72 6f 70 65 72 74 69 65 73 3a wing properties:
1730: 0a 2a 2a 0a 2a 2a 20 45 61 63 68 20 76 61 6c 75 .**.** Each valu
1740: 65 20 68 61 73 20 61 20 6d 61 6e 69 66 65 73 74 e has a manifest
1750: 20 74 79 70 65 2e 20 54 68 65 20 6d 61 6e 69 66 type. The manif
1760: 65 73 74 20 74 79 70 65 20 6f 66 20 74 68 65 20 est type of the
1770: 76 61 6c 75 65 20 73 74 6f 72 65 64 0a 2a 2a 20 value stored.**
1780: 69 6e 20 61 20 4d 65 6d 20 73 74 72 75 63 74 20 in a Mem struct
1790: 69 73 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 is returned by t
17a0: 68 65 20 4d 65 6d 54 79 70 65 28 4d 65 6d 2a 29 he MemType(Mem*)
17b0: 20 6d 61 63 72 6f 2e 20 54 68 65 20 74 79 70 65 macro. The type
17c0: 20 69 73 0a 2a 2a 20 6f 6e 65 20 6f 66 20 53 51 is.** one of SQ
17d0: 4c 49 54 45 5f 4e 55 4c 4c 2c 20 53 51 4c 49 54 LITE_NULL, SQLIT
17e0: 45 5f 49 4e 54 45 47 45 52 2c 20 53 51 4c 49 54 E_INTEGER, SQLIT
17f0: 45 5f 52 45 41 4c 2c 20 53 51 4c 49 54 45 5f 54 E_REAL, SQLITE_T
1800: 45 58 54 20 6f 72 0a 2a 2a 20 53 51 4c 49 54 45 EXT or.** SQLITE
1810: 5f 42 4c 4f 42 2e 0a 2a 2f 0a 73 74 72 75 63 74 _BLOB..*/.struct
1820: 20 4d 65 6d 20 7b 0a 20 20 75 6e 69 6f 6e 20 7b Mem {. union {
1830: 0a 20 20 20 20 69 36 34 20 69 3b 20 20 20 20 20 . i64 i;
1840: 20 20 20 20 20 20 20 20 20 2f 2a 20 49 6e 74 65 /* Inte
1850: 67 65 72 20 76 61 6c 75 65 2e 20 2a 2f 0a 20 20 ger value. */.
1860: 20 20 69 6e 74 20 6e 5a 65 72 6f 3b 20 20 20 20 int nZero;
1870: 20 20 20 20 20 20 2f 2a 20 55 73 65 64 20 77 68 /* Used wh
1880: 65 6e 20 62 69 74 20 4d 45 4d 5f 5a 65 72 6f 20 en bit MEM_Zero
1890: 69 73 20 73 65 74 20 69 6e 20 66 6c 61 67 73 20 is set in flags
18a0: 2a 2f 0a 20 20 20 20 46 75 6e 63 44 65 66 20 2a */. FuncDef *
18b0: 70 44 65 66 3b 20 20 20 20 20 20 2f 2a 20 55 73 pDef; /* Us
18c0: 65 64 20 6f 6e 6c 79 20 77 68 65 6e 20 66 6c 61 ed only when fla
18d0: 67 73 3d 3d 4d 45 4d 5f 41 67 67 20 2a 2f 0a 20 gs==MEM_Agg */.
18e0: 20 20 20 52 6f 77 53 65 74 20 2a 70 52 6f 77 53 RowSet *pRowS
18f0: 65 74 3b 20 20 20 20 2f 2a 20 55 73 65 64 20 6f et; /* Used o
1900: 6e 6c 79 20 77 68 65 6e 20 66 6c 61 67 73 3d 3d nly when flags==
1910: 4d 45 4d 5f 52 6f 77 53 65 74 20 2a 2f 0a 20 20 MEM_RowSet */.
1920: 20 20 56 64 62 65 46 72 61 6d 65 20 2a 70 46 72 VdbeFrame *pFr
1930: 61 6d 65 3b 20 20 2f 2a 20 55 73 65 64 20 77 68 ame; /* Used wh
1940: 65 6e 20 66 6c 61 67 73 3d 3d 4d 45 4d 5f 46 72 en flags==MEM_Fr
1950: 61 6d 65 20 2a 2f 0a 20 20 7d 20 75 3b 0a 20 20 ame */. } u;.
1960: 64 6f 75 62 6c 65 20 72 3b 20 20 20 20 20 20 20 double r;
1970: 20 20 20 20 2f 2a 20 52 65 61 6c 20 76 61 6c 75 /* Real valu
1980: 65 20 2a 2f 0a 20 20 73 71 6c 69 74 65 33 20 2a e */. sqlite3 *
1990: 64 62 3b 20 20 20 20 20 20 20 20 2f 2a 20 54 68 db; /* Th
19a0: 65 20 61 73 73 6f 63 69 61 74 65 64 20 64 61 74 e associated dat
19b0: 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
19c0: 20 2a 2f 0a 20 20 63 68 61 72 20 2a 7a 3b 20 20 */. char *z;
19d0: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 53 74 72 /* Str
19e0: 69 6e 67 20 6f 72 20 42 4c 4f 42 20 76 61 6c 75 ing or BLOB valu
19f0: 65 20 2a 2f 0a 20 20 69 6e 74 20 6e 3b 20 20 20 e */. int n;
1a00: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 /* Nu
1a10: 6d 62 65 72 20 6f 66 20 63 68 61 72 61 63 74 65 mber of characte
1a20: 72 73 20 69 6e 20 73 74 72 69 6e 67 20 76 61 6c rs in string val
1a30: 75 65 2c 20 65 78 63 6c 75 64 69 6e 67 20 27 5c ue, excluding '\
1a40: 30 27 20 2a 2f 0a 20 20 75 31 36 20 66 6c 61 67 0' */. u16 flag
1a50: 73 3b 20 20 20 20 20 20 20 20 20 20 2f 2a 20 53 s; /* S
1a60: 6f 6d 65 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 ome combination
1a70: 6f 66 20 4d 45 4d 5f 4e 75 6c 6c 2c 20 4d 45 4d of MEM_Null, MEM
1a80: 5f 53 74 72 2c 20 4d 45 4d 5f 44 79 6e 2c 20 65 _Str, MEM_Dyn, e
1a90: 74 63 2e 20 2a 2f 0a 20 20 75 38 20 20 74 79 70 tc. */. u8 typ
1aa0: 65 3b 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 e; /*
1ab0: 4f 6e 65 20 6f 66 20 53 51 4c 49 54 45 5f 4e 55 One of SQLITE_NU
1ac0: 4c 4c 2c 20 53 51 4c 49 54 45 5f 54 45 58 54 2c LL, SQLITE_TEXT,
1ad0: 20 53 51 4c 49 54 45 5f 49 4e 54 45 47 45 52 2c SQLITE_INTEGER,
1ae0: 20 65 74 63 20 2a 2f 0a 20 20 75 38 20 20 65 6e etc */. u8 en
1af0: 63 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a c; /*
1b00: 20 53 51 4c 49 54 45 5f 55 54 46 38 2c 20 53 51 SQLITE_UTF8, SQ
1b10: 4c 49 54 45 5f 55 54 46 31 36 42 45 2c 20 53 51 LITE_UTF16BE, SQ
1b20: 4c 49 54 45 5f 55 54 46 31 36 4c 45 20 2a 2f 0a LITE_UTF16LE */.
1b30: 20 20 76 6f 69 64 20 28 2a 78 44 65 6c 29 28 76 void (*xDel)(v
1b40: 6f 69 64 20 2a 29 3b 20 20 2f 2a 20 49 66 20 6e oid *); /* If n
1b50: 6f 74 20 6e 75 6c 6c 2c 20 63 61 6c 6c 20 74 68 ot null, call th
1b60: 69 73 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 64 is function to d
1b70: 65 6c 65 74 65 20 4d 65 6d 2e 7a 20 2a 2f 0a 20 elete Mem.z */.
1b80: 20 63 68 61 72 20 2a 7a 4d 61 6c 6c 6f 63 3b 20 char *zMalloc;
1b90: 20 20 20 20 20 2f 2a 20 44 79 6e 61 6d 69 63 20 /* Dynamic
1ba0: 62 75 66 66 65 72 20 61 6c 6c 6f 63 61 74 65 64 buffer allocated
1bb0: 20 62 79 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c by sqlite3_mall
1bc0: 6f 63 28 29 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 20 4f oc() */.};../* O
1bd0: 6e 65 20 6f 72 20 6d 6f 72 65 20 6f 66 20 74 68 ne or more of th
1be0: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 66 6c 61 67 e following flag
1bf0: 73 20 61 72 65 20 73 65 74 20 74 6f 20 69 6e 64 s are set to ind
1c00: 69 63 61 74 65 20 74 68 65 20 76 61 6c 69 64 4f icate the validO
1c10: 4b 0a 2a 2a 20 72 65 70 72 65 73 65 6e 74 61 74 K.** representat
1c20: 69 6f 6e 73 20 6f 66 20 74 68 65 20 76 61 6c 75 ions of the valu
1c30: 65 20 73 74 6f 72 65 64 20 69 6e 20 74 68 65 20 e stored in the
1c40: 4d 65 6d 20 73 74 72 75 63 74 2e 0a 2a 2a 0a 2a Mem struct..**.*
1c50: 2a 20 49 66 20 74 68 65 20 4d 45 4d 5f 4e 75 6c * If the MEM_Nul
1c60: 6c 20 66 6c 61 67 20 69 73 20 73 65 74 2c 20 74 l flag is set, t
1c70: 68 65 6e 20 74 68 65 20 76 61 6c 75 65 20 69 73 hen the value is
1c80: 20 61 6e 20 53 51 4c 20 4e 55 4c 4c 20 76 61 6c an SQL NULL val
1c90: 75 65 2e 0a 2a 2a 20 4e 6f 20 6f 74 68 65 72 20 ue..** No other
1ca0: 66 6c 61 67 73 20 6d 61 79 20 62 65 20 73 65 74 flags may be set
1cb0: 20 69 6e 20 74 68 69 73 20 63 61 73 65 2e 0a 2a in this case..*
1cc0: 2a 0a 2a 2a 20 49 66 20 74 68 65 20 4d 45 4d 5f *.** If the MEM_
1cd0: 53 74 72 20 66 6c 61 67 20 69 73 20 73 65 74 20 Str flag is set
1ce0: 74 68 65 6e 20 4d 65 6d 2e 7a 20 70 6f 69 6e 74 then Mem.z point
1cf0: 73 20 61 74 20 61 20 73 74 72 69 6e 67 20 72 65 s at a string re
1d00: 70 72 65 73 65 6e 74 61 74 69 6f 6e 2e 0a 2a 2a presentation..**
1d10: 20 55 73 75 61 6c 6c 79 20 74 68 69 73 20 69 73 Usually this is
1d20: 20 65 6e 63 6f 64 65 64 20 69 6e 20 74 68 65 20 encoded in the
1d30: 73 61 6d 65 20 75 6e 69 63 6f 64 65 20 65 6e 63 same unicode enc
1d40: 6f 64 69 6e 67 20 61 73 20 74 68 65 20 6d 61 69 oding as the mai
1d50: 6e 0a 2a 2a 20 64 61 74 61 62 61 73 65 20 28 73 n.** database (s
1d60: 65 65 20 62 65 6c 6f 77 20 66 6f 72 20 65 78 63 ee below for exc
1d70: 65 70 74 69 6f 6e 73 29 2e 20 49 66 20 74 68 65 eptions). If the
1d80: 20 4d 45 4d 5f 54 65 72 6d 20 66 6c 61 67 20 69 MEM_Term flag i
1d90: 73 20 61 6c 73 6f 0a 2a 2a 20 73 65 74 2c 20 74 s also.** set, t
1da0: 68 65 6e 20 74 68 65 20 73 74 72 69 6e 67 20 69 hen the string i
1db0: 73 20 6e 75 6c 20 74 65 72 6d 69 6e 61 74 65 64 s nul terminated
1dc0: 2e 20 54 68 65 20 4d 45 4d 5f 49 6e 74 20 61 6e . The MEM_Int an
1dd0: 64 20 4d 45 4d 5f 52 65 61 6c 20 0a 2a 2a 20 66 d MEM_Real .** f
1de0: 6c 61 67 73 20 6d 61 79 20 63 6f 65 78 69 73 74 lags may coexist
1df0: 20 77 69 74 68 20 74 68 65 20 4d 45 4d 5f 53 74 with the MEM_St
1e00: 72 20 66 6c 61 67 2e 0a 2a 2a 0a 2a 2a 20 4d 75 r flag..**.** Mu
1e10: 6c 74 69 70 6c 65 20 6f 66 20 74 68 65 73 65 20 ltiple of these
1e20: 76 61 6c 75 65 73 20 63 61 6e 20 61 70 70 65 61 values can appea
1e30: 72 20 69 6e 20 4d 65 6d 2e 66 6c 61 67 73 2e 20 r in Mem.flags.
1e40: 20 42 75 74 20 6f 6e 6c 79 20 6f 6e 65 0a 2a 2a But only one.**
1e50: 20 61 74 20 61 20 74 69 6d 65 20 63 61 6e 20 61 at a time can a
1e60: 70 70 65 61 72 20 69 6e 20 4d 65 6d 2e 74 79 70 ppear in Mem.typ
1e70: 65 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 4d 45 e..*/.#define ME
1e80: 4d 5f 4e 75 6c 6c 20 20 20 20 20 20 30 78 30 30 M_Null 0x00
1e90: 30 31 20 20 20 2f 2a 20 56 61 6c 75 65 20 69 73 01 /* Value is
1ea0: 20 4e 55 4c 4c 20 2a 2f 0a 23 64 65 66 69 6e 65 NULL */.#define
1eb0: 20 4d 45 4d 5f 53 74 72 20 20 20 20 20 20 20 30 MEM_Str 0
1ec0: 78 30 30 30 32 20 20 20 2f 2a 20 56 61 6c 75 65 x0002 /* Value
1ed0: 20 69 73 20 61 20 73 74 72 69 6e 67 20 2a 2f 0a is a string */.
1ee0: 23 64 65 66 69 6e 65 20 4d 45 4d 5f 49 6e 74 20 #define MEM_Int
1ef0: 20 20 20 20 20 20 30 78 30 30 30 34 20 20 20 2f 0x0004 /
1f00: 2a 20 56 61 6c 75 65 20 69 73 20 61 6e 20 69 6e * Value is an in
1f10: 74 65 67 65 72 20 2a 2f 0a 23 64 65 66 69 6e 65 teger */.#define
1f20: 20 4d 45 4d 5f 52 65 61 6c 20 20 20 20 20 20 30 MEM_Real 0
1f30: 78 30 30 30 38 20 20 20 2f 2a 20 56 61 6c 75 65 x0008 /* Value
1f40: 20 69 73 20 61 20 72 65 61 6c 20 6e 75 6d 62 65 is a real numbe
1f50: 72 20 2a 2f 0a 23 64 65 66 69 6e 65 20 4d 45 4d r */.#define MEM
1f60: 5f 42 6c 6f 62 20 20 20 20 20 20 30 78 30 30 31 _Blob 0x001
1f70: 30 20 20 20 2f 2a 20 56 61 6c 75 65 20 69 73 20 0 /* Value is
1f80: 61 20 42 4c 4f 42 20 2a 2f 0a 23 64 65 66 69 6e a BLOB */.#defin
1f90: 65 20 4d 45 4d 5f 52 6f 77 53 65 74 20 20 20 20 e MEM_RowSet
1fa0: 30 78 30 30 32 30 20 20 20 2f 2a 20 56 61 6c 75 0x0020 /* Valu
1fb0: 65 20 69 73 20 61 20 52 6f 77 53 65 74 20 6f 62 e is a RowSet ob
1fc0: 6a 65 63 74 20 2a 2f 0a 23 64 65 66 69 6e 65 20 ject */.#define
1fd0: 4d 45 4d 5f 46 72 61 6d 65 20 20 20 20 20 30 78 MEM_Frame 0x
1fe0: 30 30 34 30 20 20 20 2f 2a 20 56 61 6c 75 65 20 0040 /* Value
1ff0: 69 73 20 61 20 56 64 62 65 46 72 61 6d 65 20 6f is a VdbeFrame o
2000: 62 6a 65 63 74 20 2a 2f 0a 23 64 65 66 69 6e 65 bject */.#define
2010: 20 4d 45 4d 5f 54 79 70 65 4d 61 73 6b 20 20 30 MEM_TypeMask 0
2020: 78 30 30 66 66 20 20 20 2f 2a 20 4d 61 73 6b 20 x00ff /* Mask
2030: 6f 66 20 74 79 70 65 20 62 69 74 73 20 2a 2f 0a of type bits */.
2040: 0a 2f 2a 20 57 68 65 6e 65 76 65 72 20 4d 65 6d ./* Whenever Mem
2050: 20 63 6f 6e 74 61 69 6e 73 20 61 20 76 61 6c 69 contains a vali
2060: 64 20 73 74 72 69 6e 67 20 6f 72 20 62 6c 6f 62 d string or blob
2070: 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 2c representation,
2080: 20 6f 6e 65 20 6f 66 0a 2a 2a 20 74 68 65 20 66 one of.** the f
2090: 6f 6c 6c 6f 77 69 6e 67 20 66 6c 61 67 73 20 6d ollowing flags m
20a0: 75 73 74 20 62 65 20 73 65 74 20 74 6f 20 64 65 ust be set to de
20b0: 74 65 72 6d 69 6e 65 20 74 68 65 20 6d 65 6d 6f termine the memo
20c0: 72 79 20 6d 61 6e 61 67 65 6d 65 6e 74 0a 2a 2a ry management.**
20d0: 20 70 6f 6c 69 63 79 20 66 6f 72 20 4d 65 6d 2e policy for Mem.
20e0: 7a 2e 20 20 54 68 65 20 4d 45 4d 5f 54 65 72 6d z. The MEM_Term
20f0: 20 66 6c 61 67 20 74 65 6c 6c 73 20 75 73 20 77 flag tells us w
2100: 68 65 74 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 hether or not th
2110: 65 0a 2a 2a 20 73 74 72 69 6e 67 20 69 73 20 5c e.** string is \
2120: 30 30 30 20 6f 72 20 5c 75 30 30 30 30 20 74 65 000 or \u0000 te
2130: 72 6d 69 6e 61 74 65 64 0a 2a 2f 0a 23 64 65 66 rminated.*/.#def
2140: 69 6e 65 20 4d 45 4d 5f 54 65 72 6d 20 20 20 20 ine MEM_Term
2150: 20 20 30 78 30 32 30 30 20 20 20 2f 2a 20 53 74 0x0200 /* St
2160: 72 69 6e 67 20 72 65 70 20 69 73 20 6e 75 6c 20 ring rep is nul
2170: 74 65 72 6d 69 6e 61 74 65 64 20 2a 2f 0a 23 64 terminated */.#d
2180: 65 66 69 6e 65 20 4d 45 4d 5f 44 79 6e 20 20 20 efine MEM_Dyn
2190: 20 20 20 20 30 78 30 34 30 30 20 20 20 2f 2a 20 0x0400 /*
21a0: 4e 65 65 64 20 74 6f 20 63 61 6c 6c 20 73 71 6c Need to call sql
21b0: 69 74 65 46 72 65 65 28 29 20 6f 6e 20 4d 65 6d iteFree() on Mem
21c0: 2e 7a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 4d 45 .z */.#define ME
21d0: 4d 5f 53 74 61 74 69 63 20 20 20 20 30 78 30 38 M_Static 0x08
21e0: 30 30 20 20 20 2f 2a 20 4d 65 6d 2e 7a 20 70 6f 00 /* Mem.z po
21f0: 69 6e 74 73 20 74 6f 20 61 20 73 74 61 74 69 63 ints to a static
2200: 20 73 74 72 69 6e 67 20 2a 2f 0a 23 64 65 66 69 string */.#defi
2210: 6e 65 20 4d 45 4d 5f 45 70 68 65 6d 20 20 20 20 ne MEM_Ephem
2220: 20 30 78 31 30 30 30 20 20 20 2f 2a 20 4d 65 6d 0x1000 /* Mem
2230: 2e 7a 20 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 .z points to an
2240: 65 70 68 65 6d 65 72 61 6c 20 73 74 72 69 6e 67 ephemeral string
2250: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 4d 45 4d 5f */.#define MEM_
2260: 41 67 67 20 20 20 20 20 20 20 30 78 32 30 30 30 Agg 0x2000
2270: 20 20 20 2f 2a 20 4d 65 6d 2e 7a 20 70 6f 69 6e /* Mem.z poin
2280: 74 73 20 74 6f 20 61 6e 20 61 67 67 20 66 75 6e ts to an agg fun
2290: 63 74 69 6f 6e 20 63 6f 6e 74 65 78 74 20 2a 2f ction context */
22a0: 0a 23 64 65 66 69 6e 65 20 4d 45 4d 5f 5a 65 72 .#define MEM_Zer
22b0: 6f 20 20 20 20 20 20 30 78 34 30 30 30 20 20 20 o 0x4000
22c0: 2f 2a 20 4d 65 6d 2e 69 20 63 6f 6e 74 61 69 6e /* Mem.i contain
22d0: 73 20 63 6f 75 6e 74 20 6f 66 20 30 73 20 61 70 s count of 0s ap
22e0: 70 65 6e 64 65 64 20 74 6f 20 62 6c 6f 62 20 2a pended to blob *
22f0: 2f 0a 0a 23 69 66 64 65 66 20 53 51 4c 49 54 45 /..#ifdef SQLITE
2300: 5f 4f 4d 49 54 5f 49 4e 43 52 42 4c 4f 42 0a 20 _OMIT_INCRBLOB.
2310: 20 23 75 6e 64 65 66 20 4d 45 4d 5f 5a 65 72 6f #undef MEM_Zero
2320: 0a 20 20 23 64 65 66 69 6e 65 20 4d 45 4d 5f 5a . #define MEM_Z
2330: 65 72 6f 20 30 78 30 30 30 30 0a 23 65 6e 64 69 ero 0x0000.#endi
2340: 66 0a 0a 0a 2f 2a 0a 2a 2a 20 43 6c 65 61 72 20 f.../*.** Clear
2350: 61 6e 79 20 65 78 69 73 74 69 6e 67 20 74 79 70 any existing typ
2360: 65 20 66 6c 61 67 73 20 66 72 6f 6d 20 61 20 4d e flags from a M
2370: 65 6d 20 61 6e 64 20 72 65 70 6c 61 63 65 20 74 em and replace t
2380: 68 65 6d 20 77 69 74 68 20 66 0a 2a 2f 0a 23 64 hem with f.*/.#d
2390: 65 66 69 6e 65 20 4d 65 6d 53 65 74 54 79 70 65 efine MemSetType
23a0: 46 6c 61 67 28 70 2c 20 66 29 20 5c 0a 20 20 20 Flag(p, f) \.
23b0: 28 28 70 29 2d 3e 66 6c 61 67 73 20 3d 20 28 28 ((p)->flags = ((
23c0: 70 29 2d 3e 66 6c 61 67 73 26 7e 28 4d 45 4d 5f p)->flags&~(MEM_
23d0: 54 79 70 65 4d 61 73 6b 7c 4d 45 4d 5f 5a 65 72 TypeMask|MEM_Zer
23e0: 6f 29 29 7c 66 29 0a 0a 0a 2f 2a 20 41 20 56 64 o))|f).../* A Vd
23f0: 62 65 46 75 6e 63 20 69 73 20 6a 75 73 74 20 61 beFunc is just a
2400: 20 46 75 6e 63 44 65 66 20 28 64 65 66 69 6e 65 FuncDef (define
2410: 64 20 69 6e 20 73 71 6c 69 74 65 49 6e 74 2e 68 d in sqliteInt.h
2420: 29 20 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 0a ) that contains.
2430: 2a 2a 20 61 64 64 69 74 69 6f 6e 61 6c 20 69 6e ** additional in
2440: 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 formation about
2450: 61 75 78 69 6c 69 61 72 79 20 69 6e 66 6f 72 6d auxiliary inform
2460: 61 74 69 6f 6e 20 62 6f 75 6e 64 20 74 6f 20 61 ation bound to a
2470: 72 67 75 6d 65 6e 74 73 0a 2a 2a 20 6f 66 20 74 rguments.** of t
2480: 68 65 20 66 75 6e 63 74 69 6f 6e 2e 20 20 54 68 he function. Th
2490: 69 73 20 69 73 20 75 73 65 64 20 74 6f 20 69 6d is is used to im
24a0: 70 6c 65 6d 65 6e 74 20 74 68 65 20 73 71 6c 69 plement the sqli
24b0: 74 65 33 5f 67 65 74 5f 61 75 78 64 61 74 61 28 te3_get_auxdata(
24c0: 29 0a 2a 2a 20 61 6e 64 20 73 71 6c 69 74 65 33 ).** and sqlite3
24d0: 5f 73 65 74 5f 61 75 78 64 61 74 61 28 29 20 41 _set_auxdata() A
24e0: 50 49 73 2e 20 20 54 68 65 20 22 61 75 78 64 61 PIs. The "auxda
24f0: 74 61 22 20 69 73 20 73 6f 6d 65 20 61 75 78 69 ta" is some auxi
2500: 6c 69 61 72 79 20 64 61 74 61 0a 2a 2a 20 74 68 liary data.** th
2510: 61 74 20 63 61 6e 20 62 65 20 61 73 73 6f 63 69 at can be associ
2520: 61 74 65 64 20 77 69 74 68 20 61 20 63 6f 6e 73 ated with a cons
2530: 74 61 6e 74 20 61 72 67 75 6d 65 6e 74 20 74 6f tant argument to
2540: 20 61 20 66 75 6e 63 74 69 6f 6e 2e 20 20 54 68 a function. Th
2550: 69 73 0a 2a 2a 20 61 6c 6c 6f 77 73 20 66 75 6e is.** allows fun
2560: 63 74 69 6f 6e 73 20 73 75 63 68 20 61 73 20 22 ctions such as "
2570: 72 65 67 65 78 70 22 20 74 6f 20 63 6f 6d 70 69 regexp" to compi
2580: 6c 65 20 74 68 65 69 72 20 63 6f 6e 73 74 61 6e le their constan
2590: 74 20 72 65 67 75 6c 61 72 0a 2a 2a 20 65 78 70 t regular.** exp
25a0: 72 65 73 73 69 6f 6e 20 61 72 67 75 6d 65 6e 74 ression argument
25b0: 20 6f 6e 63 65 20 61 6e 64 20 72 65 75 73 65 64 once and reused
25c0: 20 74 68 65 20 63 6f 6d 70 69 6c 65 64 20 63 6f the compiled co
25d0: 64 65 20 66 6f 72 20 6d 75 6c 74 69 70 6c 65 0a de for multiple.
25e0: 2a 2a 20 69 6e 76 6f 63 61 74 69 6f 6e 73 2e 0a ** invocations..
25f0: 2a 2f 0a 73 74 72 75 63 74 20 56 64 62 65 46 75 */.struct VdbeFu
2600: 6e 63 20 7b 0a 20 20 46 75 6e 63 44 65 66 20 2a nc {. FuncDef *
2610: 70 46 75 6e 63 3b 20 20 20 20 20 20 20 20 20 20 pFunc;
2620: 20 20 20 20 20 2f 2a 20 54 68 65 20 64 65 66 69 /* The defi
2630: 6e 69 74 69 6f 6e 20 6f 66 20 74 68 65 20 66 75 nition of the fu
2640: 6e 63 74 69 6f 6e 20 2a 2f 0a 20 20 69 6e 74 20 nction */. int
2650: 6e 41 75 78 3b 20 20 20 20 20 20 20 20 20 20 20 nAux;
2660: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d /* Num
2670: 62 65 72 20 6f 66 20 65 6e 74 72 69 65 73 20 61 ber of entries a
2680: 6c 6c 6f 63 61 74 65 64 20 66 6f 72 20 61 70 41 llocated for apA
2690: 75 78 5b 5d 20 2a 2f 0a 20 20 73 74 72 75 63 74 ux[] */. struct
26a0: 20 41 75 78 44 61 74 61 20 7b 0a 20 20 20 20 76 AuxData {. v
26b0: 6f 69 64 20 2a 70 41 75 78 3b 20 20 20 20 20 20 oid *pAux;
26c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
26d0: 41 75 78 20 64 61 74 61 20 66 6f 72 20 74 68 65 Aux data for the
26e0: 20 69 2d 74 68 20 61 72 67 75 6d 65 6e 74 20 2a i-th argument *
26f0: 2f 0a 20 20 20 20 76 6f 69 64 20 28 2a 78 44 65 /. void (*xDe
2700: 6c 65 74 65 29 28 76 6f 69 64 20 2a 29 3b 20 20 lete)(void *);
2710: 20 20 20 20 2f 2a 20 44 65 73 74 72 75 63 74 6f /* Destructo
2720: 72 20 66 6f 72 20 74 68 65 20 61 75 78 20 64 61 r for the aux da
2730: 74 61 20 2a 2f 0a 20 20 7d 20 61 70 41 75 78 5b ta */. } apAux[
2740: 31 5d 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 1];
2750: 20 20 20 20 20 20 2f 2a 20 4f 6e 65 20 73 6c 6f /* One slo
2760: 74 20 66 6f 72 20 65 61 63 68 20 66 75 6e 63 74 t for each funct
2770: 69 6f 6e 20 61 72 67 75 6d 65 6e 74 20 2a 2f 0a ion argument */.
2780: 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 22 63 };../*.** The "c
2790: 6f 6e 74 65 78 74 22 20 61 72 67 75 6d 65 6e 74 ontext" argument
27a0: 20 66 6f 72 20 61 20 69 6e 73 74 61 6c 6c 61 62 for a installab
27b0: 6c 65 20 66 75 6e 63 74 69 6f 6e 2e 20 20 41 20 le function. A
27c0: 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e 0a 2a 2a pointer to an.**
27d0: 20 69 6e 73 74 61 6e 63 65 20 6f 66 20 74 68 69 instance of thi
27e0: 73 20 73 74 72 75 63 74 75 72 65 20 69 73 20 74 s structure is t
27f0: 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e he first argumen
2800: 74 20 74 6f 20 74 68 65 20 72 6f 75 74 69 6e 65 t to the routine
2810: 73 20 75 73 65 64 0a 2a 2a 20 69 6d 70 6c 65 6d s used.** implem
2820: 65 6e 74 20 74 68 65 20 53 51 4c 20 66 75 6e 63 ent the SQL func
2830: 74 69 6f 6e 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 tions..**.** The
2840: 72 65 20 69 73 20 61 20 74 79 70 65 64 65 66 20 re is a typedef
2850: 66 6f 72 20 74 68 69 73 20 73 74 72 75 63 74 75 for this structu
2860: 72 65 20 69 6e 20 73 71 6c 69 74 65 2e 68 2e 20 re in sqlite.h.
2870: 20 53 6f 20 61 6c 6c 20 72 6f 75 74 69 6e 65 73 So all routines
2880: 2c 0a 2a 2a 20 65 76 65 6e 20 74 68 65 20 70 75 ,.** even the pu
2890: 62 6c 69 63 20 69 6e 74 65 72 66 61 63 65 20 74 blic interface t
28a0: 6f 20 53 51 4c 69 74 65 2c 20 63 61 6e 20 75 73 o SQLite, can us
28b0: 65 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 e a pointer to t
28c0: 68 69 73 20 73 74 72 75 63 74 75 72 65 2e 0a 2a his structure..*
28d0: 2a 20 42 75 74 20 74 68 69 73 20 66 69 6c 65 20 * But this file
28e0: 69 73 20 74 68 65 20 6f 6e 6c 79 20 70 6c 61 63 is the only plac
28f0: 65 20 77 68 65 72 65 20 74 68 65 20 69 6e 74 65 e where the inte
2900: 72 6e 61 6c 20 64 65 74 61 69 6c 73 20 6f 66 20 rnal details of
2910: 74 68 69 73 0a 2a 2a 20 73 74 72 75 63 74 75 72 this.** structur
2920: 65 20 61 72 65 20 6b 6e 6f 77 6e 2e 0a 2a 2a 0a e are known..**.
2930: 2a 2a 20 54 68 69 73 20 73 74 72 75 63 74 75 72 ** This structur
2940: 65 20 69 73 20 64 65 66 69 6e 65 64 20 69 6e 73 e is defined ins
2950: 69 64 65 20 6f 66 20 76 64 62 65 49 6e 74 2e 68 ide of vdbeInt.h
2960: 20 62 65 63 61 75 73 65 20 69 74 20 75 73 65 73 because it uses
2970: 20 73 75 62 73 74 72 75 63 74 75 72 65 73 0a 2a substructures.*
2980: 2a 20 28 4d 65 6d 29 20 77 68 69 63 68 20 61 72 * (Mem) which ar
2990: 65 20 6f 6e 6c 79 20 64 65 66 69 6e 65 64 20 74 e only defined t
29a0: 68 65 72 65 2e 0a 2a 2f 0a 73 74 72 75 63 74 20 here..*/.struct
29b0: 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 20 sqlite3_context
29c0: 7b 0a 20 20 46 75 6e 63 44 65 66 20 2a 70 46 75 {. FuncDef *pFu
29d0: 6e 63 3b 20 20 20 20 20 20 20 2f 2a 20 50 6f 69 nc; /* Poi
29e0: 6e 74 65 72 20 74 6f 20 66 75 6e 63 74 69 6f 6e nter to function
29f0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 20 20 4d information. M
2a00: 55 53 54 20 42 45 20 46 49 52 53 54 20 2a 2f 0a UST BE FIRST */.
2a10: 20 20 56 64 62 65 46 75 6e 63 20 2a 70 56 64 62 VdbeFunc *pVdb
2a20: 65 46 75 6e 63 3b 20 20 2f 2a 20 41 75 78 69 6c eFunc; /* Auxil
2a30: 61 72 79 20 64 61 74 61 2c 20 69 66 20 63 72 65 ary data, if cre
2a40: 61 74 65 64 2e 20 2a 2f 0a 20 20 4d 65 6d 20 73 ated. */. Mem s
2a50: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
2a60: 20 2f 2a 20 54 68 65 20 72 65 74 75 72 6e 20 76 /* The return v
2a70: 61 6c 75 65 20 69 73 20 73 74 6f 72 65 64 20 68 alue is stored h
2a80: 65 72 65 20 2a 2f 0a 20 20 4d 65 6d 20 2a 70 4d ere */. Mem *pM
2a90: 65 6d 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f em; /
2aa0: 2a 20 4d 65 6d 6f 72 79 20 63 65 6c 6c 20 75 73 * Memory cell us
2ab0: 65 64 20 74 6f 20 73 74 6f 72 65 20 61 67 67 72 ed to store aggr
2ac0: 65 67 61 74 65 20 63 6f 6e 74 65 78 74 20 2a 2f egate context */
2ad0: 0a 20 20 69 6e 74 20 69 73 45 72 72 6f 72 3b 20 . int isError;
2ae0: 20 20 20 20 20 20 20 20 20 2f 2a 20 45 72 72 6f /* Erro
2af0: 72 20 63 6f 64 65 20 72 65 74 75 72 6e 65 64 20 r code returned
2b00: 62 79 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 2e by the function.
2b10: 20 2a 2f 0a 20 20 43 6f 6c 6c 53 65 71 20 2a 70 */. CollSeq *p
2b20: 43 6f 6c 6c 3b 20 20 20 20 20 20 20 2f 2a 20 43 Coll; /* C
2b30: 6f 6c 6c 61 74 69 6e 67 20 73 65 71 75 65 6e 63 ollating sequenc
2b40: 65 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 41 e */.};../*.** A
2b50: 20 53 65 74 20 73 74 72 75 63 74 75 72 65 20 69 Set structure i
2b60: 73 20 75 73 65 64 20 66 6f 72 20 71 75 69 63 6b s used for quick
2b70: 20 74 65 73 74 69 6e 67 20 74 6f 20 73 65 65 20 testing to see
2b80: 69 66 20 61 20 76 61 6c 75 65 0a 2a 2a 20 69 73 if a value.** is
2b90: 20 70 61 72 74 20 6f 66 20 61 20 73 6d 61 6c 6c part of a small
2ba0: 20 73 65 74 2e 20 20 53 65 74 73 20 61 72 65 20 set. Sets are
2bb0: 75 73 65 64 20 74 6f 20 69 6d 70 6c 65 6d 65 6e used to implemen
2bc0: 74 20 63 6f 64 65 20 6c 69 6b 65 0a 2a 2a 20 74 t code like.** t
2bd0: 68 69 73 3a 0a 2a 2a 20 20 20 20 20 20 20 20 20 his:.**
2be0: 20 20 20 78 2e 79 20 49 4e 20 28 27 68 69 27 2c x.y IN ('hi',
2bf0: 27 68 6f 6f 27 2c 27 68 75 6d 27 29 0a 2a 2f 0a 'hoo','hum').*/.
2c00: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 53 typedef struct S
2c10: 65 74 20 53 65 74 3b 0a 73 74 72 75 63 74 20 53 et Set;.struct S
2c20: 65 74 20 7b 0a 20 20 48 61 73 68 20 68 61 73 68 et {. Hash hash
2c30: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a ; /*
2c40: 20 41 20 73 65 74 20 69 73 20 6a 75 73 74 20 61 A set is just a
2c50: 20 68 61 73 68 20 74 61 62 6c 65 20 2a 2f 0a 20 hash table */.
2c60: 20 48 61 73 68 45 6c 65 6d 20 2a 70 72 65 76 3b HashElem *prev;
2c70: 20 20 20 20 20 20 20 20 2f 2a 20 50 72 65 76 69 /* Previ
2c80: 6f 75 73 6c 79 20 61 63 63 65 73 73 65 64 20 68 ously accessed h
2c90: 61 73 68 20 65 6c 65 6d 65 6e 20 2a 2f 0a 7d 3b ash elemen */.};
2ca0: 0a 0a 2f 2a 0a 2a 2a 20 41 6e 20 69 6e 73 74 61 ../*.** An insta
2cb0: 6e 63 65 20 6f 66 20 74 68 65 20 76 69 72 74 75 nce of the virtu
2cc0: 61 6c 20 6d 61 63 68 69 6e 65 2e 20 20 54 68 69 al machine. Thi
2cd0: 73 20 73 74 72 75 63 74 75 72 65 20 63 6f 6e 74 s structure cont
2ce0: 61 69 6e 73 20 74 68 65 20 63 6f 6d 70 6c 65 74 ains the complet
2cf0: 65 0a 2a 2a 20 73 74 61 74 65 20 6f 66 20 74 68 e.** state of th
2d00: 65 20 76 69 72 74 75 61 6c 20 6d 61 63 68 69 6e e virtual machin
2d10: 65 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 22 73 71 e..**.** The "sq
2d20: 6c 69 74 65 33 5f 73 74 6d 74 22 20 73 74 72 75 lite3_stmt" stru
2d30: 63 74 75 72 65 20 70 6f 69 6e 74 65 72 20 74 68 cture pointer th
2d40: 61 74 20 69 73 20 72 65 74 75 72 6e 65 64 20 62 at is returned b
2d50: 79 20 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 6c y sqlite3_compil
2d60: 65 28 29 0a 2a 2a 20 69 73 20 72 65 61 6c 6c 79 e().** is really
2d70: 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e a pointer to an
2d80: 20 69 6e 73 74 61 6e 63 65 20 6f 66 20 74 68 69 instance of thi
2d90: 73 20 73 74 72 75 63 74 75 72 65 2e 0a 2a 2a 0a s structure..**.
2da0: 2a 2a 20 54 68 65 20 56 64 62 65 2e 69 6e 56 74 ** The Vdbe.inVt
2db0: 61 62 4d 65 74 68 6f 64 20 76 61 72 69 61 62 6c abMethod variabl
2dc0: 65 20 69 73 20 73 65 74 20 74 6f 20 6e 6f 6e 2d e is set to non-
2dd0: 7a 65 72 6f 20 66 6f 72 20 74 68 65 20 64 75 72 zero for the dur
2de0: 61 74 69 6f 6e 20 6f 66 0a 2a 2a 20 61 6e 79 20 ation of.** any
2df0: 76 69 72 74 75 61 6c 20 74 61 62 6c 65 20 6d 65 virtual table me
2e00: 74 68 6f 64 20 69 6e 76 6f 63 61 74 69 6f 6e 73 thod invocations
2e10: 20 6d 61 64 65 20 62 79 20 74 68 65 20 76 64 62 made by the vdb
2e20: 65 20 70 72 6f 67 72 61 6d 2e 20 49 74 20 69 73 e program. It is
2e30: 0a 2a 2a 20 73 65 74 20 74 6f 20 32 20 66 6f 72 .** set to 2 for
2e40: 20 78 44 65 73 74 72 6f 79 20 6d 65 74 68 6f 64 xDestroy method
2e50: 20 63 61 6c 6c 73 20 61 6e 64 20 31 20 66 6f 72 calls and 1 for
2e60: 20 61 6c 6c 20 6f 74 68 65 72 20 6d 65 74 68 6f all other metho
2e70: 64 73 2e 20 54 68 69 73 0a 2a 2a 20 76 61 72 69 ds. This.** vari
2e80: 61 62 6c 65 20 69 73 20 75 73 65 64 20 66 6f 72 able is used for
2e90: 20 74 77 6f 20 70 75 72 70 6f 73 65 73 3a 20 74 two purposes: t
2ea0: 6f 20 61 6c 6c 6f 77 20 78 44 65 73 74 72 6f 79 o allow xDestroy
2eb0: 20 6d 65 74 68 6f 64 73 20 74 6f 20 65 78 65 63 methods to exec
2ec0: 75 74 65 0a 2a 2a 20 22 44 52 4f 50 20 54 41 42 ute.** "DROP TAB
2ed0: 4c 45 22 20 73 74 61 74 65 6d 65 6e 74 73 20 61 LE" statements a
2ee0: 6e 64 20 74 6f 20 70 72 65 76 65 6e 74 20 73 6f nd to prevent so
2ef0: 6d 65 20 6e 61 73 74 79 20 73 69 64 65 20 65 66 me nasty side ef
2f00: 66 65 63 74 73 20 6f 66 0a 2a 2a 20 6d 61 6c 6c fects of.** mall
2f10: 6f 63 20 66 61 69 6c 75 72 65 20 77 68 65 6e 20 oc failure when
2f20: 53 51 4c 69 74 65 20 69 73 20 69 6e 76 6f 6b 65 SQLite is invoke
2f30: 64 20 72 65 63 75 72 73 69 76 65 6c 79 20 62 79 d recursively by
2f40: 20 61 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 a virtual table
2f50: 20 0a 2a 2a 20 6d 65 74 68 6f 64 20 66 75 6e 63 .** method func
2f60: 74 69 6f 6e 2e 0a 2a 2f 0a 73 74 72 75 63 74 20 tion..*/.struct
2f70: 56 64 62 65 20 7b 0a 20 20 73 71 6c 69 74 65 33 Vdbe {. sqlite3
2f80: 20 2a 64 62 3b 20 20 20 20 20 20 20 20 20 20 20 *db;
2f90: 20 2f 2a 20 54 68 65 20 64 61 74 61 62 61 73 65 /* The database
2fa0: 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 68 61 74 connection that
2fb0: 20 6f 77 6e 73 20 74 68 69 73 20 73 74 61 74 65 owns this state
2fc0: 6d 65 6e 74 20 2a 2f 0a 20 20 56 64 62 65 20 2a ment */. Vdbe *
2fd0: 70 50 72 65 76 2c 2a 70 4e 65 78 74 3b 20 20 20 pPrev,*pNext;
2fe0: 20 20 2f 2a 20 4c 69 6e 6b 65 64 20 6c 69 73 74 /* Linked list
2ff0: 20 6f 66 20 56 44 42 45 73 20 77 69 74 68 20 74 of VDBEs with t
3000: 68 65 20 73 61 6d 65 20 56 64 62 65 2e 64 62 20 he same Vdbe.db
3010: 2a 2f 0a 20 20 69 6e 74 20 6e 4f 70 3b 20 20 20 */. int nOp;
3020: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
3030: 4e 75 6d 62 65 72 20 6f 66 20 69 6e 73 74 72 75 Number of instru
3040: 63 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 70 72 ctions in the pr
3050: 6f 67 72 61 6d 20 2a 2f 0a 20 20 69 6e 74 20 6e ogram */. int n
3060: 4f 70 41 6c 6c 6f 63 3b 20 20 20 20 20 20 20 20 OpAlloc;
3070: 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 /* Number of
3080: 73 6c 6f 74 73 20 61 6c 6c 6f 63 61 74 65 64 20 slots allocated
3090: 66 6f 72 20 61 4f 70 5b 5d 20 2a 2f 0a 20 20 4f for aOp[] */. O
30a0: 70 20 2a 61 4f 70 3b 20 20 20 20 20 20 20 20 20 p *aOp;
30b0: 20 20 20 20 20 20 20 2f 2a 20 53 70 61 63 65 20 /* Space
30c0: 74 6f 20 68 6f 6c 64 20 74 68 65 20 76 69 72 74 to hold the virt
30d0: 75 61 6c 20 6d 61 63 68 69 6e 65 27 73 20 70 72 ual machine's pr
30e0: 6f 67 72 61 6d 20 2a 2f 0a 20 20 69 6e 74 20 6e ogram */. int n
30f0: 4c 61 62 65 6c 3b 20 20 20 20 20 20 20 20 20 20 Label;
3100: 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 20 /* Number of
3110: 6c 61 62 65 6c 73 20 75 73 65 64 20 2a 2f 0a 20 labels used */.
3120: 20 69 6e 74 20 6e 4c 61 62 65 6c 41 6c 6c 6f 63 int nLabelAlloc
3130: 3b 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 ; /* Numb
3140: 65 72 20 6f 66 20 73 6c 6f 74 73 20 61 6c 6c 6f er of slots allo
3150: 63 61 74 65 64 20 69 6e 20 61 4c 61 62 65 6c 5b cated in aLabel[
3160: 5d 20 2a 2f 0a 20 20 69 6e 74 20 2a 61 4c 61 62 ] */. int *aLab
3170: 65 6c 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f el; /
3180: 2a 20 53 70 61 63 65 20 74 6f 20 68 6f 6c 64 20 * Space to hold
3190: 74 68 65 20 6c 61 62 65 6c 73 20 2a 2f 0a 20 20 the labels */.
31a0: 4d 65 6d 20 2a 2a 61 70 41 72 67 3b 20 20 20 20 Mem **apArg;
31b0: 20 20 20 20 20 20 20 20 2f 2a 20 41 72 67 75 6d /* Argum
31c0: 65 6e 74 73 20 74 6f 20 63 75 72 72 65 6e 74 6c ents to currentl
31d0: 79 20 65 78 65 63 75 74 69 6e 67 20 75 73 65 72 y executing user
31e0: 20 66 75 6e 63 74 69 6f 6e 20 2a 2f 0a 20 20 4d function */. M
31f0: 65 6d 20 2a 61 43 6f 6c 4e 61 6d 65 3b 20 20 20 em *aColName;
3200: 20 20 20 20 20 20 20 2f 2a 20 43 6f 6c 75 6d 6e /* Column
3210: 20 6e 61 6d 65 73 20 74 6f 20 72 65 74 75 72 6e names to return
3220: 20 2a 2f 0a 20 20 4d 65 6d 20 2a 70 52 65 73 75 */. Mem *pResu
3230: 6c 74 53 65 74 3b 20 20 20 20 20 20 20 20 2f 2a ltSet; /*
3240: 20 50 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 61 Pointer to an a
3250: 72 72 61 79 20 6f 66 20 72 65 73 75 6c 74 73 20 rray of results
3260: 2a 2f 0a 20 20 75 31 36 20 6e 52 65 73 43 6f 6c */. u16 nResCol
3270: 75 6d 6e 3b 20 20 20 20 20 20 20 20 20 2f 2a 20 umn; /*
3280: 4e 75 6d 62 65 72 20 6f 66 20 63 6f 6c 75 6d 6e Number of column
3290: 73 20 69 6e 20 6f 6e 65 20 72 6f 77 20 6f 66 20 s in one row of
32a0: 74 68 65 20 72 65 73 75 6c 74 20 73 65 74 20 2a the result set *
32b0: 2f 0a 20 20 75 31 36 20 6e 43 75 72 73 6f 72 3b /. u16 nCursor;
32c0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e /* N
32d0: 75 6d 62 65 72 20 6f 66 20 73 6c 6f 74 73 20 69 umber of slots i
32e0: 6e 20 61 70 43 73 72 5b 5d 20 2a 2f 0a 20 20 56 n apCsr[] */. V
32f0: 64 62 65 43 75 72 73 6f 72 20 2a 2a 61 70 43 73 dbeCursor **apCs
3300: 72 3b 20 20 20 20 20 2f 2a 20 4f 6e 65 20 65 6c r; /* One el
3310: 65 6d 65 6e 74 20 6f 66 20 74 68 69 73 20 61 72 ement of this ar
3320: 72 61 79 20 66 6f 72 20 65 61 63 68 20 6f 70 65 ray for each ope
3330: 6e 20 63 75 72 73 6f 72 20 2a 2f 0a 20 20 75 38 n cursor */. u8
3340: 20 65 72 72 6f 72 41 63 74 69 6f 6e 3b 20 20 20 errorAction;
3350: 20 20 20 20 20 20 2f 2a 20 52 65 63 6f 76 65 72 /* Recover
3360: 79 20 61 63 74 69 6f 6e 20 74 6f 20 64 6f 20 69 y action to do i
3370: 6e 20 63 61 73 65 20 6f 66 20 61 6e 20 65 72 72 n case of an err
3380: 6f 72 20 2a 2f 0a 20 20 75 38 20 6f 6b 56 61 72 or */. u8 okVar
3390: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
33a0: 2f 2a 20 54 72 75 65 20 69 66 20 61 7a 56 61 72 /* True if azVar
33b0: 5b 5d 20 68 61 73 20 62 65 65 6e 20 69 6e 69 74 [] has been init
33c0: 69 61 6c 69 7a 65 64 20 2a 2f 0a 20 20 75 31 36 ialized */. u16
33d0: 20 6e 56 61 72 3b 20 20 20 20 20 20 20 20 20 20 nVar;
33e0: 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f /* Number o
33f0: 66 20 65 6e 74 72 69 65 73 20 69 6e 20 61 56 61 f entries in aVa
3400: 72 5b 5d 20 2a 2f 0a 20 20 4d 65 6d 20 2a 61 56 r[] */. Mem *aV
3410: 61 72 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 ar;
3420: 20 2f 2a 20 56 61 6c 75 65 73 20 66 6f 72 20 74 /* Values for t
3430: 68 65 20 4f 50 5f 56 61 72 69 61 62 6c 65 20 6f he OP_Variable o
3440: 70 63 6f 64 65 2e 20 2a 2f 0a 20 20 63 68 61 72 pcode. */. char
3450: 20 2a 2a 61 7a 56 61 72 3b 20 20 20 20 20 20 20 **azVar;
3460: 20 20 20 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 76 /* Name of v
3470: 61 72 69 61 62 6c 65 73 20 2a 2f 0a 20 20 75 33 ariables */. u3
3480: 32 20 6d 61 67 69 63 3b 20 20 20 20 20 20 20 20 2 magic;
3490: 20 20 20 20 20 20 2f 2a 20 4d 61 67 69 63 20 6e /* Magic n
34a0: 75 6d 62 65 72 20 66 6f 72 20 73 61 6e 69 74 79 umber for sanity
34b0: 20 63 68 65 63 6b 69 6e 67 20 2a 2f 0a 20 20 69 checking */. i
34c0: 6e 74 20 6e 4d 65 6d 3b 20 20 20 20 20 20 20 20 nt nMem;
34d0: 20 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 /* Number
34e0: 20 6f 66 20 6d 65 6d 6f 72 79 20 6c 6f 63 61 74 of memory locat
34f0: 69 6f 6e 73 20 63 75 72 72 65 6e 74 6c 79 20 61 ions currently a
3500: 6c 6c 6f 63 61 74 65 64 20 2a 2f 0a 20 20 4d 65 llocated */. Me
3510: 6d 20 2a 61 4d 65 6d 3b 20 20 20 20 20 20 20 20 m *aMem;
3520: 20 20 20 20 20 20 2f 2a 20 54 68 65 20 6d 65 6d /* The mem
3530: 6f 72 79 20 6c 6f 63 61 74 69 6f 6e 73 20 2a 2f ory locations */
3540: 0a 20 20 75 33 32 20 63 61 63 68 65 43 74 72 3b . u32 cacheCtr;
3550: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 56 64 /* Vd
3560: 62 65 43 75 72 73 6f 72 20 72 6f 77 20 63 61 63 beCursor row cac
3570: 68 65 20 67 65 6e 65 72 61 74 69 6f 6e 20 63 6f he generation co
3580: 75 6e 74 65 72 20 2a 2f 0a 20 20 69 6e 74 20 70 unter */. int p
3590: 63 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 c;
35a0: 20 20 20 2f 2a 20 54 68 65 20 70 72 6f 67 72 61 /* The progra
35b0: 6d 20 63 6f 75 6e 74 65 72 20 2a 2f 0a 20 20 69 m counter */. i
35c0: 6e 74 20 72 63 3b 20 20 20 20 20 20 20 20 20 20 nt rc;
35d0: 20 20 20 20 20 20 20 2f 2a 20 56 61 6c 75 65 20 /* Value
35e0: 74 6f 20 72 65 74 75 72 6e 20 2a 2f 0a 20 20 63 to return */. c
35f0: 68 61 72 20 2a 7a 45 72 72 4d 73 67 3b 20 20 20 har *zErrMsg;
3600: 20 20 20 20 20 20 20 2f 2a 20 45 72 72 6f 72 20 /* Error
3610: 6d 65 73 73 61 67 65 20 77 72 69 74 74 65 6e 20 message written
3620: 68 65 72 65 20 2a 2f 0a 20 20 75 38 20 65 78 70 here */. u8 exp
3630: 6c 61 69 6e 3b 20 20 20 20 20 20 20 20 20 20 20 lain;
3640: 20 20 2f 2a 20 54 72 75 65 20 69 66 20 45 58 50 /* True if EXP
3650: 4c 41 49 4e 20 70 72 65 73 65 6e 74 20 6f 6e 20 LAIN present on
3660: 53 51 4c 20 63 6f 6d 6d 61 6e 64 20 2a 2f 0a 20 SQL command */.
3670: 20 75 38 20 63 68 61 6e 67 65 43 6e 74 4f 6e 3b u8 changeCntOn;
3680: 20 20 20 20 20 20 20 20 20 2f 2a 20 54 72 75 65 /* True
3690: 20 74 6f 20 75 70 64 61 74 65 20 74 68 65 20 63 to update the c
36a0: 68 61 6e 67 65 2d 63 6f 75 6e 74 65 72 20 2a 2f hange-counter */
36b0: 0a 20 20 75 38 20 65 78 70 69 72 65 64 3b 20 20 . u8 expired;
36c0: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 72 /* Tr
36d0: 75 65 20 69 66 20 74 68 65 20 56 4d 20 6e 65 65 ue if the VM nee
36e0: 64 73 20 74 6f 20 62 65 20 72 65 63 6f 6d 70 69 ds to be recompi
36f0: 6c 65 64 20 2a 2f 0a 20 20 75 38 20 6d 69 6e 57 led */. u8 minW
3700: 72 69 74 65 46 69 6c 65 46 6f 72 6d 61 74 3b 20 riteFileFormat;
3710: 20 2f 2a 20 4d 69 6e 69 6d 75 6d 20 66 69 6c 65 /* Minimum file
3720: 20 66 6f 72 6d 61 74 20 66 6f 72 20 77 72 69 74 format for writ
3730: 61 62 6c 65 20 64 61 74 61 62 61 73 65 20 66 69 able database fi
3740: 6c 65 73 20 2a 2f 0a 20 20 75 38 20 69 6e 56 74 les */. u8 inVt
3750: 61 62 4d 65 74 68 6f 64 3b 20 20 20 20 20 20 20 abMethod;
3760: 20 2f 2a 20 53 65 65 20 63 6f 6d 6d 65 6e 74 73 /* See comments
3770: 20 61 62 6f 76 65 20 2a 2f 0a 20 20 75 38 20 75 above */. u8 u
3780: 73 65 73 53 74 6d 74 4a 6f 75 72 6e 61 6c 3b 20 sesStmtJournal;
3790: 20 20 20 20 2f 2a 20 54 72 75 65 20 69 66 20 75 /* True if u
37a0: 73 65 73 20 61 20 73 74 61 74 65 6d 65 6e 74 20 ses a statement
37b0: 6a 6f 75 72 6e 61 6c 20 2a 2f 0a 20 20 75 38 20 journal */. u8
37c0: 72 65 61 64 4f 6e 6c 79 3b 20 20 20 20 20 20 20 readOnly;
37d0: 20 20 20 20 20 2f 2a 20 54 72 75 65 20 66 6f 72 /* True for
37e0: 20 72 65 61 64 2d 6f 6e 6c 79 20 73 74 61 74 65 read-only state
37f0: 6d 65 6e 74 73 20 2a 2f 0a 20 20 75 38 20 69 73 ments */. u8 is
3800: 50 72 65 70 61 72 65 56 32 3b 20 20 20 20 20 20 PrepareV2;
3810: 20 20 20 2f 2a 20 54 72 75 65 20 69 66 20 70 72 /* True if pr
3820: 65 70 61 72 65 64 20 77 69 74 68 20 70 72 65 70 epared with prep
3830: 61 72 65 5f 76 32 28 29 20 2a 2f 0a 20 20 69 6e are_v2() */. in
3840: 74 20 6e 43 68 61 6e 67 65 3b 20 20 20 20 20 20 t nChange;
3850: 20 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 /* Number
3860: 6f 66 20 64 62 20 63 68 61 6e 67 65 73 20 6d 61 of db changes ma
3870: 64 65 20 73 69 6e 63 65 20 6c 61 73 74 20 72 65 de since last re
3880: 73 65 74 20 2a 2f 0a 20 20 69 6e 74 20 62 74 72 set */. int btr
3890: 65 65 4d 61 73 6b 3b 20 20 20 20 20 20 20 20 20 eeMask;
38a0: 20 2f 2a 20 42 69 74 6d 61 73 6b 20 6f 66 20 64 /* Bitmask of d
38b0: 62 2d 3e 61 44 62 5b 5d 20 65 6e 74 72 69 65 73 b->aDb[] entries
38c0: 20 72 65 66 65 72 65 6e 63 65 64 20 2a 2f 0a 20 referenced */.
38d0: 20 69 36 34 20 73 74 61 72 74 54 69 6d 65 3b 20 i64 startTime;
38e0: 20 20 20 20 20 20 20 20 20 2f 2a 20 54 69 6d 65 /* Time
38f0: 20 77 68 65 6e 20 71 75 65 72 79 20 73 74 61 72 when query star
3900: 74 65 64 20 2d 20 75 73 65 64 20 66 6f 72 20 70 ted - used for p
3910: 72 6f 66 69 6c 69 6e 67 20 2a 2f 0a 20 20 42 74 rofiling */. Bt
3920: 72 65 65 4d 75 74 65 78 41 72 72 61 79 20 61 4d reeMutexArray aM
3930: 75 74 65 78 3b 20 2f 2a 20 41 6e 20 61 72 72 61 utex; /* An arra
3940: 79 20 6f 66 20 42 74 72 65 65 20 75 73 65 64 20 y of Btree used
3950: 68 65 72 65 20 61 6e 64 20 6e 65 65 64 69 6e 67 here and needing
3960: 20 6c 6f 63 6b 73 20 2a 2f 0a 20 20 69 6e 74 20 locks */. int
3970: 61 43 6f 75 6e 74 65 72 5b 32 5d 3b 20 20 20 20 aCounter[2];
3980: 20 20 20 20 2f 2a 20 43 6f 75 6e 74 65 72 73 20 /* Counters
3990: 75 73 65 64 20 62 79 20 73 71 6c 69 74 65 33 5f used by sqlite3_
39a0: 73 74 6d 74 5f 73 74 61 74 75 73 28 29 20 2a 2f stmt_status() */
39b0: 0a 20 20 63 68 61 72 20 2a 7a 53 71 6c 3b 20 20 . char *zSql;
39c0: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 65 /* Te
39d0: 78 74 20 6f 66 20 74 68 65 20 53 51 4c 20 73 74 xt of the SQL st
39e0: 61 74 65 6d 65 6e 74 20 74 68 61 74 20 67 65 6e atement that gen
39f0: 65 72 61 74 65 64 20 74 68 69 73 20 2a 2f 0a 20 erated this */.
3a00: 20 76 6f 69 64 20 2a 70 46 72 65 65 3b 20 20 20 void *pFree;
3a10: 20 20 20 20 20 20 20 20 20 2f 2a 20 46 72 65 65 /* Free
3a20: 20 74 68 69 73 20 77 68 65 6e 20 64 65 6c 65 74 this when delet
3a30: 69 6e 67 20 74 68 65 20 76 64 62 65 20 2a 2f 0a ing the vdbe */.
3a40: 20 20 69 6e 74 20 69 53 74 61 74 65 6d 65 6e 74 int iStatement
3a50: 3b 20 20 20 20 20 20 20 20 20 2f 2a 20 53 74 61 ; /* Sta
3a60: 74 65 6d 65 6e 74 20 6e 75 6d 62 65 72 20 28 6f tement number (o
3a70: 72 20 30 20 69 66 20 68 61 73 20 6e 6f 74 20 6f r 0 if has not o
3a80: 70 65 6e 65 64 20 73 74 6d 74 29 20 2a 2f 0a 23 pened stmt) */.#
3a90: 69 66 64 65 66 20 53 51 4c 49 54 45 5f 44 45 42 ifdef SQLITE_DEB
3aa0: 55 47 0a 20 20 46 49 4c 45 20 2a 74 72 61 63 65 UG. FILE *trace
3ab0: 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 ; /*
3ac0: 57 72 69 74 65 20 61 6e 20 65 78 65 63 75 74 69 Write an executi
3ad0: 6f 6e 20 74 72 61 63 65 20 68 65 72 65 2c 20 69 on trace here, i
3ae0: 66 20 6e 6f 74 20 4e 55 4c 4c 20 2a 2f 0a 23 65 f not NULL */.#e
3af0: 6e 64 69 66 0a 20 20 56 64 62 65 46 72 61 6d 65 ndif. VdbeFrame
3b00: 20 2a 70 46 72 61 6d 65 3b 20 20 20 20 20 20 2f *pFrame; /
3b10: 2a 20 50 61 72 65 6e 74 20 66 72 61 6d 65 20 2a * Parent frame *
3b20: 2f 0a 20 20 69 6e 74 20 6e 46 72 61 6d 65 3b 20 /. int nFrame;
3b30: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e /* N
3b40: 75 6d 62 65 72 20 6f 66 20 66 72 61 6d 65 73 20 umber of frames
3b50: 69 6e 20 70 46 72 61 6d 65 20 6c 69 73 74 20 2a in pFrame list *
3b60: 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 /.};../*.** The
3b70: 66 6f 6c 6c 6f 77 69 6e 67 20 61 72 65 20 61 6c following are al
3b80: 6c 6f 77 65 64 20 76 61 6c 75 65 73 20 66 6f 72 lowed values for
3b90: 20 56 64 62 65 2e 6d 61 67 69 63 0a 2a 2f 0a 23 Vdbe.magic.*/.#
3ba0: 64 65 66 69 6e 65 20 56 44 42 45 5f 4d 41 47 49 define VDBE_MAGI
3bb0: 43 5f 49 4e 49 54 20 20 20 20 20 30 78 32 36 62 C_INIT 0x26b
3bc0: 63 65 61 61 35 20 20 20 20 2f 2a 20 42 75 69 6c ceaa5 /* Buil
3bd0: 64 69 6e 67 20 61 20 56 44 42 45 20 70 72 6f 67 ding a VDBE prog
3be0: 72 61 6d 20 2a 2f 0a 23 64 65 66 69 6e 65 20 56 ram */.#define V
3bf0: 44 42 45 5f 4d 41 47 49 43 5f 52 55 4e 20 20 20 DBE_MAGIC_RUN
3c00: 20 20 20 30 78 62 64 66 32 30 64 61 33 20 20 20 0xbdf20da3
3c10: 20 2f 2a 20 56 44 42 45 20 69 73 20 72 65 61 64 /* VDBE is read
3c20: 79 20 74 6f 20 65 78 65 63 75 74 65 20 2a 2f 0a y to execute */.
3c30: 23 64 65 66 69 6e 65 20 56 44 42 45 5f 4d 41 47 #define VDBE_MAG
3c40: 49 43 5f 48 41 4c 54 20 20 20 20 20 30 78 35 31 IC_HALT 0x51
3c50: 39 63 32 39 37 33 20 20 20 20 2f 2a 20 56 44 42 9c2973 /* VDB
3c60: 45 20 68 61 73 20 63 6f 6d 70 6c 65 74 65 64 20 E has completed
3c70: 65 78 65 63 75 74 69 6f 6e 20 2a 2f 0a 23 64 65 execution */.#de
3c80: 66 69 6e 65 20 56 44 42 45 5f 4d 41 47 49 43 5f fine VDBE_MAGIC_
3c90: 44 45 41 44 20 20 20 20 20 30 78 62 36 30 36 63 DEAD 0xb606c
3ca0: 33 63 38 20 20 20 20 2f 2a 20 54 68 65 20 56 44 3c8 /* The VD
3cb0: 42 45 20 68 61 73 20 62 65 65 6e 20 64 65 61 6c BE has been deal
3cc0: 6c 6f 63 61 74 65 64 20 2a 2f 0a 0a 2f 2a 0a 2a located */../*.*
3cd0: 2a 20 46 75 6e 63 74 69 6f 6e 20 70 72 6f 74 6f * Function proto
3ce0: 74 79 70 65 73 0a 2a 2f 0a 76 6f 69 64 20 73 71 types.*/.void sq
3cf0: 6c 69 74 65 33 56 64 62 65 46 72 65 65 43 75 72 lite3VdbeFreeCur
3d00: 73 6f 72 28 56 64 62 65 20 2a 2c 20 56 64 62 65 sor(Vdbe *, Vdbe
3d10: 43 75 72 73 6f 72 2a 29 3b 0a 76 6f 69 64 20 73 Cursor*);.void s
3d20: 71 6c 69 74 65 56 64 62 65 50 6f 70 53 74 61 63 qliteVdbePopStac
3d30: 6b 28 56 64 62 65 2a 2c 69 6e 74 29 3b 0a 69 6e k(Vdbe*,int);.in
3d40: 74 20 73 71 6c 69 74 65 33 56 64 62 65 43 75 72 t sqlite3VdbeCur
3d50: 73 6f 72 4d 6f 76 65 74 6f 28 56 64 62 65 43 75 sorMoveto(VdbeCu
3d60: 72 73 6f 72 2a 29 3b 0a 23 69 66 20 64 65 66 69 rsor*);.#if defi
3d70: 6e 65 64 28 53 51 4c 49 54 45 5f 44 45 42 55 47 ned(SQLITE_DEBUG
3d80: 29 20 7c 7c 20 64 65 66 69 6e 65 64 28 56 44 42 ) || defined(VDB
3d90: 45 5f 50 52 4f 46 49 4c 45 29 0a 76 6f 69 64 20 E_PROFILE).void
3da0: 73 71 6c 69 74 65 33 56 64 62 65 50 72 69 6e 74 sqlite3VdbePrint
3db0: 4f 70 28 46 49 4c 45 2a 2c 20 69 6e 74 2c 20 4f Op(FILE*, int, O
3dc0: 70 2a 29 3b 0a 23 65 6e 64 69 66 0a 75 33 32 20 p*);.#endif.u32
3dd0: 73 71 6c 69 74 65 33 56 64 62 65 53 65 72 69 61 sqlite3VdbeSeria
3de0: 6c 54 79 70 65 4c 65 6e 28 75 33 32 29 3b 0a 75 lTypeLen(u32);.u
3df0: 33 32 20 73 71 6c 69 74 65 33 56 64 62 65 53 65 32 sqlite3VdbeSe
3e00: 72 69 61 6c 54 79 70 65 28 4d 65 6d 2a 2c 20 69 rialType(Mem*, i
3e10: 6e 74 29 3b 0a 75 33 32 20 73 71 6c 69 74 65 33 nt);.u32 sqlite3
3e20: 56 64 62 65 53 65 72 69 61 6c 50 75 74 28 75 6e VdbeSerialPut(un
3e30: 73 69 67 6e 65 64 20 63 68 61 72 2a 2c 20 69 6e signed char*, in
3e40: 74 2c 20 4d 65 6d 2a 2c 20 69 6e 74 29 3b 0a 75 t, Mem*, int);.u
3e50: 33 32 20 73 71 6c 69 74 65 33 56 64 62 65 53 65 32 sqlite3VdbeSe
3e60: 72 69 61 6c 47 65 74 28 63 6f 6e 73 74 20 75 6e rialGet(const un
3e70: 73 69 67 6e 65 64 20 63 68 61 72 2a 2c 20 75 33 signed char*, u3
3e80: 32 2c 20 4d 65 6d 2a 29 3b 0a 76 6f 69 64 20 73 2, Mem*);.void s
3e90: 71 6c 69 74 65 33 56 64 62 65 44 65 6c 65 74 65 qlite3VdbeDelete
3ea0: 41 75 78 44 61 74 61 28 56 64 62 65 46 75 6e 63 AuxData(VdbeFunc
3eb0: 2a 2c 20 69 6e 74 29 3b 0a 0a 69 6e 74 20 73 71 *, int);..int sq
3ec0: 6c 69 74 65 32 42 74 72 65 65 4b 65 79 43 6f 6d lite2BtreeKeyCom
3ed0: 70 61 72 65 28 42 74 43 75 72 73 6f 72 20 2a 2c pare(BtCursor *,
3ee0: 20 63 6f 6e 73 74 20 76 6f 69 64 20 2a 2c 20 69 const void *, i
3ef0: 6e 74 2c 20 69 6e 74 2c 20 69 6e 74 20 2a 29 3b nt, int, int *);
3f00: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
3f10: 49 64 78 4b 65 79 43 6f 6d 70 61 72 65 28 56 64 IdxKeyCompare(Vd
3f20: 62 65 43 75 72 73 6f 72 2a 2c 55 6e 70 61 63 6b beCursor*,Unpack
3f30: 65 64 52 65 63 6f 72 64 2a 2c 69 6e 74 2a 29 3b edRecord*,int*);
3f40: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
3f50: 49 64 78 52 6f 77 69 64 28 73 71 6c 69 74 65 33 IdxRowid(sqlite3
3f60: 2a 2c 20 42 74 43 75 72 73 6f 72 20 2a 2c 20 69 *, BtCursor *, i
3f70: 36 34 20 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 64 *);.int sqlit
3f80: 65 33 4d 65 6d 43 6f 6d 70 61 72 65 28 63 6f 6e e3MemCompare(con
3f90: 73 74 20 4d 65 6d 2a 2c 20 63 6f 6e 73 74 20 4d st Mem*, const M
3fa0: 65 6d 2a 2c 20 63 6f 6e 73 74 20 43 6f 6c 6c 53 em*, const CollS
3fb0: 65 71 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 eq*);.int sqlite
3fc0: 33 56 64 62 65 45 78 65 63 28 56 64 62 65 2a 29 3VdbeExec(Vdbe*)
3fd0: 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 ;.int sqlite3Vdb
3fe0: 65 4c 69 73 74 28 56 64 62 65 2a 29 3b 0a 69 6e eList(Vdbe*);.in
3ff0: 74 20 73 71 6c 69 74 65 33 56 64 62 65 48 61 6c t sqlite3VdbeHal
4000: 74 28 56 64 62 65 2a 29 3b 0a 69 6e 74 20 73 71 t(Vdbe*);.int sq
4010: 6c 69 74 65 33 56 64 62 65 43 68 61 6e 67 65 45 lite3VdbeChangeE
4020: 6e 63 6f 64 69 6e 67 28 4d 65 6d 20 2a 2c 20 69 ncoding(Mem *, i
4030: 6e 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 nt);.int sqlite3
4040: 56 64 62 65 4d 65 6d 54 6f 6f 42 69 67 28 4d 65 VdbeMemTooBig(Me
4050: 6d 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 m*);.int sqlite3
4060: 56 64 62 65 4d 65 6d 43 6f 70 79 28 4d 65 6d 2a VdbeMemCopy(Mem*
4070: 2c 20 63 6f 6e 73 74 20 4d 65 6d 2a 29 3b 0a 76 , const Mem*);.v
4080: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d oid sqlite3VdbeM
4090: 65 6d 53 68 61 6c 6c 6f 77 43 6f 70 79 28 4d 65 emShallowCopy(Me
40a0: 6d 2a 2c 20 63 6f 6e 73 74 20 4d 65 6d 2a 2c 20 m*, const Mem*,
40b0: 69 6e 74 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 int);.void sqlit
40c0: 65 33 56 64 62 65 4d 65 6d 4d 6f 76 65 28 4d 65 e3VdbeMemMove(Me
40d0: 6d 2a 2c 20 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 m*, Mem*);.int s
40e0: 71 6c 69 74 65 33 56 64 62 65 4d 65 6d 4e 75 6c qlite3VdbeMemNul
40f0: 54 65 72 6d 69 6e 61 74 65 28 4d 65 6d 2a 29 3b Terminate(Mem*);
4100: 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 .int sqlite3Vdbe
4110: 4d 65 6d 53 65 74 53 74 72 28 4d 65 6d 2a 2c 20 MemSetStr(Mem*,
4120: 63 6f 6e 73 74 20 63 68 61 72 2a 2c 20 69 6e 74 const char*, int
4130: 2c 20 75 38 2c 20 76 6f 69 64 28 2a 29 28 76 6f , u8, void(*)(vo
4140: 69 64 2a 29 29 3b 0a 76 6f 69 64 20 73 71 6c 69 id*));.void sqli
4150: 74 65 33 56 64 62 65 4d 65 6d 53 65 74 49 6e 74 te3VdbeMemSetInt
4160: 36 34 28 4d 65 6d 2a 2c 20 69 36 34 29 3b 0a 76 64(Mem*, i64);.v
4170: 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d oid sqlite3VdbeM
4180: 65 6d 53 65 74 44 6f 75 62 6c 65 28 4d 65 6d 2a emSetDouble(Mem*
4190: 2c 20 64 6f 75 62 6c 65 29 3b 0a 76 6f 69 64 20 , double);.void
41a0: 73 71 6c 69 74 65 33 56 64 62 65 4d 65 6d 53 65 sqlite3VdbeMemSe
41b0: 74 4e 75 6c 6c 28 4d 65 6d 2a 29 3b 0a 76 6f 69 tNull(Mem*);.voi
41c0: 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d 65 6d d sqlite3VdbeMem
41d0: 53 65 74 5a 65 72 6f 42 6c 6f 62 28 4d 65 6d 2a SetZeroBlob(Mem*
41e0: 2c 69 6e 74 29 3b 0a 76 6f 69 64 20 73 71 6c 69 ,int);.void sqli
41f0: 74 65 33 56 64 62 65 4d 65 6d 53 65 74 52 6f 77 te3VdbeMemSetRow
4200: 53 65 74 28 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 Set(Mem*);.int s
4210: 71 6c 69 74 65 33 56 64 62 65 4d 65 6d 4d 61 6b qlite3VdbeMemMak
4220: 65 57 72 69 74 65 61 62 6c 65 28 4d 65 6d 2a 29 eWriteable(Mem*)
4230: 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 62 ;.int sqlite3Vdb
4240: 65 4d 65 6d 53 74 72 69 6e 67 69 66 79 28 4d 65 eMemStringify(Me
4250: 6d 2a 2c 20 69 6e 74 29 3b 0a 69 36 34 20 73 71 m*, int);.i64 sq
4260: 6c 69 74 65 33 56 64 62 65 49 6e 74 56 61 6c 75 lite3VdbeIntValu
4270: 65 28 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 71 6c e(Mem*);.int sql
4280: 69 74 65 33 56 64 62 65 4d 65 6d 49 6e 74 65 67 ite3VdbeMemInteg
4290: 65 72 69 66 79 28 4d 65 6d 2a 29 3b 0a 64 6f 75 erify(Mem*);.dou
42a0: 62 6c 65 20 73 71 6c 69 74 65 33 56 64 62 65 52 ble sqlite3VdbeR
42b0: 65 61 6c 56 61 6c 75 65 28 4d 65 6d 2a 29 3b 0a ealValue(Mem*);.
42c0: 76 6f 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 void sqlite3Vdbe
42d0: 49 6e 74 65 67 65 72 41 66 66 69 6e 69 74 79 28 IntegerAffinity(
42e0: 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 Mem*);.int sqlit
42f0: 65 33 56 64 62 65 4d 65 6d 52 65 61 6c 69 66 79 e3VdbeMemRealify
4300: 28 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 (Mem*);.int sqli
4310: 74 65 33 56 64 62 65 4d 65 6d 4e 75 6d 65 72 69 te3VdbeMemNumeri
4320: 66 79 28 4d 65 6d 2a 29 3b 0a 69 6e 74 20 73 71 fy(Mem*);.int sq
4330: 6c 69 74 65 33 56 64 62 65 4d 65 6d 46 72 6f 6d lite3VdbeMemFrom
4340: 42 74 72 65 65 28 42 74 43 75 72 73 6f 72 2a 2c Btree(BtCursor*,
4350: 69 6e 74 2c 69 6e 74 2c 69 6e 74 2c 4d 65 6d 2a int,int,int,Mem*
4360: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
4370: 64 62 65 4d 65 6d 52 65 6c 65 61 73 65 28 4d 65 dbeMemRelease(Me
4380: 6d 20 2a 70 29 3b 0a 76 6f 69 64 20 73 71 6c 69 m *p);.void sqli
4390: 74 65 33 56 64 62 65 4d 65 6d 52 65 6c 65 61 73 te3VdbeMemReleas
43a0: 65 45 78 74 65 72 6e 61 6c 28 4d 65 6d 20 2a 70 eExternal(Mem *p
43b0: 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 );.int sqlite3Vd
43c0: 62 65 4d 65 6d 46 69 6e 61 6c 69 7a 65 28 4d 65 beMemFinalize(Me
43d0: 6d 2a 2c 20 46 75 6e 63 44 65 66 2a 29 3b 0a 63 m*, FuncDef*);.c
43e0: 6f 6e 73 74 20 63 68 61 72 20 2a 73 71 6c 69 74 onst char *sqlit
43f0: 65 33 4f 70 63 6f 64 65 4e 61 6d 65 28 69 6e 74 e3OpcodeName(int
4400: 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 56 64 );.int sqlite3Vd
4410: 62 65 4f 70 63 6f 64 65 48 61 73 50 72 6f 70 65 beOpcodeHasPrope
4420: 72 74 79 28 69 6e 74 2c 20 69 6e 74 29 3b 0a 69 rty(int, int);.i
4430: 6e 74 20 73 71 6c 69 74 65 33 56 64 62 65 4d 65 nt sqlite3VdbeMe
4440: 6d 47 72 6f 77 28 4d 65 6d 20 2a 70 4d 65 6d 2c mGrow(Mem *pMem,
4450: 20 69 6e 74 20 6e 2c 20 69 6e 74 20 70 72 65 73 int n, int pres
4460: 65 72 76 65 29 3b 0a 69 6e 74 20 73 71 6c 69 74 erve);.int sqlit
4470: 65 33 56 64 62 65 43 6c 6f 73 65 53 74 61 74 65 e3VdbeCloseState
4480: 6d 65 6e 74 28 56 64 62 65 20 2a 2c 20 69 6e 74 ment(Vdbe *, int
4490: 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 65 33 56 );.void sqlite3V
44a0: 64 62 65 46 72 61 6d 65 44 65 6c 65 74 65 28 56 dbeFrameDelete(V
44b0: 64 62 65 46 72 61 6d 65 2a 29 3b 0a 69 6e 74 20 dbeFrame*);.int
44c0: 73 71 6c 69 74 65 33 56 64 62 65 46 72 61 6d 65 sqlite3VdbeFrame
44d0: 52 65 73 74 6f 72 65 28 56 64 62 65 46 72 61 6d Restore(VdbeFram
44e0: 65 20 2a 29 3b 0a 23 69 66 64 65 66 20 53 51 4c e *);.#ifdef SQL
44f0: 49 54 45 5f 45 4e 41 42 4c 45 5f 4d 45 4d 4f 52 ITE_ENABLE_MEMOR
4500: 59 5f 4d 41 4e 41 47 45 4d 45 4e 54 0a 69 6e 74 Y_MANAGEMENT.int
4510: 20 73 71 6c 69 74 65 33 56 64 62 65 52 65 6c 65 sqlite3VdbeRele
4520: 61 73 65 42 75 66 66 65 72 73 28 56 64 62 65 20 aseBuffers(Vdbe
4530: 2a 70 29 3b 0a 23 65 6e 64 69 66 0a 0a 23 69 66 *p);.#endif..#if
4540: 6e 64 65 66 20 53 51 4c 49 54 45 5f 4f 4d 49 54 ndef SQLITE_OMIT
4550: 5f 53 48 41 52 45 44 5f 43 41 43 48 45 0a 76 6f _SHARED_CACHE.vo
4560: 69 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d 75 id sqlite3VdbeMu
4570: 74 65 78 41 72 72 61 79 45 6e 74 65 72 28 56 64 texArrayEnter(Vd
4580: 62 65 20 2a 70 29 3b 0a 23 65 6c 73 65 0a 23 20 be *p);.#else.#
4590: 64 65 66 69 6e 65 20 73 71 6c 69 74 65 33 56 64 define sqlite3Vd
45a0: 62 65 4d 75 74 65 78 41 72 72 61 79 45 6e 74 65 beMutexArrayEnte
45b0: 72 28 70 29 0a 23 65 6e 64 69 66 0a 0a 69 6e 74 r(p).#endif..int
45c0: 20 73 71 6c 69 74 65 33 56 64 62 65 4d 65 6d 54 sqlite3VdbeMemT
45d0: 72 61 6e 73 6c 61 74 65 28 4d 65 6d 2a 2c 20 75 ranslate(Mem*, u
45e0: 38 29 3b 0a 23 69 66 64 65 66 20 53 51 4c 49 54 8);.#ifdef SQLIT
45f0: 45 5f 44 45 42 55 47 0a 20 20 76 6f 69 64 20 73 E_DEBUG. void s
4600: 71 6c 69 74 65 33 56 64 62 65 50 72 69 6e 74 53 qlite3VdbePrintS
4610: 71 6c 28 56 64 62 65 2a 29 3b 0a 20 20 76 6f 69 ql(Vdbe*);. voi
4620: 64 20 73 71 6c 69 74 65 33 56 64 62 65 4d 65 6d d sqlite3VdbeMem
4630: 50 72 65 74 74 79 50 72 69 6e 74 28 4d 65 6d 20 PrettyPrint(Mem
4640: 2a 70 4d 65 6d 2c 20 63 68 61 72 20 2a 7a 42 75 *pMem, char *zBu
4650: 66 29 3b 0a 23 65 6e 64 69 66 0a 69 6e 74 20 73 f);.#endif.int s
4660: 71 6c 69 74 65 33 56 64 62 65 4d 65 6d 48 61 6e qlite3VdbeMemHan
4670: 64 6c 65 42 6f 6d 28 4d 65 6d 20 2a 70 4d 65 6d dleBom(Mem *pMem
4680: 29 3b 0a 0a 23 69 66 6e 64 65 66 20 53 51 4c 49 );..#ifndef SQLI
4690: 54 45 5f 4f 4d 49 54 5f 49 4e 43 52 42 4c 4f 42 TE_OMIT_INCRBLOB
46a0: 0a 20 20 69 6e 74 20 73 71 6c 69 74 65 33 56 64 . int sqlite3Vd
46b0: 62 65 4d 65 6d 45 78 70 61 6e 64 42 6c 6f 62 28 beMemExpandBlob(
46c0: 4d 65 6d 20 2a 29 3b 0a 23 65 6c 73 65 0a 20 20 Mem *);.#else.
46d0: 23 64 65 66 69 6e 65 20 73 71 6c 69 74 65 33 56 #define sqlite3V
46e0: 64 62 65 4d 65 6d 45 78 70 61 6e 64 42 6c 6f 62 dbeMemExpandBlob
46f0: 28 78 29 20 53 51 4c 49 54 45 5f 4f 4b 0a 23 65 (x) SQLITE_OK.#e
4700: 6e 64 69 66 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 ndif..#endif /*
4710: 21 64 65 66 69 6e 65 64 28 5f 56 44 42 45 49 4e !defined(_VDBEIN
4720: 54 5f 48 5f 29 20 2a 2f 0a T_H_) */.