drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1 | /* |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 2 | ** 2001 September 15 |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 3 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 6 | ** |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** Header file for the Virtual DataBase Engine (VDBE) |
| 13 | ** |
| 14 | ** This header defines the interface to the virtual database engine |
| 15 | ** or VDBE. The VDBE implements an abstract machine that runs a |
| 16 | ** simple program to access and modify the underlying database. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 17 | */ |
drh | 43f58d6 | 2016-07-09 16:14:45 +0000 | [diff] [blame] | 18 | #ifndef SQLITE_VDBE_H |
| 19 | #define SQLITE_VDBE_H |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | |
| 22 | /* |
| 23 | ** A single VDBE is an opaque structure named "Vdbe". Only routines |
| 24 | ** in the source file sqliteVdbe.c are allowed to see the insides |
| 25 | ** of this structure. |
| 26 | */ |
| 27 | typedef struct Vdbe Vdbe; |
| 28 | |
| 29 | /* |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 30 | ** The names of the following types declared in vdbeInt.h are required |
| 31 | ** for the VdbeOp definition. |
| 32 | */ |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 33 | typedef struct Mem Mem; |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 34 | typedef struct SubProgram SubProgram; |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 35 | |
| 36 | /* |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 37 | ** A single instruction of the virtual machine has an opcode |
| 38 | ** and as many as three operands. The instruction is recorded |
| 39 | ** as an instance of the following structure: |
| 40 | */ |
| 41 | struct VdbeOp { |
drh | 905793e | 2004-02-21 13:31:09 +0000 | [diff] [blame] | 42 | u8 opcode; /* What operation to perform */ |
drh | c920628 | 2008-01-09 18:31:45 +0000 | [diff] [blame] | 43 | signed char p4type; /* One of the P4_xxx constants for p4 */ |
drh | 7cc84c2 | 2016-04-11 13:36:42 +0000 | [diff] [blame] | 44 | u8 notUsed1; |
drh | 119a531 | 2008-01-02 17:25:54 +0000 | [diff] [blame] | 45 | u8 p5; /* Fifth parameter is an unsigned character */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 46 | int p1; /* First operand */ |
| 47 | int p2; /* Second parameter (often the jump destination) */ |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 48 | int p3; /* The third parameter */ |
drh | 9c7c913 | 2015-06-26 18:16:52 +0000 | [diff] [blame] | 49 | union p4union { /* fourth parameter */ |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 50 | int i; /* Integer value if p4type==P4_INT32 */ |
| 51 | void *p; /* Generic pointer */ |
| 52 | char *z; /* Pointer to data for string (char array) types */ |
| 53 | i64 *pI64; /* Used when p4type is P4_INT64 */ |
| 54 | double *pReal; /* Used when p4type is P4_REAL */ |
| 55 | FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */ |
drh | 9c7c913 | 2015-06-26 18:16:52 +0000 | [diff] [blame] | 56 | sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */ |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 57 | CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ |
| 58 | Mem *pMem; /* Used when p4type is P4_MEM */ |
danielk1977 | 595a523 | 2009-07-24 17:58:53 +0000 | [diff] [blame] | 59 | VTable *pVtab; /* Used when p4type is P4_VTAB */ |
danielk1977 | 2dca4ac | 2008-01-03 11:50:29 +0000 | [diff] [blame] | 60 | KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ |
drh | 0acb7e4 | 2008-06-25 00:12:41 +0000 | [diff] [blame] | 61 | int *ai; /* Used when p4type is P4_INTARRAY */ |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 62 | SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ |
dan | 319eeb7 | 2011-03-19 08:38:50 +0000 | [diff] [blame] | 63 | Table *pTab; /* Used when p4type is P4_TABLE */ |
drh | 2893536 | 2013-12-07 20:39:19 +0000 | [diff] [blame] | 64 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 65 | Expr *pExpr; /* Used when p4type is P4_EXPR */ |
| 66 | #endif |
dan | a205a48 | 2011-08-27 18:48:57 +0000 | [diff] [blame] | 67 | int (*xAdvance)(BtCursor *, int *); |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 68 | } p4; |
drh | c7379ce | 2013-10-30 02:28:23 +0000 | [diff] [blame] | 69 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
shane | 9bcbdad | 2008-05-29 20:22:37 +0000 | [diff] [blame] | 70 | char *zComment; /* Comment to improve readability */ |
drh | d4e70eb | 2008-01-02 00:34:36 +0000 | [diff] [blame] | 71 | #endif |
drh | 7b39686 | 2003-01-01 23:06:20 +0000 | [diff] [blame] | 72 | #ifdef VDBE_PROFILE |
drh | 15ab941 | 2014-02-24 14:24:01 +0000 | [diff] [blame] | 73 | u32 cnt; /* Number of times this instruction was executed */ |
shane | 9bcbdad | 2008-05-29 20:22:37 +0000 | [diff] [blame] | 74 | u64 cycles; /* Total time spent executing this instruction */ |
drh | 7b39686 | 2003-01-01 23:06:20 +0000 | [diff] [blame] | 75 | #endif |
drh | 688852a | 2014-02-17 22:40:43 +0000 | [diff] [blame] | 76 | #ifdef SQLITE_VDBE_COVERAGE |
| 77 | int iSrcLine; /* Source-code line that generated this opcode */ |
| 78 | #endif |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 79 | }; |
| 80 | typedef struct VdbeOp VdbeOp; |
| 81 | |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 82 | |
| 83 | /* |
| 84 | ** A sub-routine used to implement a trigger program. |
| 85 | */ |
| 86 | struct SubProgram { |
| 87 | VdbeOp *aOp; /* Array of opcodes for sub-program */ |
| 88 | int nOp; /* Elements in aOp[] */ |
| 89 | int nMem; /* Number of memory cells required */ |
| 90 | int nCsr; /* Number of cursors required */ |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 91 | void *token; /* id that may be used to recursive triggers */ |
dan | d46def7 | 2010-07-24 11:28:28 +0000 | [diff] [blame] | 92 | SubProgram *pNext; /* Next sub-program already visited */ |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 95 | /* |
drh | 905793e | 2004-02-21 13:31:09 +0000 | [diff] [blame] | 96 | ** A smaller version of VdbeOp used for the VdbeAddOpList() function because |
| 97 | ** it takes up less space. |
| 98 | */ |
| 99 | struct VdbeOpList { |
| 100 | u8 opcode; /* What operation to perform */ |
| 101 | signed char p1; /* First operand */ |
drh | 2400345 | 2008-01-03 01:28:59 +0000 | [diff] [blame] | 102 | signed char p2; /* Second parameter (often the jump destination) */ |
| 103 | signed char p3; /* Third parameter */ |
drh | 905793e | 2004-02-21 13:31:09 +0000 | [diff] [blame] | 104 | }; |
| 105 | typedef struct VdbeOpList VdbeOpList; |
| 106 | |
| 107 | /* |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 108 | ** Allowed values of VdbeOp.p4type |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 109 | */ |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 110 | #define P4_NOTUSED 0 /* The P4 parameter is not used */ |
| 111 | #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */ |
| 112 | #define P4_STATIC (-2) /* Pointer to a static string */ |
| 113 | #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */ |
| 114 | #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */ |
| 115 | #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */ |
drh | 2893536 | 2013-12-07 20:39:19 +0000 | [diff] [blame] | 116 | #define P4_EXPR (-7) /* P4 is a pointer to an Expr tree */ |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 117 | #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */ |
drh | 8d12942 | 2011-04-05 12:25:19 +0000 | [diff] [blame] | 118 | #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */ |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 119 | #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */ |
| 120 | #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */ |
| 121 | #define P4_REAL (-12) /* P4 is a 64-bit floating point value */ |
| 122 | #define P4_INT64 (-13) /* P4 is a 64-bit signed integer */ |
| 123 | #define P4_INT32 (-14) /* P4 is a 32-bit signed integer */ |
drh | 0acb7e4 | 2008-06-25 00:12:41 +0000 | [diff] [blame] | 124 | #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 125 | #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ |
dan | a205a48 | 2011-08-27 18:48:57 +0000 | [diff] [blame] | 126 | #define P4_ADVANCE (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */ |
dan | 93bca69 | 2011-09-14 19:41:44 +0000 | [diff] [blame] | 127 | #define P4_TABLE (-20) /* P4 is a pointer to a Table structure */ |
drh | 59b4bd4 | 2015-06-30 16:29:59 +0000 | [diff] [blame] | 128 | #define P4_FUNCCTX (-21) /* P4 is a pointer to an sqlite3_context object */ |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 129 | |
drh | f9c8ce3 | 2013-11-05 13:33:55 +0000 | [diff] [blame] | 130 | /* Error message codes for OP_Halt */ |
| 131 | #define P5_ConstraintNotNull 1 |
| 132 | #define P5_ConstraintUnique 2 |
| 133 | #define P5_ConstraintCheck 3 |
| 134 | #define P5_ConstraintFK 4 |
drh | ffbc308 | 2004-05-21 01:29:06 +0000 | [diff] [blame] | 135 | |
drh | 99fcd71 | 2001-10-13 01:06:47 +0000 | [diff] [blame] | 136 | /* |
danielk1977 | 955de52 | 2006-02-10 02:27:42 +0000 | [diff] [blame] | 137 | ** The Vdbe.aColName array contains 5n Mem structures, where n is the |
| 138 | ** number of columns of data returned by the statement. |
| 139 | */ |
| 140 | #define COLNAME_NAME 0 |
| 141 | #define COLNAME_DECLTYPE 1 |
| 142 | #define COLNAME_DATABASE 2 |
| 143 | #define COLNAME_TABLE 3 |
| 144 | #define COLNAME_COLUMN 4 |
drh | 3f91357 | 2008-03-22 01:07:17 +0000 | [diff] [blame] | 145 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 146 | # define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ |
| 147 | #else |
| 148 | # ifdef SQLITE_OMIT_DECLTYPE |
| 149 | # define COLNAME_N 1 /* Store only the name */ |
| 150 | # else |
| 151 | # define COLNAME_N 2 /* Store the name and decltype */ |
| 152 | # endif |
| 153 | #endif |
danielk1977 | 955de52 | 2006-02-10 02:27:42 +0000 | [diff] [blame] | 154 | |
| 155 | /* |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 156 | ** The following macro converts a relative address in the p2 field |
| 157 | ** of a VdbeOp structure into a negative number so that |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 158 | ** sqlite3VdbeAddOpList() knows that the address is relative. Calling |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 159 | ** the macro again restores the address. |
| 160 | */ |
| 161 | #define ADDR(X) (-1-(X)) |
| 162 | |
| 163 | /* |
drh | 8f619cc | 2002-09-08 00:04:50 +0000 | [diff] [blame] | 164 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 165 | ** header file that defines a number for each opcode used by the VDBE. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 166 | */ |
drh | 8f619cc | 2002-09-08 00:04:50 +0000 | [diff] [blame] | 167 | #include "opcodes.h" |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 168 | |
| 169 | /* |
| 170 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 171 | ** for a description of what each of these routines does. |
| 172 | */ |
drh | 9ac7962 | 2013-12-18 15:11:47 +0000 | [diff] [blame] | 173 | Vdbe *sqlite3VdbeCreate(Parse*); |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 174 | int sqlite3VdbeAddOp0(Vdbe*,int); |
| 175 | int sqlite3VdbeAddOp1(Vdbe*,int,int); |
| 176 | int sqlite3VdbeAddOp2(Vdbe*,int,int,int); |
drh | 076e85f | 2015-09-03 13:46:12 +0000 | [diff] [blame] | 177 | int sqlite3VdbeGoto(Vdbe*,int); |
| 178 | int sqlite3VdbeLoadString(Vdbe*,int,const char*); |
| 179 | void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...); |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 180 | int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); |
| 181 | int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); |
drh | 97bae79 | 2015-06-05 15:59:57 +0000 | [diff] [blame] | 182 | int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); |
drh | 8cff69d | 2009-11-12 19:59:44 +0000 | [diff] [blame] | 183 | int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); |
drh | 2fade2f | 2016-02-09 02:12:20 +0000 | [diff] [blame] | 184 | void sqlite3VdbeEndCoroutine(Vdbe*,int); |
drh | dad300d | 2016-01-18 00:20:26 +0000 | [diff] [blame] | 185 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) |
| 186 | void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N); |
drh | 2ce1865 | 2016-01-16 20:50:21 +0000 | [diff] [blame] | 187 | #else |
drh | dad300d | 2016-01-18 00:20:26 +0000 | [diff] [blame] | 188 | # define sqlite3VdbeVerifyNoMallocRequired(A,B) |
drh | 2ce1865 | 2016-01-16 20:50:21 +0000 | [diff] [blame] | 189 | #endif |
| 190 | VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno); |
drh | 5d9c9da | 2011-06-03 20:11:17 +0000 | [diff] [blame] | 191 | void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); |
drh | 0ff287f | 2015-09-02 18:40:33 +0000 | [diff] [blame] | 192 | void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8); |
drh | 88caeac | 2011-08-24 15:12:08 +0000 | [diff] [blame] | 193 | void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); |
| 194 | void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); |
| 195 | void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); |
drh | 3557335 | 2008-01-08 23:54:25 +0000 | [diff] [blame] | 196 | void sqlite3VdbeChangeP5(Vdbe*, u8 P5); |
drh | d654be8 | 2005-09-20 17:42:23 +0000 | [diff] [blame] | 197 | void sqlite3VdbeJumpHere(Vdbe*, int addr); |
drh | 2ce1865 | 2016-01-16 20:50:21 +0000 | [diff] [blame] | 198 | int sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
drh | 61019c7 | 2014-01-04 16:49:02 +0000 | [diff] [blame] | 199 | int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); |
drh | 66a5167 | 2008-01-03 00:01:23 +0000 | [diff] [blame] | 200 | void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
drh | 2ec2fb2 | 2013-11-06 19:59:23 +0000 | [diff] [blame] | 201 | void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
drh | fb98264 | 2007-08-30 01:19:59 +0000 | [diff] [blame] | 202 | void sqlite3VdbeUsesBtree(Vdbe*, int); |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 203 | VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| 204 | int sqlite3VdbeMakeLabel(Vdbe*); |
drh | 4611d92 | 2010-02-25 14:47:01 +0000 | [diff] [blame] | 205 | void sqlite3VdbeRunOnlyOnce(Vdbe*); |
drh | f71a366 | 2016-03-16 20:44:45 +0000 | [diff] [blame] | 206 | void sqlite3VdbeReusable(Vdbe*); |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 207 | void sqlite3VdbeDelete(Vdbe*); |
drh | cb103b9 | 2012-10-26 00:11:23 +0000 | [diff] [blame] | 208 | void sqlite3VdbeClearObject(sqlite3*,Vdbe*); |
drh | 124c0b4 | 2011-06-01 18:15:55 +0000 | [diff] [blame] | 209 | void sqlite3VdbeMakeReady(Vdbe*,Parse*); |
danielk1977 | 9e6db7d | 2004-06-21 08:18:51 +0000 | [diff] [blame] | 210 | int sqlite3VdbeFinalize(Vdbe*); |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 211 | void sqlite3VdbeResolveLabel(Vdbe*, int); |
| 212 | int sqlite3VdbeCurrentAddr(Vdbe*); |
drh | 87cc3b3 | 2007-05-08 21:45:27 +0000 | [diff] [blame] | 213 | #ifdef SQLITE_DEBUG |
dan | f367721 | 2009-09-10 16:14:50 +0000 | [diff] [blame] | 214 | int sqlite3VdbeAssertMayAbort(Vdbe *, int); |
drh | 87cc3b3 | 2007-05-08 21:45:27 +0000 | [diff] [blame] | 215 | #endif |
drh | 3c23a88 | 2007-01-09 14:01:13 +0000 | [diff] [blame] | 216 | void sqlite3VdbeResetStepResult(Vdbe*); |
drh | 124c0b4 | 2011-06-01 18:15:55 +0000 | [diff] [blame] | 217 | void sqlite3VdbeRewind(Vdbe*); |
drh | c890fec | 2008-08-01 20:10:08 +0000 | [diff] [blame] | 218 | int sqlite3VdbeReset(Vdbe*); |
danielk1977 | 22322fd | 2004-05-25 23:35:17 +0000 | [diff] [blame] | 219 | void sqlite3VdbeSetNumCols(Vdbe*,int); |
danielk1977 | 10fb749 | 2008-10-31 10:53:22 +0000 | [diff] [blame] | 220 | int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); |
danielk1977 | b28af71 | 2004-06-21 06:50:26 +0000 | [diff] [blame] | 221 | void sqlite3VdbeCountChanges(Vdbe*); |
danielk1977 | aee18ef | 2005-03-09 12:26:50 +0000 | [diff] [blame] | 222 | sqlite3 *sqlite3VdbeDb(Vdbe*); |
danielk1977 | 6ab3a2e | 2009-02-19 14:39:25 +0000 | [diff] [blame] | 223 | void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); |
drh | c515525 | 2007-01-08 21:07:17 +0000 | [diff] [blame] | 224 | void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
dan | 165921a | 2009-08-28 18:53:45 +0000 | [diff] [blame] | 225 | VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); |
drh | cf0fd4a | 2013-08-01 12:21:58 +0000 | [diff] [blame] | 226 | sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8); |
dan | 1d2ce4f | 2009-10-19 18:11:09 +0000 | [diff] [blame] | 227 | void sqlite3VdbeSetVarmask(Vdbe*, int); |
drh | c7bc4fd | 2009-11-25 18:03:42 +0000 | [diff] [blame] | 228 | #ifndef SQLITE_OMIT_TRACE |
| 229 | char *sqlite3VdbeExpandSql(Vdbe*, const char*); |
| 230 | #endif |
drh | 3eddb23 | 2014-06-28 14:28:06 +0000 | [diff] [blame] | 231 | int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 232 | |
dan | 03e9cfc | 2011-09-05 14:20:27 +0000 | [diff] [blame] | 233 | void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*); |
drh | 75179de | 2014-09-16 14:37:35 +0000 | [diff] [blame] | 234 | int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
dan | 7004f3f | 2015-03-30 12:06:26 +0000 | [diff] [blame] | 235 | int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int); |
dan | 03e9cfc | 2011-09-05 14:20:27 +0000 | [diff] [blame] | 236 | UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **); |
drh | 1e968a0 | 2008-03-25 00:22:21 +0000 | [diff] [blame] | 237 | |
drh | 75179de | 2014-09-16 14:37:35 +0000 | [diff] [blame] | 238 | typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); |
dan | 3b9330f | 2014-02-27 20:44:18 +0000 | [diff] [blame] | 239 | RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); |
dan | 1fed5da | 2014-02-25 21:01:25 +0000 | [diff] [blame] | 240 | |
dan | d19c933 | 2010-07-26 12:05:17 +0000 | [diff] [blame] | 241 | #ifndef SQLITE_OMIT_TRIGGER |
| 242 | void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 243 | #endif |
| 244 | |
drh | 72ffd09 | 2013-10-30 15:52:32 +0000 | [diff] [blame] | 245 | /* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on |
| 246 | ** each VDBE opcode. |
| 247 | ** |
| 248 | ** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op |
| 249 | ** comments in VDBE programs that show key decision points in the code |
| 250 | ** generator. |
| 251 | */ |
drh | c7379ce | 2013-10-30 02:28:23 +0000 | [diff] [blame] | 252 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
drh | d3d39e9 | 2004-05-20 22:16:29 +0000 | [diff] [blame] | 253 | void sqlite3VdbeComment(Vdbe*, const char*, ...); |
| 254 | # define VdbeComment(X) sqlite3VdbeComment X |
drh | 16ee60f | 2008-06-20 18:13:25 +0000 | [diff] [blame] | 255 | void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); |
| 256 | # define VdbeNoopComment(X) sqlite3VdbeNoopComment X |
drh | 72ffd09 | 2013-10-30 15:52:32 +0000 | [diff] [blame] | 257 | # ifdef SQLITE_ENABLE_MODULE_COMMENTS |
| 258 | # define VdbeModuleComment(X) sqlite3VdbeNoopComment X |
| 259 | # else |
| 260 | # define VdbeModuleComment(X) |
| 261 | # endif |
drh | d3d39e9 | 2004-05-20 22:16:29 +0000 | [diff] [blame] | 262 | #else |
| 263 | # define VdbeComment(X) |
drh | 16ee60f | 2008-06-20 18:13:25 +0000 | [diff] [blame] | 264 | # define VdbeNoopComment(X) |
drh | 72ffd09 | 2013-10-30 15:52:32 +0000 | [diff] [blame] | 265 | # define VdbeModuleComment(X) |
drh | d3d39e9 | 2004-05-20 22:16:29 +0000 | [diff] [blame] | 266 | #endif |
| 267 | |
drh | 5655c54 | 2014-02-19 19:14:34 +0000 | [diff] [blame] | 268 | /* |
| 269 | ** The VdbeCoverage macros are used to set a coverage testing point |
| 270 | ** for VDBE branch instructions. The coverage testing points are line |
| 271 | ** numbers in the sqlite3.c source file. VDBE branch coverage testing |
| 272 | ** only works with an amalagmation build. That's ok since a VDBE branch |
| 273 | ** coverage build designed for testing the test suite only. No application |
| 274 | ** should ever ship with VDBE branch coverage measuring turned on. |
| 275 | ** |
| 276 | ** VdbeCoverage(v) // Mark the previously coded instruction |
| 277 | ** // as a branch |
| 278 | ** |
| 279 | ** VdbeCoverageIf(v, conditional) // Mark previous if conditional true |
| 280 | ** |
| 281 | ** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken |
| 282 | ** |
| 283 | ** VdbeCoverageNeverTaken(v) // Previous branch is never taken |
| 284 | ** |
| 285 | ** Every VDBE branch operation must be tagged with one of the macros above. |
| 286 | ** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and |
| 287 | ** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch() |
| 288 | ** routine in vdbe.c, alerting the developer to the missed tag. |
| 289 | */ |
drh | 688852a | 2014-02-17 22:40:43 +0000 | [diff] [blame] | 290 | #ifdef SQLITE_VDBE_COVERAGE |
| 291 | void sqlite3VdbeSetLineNumber(Vdbe*,int); |
| 292 | # define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__) |
| 293 | # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__) |
drh | 5655c54 | 2014-02-19 19:14:34 +0000 | [diff] [blame] | 294 | # define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2); |
| 295 | # define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1); |
drh | b06a4ec | 2014-03-10 18:03:09 +0000 | [diff] [blame] | 296 | # define VDBE_OFFSET_LINENO(x) (__LINE__+x) |
drh | 688852a | 2014-02-17 22:40:43 +0000 | [diff] [blame] | 297 | #else |
| 298 | # define VdbeCoverage(v) |
| 299 | # define VdbeCoverageIf(v,x) |
drh | 5655c54 | 2014-02-19 19:14:34 +0000 | [diff] [blame] | 300 | # define VdbeCoverageAlwaysTaken(v) |
| 301 | # define VdbeCoverageNeverTaken(v) |
drh | b06a4ec | 2014-03-10 18:03:09 +0000 | [diff] [blame] | 302 | # define VDBE_OFFSET_LINENO(x) 0 |
drh | 688852a | 2014-02-17 22:40:43 +0000 | [diff] [blame] | 303 | #endif |
| 304 | |
dan | 6f9702e | 2014-11-01 20:38:06 +0000 | [diff] [blame] | 305 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
drh | 518140e | 2014-11-06 03:55:10 +0000 | [diff] [blame] | 306 | void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*); |
dan | 6f9702e | 2014-11-01 20:38:06 +0000 | [diff] [blame] | 307 | #else |
dan | 037b532 | 2014-11-03 11:25:32 +0000 | [diff] [blame] | 308 | # define sqlite3VdbeScanStatus(a,b,c,d,e) |
dan | 6f9702e | 2014-11-01 20:38:06 +0000 | [diff] [blame] | 309 | #endif |
| 310 | |
drh | 43f58d6 | 2016-07-09 16:14:45 +0000 | [diff] [blame] | 311 | #endif /* SQLITE_VDBE_H */ |