sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | /* |
| 2 | ** 2001 September 15 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 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. |
| 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. |
| 17 | */ |
| 18 | #ifndef SQLITE_VDBE_H |
| 19 | #define SQLITE_VDBE_H |
| 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 | /* |
| 30 | ** The names of the following types declared in vdbeInt.h are required |
| 31 | ** for the VdbeOp definition. |
| 32 | */ |
| 33 | typedef struct sqlite3_value Mem; |
| 34 | typedef struct SubProgram SubProgram; |
| 35 | typedef struct SubrtnSig SubrtnSig; |
| 36 | |
| 37 | /* |
| 38 | ** A signature for a reusable subroutine that materializes the RHS of |
| 39 | ** an IN operator. |
| 40 | */ |
| 41 | struct SubrtnSig { |
| 42 | int selId; /* SELECT-id for the SELECT statement on the RHS */ |
| 43 | u8 bComplete; /* True if fully coded and available for reusable */ |
| 44 | char *zAff; /* Affinity of the overall IN expression */ |
| 45 | int iTable; /* Ephemeral table generated by the subroutine */ |
| 46 | int iAddr; /* Subroutine entry address */ |
| 47 | int regReturn; /* Register used to hold return address */ |
| 48 | }; |
| 49 | |
| 50 | /* |
| 51 | ** A single instruction of the virtual machine has an opcode |
| 52 | ** and as many as three operands. The instruction is recorded |
| 53 | ** as an instance of the following structure: |
| 54 | */ |
| 55 | struct VdbeOp { |
| 56 | u8 opcode; /* What operation to perform */ |
| 57 | signed char p4type; /* One of the P4_xxx constants for p4 */ |
| 58 | u16 p5; /* Fifth parameter is an unsigned 16-bit integer */ |
| 59 | int p1; /* First operand */ |
| 60 | int p2; /* Second parameter (often the jump destination) */ |
| 61 | int p3; /* The third parameter */ |
| 62 | union p4union { /* fourth parameter */ |
| 63 | int i; /* Integer value if p4type==P4_INT32 */ |
| 64 | void *p; /* Generic pointer */ |
| 65 | char *z; /* Pointer to data for string (char array) types */ |
| 66 | FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */ |
| 67 | sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */ |
| 68 | CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ |
| 69 | Mem *pMem; /* Used when p4type is P4_MEM */ |
| 70 | VTable *pVtab; /* Used when p4type is P4_VTAB */ |
| 71 | KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ |
| 72 | u32 *ai; /* Used when p4type is P4_INTARRAY */ |
| 73 | SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ |
| 74 | Table *pTab; /* Used when p4type is P4_TABLE */ |
| 75 | SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */ |
| 76 | Index *pIdx; /* Used when p4type is P4_INDEX */ |
| 77 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 78 | Expr *pExpr; /* Used when p4type is P4_EXPR */ |
| 79 | #endif |
| 80 | } p4; |
| 81 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 82 | char *zComment; /* Comment to improve readability */ |
| 83 | #endif |
| 84 | #ifdef SQLITE_VDBE_COVERAGE |
| 85 | u32 iSrcLine; /* Source-code line that generated this opcode |
| 86 | ** with flags in the upper 8 bits */ |
| 87 | #endif |
| 88 | #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE) |
| 89 | u64 nExec; |
| 90 | u64 nCycle; |
| 91 | #endif |
| 92 | }; |
| 93 | typedef struct VdbeOp VdbeOp; |
| 94 | |
| 95 | |
| 96 | /* |
| 97 | ** A sub-routine used to implement a trigger program. |
| 98 | */ |
| 99 | struct SubProgram { |
| 100 | VdbeOp *aOp; /* Array of opcodes for sub-program */ |
| 101 | int nOp; /* Elements in aOp[] */ |
| 102 | int nMem; /* Number of memory cells required */ |
| 103 | int nCsr; /* Number of cursors required */ |
| 104 | u8 *aOnce; /* Array of OP_Once flags */ |
| 105 | void *token; /* id that may be used to recursive triggers */ |
| 106 | SubProgram *pNext; /* Next sub-program already visited */ |
| 107 | }; |
| 108 | |
| 109 | /* |
| 110 | ** A smaller version of VdbeOp used for the VdbeAddOpList() function because |
| 111 | ** it takes up less space. |
| 112 | */ |
| 113 | struct VdbeOpList { |
| 114 | u8 opcode; /* What operation to perform */ |
| 115 | signed char p1; /* First operand */ |
| 116 | signed char p2; /* Second parameter (often the jump destination) */ |
| 117 | signed char p3; /* Third parameter */ |
| 118 | }; |
| 119 | typedef struct VdbeOpList VdbeOpList; |
| 120 | |
| 121 | /* |
| 122 | ** Combine two int32 values into a single int64. The least significant |
| 123 | ** term comes first. |
| 124 | */ |
| 125 | #define INT32_TO_64(a,b) (i64)(((u64)(u32)(b)<<32)|(u32)(a)) |
| 126 | |
| 127 | /* |
| 128 | ** Return an int32 that is the lower or upper 32-bits of an int64. |
| 129 | */ |
| 130 | #define LOWER32(x) (int)(((u64)(x))&0xffffffff) |
| 131 | #define UPPER32(x) (int)(((u64)(x))>>32) |
| 132 | |
| 133 | |
| 134 | /* |
| 135 | ** Allowed values of VdbeOp.p4type |
| 136 | */ |
| 137 | #define P4_NOTUSED 0 /* The P4 parameter is not used */ |
| 138 | #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */ |
| 139 | #define P4_STATIC (-1) /* Pointer to a static string */ |
| 140 | #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */ |
| 141 | #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */ |
| 142 | #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */ |
| 143 | #define P4_TABLE (-5) /* P4 is a pointer to a Table structure */ |
| 144 | #define P4_INDEX (-6) /* P4 is a pointer to an Index structure */ |
| 145 | /* Above do not own any resources. Must free those below */ |
| 146 | #define P4_FREE_IF_LE (-7) |
| 147 | #define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */ |
| 148 | #define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */ |
| 149 | #define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */ |
| 150 | #define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */ |
| 151 | #define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */ |
| 152 | #define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */ |
| 153 | #define P4_INTARRAY (-13) /* P4 is a vector of 32-bit integers */ |
| 154 | #define P4_FUNCCTX (-14) /* P4 is a pointer to an sqlite3_context object */ |
| 155 | #define P4_TABLEREF (-15) /* Like P4_TABLE, but reference counted */ |
| 156 | #define P4_SUBRTNSIG (-16) /* P4 is a SubrtnSig pointer */ |
| 157 | |
| 158 | /* Error message codes for OP_Halt */ |
| 159 | #define P5_ConstraintNotNull 1 |
| 160 | #define P5_ConstraintUnique 2 |
| 161 | #define P5_ConstraintCheck 3 |
| 162 | #define P5_ConstraintFK 4 |
| 163 | |
| 164 | /* |
| 165 | ** The Vdbe.aColName array contains 5n Mem structures, where n is the |
| 166 | ** number of columns of data returned by the statement. |
| 167 | */ |
| 168 | #define COLNAME_NAME 0 |
| 169 | #define COLNAME_DECLTYPE 1 |
| 170 | #define COLNAME_DATABASE 2 |
| 171 | #define COLNAME_TABLE 3 |
| 172 | #define COLNAME_COLUMN 4 |
| 173 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 174 | # define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ |
| 175 | #else |
| 176 | # ifdef SQLITE_OMIT_DECLTYPE |
| 177 | # define COLNAME_N 1 /* Store only the name */ |
| 178 | # else |
| 179 | # define COLNAME_N 2 /* Store the name and decltype */ |
| 180 | # endif |
| 181 | #endif |
| 182 | |
| 183 | /* |
| 184 | ** The following macro converts a label returned by sqlite3VdbeMakeLabel() |
| 185 | ** into an index into the Parse.aLabel[] array that contains the resolved |
| 186 | ** address of that label. |
| 187 | */ |
| 188 | #define ADDR(X) (~(X)) |
| 189 | |
| 190 | /* |
| 191 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 192 | ** header file that defines a number for each opcode used by the VDBE. |
| 193 | */ |
| 194 | #include "opcodes.h" |
| 195 | |
| 196 | /* |
| 197 | ** Additional non-public SQLITE_PREPARE_* flags |
| 198 | */ |
| 199 | #define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */ |
| 200 | #define SQLITE_PREPARE_MASK 0x3f /* Mask of public flags */ |
| 201 | |
| 202 | /* |
| 203 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 204 | ** for a description of what each of these routines does. |
| 205 | */ |
| 206 | Vdbe *sqlite3VdbeCreate(Parse*); |
| 207 | Parse *sqlite3VdbeParser(Vdbe*); |
| 208 | int sqlite3VdbeAddOp0(Vdbe*,int); |
| 209 | int sqlite3VdbeAddOp1(Vdbe*,int,int); |
| 210 | int sqlite3VdbeAddOp2(Vdbe*,int,int,int); |
| 211 | int sqlite3VdbeGoto(Vdbe*,int); |
| 212 | int sqlite3VdbeLoadString(Vdbe*,int,const char*); |
| 213 | void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...); |
| 214 | int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); |
| 215 | int sqlite3VdbeAddInt64(Vdbe*,int,i64); |
| 216 | int sqlite3VdbeAddDouble(Vdbe*,int,double); |
| 217 | int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); |
| 218 | int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); |
| 219 | int sqlite3VdbeAddFunctionCall(Parse*,int,int,int,int,const FuncDef*,int); |
| 220 | void sqlite3VdbeEndCoroutine(Vdbe*,int); |
| 221 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) |
| 222 | void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N); |
| 223 | void sqlite3VdbeVerifyNoResultRow(Vdbe *p); |
| 224 | #else |
| 225 | # define sqlite3VdbeVerifyNoMallocRequired(A,B) |
| 226 | # define sqlite3VdbeVerifyNoResultRow(A) |
| 227 | #endif |
| 228 | #if defined(SQLITE_DEBUG) |
| 229 | void sqlite3VdbeVerifyAbortable(Vdbe *p, int); |
| 230 | void sqlite3VdbeNoJumpsOutsideSubrtn(Vdbe*,int,int,int); |
| 231 | #else |
| 232 | # define sqlite3VdbeVerifyAbortable(A,B) |
| 233 | # define sqlite3VdbeNoJumpsOutsideSubrtn(A,B,C,D) |
| 234 | #endif |
| 235 | VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno); |
| 236 | #ifndef SQLITE_OMIT_EXPLAIN |
| 237 | int sqlite3VdbeExplain(Parse*,u8,const char*,...); |
| 238 | void sqlite3VdbeExplainPop(Parse*); |
| 239 | int sqlite3VdbeExplainParent(Parse*); |
| 240 | # define ExplainQueryPlan(P) sqlite3VdbeExplain P |
| 241 | # ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 242 | # define ExplainQueryPlan2(V,P) (V = sqlite3VdbeExplain P) |
| 243 | # else |
| 244 | # define ExplainQueryPlan2(V,P) ExplainQueryPlan(P) |
| 245 | # endif |
| 246 | # define ExplainQueryPlanPop(P) sqlite3VdbeExplainPop(P) |
| 247 | # define ExplainQueryPlanParent(P) sqlite3VdbeExplainParent(P) |
| 248 | #else |
| 249 | # define ExplainQueryPlan(P) |
| 250 | # define ExplainQueryPlan2(V,P) |
| 251 | # define ExplainQueryPlanPop(P) |
| 252 | # define ExplainQueryPlanParent(P) 0 |
| 253 | # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ |
| 254 | #endif |
| 255 | #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN) |
| 256 | void sqlite3ExplainBreakpoint(const char*,const char*); |
| 257 | #else |
| 258 | # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ |
| 259 | #endif |
| 260 | void sqlite3VdbeAddParseSchemaOp(Vdbe*, int, char*, u16); |
| 261 | void sqlite3VdbeChangeOpcode(Vdbe*, int addr, u8); |
| 262 | void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); |
| 263 | void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); |
| 264 | void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); |
| 265 | void sqlite3VdbeChangeP5(Vdbe*, u16 P5); |
| 266 | void sqlite3VdbeTypeofColumn(Vdbe*, int); |
| 267 | void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| 268 | void sqlite3VdbeJumpHereOrPopInst(Vdbe*, int addr); |
| 269 | int sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
| 270 | int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); |
| 271 | #ifdef SQLITE_DEBUG |
| 272 | void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask, int); |
| 273 | #else |
| 274 | # define sqlite3VdbeReleaseRegisters(P,A,N,M,F) |
| 275 | #endif |
| 276 | void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
| 277 | void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); |
| 278 | void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
| 279 | void sqlite3VdbeUsesBtree(Vdbe*, int); |
| 280 | VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| 281 | VdbeOp *sqlite3VdbeGetLastOp(Vdbe*); |
| 282 | int sqlite3VdbeMakeLabel(Parse*); |
| 283 | void sqlite3VdbeRunOnlyOnce(Vdbe*); |
| 284 | void sqlite3VdbeReusable(Vdbe*); |
| 285 | void sqlite3VdbeDelete(Vdbe*); |
| 286 | void sqlite3VdbeMakeReady(Vdbe*,Parse*); |
| 287 | int sqlite3VdbeFinalize(Vdbe*); |
| 288 | void sqlite3VdbeResolveLabel(Vdbe*, int); |
| 289 | int sqlite3VdbeCurrentAddr(Vdbe*); |
| 290 | #ifdef SQLITE_DEBUG |
| 291 | int sqlite3VdbeAssertMayAbort(Vdbe *, int); |
| 292 | #endif |
| 293 | void sqlite3VdbeResetStepResult(Vdbe*); |
| 294 | void sqlite3VdbeRewind(Vdbe*); |
| 295 | int sqlite3VdbeReset(Vdbe*); |
| 296 | void sqlite3VdbeSetNumCols(Vdbe*,int); |
| 297 | int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); |
| 298 | void sqlite3VdbeCountChanges(Vdbe*); |
| 299 | sqlite3 *sqlite3VdbeDb(Vdbe*); |
| 300 | u8 sqlite3VdbePrepareFlags(Vdbe*); |
| 301 | void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8); |
| 302 | #ifdef SQLITE_ENABLE_NORMALIZE |
| 303 | void sqlite3VdbeAddDblquoteStr(sqlite3*,Vdbe*,const char*); |
| 304 | int sqlite3VdbeUsesDoubleQuotedString(Vdbe*,const char*); |
| 305 | #endif |
| 306 | void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
| 307 | VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); |
| 308 | sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8); |
| 309 | void sqlite3VdbeReprepareOnBind(Vdbe*, int, int); |
| 310 | #ifndef SQLITE_OMIT_TRACE |
| 311 | char *sqlite3VdbeExpandSql(Vdbe*, const char*); |
| 312 | #endif |
| 313 | int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); |
| 314 | int sqlite3BlobCompare(const Mem*, const Mem*); |
| 315 | #ifdef SQLITE_ENABLE_PERCENTILE |
| 316 | const char *sqlite3VdbeFuncName(const sqlite3_context*); |
| 317 | #endif |
| 318 | |
| 319 | void sqlite3VdbeRecordUnpack(int,const void*,UnpackedRecord*); |
| 320 | int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
| 321 | int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int); |
| 322 | UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*); |
| 323 | |
| 324 | typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); |
| 325 | RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); |
| 326 | |
| 327 | void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 328 | int sqlite3VdbeHasSubProgram(Vdbe*); |
| 329 | |
| 330 | void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val); |
| 331 | |
| 332 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 333 | int sqlite3NotPureFunc(sqlite3_context*); |
| 334 | #endif |
| 335 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 336 | int sqlite3VdbeBytecodeVtabInit(sqlite3*); |
| 337 | #endif |
| 338 | |
| 339 | /* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra |
| 340 | ** comments on each VDBE opcode. |
| 341 | ** |
| 342 | ** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op |
| 343 | ** comments in VDBE programs that show key decision points in the code |
| 344 | ** generator. |
| 345 | */ |
| 346 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 347 | void sqlite3VdbeComment(Vdbe*, const char*, ...); |
| 348 | # define VdbeComment(X) sqlite3VdbeComment X |
| 349 | void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); |
| 350 | # define VdbeNoopComment(X) sqlite3VdbeNoopComment X |
| 351 | # ifdef SQLITE_ENABLE_MODULE_COMMENTS |
| 352 | # define VdbeModuleComment(X) sqlite3VdbeNoopComment X |
| 353 | # else |
| 354 | # define VdbeModuleComment(X) |
| 355 | # endif |
| 356 | #else |
| 357 | # define VdbeComment(X) |
| 358 | # define VdbeNoopComment(X) |
| 359 | # define VdbeModuleComment(X) |
| 360 | #endif |
| 361 | |
| 362 | /* |
| 363 | ** The VdbeCoverage macros are used to set a coverage testing point |
| 364 | ** for VDBE branch instructions. The coverage testing points are line |
| 365 | ** numbers in the sqlite3.c source file. VDBE branch coverage testing |
| 366 | ** only works with an amalgamation build. That's ok since a VDBE branch |
| 367 | ** coverage build designed for testing the test suite only. No application |
| 368 | ** should ever ship with VDBE branch coverage measuring turned on. |
| 369 | ** |
| 370 | ** VdbeCoverage(v) // Mark the previously coded instruction |
| 371 | ** // as a branch |
| 372 | ** |
| 373 | ** VdbeCoverageIf(v, conditional) // Mark previous if conditional true |
| 374 | ** |
| 375 | ** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken |
| 376 | ** |
| 377 | ** VdbeCoverageNeverTaken(v) // Previous branch is never taken |
| 378 | ** |
| 379 | ** VdbeCoverageNeverNull(v) // Previous three-way branch is only |
| 380 | ** // taken on the first two ways. The |
| 381 | ** // NULL option is not possible |
| 382 | ** |
| 383 | ** VdbeCoverageEqNe(v) // Previous OP_Jump is only interested |
| 384 | ** // in distinguishing equal and not-equal. |
| 385 | ** |
| 386 | ** Every VDBE branch operation must be tagged with one of the macros above. |
| 387 | ** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and |
| 388 | ** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch() |
| 389 | ** routine in vdbe.c, alerting the developer to the missed tag. |
| 390 | ** |
| 391 | ** During testing, the test application will invoke |
| 392 | ** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback |
| 393 | ** routine that is invoked as each bytecode branch is taken. The callback |
| 394 | ** contains the sqlite3.c source line number of the VdbeCoverage macro and |
| 395 | ** flags to indicate whether or not the branch was taken. The test application |
| 396 | ** is responsible for keeping track of this and reporting byte-code branches |
| 397 | ** that are never taken. |
| 398 | ** |
| 399 | ** See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the |
| 400 | ** vdbe.c source file for additional information. |
| 401 | */ |
| 402 | #ifdef SQLITE_VDBE_COVERAGE |
| 403 | void sqlite3VdbeSetLineNumber(Vdbe*,int); |
| 404 | # define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__) |
| 405 | # define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__) |
| 406 | # define VdbeCoverageAlwaysTaken(v) \ |
| 407 | sqlite3VdbeSetLineNumber(v,__LINE__|0x5000000); |
| 408 | # define VdbeCoverageNeverTaken(v) \ |
| 409 | sqlite3VdbeSetLineNumber(v,__LINE__|0x6000000); |
| 410 | # define VdbeCoverageNeverNull(v) \ |
| 411 | sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000); |
| 412 | # define VdbeCoverageNeverNullIf(v,x) \ |
| 413 | if(x)sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000); |
| 414 | # define VdbeCoverageEqNe(v) \ |
| 415 | sqlite3VdbeSetLineNumber(v,__LINE__|0x8000000); |
| 416 | # define VDBE_OFFSET_LINENO(x) (__LINE__+x) |
| 417 | #else |
| 418 | # define VdbeCoverage(v) |
| 419 | # define VdbeCoverageIf(v,x) |
| 420 | # define VdbeCoverageAlwaysTaken(v) |
| 421 | # define VdbeCoverageNeverTaken(v) |
| 422 | # define VdbeCoverageNeverNull(v) |
| 423 | # define VdbeCoverageNeverNullIf(v,x) |
| 424 | # define VdbeCoverageEqNe(v) |
| 425 | # define VDBE_OFFSET_LINENO(x) 0 |
| 426 | #endif |
| 427 | |
| 428 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 429 | void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*); |
| 430 | void sqlite3VdbeScanStatusRange(Vdbe*, int, int, int); |
| 431 | void sqlite3VdbeScanStatusCounters(Vdbe*, int, int, int); |
| 432 | #else |
| 433 | # define sqlite3VdbeScanStatus(a,b,c,d,e,f) |
| 434 | # define sqlite3VdbeScanStatusRange(a,b,c,d) |
| 435 | # define sqlite3VdbeScanStatusCounters(a,b,c,d) |
| 436 | #endif |
| 437 | |
| 438 | #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) |
| 439 | void sqlite3VdbePrintOp(FILE*, int, VdbeOp*); |
| 440 | #endif |
| 441 | |
| 442 | #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG) |
| 443 | int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr); |
| 444 | #endif |
| 445 | |
| 446 | #endif /* SQLITE_VDBE_H */ |