OpenCoverage

whereexpr.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/whereexpr.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2** 2015-06-08-
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** This module contains C code that generates VDBE code used to process-
13** the WHERE clause of SQL statements.-
14**-
15** This file was originally part of where.c but was split out to improve-
16** readability and editabiliity. This file contains utility routines for-
17** analyzing Expr objects in the WHERE clause.-
18*/-
19#include "sqliteInt.h"-
20#include "whereInt.h"-
21-
22/* Forward declarations */-
23static void exprAnalyze(SrcList*, WhereClause*, int);-
24-
25/*-
26** Deallocate all memory associated with a WhereOrInfo object.-
27*/-
28static void whereOrInfoDelete(sqlite3 *db, WhereOrInfo *p){-
29 sqlite3WhereClauseClear(&p->wc);-
30 sqlite3DbFree(db, p);-
31}
executed 5128 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
5128
32-
33/*-
34** Deallocate all memory associated with a WhereAndInfo object.-
35*/-
36static void whereAndInfoDelete(sqlite3 *db, WhereAndInfo *p){-
37 sqlite3WhereClauseClear(&p->wc);-
38 sqlite3DbFree(db, p);-
39}
executed 11304 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
11304
40-
41/*-
42** Add a single new WhereTerm entry to the WhereClause object pWC.-
43** The new WhereTerm object is constructed from Expr p and with wtFlags.-
44** The index in pWC->a[] of the new WhereTerm is returned on success.-
45** 0 is returned if the new WhereTerm could not be added due to a memory-
46** allocation error. The memory allocation failure will be recorded in-
47** the db->mallocFailed flag so that higher-level functions can detect it.-
48**-
49** This routine will increase the size of the pWC->a[] array as necessary.-
50**-
51** If the wtFlags argument includes TERM_DYNAMIC, then responsibility-
52** for freeing the expression p is assumed by the WhereClause object pWC.-
53** This is true even if this routine fails to allocate a new WhereTerm.-
54**-
55** WARNING: This routine might reallocate the space used to store-
56** WhereTerms. All pointers to WhereTerms should be invalidated after-
57** calling this routine. Such pointers may be reinitialized by referencing-
58** the pWC->a[] array.-
59*/-
60static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){-
61 WhereTerm *pTerm;-
62 int idx;-
63 testcase( wtFlags & TERM_VIRTUAL );-
64 if( pWC->nTerm>=pWC->nSlot ){
pWC->nTerm>=pWC->nSlotDescription
TRUEevaluated 863 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 281009 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
863-281009
65 WhereTerm *pOld = pWC->a;-
66 sqlite3 *db = pWC->pWInfo->pParse->db;-
67 pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 );-
68 if( pWC->a==0 ){
pWC->a==0Description
TRUEnever evaluated
FALSEevaluated 863 times by 1 test
Evaluated by:
  • Self test (438)
0-863
69 if( wtFlags & TERM_DYNAMIC ){
wtFlags & 0x01Description
TRUEnever evaluated
FALSEnever evaluated
0
70 sqlite3ExprDelete(db, p);-
71 }
never executed: end of block
0
72 pWC->a = pOld;-
73 return 0;
never executed: return 0;
0
74 }-
75 memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);-
76 if( pOld!=pWC->aStatic ){
pOld!=pWC->aStaticDescription
TRUEevaluated 139 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 724 times by 1 test
Evaluated by:
  • Self test (438)
139-724
77 sqlite3DbFree(db, pOld);-
78 }
executed 139 times by 1 test: end of block
Executed by:
  • Self test (438)
139
79 pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);-
80 }
executed 863 times by 1 test: end of block
Executed by:
  • Self test (438)
863
81 pTerm = &pWC->a[idx = pWC->nTerm++];-
82 if( p && ExprHasProperty(p, EP_Unlikely) ){
pDescription
TRUEevaluated 281836 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test (438)
(((p)->flags&(0x040000))!=0)Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 281795 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
36-281836
83 pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;-
84 }else{
executed 41 times by 1 test: end of block
Executed by:
  • Self test (438)
41
85 pTerm->truthProb = 1;-
86 }
executed 281831 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
281831
87 pTerm->pExpr = sqlite3ExprSkipCollate(p);-
88 pTerm->wtFlags = wtFlags;-
89 pTerm->pWC = pWC;-
90 pTerm->iParent = -1;-
91 memset(&pTerm->eOperator, 0,-
92 sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));-
93 return idx;
executed 281872 times by 368 tests: return idx;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
281872
94}-
95-
96/*-
97** Return TRUE if the given operator is one of the operators that is-
98** allowed for an indexable WHERE clause term. The allowed operators are-
99** "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL"-
100*/-
101static int allowedOp(int op){-
102 assert( TK_GT>TK_EQ && TK_GT<TK_GE );-
103 assert( TK_LT>TK_EQ && TK_LT<TK_GE );-
104 assert( TK_LE>TK_EQ && TK_LE<TK_GE );-
105 assert( TK_GE==TK_EQ+4 );-
106 return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS;
executed 304991 times by 368 tests: return op==49 || (op>=53 && op<=57) || op==50 || op==45;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
op==49Description
TRUEevaluated 5561 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 299430 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
op>=53Description
TRUEevaluated 230815 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 68615 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
op<=57Description
TRUEevaluated 210152 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 20663 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (47)
op==50Description
TRUEevaluated 568 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 88710 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
op==45Description
TRUEevaluated 2992 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 85718 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
568-304991
107}-
108-
109/*-
110** Commute a comparison operator. Expressions of the form "X op Y"-
111** are converted into "Y op X".-
112**-
113** If left/right precedence rules come into play when determining the-
114** collating sequence, then COLLATE operators are adjusted to ensure-
115** that the collating sequence does not change. For example:-
116** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on-
117** the left hand side of a comparison overrides any collation sequence -
118** attached to the right. For the same reason the EP_Collate flag-
119** is not commuted.-
120*/-
121static void exprCommute(Parse *pParse, Expr *pExpr){-
122 u16 expRight = (pExpr->pRight->flags & EP_Collate);-
123 u16 expLeft = (pExpr->pLeft->flags & EP_Collate);-
124 assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );-
125 if( expRight==expLeft ){
expRight==expLeftDescription
TRUEevaluated 11654 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1062 times by 1 test
Evaluated by:
  • Self test (438)
1062-11654
126 /* Either X and Y both have COLLATE operator or neither do */-
127 if( expRight ){
expRightDescription
TRUEnever evaluated
FALSEevaluated 11654 times by 1 test
Evaluated by:
  • Self test (438)
0-11654
128 /* Both X and Y have COLLATE operators. Make sure X is always-
129 ** used by clearing the EP_Collate flag from Y. */-
130 pExpr->pRight->flags &= ~EP_Collate;-
131 }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){
never executed: end of block
sqlite3ExprCol...xpr->pLeft)!=0Description
TRUEevaluated 7966 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3688 times by 1 test
Evaluated by:
  • Self test (438)
0-7966
132 /* Neither X nor Y have COLLATE operators, but X has a non-default-
133 ** collating sequence. So add the EP_Collate marker on X to cause-
134 ** it to be searched first. */-
135 pExpr->pLeft->flags |= EP_Collate;-
136 }
executed 7966 times by 1 test: end of block
Executed by:
  • Self test (438)
7966
137 }
executed 11654 times by 1 test: end of block
Executed by:
  • Self test (438)
11654
138 SWAP(Expr*,pExpr->pRight,pExpr->pLeft);-
139 if( pExpr->op>=TK_GT ){
pExpr->op>=54Description
TRUEevaluated 5551 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 7165 times by 1 test
Evaluated by:
  • Self test (438)
5551-7165
140 assert( TK_LT==TK_GT+2 );-
141 assert( TK_GE==TK_LE+2 );-
142 assert( TK_GT>TK_EQ );-
143 assert( TK_GT<TK_LE );-
144 assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );-
145 pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;-
146 }
executed 5551 times by 1 test: end of block
Executed by:
  • Self test (438)
5551
147}
executed 12716 times by 1 test: end of block
Executed by:
  • Self test (438)
12716
148-
149/*-
150** Translate from TK_xx operator to WO_xx bitmask.-
151*/-
152static u16 operatorMask(int op){-
153 u16 c;-
154 assert( allowedOp(op) );-
155 if( op==TK_IN ){
op==49Description
TRUEevaluated 3714 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 195992 times by 36 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
3714-195992
156 c = WO_IN;-
157 }else if( op==TK_ISNULL ){
executed 3714 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
op==50Description
TRUEevaluated 464 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 195528 times by 36 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
464-195528
158 c = WO_ISNULL;-
159 }else if( op==TK_IS ){
executed 464 times by 1 test: end of block
Executed by:
  • Self test (438)
op==45Description
TRUEevaluated 2365 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 193163 times by 36 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
464-193163
160 c = WO_IS;-
161 }else{
executed 2365 times by 1 test: end of block
Executed by:
  • Self test (438)
2365
162 assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff );-
163 c = (u16)(WO_EQ<<(op-TK_EQ));-
164 }
executed 193163 times by 36 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
193163
165 assert( op!=TK_ISNULL || c==WO_ISNULL );-
166 assert( op!=TK_IN || c==WO_IN );-
167 assert( op!=TK_EQ || c==WO_EQ );-
168 assert( op!=TK_LT || c==WO_LT );-
169 assert( op!=TK_LE || c==WO_LE );-
170 assert( op!=TK_GT || c==WO_GT );-
171 assert( op!=TK_GE || c==WO_GE );-
172 assert( op!=TK_IS || c==WO_IS );-
173 return c;
executed 199706 times by 36 tests: return c;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
199706
174}-
175-
176-
177#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION-
178/*-
179** Check to see if the given expression is a LIKE or GLOB operator that-
180** can be optimized using inequality constraints. Return TRUE if it is-
181** so and false if not.-
182**-
183** In order for the operator to be optimizible, the RHS must be a string-
184** literal that does not begin with a wildcard. The LHS must be a column-
185** that may only be NULL, a string, or a BLOB, never a number. (This means-
186** that virtual tables cannot participate in the LIKE optimization.) The-
187** collating sequence for the column on the LHS must be appropriate for-
188** the operator.-
189*/-
190static int isLikeOrGlob(-
191 Parse *pParse, /* Parsing and code generating context */-
192 Expr *pExpr, /* Test this expression */-
193 Expr **ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */-
194 int *pisComplete, /* True if the only wildcard is % in the last character */-
195 int *pnoCase /* True if uppercase is equivalent to lowercase */-
196){-
197 const u8 *z = 0; /* String on RHS of LIKE operator */-
198 Expr *pRight, *pLeft; /* Right and left size of LIKE operator */-
199 ExprList *pList; /* List of operands to the LIKE operator */-
200 u8 c; /* One character in z[] */-
201 int cnt; /* Number of non-wildcard prefix characters */-
202 u8 wc[4]; /* Wildcard characters */-
203 sqlite3 *db = pParse->db; /* Database connection */-
204 sqlite3_value *pVal = 0;-
205 int op; /* Opcode of pRight */-
206 int rc; /* Result code to return */-
207-
208 if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, (char*)wc) ){
!sqlite3IsLike...se, (char*)wc)Description
TRUEevaluated 236929 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 11458 times by 1 test
Evaluated by:
  • Self test (438)
11458-236929
209 return 0;
executed 236929 times by 368 tests: return 0;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
236929
210 }-
211#ifdef SQLITE_EBCDIC-
212 if( *pnoCase ) return 0;-
213#endif-
214 pList = pExpr->x.pList;-
215 pLeft = pList->a[1].pExpr;-
216-
217 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);-
218 op = pRight->op;-
219 if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){
op==144Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11442 times by 1 test
Evaluated by:
  • Self test (438)
(db->flags & 0x00800000)==0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-11442
220 Vdbe *pReprepare = pParse->pReprepare;-
221 int iCol = pRight->iColumn;-
222 pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);-
223 if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
pValDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3_value_type(pVal)==3Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-10
224 z = sqlite3_value_text(pVal);-
225 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
226 sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);-
227 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );-
228 }else if( op==TK_STRING ){
executed 14 times by 1 test: end of block
Executed by:
  • Self test (438)
op==106Description
TRUEevaluated 11430 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
14-11430
229 z = (u8*)pRight->u.zToken;-
230 }
executed 11430 times by 1 test: end of block
Executed by:
  • Self test (438)
11430
231 if( z ){
zDescription
TRUEevaluated 11434 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
24-11434
232-
233 /* Count the number of prefix characters prior to the first wildcard */-
234 cnt = 0;-
235 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
(c=z[cnt])!=0Description
TRUEevaluated 35777 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test (438)
c!=wc[0]Description
TRUEevaluated 25372 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10405 times by 1 test
Evaluated by:
  • Self test (438)
c!=wc[1]Description
TRUEevaluated 24378 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 994 times by 1 test
Evaluated by:
  • Self test (438)
c!=wc[2]Description
TRUEevaluated 24376 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-35777
236 cnt++;-
237 if( c==wc[3] && z[cnt]!=0 ) cnt++;
executed 10 times by 1 test: cnt++;
Executed by:
  • Self test (438)
c==wc[3]Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24363 times by 1 test
Evaluated by:
  • Self test (438)
z[cnt]!=0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
3-24363
238 }
executed 24376 times by 1 test: end of block
Executed by:
  • Self test (438)
24376
239-
240 /* The optimization is possible only if (1) the pattern does not begin-
241 ** with a wildcard and if (2) the non-wildcard prefix does not end with-
242 ** an (illegal 0xff) character, or (3) the pattern does not consist of-
243 ** a single escape character. The second condition is necessary so-
244 ** that we can increment the prefix key to find an upper bound for the-
245 ** range search. The third is because the caller assumes that the pattern-
246 ** consists of at least one character after all escapes have been-
247 ** removed. */-
248 if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){
cnt!=0Description
TRUEevaluated 5350 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6084 times by 1 test
Evaluated by:
  • Self test (438)
255!=(u8)z[cnt-1]Description
TRUEevaluated 5347 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
cnt>1Description
TRUEevaluated 5109 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 238 times by 1 test
Evaluated by:
  • Self test (438)
z[0]!=wc[3]Description
TRUEevaluated 235 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
3-6084
249 Expr *pPrefix;-
250-
251 /* A "complete" match if the pattern ends with "*" or "%" */-
252 *pisComplete = c==wc[0] && z[cnt+1]==0;
c==wc[0]Description
TRUEevaluated 5301 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test (438)
z[cnt+1]==0Description
TRUEevaluated 5295 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
6-5301
253-
254 /* Get the pattern prefix. Remove all escapes from the prefix. */-
255 pPrefix = sqlite3Expr(db, TK_STRING, (char*)z);-
256 if( pPrefix ){
pPrefixDescription
TRUEevaluated 5344 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-5344
257 int iFrom, iTo;-
258 char *zNew = pPrefix->u.zToken;-
259 zNew[cnt] = 0;-
260 for(iFrom=iTo=0; iFrom<cnt; iFrom++){
iFrom<cntDescription
TRUEevaluated 24370 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5344 times by 1 test
Evaluated by:
  • Self test (438)
5344-24370
261 if( zNew[iFrom]==wc[3] ) iFrom++;
executed 10 times by 1 test: iFrom++;
Executed by:
  • Self test (438)
zNew[iFrom]==wc[3]Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24360 times by 1 test
Evaluated by:
  • Self test (438)
10-24360
262 zNew[iTo++] = zNew[iFrom];-
263 }
executed 24370 times by 1 test: end of block
Executed by:
  • Self test (438)
24370
264 zNew[iTo] = 0;-
265-
266 /* If the RHS begins with a digit or a minus sign, then the LHS must be-
267 ** an ordinary column (not a virtual table column) with TEXT affinity.-
268 ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false-
269 ** even though "lhs LIKE rhs" is true. But if the RHS does not start-
270 ** with a digit or '-', then "lhs LIKE rhs" will always be false if-
271 ** the LHS is numeric and so the optimization still works.-
272 **-
273 ** 2018-09-10 ticket c94369cae9b561b1f996d0054bfab11389f9d033-
274 ** The RHS pattern must not be '/%' because the termination condition-
275 ** will then become "x<'0'" and if the affinity is numeric, will then-
276 ** be converted into "x<0", which is incorrect.-
277 */-
278 if( sqlite3Isdigit(zNew[0])
(sqlite3CtypeM...New[0])]&0x04)Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5288 times by 1 test
Evaluated by:
  • Self test (438)
56-5288
279 || zNew[0]=='-'
zNew[0]=='-'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5285 times by 1 test
Evaluated by:
  • Self test (438)
3-5285
280 || (zNew[0]+1=='0' && iTo==1)
zNew[0]+1=='0'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5274 times by 1 test
Evaluated by:
  • Self test (438)
iTo==1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
5-5274
281 ){-
282 if( pLeft->op!=TK_COLUMN
pLeft->op!=158Description
TRUEnever evaluated
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test (438)
0-65
283 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
sqlite3ExprAff...ty(pLeft)!='B'Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
8-57
284 || IsVirtual(pLeft->y.pTab) /* Value might be numeric */
((pLeft->y.pTab)->nModuleArg)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-6
285 ){-
286 sqlite3ExprDelete(db, pPrefix);-
287 sqlite3ValueFree(pVal);-
288 return 0;
executed 63 times by 1 test: return 0;
Executed by:
  • Self test (438)
63
289 }-
290 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test (438)
2
291 }
executed 5281 times by 1 test: end of block
Executed by:
  • Self test (438)
5281
292 *ppPrefix = pPrefix;-
293-
294 /* If the RHS pattern is a bound parameter, make arrangements to-
295 ** reprepare the statement when that parameter is rebound */-
296 if( op==TK_VARIABLE ){
op==144Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5277 times by 1 test
Evaluated by:
  • Self test (438)
4-5277
297 Vdbe *v = pParse->pVdbe;-
298 sqlite3VdbeSetVarmask(v, pRight->iColumn);-
299 if( *pisComplete && pRight->u.zToken[1] ){
*pisCompleteDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
pRight->u.zToken[1]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-4
300 /* If the rhs of the LIKE expression is a variable, and the current-
301 ** value of the variable means there is no need to invoke the LIKE-
302 ** function, then no OP_Variable will be added to the program.-
303 ** This causes problems for the sqlite3_bind_parameter_name()-
304 ** API. To work around them, add a dummy OP_Variable here.-
305 */ -
306 int r1 = sqlite3GetTempReg(pParse);-
307 sqlite3ExprCodeTarget(pParse, pRight, r1);-
308 sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);-
309 sqlite3ReleaseTempReg(pParse, r1);-
310 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
311 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
312 }else{
executed 5281 times by 1 test: end of block
Executed by:
  • Self test (438)
5281
313 z = 0;-
314 }
executed 6090 times by 1 test: end of block
Executed by:
  • Self test (438)
6090
315 }-
316-
317 rc = (z!=0);-
318 sqlite3ValueFree(pVal);-
319 return rc;
executed 11395 times by 1 test: return rc;
Executed by:
  • Self test (438)
11395
320}-
321#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */-
322-
323-
324#ifndef SQLITE_OMIT_VIRTUALTABLE-
325/*-
326** Check to see if the pExpr expression is a form that needs to be passed-
327** to the xBestIndex method of virtual tables. Forms of interest include:-
328**-
329** Expression Virtual Table Operator-
330** ----------------------- ----------------------------------
331** 1. column MATCH expr SQLITE_INDEX_CONSTRAINT_MATCH-
332** 2. column GLOB expr SQLITE_INDEX_CONSTRAINT_GLOB-
333** 3. column LIKE expr SQLITE_INDEX_CONSTRAINT_LIKE-
334** 4. column REGEXP expr SQLITE_INDEX_CONSTRAINT_REGEXP-
335** 5. column != expr SQLITE_INDEX_CONSTRAINT_NE-
336** 6. expr != column SQLITE_INDEX_CONSTRAINT_NE-
337** 7. column IS NOT expr SQLITE_INDEX_CONSTRAINT_ISNOT-
338** 8. expr IS NOT column SQLITE_INDEX_CONSTRAINT_ISNOT-
339** 9. column IS NOT NULL SQLITE_INDEX_CONSTRAINT_ISNOTNULL-
340**-
341** In every case, "column" must be a column of a virtual table. If there-
342** is a match, set *ppLeft to the "column" expression, set *ppRight to the -
343** "expr" expression (even though in forms (6) and (8) the column is on the-
344** right and the expression is on the left). Also set *peOp2 to the-
345** appropriate virtual table operator. The return value is 1 or 2 if there-
346** is a match. The usual return is 1, but if the RHS is also a column-
347** of virtual table in forms (5) or (7) then return 2.-
348**-
349** If the expression matches none of the patterns above, return 0.-
350*/-
351static int isAuxiliaryVtabOperator(-
352 sqlite3 *db, /* Parsing context */-
353 Expr *pExpr, /* Test this expression */-
354 unsigned char *peOp2, /* OUT: 0 for MATCH, or else an op2 value */-
355 Expr **ppLeft, /* Column expression to left of MATCH/op2 */-
356 Expr **ppRight /* Expression to left of MATCH/op2 */-
357){-
358 if( pExpr->op==TK_FUNCTION ){
pExpr->op==157Description
TRUEevaluated 11590 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 236797 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
11590-236797
359 static const struct Op2 {-
360 const char *zOp;-
361 unsigned char eOp2;-
362 } aOp[] = {-
363 { "match", SQLITE_INDEX_CONSTRAINT_MATCH },-
364 { "glob", SQLITE_INDEX_CONSTRAINT_GLOB },-
365 { "like", SQLITE_INDEX_CONSTRAINT_LIKE },-
366 { "regexp", SQLITE_INDEX_CONSTRAINT_REGEXP }-
367 };-
368 ExprList *pList;-
369 Expr *pCol; /* Column reference */-
370 int i;-
371-
372 pList = pExpr->x.pList;-
373 if( pList==0 || pList->nExpr!=2 ){
pList==0Description
TRUEnever evaluated
FALSEevaluated 11590 times by 1 test
Evaluated by:
  • Self test (438)
pList->nExpr!=2Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11558 times by 1 test
Evaluated by:
  • Self test (438)
0-11590
374 return 0;
executed 32 times by 1 test: return 0;
Executed by:
  • Self test (438)
32
375 }-
376-
377 /* Built-in operators MATCH, GLOB, LIKE, and REGEXP attach to a-
378 ** virtual table on their second argument, which is the same as-
379 ** the left-hand side operand in their in-fix form.-
380 **-
381 ** vtab_column MATCH expression-
382 ** MATCH(expression,vtab_column)-
383 */-
384 pCol = pList->a[1].pExpr;-
385 if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
pCol->op==158Description
TRUEevaluated 11529 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
((pCol->y.pTab)->nModuleArg)Description
TRUEevaluated 104 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11425 times by 1 test
Evaluated by:
  • Self test (438)
29-11529
386 for(i=0; i<ArraySize(aOp); i++){
i<((int)(sizeo...zeof(aOp[0])))Description
TRUEevaluated 176 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-176
387 if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
sqlite3StrICmp...aOp[i].zOp)==0Description
TRUEevaluated 104 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
72-104
388 *peOp2 = aOp[i].eOp2;-
389 *ppRight = pList->a[0].pExpr;-
390 *ppLeft = pCol;-
391 return 1;
executed 104 times by 1 test: return 1;
Executed by:
  • Self test (438)
104
392 }-
393 }
executed 72 times by 1 test: end of block
Executed by:
  • Self test (438)
72
394 }
never executed: end of block
0
395-
396 /* We can also match against the first column of overloaded-
397 ** functions where xFindFunction returns a value of at least-
398 ** SQLITE_INDEX_CONSTRAINT_FUNCTION.-
399 **-
400 ** OVERLOADED(vtab_column,expression)-
401 **-
402 ** Historically, xFindFunction expected to see lower-case function-
403 ** names. But for this use case, xFindFunction is expected to deal-
404 ** with function names in an arbitrary case.-
405 */-
406 pCol = pList->a[0].pExpr;-
407 if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
pCol->op==158Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11448 times by 1 test
Evaluated by:
  • Self test (438)
((pCol->y.pTab)->nModuleArg)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
0-11448
408 sqlite3_vtab *pVtab;-
409 sqlite3_module *pMod;-
410 void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);-
411 void *pNotUsed;-
412 pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab;-
413 assert( pVtab!=0 );-
414 assert( pVtab->pModule!=0 );-
415 pMod = (sqlite3_module *)pVtab->pModule;-
416 if( pMod->xFindFunction!=0 ){
pMod->xFindFunction!=0Description
TRUEnever evaluated
FALSEnever evaluated
0
417 i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);-
418 if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){
i>=150Description
TRUEnever evaluated
FALSEnever evaluated
0
419 *peOp2 = i;-
420 *ppRight = pList->a[1].pExpr;-
421 *ppLeft = pCol;-
422 return 1;
never executed: return 1;
0
423 }-
424 }
never executed: end of block
0
425 }
never executed: end of block
0
426 }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){
executed 11454 times by 1 test: end of block
Executed by:
  • Self test (438)
pExpr->op==52Description
TRUEevaluated 24223 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
FALSEevaluated 212574 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
pExpr->op==156Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 212566 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
pExpr->op==51Description
TRUEevaluated 4748 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 207818 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
8-212574
427 int res = 0;-
428 Expr *pLeft = pExpr->pLeft;-
429 Expr *pRight = pExpr->pRight;-
430 if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->y.pTab) ){
pLeft->op==158Description
TRUEevaluated 28381 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
FALSEevaluated 598 times by 1 test
Evaluated by:
  • Self test (438)
((pLeft->y.pTab)->nModuleArg)Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28350 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
31-28381
431 res++;-
432 }
executed 31 times by 1 test: end of block
Executed by:
  • Self test (438)
31
433 if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->y.pTab) ){
pRightDescription
TRUEevaluated 24231 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
FALSEevaluated 4748 times by 1 test
Evaluated by:
  • Self test (438)
pRight->op==158Description
TRUEevaluated 582 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 23649 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
((pRight->y.pTab)->nModuleArg)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 577 times by 1 test
Evaluated by:
  • Self test (438)
5-24231
434 res++;-
435 SWAP(Expr*, pLeft, pRight);-
436 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
5
437 *ppLeft = pLeft;-
438 *ppRight = pRight;-
439 if( pExpr->op==TK_NE ) *peOp2 = SQLITE_INDEX_CONSTRAINT_NE;
executed 24223 times by 28 tests: *peOp2 = 68;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
pExpr->op==52Description
TRUEevaluated 24223 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
FALSEevaluated 4756 times by 1 test
Evaluated by:
  • Self test (438)
4756-24223
440 if( pExpr->op==TK_ISNOT ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOT;
executed 8 times by 1 test: *peOp2 = 69;
Executed by:
  • Self test (438)
pExpr->op==156Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28971 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
8-28971
441 if( pExpr->op==TK_NOTNULL ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOTNULL;
executed 4748 times by 1 test: *peOp2 = 70;
Executed by:
  • Self test (438)
pExpr->op==51Description
TRUEevaluated 4748 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24231 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
4748-24231
442 return res;
executed 28979 times by 28 tests: return res;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
28979
443 }-
444 return 0;
executed 219272 times by 368 tests: return 0;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
219272
445}-
446#endif /* SQLITE_OMIT_VIRTUALTABLE */-
447-
448/*-
449** If the pBase expression originated in the ON or USING clause of-
450** a join, then transfer the appropriate markings over to derived.-
451*/-
452static void transferJoinMarkings(Expr *pDerived, Expr *pBase){-
453 if( pDerived ){
pDerivedDescription
TRUEevaluated 25358 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test (438)
36-25358
454 pDerived->flags |= pBase->flags & EP_FromJoin;-
455 pDerived->iRightJoinTable = pBase->iRightJoinTable;-
456 }
executed 25358 times by 1 test: end of block
Executed by:
  • Self test (438)
25358
457}
executed 25394 times by 1 test: end of block
Executed by:
  • Self test (438)
25394
458-
459/*-
460** Mark term iChild as being a child of term iParent-
461*/-
462static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){-
463 pWC->a[iChild].iParent = iParent;-
464 pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;-
465 pWC->a[iParent].nChild++;-
466}
executed 31000 times by 1 test: end of block
Executed by:
  • Self test (438)
31000
467-
468/*-
469** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not-
470** a conjunction, then return just pTerm when N==0. If N is exceeds-
471** the number of available subterms, return NULL.-
472*/-
473static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){-
474 if( pTerm->eOperator!=WO_AND ){
pTerm->eOperator!=0x0400Description
TRUEevaluated 3480 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 5932 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
3480-5932
475 return N==0 ? pTerm : 0;
executed 3480 times by 2 tests: return N==0 ? pTerm : 0;
Executed by:
  • Self test (34)
  • Self test (438)
N==0Description
TRUEevaluated 1740 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1740 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
1740-3480
476 }-
477 if( N<pTerm->u.pAndInfo->wc.nTerm ){
N<pTerm->u.pAndInfo->wc.nTermDescription
TRUEevaluated 4329 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1603 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
1603-4329
478 return &pTerm->u.pAndInfo->wc.a[N];
executed 4329 times by 2 tests: return &pTerm->u.pAndInfo->wc.a[N];
Executed by:
  • Self test (34)
  • Self test (438)
4329
479 }-
480 return 0;
executed 1603 times by 2 tests: return 0;
Executed by:
  • Self test (34)
  • Self test (438)
1603
481}-
482-
483/*-
484** Subterms pOne and pTwo are contained within WHERE clause pWC. The-
485** two subterms are in disjunction - they are OR-ed together.-
486**-
487** If these two terms are both of the form: "A op B" with the same-
488** A and B values but different operators and if the operators are-
489** compatible (if one is = and the other is <, for example) then-
490** add a new virtual AND term to pWC that is the combination of the-
491** two.-
492**-
493** Some examples:-
494**-
495** x<y OR x=y --> x<=y-
496** x=y OR x=y --> x=y-
497** x<=y OR x<y --> x<=y-
498**-
499** The following is NOT generated:-
500**-
501** x<y OR x>y --> x!=y -
502*/-
503static void whereCombineDisjuncts(-
504 SrcList *pSrc, /* the FROM clause */-
505 WhereClause *pWC, /* The complete WHERE clause */-
506 WhereTerm *pOne, /* First disjunct */-
507 WhereTerm *pTwo /* Second disjunct */-
508){-
509 u16 eOp = pOne->eOperator | pTwo->eOperator;-
510 sqlite3 *db; /* Database connection (for malloc) */-
511 Expr *pNew; /* New virtual expression */-
512 int op; /* Operator for the combined expression */-
513 int idxNew; /* Index in pWC of the next virtual term */-
514-
515 if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
executed 2259 times by 2 tests: return;
Executed by:
  • Self test (34)
  • Self test (438)
(pOne->eOperat...(57 -53))))==0Description
TRUEevaluated 2259 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1793 times by 1 test
Evaluated by:
  • Self test (438)
1793-2259
516 if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
executed 537 times by 1 test: return;
Executed by:
  • Self test (438)
(pTwo->eOperat...(57 -53))))==0Description
TRUEevaluated 537 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1256 times by 1 test
Evaluated by:
  • Self test (438)
537-1256
517 if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
(eOp & (0x0002...5 -53))))!=eOpDescription
TRUEevaluated 496 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 760 times by 1 test
Evaluated by:
  • Self test (438)
496-760
518 && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
executed 197 times by 1 test: return;
Executed by:
  • Self test (438)
(eOp & (0x0002...7 -53))))!=eOpDescription
TRUEevaluated 197 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 299 times by 1 test
Evaluated by:
  • Self test (438)
197-299
519 assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );-
520 assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );-
521 if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
executed 761 times by 1 test: return;
Executed by:
  • Self test (438)
sqlite3ExprCom...pr->pLeft, -1)Description
TRUEevaluated 761 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 298 times by 1 test
Evaluated by:
  • Self test (438)
298-761
522 if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;
executed 260 times by 1 test: return;
Executed by:
  • Self test (438)
sqlite3ExprCom...pr->pRight,-1)Description
TRUEevaluated 260 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test (438)
38-260
523 /* If we reach this point, it means the two subterms can be combined */-
524 if( (eOp & (eOp-1))!=0 ){
(eOp & (eOp-1))!=0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
12-26
525 if( eOp & (WO_LT|WO_LE) ){
eOp & ((0x0002...02<<(55 -53)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
6-20
526 eOp = WO_LE;-
527 }else{
executed 6 times by 1 test: end of block
Executed by:
  • Self test (438)
6
528 assert( eOp & (WO_GT|WO_GE) );-
529 eOp = WO_GE;-
530 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test (438)
20
531 }-
532 db = pWC->pWInfo->pParse->db;-
533 pNew = sqlite3ExprDup(db, pOne->pExpr, 0);-
534 if( pNew==0 ) return;
never executed: return;
pNew==0Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test (438)
0-38
535 for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }
executed 92 times by 1 test: end of block
Executed by:
  • Self test (438)
eOp!=(0x0002<<(op-53))Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test (438)
38-92
536 pNew->op = op;-
537 idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);-
538 exprAnalyze(pSrc, pWC, idxNew);-
539}
executed 38 times by 1 test: end of block
Executed by:
  • Self test (438)
38
540-
541#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)-
542/*-
543** Analyze a term that consists of two or more OR-connected-
544** subterms. So in:-
545**-
546** ... WHERE (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13)-
547** ^^^^^^^^^^^^^^^^^^^^-
548**-
549** This routine analyzes terms such as the middle term in the above example.-
550** A WhereOrTerm object is computed and attached to the term under-
551** analysis, regardless of the outcome of the analysis. Hence:-
552**-
553** WhereTerm.wtFlags |= TERM_ORINFO-
554** WhereTerm.u.pOrInfo = a dynamically allocated WhereOrTerm object-
555**-
556** The term being analyzed must have two or more of OR-connected subterms.-
557** A single subterm might be a set of AND-connected sub-subterms.-
558** Examples of terms under analysis:-
559**-
560** (A) t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5-
561** (B) x=expr1 OR expr2=x OR x=expr3-
562** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)-
563** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')-
564** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)-
565** (F) x>A OR (x=A AND y>=B)-
566**-
567** CASE 1:-
568**-
569** If all subterms are of the form T.C=expr for some single column of C and-
570** a single table T (as shown in example B above) then create a new virtual-
571** term that is an equivalent IN expression. In other words, if the term-
572** being analyzed is:-
573**-
574** x = expr1 OR expr2 = x OR x = expr3-
575**-
576** then create a new virtual term like this:-
577**-
578** x IN (expr1,expr2,expr3)-
579**-
580** CASE 2:-
581**-
582** If there are exactly two disjuncts and one side has x>A and the other side-
583** has x=A (for the same x and A) then add a new virtual conjunct term to the-
584** WHERE clause of the form "x>=A". Example:-
585**-
586** x>A OR (x=A AND y>B) adds: x>=A-
587**-
588** The added conjunct can sometimes be helpful in query planning.-
589**-
590** CASE 3:-
591**-
592** If all subterms are indexable by a single table T, then set-
593**-
594** WhereTerm.eOperator = WO_OR-
595** WhereTerm.u.pOrInfo->indexable |= the cursor number for table T-
596**-
597** A subterm is "indexable" if it is of the form-
598** "T.C <op> <expr>" where C is any column of table T and -
599** <op> is one of "=", "<", "<=", ">", ">=", "IS NULL", or "IN".-
600** A subterm is also indexable if it is an AND of two or more-
601** subsubterms at least one of which is indexable. Indexable AND -
602** subterms have their eOperator set to WO_AND and they have-
603** u.pAndInfo set to a dynamically allocated WhereAndTerm object.-
604**-
605** From another point of view, "indexable" means that the subterm could-
606** potentially be used with an index if an appropriate index exists.-
607** This analysis does not consider whether or not the index exists; that-
608** is decided elsewhere. This analysis only looks at whether subterms-
609** appropriate for indexing exist.-
610**-
611** All examples A through E above satisfy case 3. But if a term-
612** also satisfies case 1 (such as B) we know that the optimizer will-
613** always prefer case 1, so in that case we pretend that case 3 is not-
614** satisfied.-
615**-
616** It might be the case that multiple tables are indexable. For example,-
617** (E) above is indexable on tables P, Q, and R.-
618**-
619** Terms that satisfy case 3 are candidates for lookup by using-
620** separate indices to find rowids for each subterm and composing-
621** the union of all rowids using a RowSet object. This is similar-
622** to "bitmap indices" in other database engines.-
623**-
624** OTHERWISE:-
625**-
626** If none of cases 1, 2, or 3 apply, then leave the eOperator set to-
627** zero. This term is not useful for search.-
628*/-
629static void exprAnalyzeOrTerm(-
630 SrcList *pSrc, /* the FROM clause */-
631 WhereClause *pWC, /* the complete WHERE clause */-
632 int idxTerm /* Index of the OR-term to be analyzed */-
633){-
634 WhereInfo *pWInfo = pWC->pWInfo; /* WHERE clause processing context */-
635 Parse *pParse = pWInfo->pParse; /* Parser context */-
636 sqlite3 *db = pParse->db; /* Database connection */-
637 WhereTerm *pTerm = &pWC->a[idxTerm]; /* The term to be analyzed */-
638 Expr *pExpr = pTerm->pExpr; /* The expression of the term */-
639 int i; /* Loop counters */-
640 WhereClause *pOrWc; /* Breakup of pTerm into subterms */-
641 WhereTerm *pOrTerm; /* A Sub-term within the pOrWc */-
642 WhereOrInfo *pOrInfo; /* Additional information associated with pTerm */-
643 Bitmask chngToIN; /* Tables that might satisfy case 1 */-
644 Bitmask indexable; /* Tables that are indexable, satisfying case 2 */-
645-
646 /*-
647 ** Break the OR clause into its separate subterms. The subterms are-
648 ** stored in a WhereClause structure containing within the WhereOrInfo-
649 ** object that is attached to the original OR clause term.-
650 */-
651 assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );-
652 assert( pExpr->op==TK_OR );-
653 pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));-
654 if( pOrInfo==0 ) return;
never executed: return;
pOrInfo==0Description
TRUEnever evaluated
FALSEevaluated 5128 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
0-5128
655 pTerm->wtFlags |= TERM_ORINFO;-
656 pOrWc = &pOrInfo->wc;-
657 memset(pOrWc->aStatic, 0, sizeof(pOrWc->aStatic));-
658 sqlite3WhereClauseInit(pOrWc, pWInfo);-
659 sqlite3WhereSplit(pOrWc, pExpr, TK_OR);-
660 sqlite3WhereExprAnalyze(pSrc, pOrWc);-
661 if( db->mallocFailed ) return;
never executed: return;
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 5128 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
0-5128
662 assert( pOrWc->nTerm>=2 );-
663-
664 /*-
665 ** Compute the set of tables that might satisfy cases 1 or 3.-
666 */-
667 indexable = ~(Bitmask)0;-
668 chngToIN = ~(Bitmask)0;-
669 for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0 && indexable; i--, pOrTerm++){
i>=0Description
TRUEevaluated 24293 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 4067 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
indexableDescription
TRUEevaluated 23232 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1061 times by 1 test
Evaluated by:
  • Self test (438)
1061-24293
670 if( (pOrTerm->eOperator & WO_SINGLE)==0 ){
(pOrTerm->eOpe...r & 0x01ff)==0Description
TRUEevaluated 11304 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 11928 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
11304-11928
671 WhereAndInfo *pAndInfo;-
672 assert( (pOrTerm->wtFlags & (TERM_ANDINFO|TERM_ORINFO))==0 );-
673 chngToIN = 0;-
674 pAndInfo = sqlite3DbMallocRawNN(db, sizeof(*pAndInfo));-
675 if( pAndInfo ){
pAndInfoDescription
TRUEevaluated 11304 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEnever evaluated
0-11304
676 WhereClause *pAndWC;-
677 WhereTerm *pAndTerm;-
678 int j;-
679 Bitmask b = 0;-
680 pOrTerm->u.pAndInfo = pAndInfo;-
681 pOrTerm->wtFlags |= TERM_ANDINFO;-
682 pOrTerm->eOperator = WO_AND;-
683 pAndWC = &pAndInfo->wc;-
684 memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));-
685 sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);-
686 sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);-
687 sqlite3WhereExprAnalyze(pSrc, pAndWC);-
688 pAndWC->pOuter = pWC;-
689 if( !db->mallocFailed ){
!db->mallocFailedDescription
TRUEevaluated 11304 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEnever evaluated
0-11304
690 for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
j<pAndWC->nTermDescription
TRUEevaluated 32555 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 11304 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
11304-32555
691 assert( pAndTerm->pExpr );-
692 if( allowedOp(pAndTerm->pExpr->op)
allowedOp(pAndTerm->pExpr->op)Description
TRUEevaluated 21781 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 10774 times by 1 test
Evaluated by:
  • Self test (438)
10774-21781
693 || pAndTerm->eOperator==WO_AUX
pAndTerm->eOperator==0x0040Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10765 times by 1 test
Evaluated by:
  • Self test (438)
9-10765
694 ){-
695 b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);-
696 }
executed 21790 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
21790
697 }
executed 32555 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
32555
698 }
executed 11304 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
11304
699 indexable &= b;-
700 }
executed 11304 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
11304
701 }else if( pOrTerm->wtFlags & TERM_COPIED ){
executed 11304 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
pOrTerm->wtFlags & 0x08Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11743 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
185-11743
702 /* Skip this term for now. We revisit it when we process the-
703 ** corresponding TERM_VIRTUAL term */-
704 }else{
executed 185 times by 1 test: end of block
Executed by:
  • Self test (438)
185
705 Bitmask b;-
706 b = sqlite3WhereGetMask(&pWInfo->sMaskSet, pOrTerm->leftCursor);-
707 if( pOrTerm->wtFlags & TERM_VIRTUAL ){
pOrTerm->wtFlags & 0x02Description
TRUEevaluated 175 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11568 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
175-11568
708 WhereTerm *pOther = &pOrWc->a[pOrTerm->iParent];-
709 b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pOther->leftCursor);-
710 }
executed 175 times by 1 test: end of block
Executed by:
  • Self test (438)
175
711 indexable &= b;-
712 if( (pOrTerm->eOperator & WO_EQ)==0 ){
(pOrTerm->eOpe...r & 0x0002)==0Description
TRUEevaluated 1510 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 10233 times by 1 test
Evaluated by:
  • Self test (438)
1510-10233
713 chngToIN = 0;-
714 }else{
executed 1510 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
1510
715 chngToIN &= b;-
716 }
executed 10233 times by 1 test: end of block
Executed by:
  • Self test (438)
10233
717 }-
718 }-
719-
720 /*-
721 ** Record the set of tables that satisfy case 3. The set might be-
722 ** empty.-
723 */-
724 pOrInfo->indexable = indexable;-
725 if( indexable ){
indexableDescription
TRUEevaluated 3801 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1327 times by 1 test
Evaluated by:
  • Self test (438)
1327-3801
726 pTerm->eOperator = WO_OR;-
727 pWC->hasOr = 1;-
728 }else{
executed 3801 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
3801
729 pTerm->eOperator = WO_OR;-
730 }
executed 1327 times by 1 test: end of block
Executed by:
  • Self test (438)
1327
731-
732 /* For a two-way OR, attempt to implementation case 2.-
733 */-
734 if( indexable && pOrWc->nTerm==2 ){
indexableDescription
TRUEevaluated 3801 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1327 times by 1 test
Evaluated by:
  • Self test (438)
pOrWc->nTerm==2Description
TRUEevaluated 1326 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 2475 times by 1 test
Evaluated by:
  • Self test (438)
1326-3801
735 int iOne = 0;-
736 WhereTerm *pOne;-
737 while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){
(pOne = whereN...0],iOne++))!=0Description
TRUEevaluated 2017 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 1326 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
1326-2017
738 int iTwo = 0;-
739 WhereTerm *pTwo;-
740 while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){
(pTwo = whereN...1],iTwo++))!=0Description
TRUEevaluated 4052 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 2017 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
2017-4052
741 whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);-
742 }
executed 4052 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
4052
743 }
executed 2017 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
2017
744 }
executed 1326 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
1326
745-
746 /*-
747 ** chngToIN holds a set of tables that *might* satisfy case 1. But-
748 ** we have to do some additional checking to see if case 1 really-
749 ** is satisfied.-
750 **-
751 ** chngToIN will hold either 0, 1, or 2 bits. The 0-bit case means-
752 ** that there is no possibility of transforming the OR clause into an-
753 ** IN operator because one or more terms in the OR clause contain-
754 ** something other than == on a column in the single table. The 1-bit-
755 ** case means that every term of the OR clause is of the form-
756 ** "table.column=expr" for some single table. The one bit that is set-
757 ** will correspond to the common table. We still need to check to make-
758 ** sure the same column is used on all terms. The 2-bit case is when-
759 ** the all terms are of the form "table1.column=table2.column". It-
760 ** might be possible to form an IN operator with either table1.column-
761 ** or table2.column as the LHS if either is common to every term of-
762 ** the OR clause.-
763 **-
764 ** Note that terms of the form "table.column1=table.column2" (the-
765 ** same table on both sizes of the ==) cannot be optimized.-
766 */-
767 if( chngToIN ){
chngToINDescription
TRUEevaluated 434 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4694 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
434-4694
768 int okToChngToIN = 0; /* True if the conversion to IN is valid */-
769 int iColumn = -1; /* Column index on lhs of IN operator */-
770 int iCursor = -1; /* Table cursor common to all terms */-
771 int j = 0; /* Loop counter */-
772-
773 /* Search for a table and column that appears on one side or the-
774 ** other of the == operator in every subterm. That table and column-
775 ** will be recorded in iCursor and iColumn. There might not be any-
776 ** such table and column. Set okToChngToIN if an appropriate table-
777 ** and column is found but leave okToChngToIN false if not found.-
778 */-
779 for(j=0; j<2 && !okToChngToIN; j++){
j<2Description
TRUEevaluated 868 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
!okToChngToINDescription
TRUEevaluated 669 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 199 times by 1 test
Evaluated by:
  • Self test (438)
18-868
780 pOrTerm = pOrWc->a;-
781 for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
i>=0Description
TRUEevaluated 3476 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 217 times by 1 test
Evaluated by:
  • Self test (438)
217-3476
782 assert( pOrTerm->eOperator & WO_EQ );-
783 pOrTerm->wtFlags &= ~TERM_OR_OK;-
784 if( pOrTerm->leftCursor==iCursor ){
pOrTerm->leftCursor==iCursorDescription
TRUEevaluated 2997 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 479 times by 1 test
Evaluated by:
  • Self test (438)
479-2997
785 /* This is the 2-bit case and we are on the second iteration and-
786 ** current term is from the first iteration. So skip this term. */-
787 assert( j==1 );-
788 continue;
executed 2997 times by 1 test: continue;
Executed by:
  • Self test (438)
2997
789 }-
790 if( (chngToIN & sqlite3WhereGetMask(&pWInfo->sMaskSet,
(chngToIN & sq...eftCursor))==0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 452 times by 1 test
Evaluated by:
  • Self test (438)
27-452
791 pOrTerm->leftCursor))==0 ){
(chngToIN & sq...eftCursor))==0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 452 times by 1 test
Evaluated by:
  • Self test (438)
27-452
792 /* This term must be of the form t1.a==t2.b where t2 is in the-
793 ** chngToIN set but t1 is not. This term will be either preceded-
794 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term -
795 ** and use its inversion. */-
796 testcase( pOrTerm->wtFlags & TERM_COPIED );-
797 testcase( pOrTerm->wtFlags & TERM_VIRTUAL );-
798 assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );-
799 continue;
executed 27 times by 1 test: continue;
Executed by:
  • Self test (438)
27
800 }-
801 iColumn = pOrTerm->u.leftColumn;-
802 iCursor = pOrTerm->leftCursor;-
803 break;
executed 452 times by 1 test: break;
Executed by:
  • Self test (438)
452
804 }-
805 if( i<0 ){
i<0Description
TRUEevaluated 217 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 452 times by 1 test
Evaluated by:
  • Self test (438)
217-452
806 /* No candidate table+column was found. This can only occur-
807 ** on the second iteration */-
808 assert( j==1 );-
809 assert( IsPowerOfTwo(chngToIN) );-
810 assert( chngToIN==sqlite3WhereGetMask(&pWInfo->sMaskSet, iCursor) );-
811 break;
executed 217 times by 1 test: break;
Executed by:
  • Self test (438)
217
812 }-
813 testcase( j==1 );-
814-
815 /* We have found a candidate table and column. Check to see if that-
816 ** table and column is common to every term in the OR clause */-
817 okToChngToIN = 1;-
818 for(; i>=0 && okToChngToIN; i--, pOrTerm++){
i>=0Description
TRUEevaluated 1208 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 332 times by 1 test
Evaluated by:
  • Self test (438)
okToChngToINDescription
TRUEevaluated 1088 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 120 times by 1 test
Evaluated by:
  • Self test (438)
120-1208
819 assert( pOrTerm->eOperator & WO_EQ );-
820 if( pOrTerm->leftCursor!=iCursor ){
pOrTerm->leftCursor!=iCursorDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1069 times by 1 test
Evaluated by:
  • Self test (438)
19-1069
821 pOrTerm->wtFlags &= ~TERM_OR_OK;-
822 }else if( pOrTerm->u.leftColumn!=iColumn ){
executed 19 times by 1 test: end of block
Executed by:
  • Self test (438)
pOrTerm->u.leftColumn!=iColumnDescription
TRUEevaluated 222 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 847 times by 1 test
Evaluated by:
  • Self test (438)
19-847
823 okToChngToIN = 0;-
824 }else{
executed 222 times by 1 test: end of block
Executed by:
  • Self test (438)
222
825 int affLeft, affRight;-
826 /* If the right-hand side is also a column, then the affinities-
827 ** of both right and left sides must be such that no type-
828 ** conversions are required on the right. (Ticket #2249)-
829 */-
830 affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);-
831 affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);-
832 if( affRight!=0 && affRight!=affLeft ){
affRight!=0Description
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 753 times by 1 test
Evaluated by:
  • Self test (438)
affRight!=affLeftDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test (438)
26-753
833 okToChngToIN = 0;-
834 }else{
executed 26 times by 1 test: end of block
Executed by:
  • Self test (438)
26
835 pOrTerm->wtFlags |= TERM_OR_OK;-
836 }
executed 821 times by 1 test: end of block
Executed by:
  • Self test (438)
821
837 }-
838 }-
839 }
executed 452 times by 1 test: end of block
Executed by:
  • Self test (438)
452
840-
841 /* At this point, okToChngToIN is true if original pTerm satisfies-
842 ** case 1. In that case, construct a new virtual term that is -
843 ** pTerm converted into an IN operator.-
844 */-
845 if( okToChngToIN ){
okToChngToINDescription
TRUEevaluated 204 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 230 times by 1 test
Evaluated by:
  • Self test (438)
204-230
846 Expr *pDup; /* A transient duplicate expression */-
847 ExprList *pList = 0; /* The RHS of the IN operator */-
848 Expr *pLeft = 0; /* The LHS of the IN operator */-
849 Expr *pNew; /* The complete IN operator */-
850-
851 for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
i>=0Description
TRUEevaluated 585 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 204 times by 1 test
Evaluated by:
  • Self test (438)
204-585
852 if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
executed 29 times by 1 test: continue;
Executed by:
  • Self test (438)
(pOrTerm->wtFlags & 0x40)==0Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 556 times by 1 test
Evaluated by:
  • Self test (438)
29-556
853 assert( pOrTerm->eOperator & WO_EQ );-
854 assert( pOrTerm->leftCursor==iCursor );-
855 assert( pOrTerm->u.leftColumn==iColumn );-
856 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);-
857 pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);-
858 pLeft = pOrTerm->pExpr->pLeft;-
859 }
executed 556 times by 1 test: end of block
Executed by:
  • Self test (438)
556
860 assert( pLeft!=0 );-
861 pDup = sqlite3ExprDup(db, pLeft, 0);-
862 pNew = sqlite3PExpr(pParse, TK_IN, pDup, 0);-
863 if( pNew ){
pNewDescription
TRUEevaluated 204 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-204
864 int idxNew;-
865 transferJoinMarkings(pNew, pExpr);-
866 assert( !ExprHasProperty(pNew, EP_xIsSelect) );-
867 pNew->x.pList = pList;-
868 idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);-
869 testcase( idxNew==0 );-
870 exprAnalyze(pSrc, pWC, idxNew);-
871 /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */-
872 markTermAsChild(pWC, idxNew, idxTerm);-
873 }else{
executed 204 times by 1 test: end of block
Executed by:
  • Self test (438)
204
874 sqlite3ExprListDelete(db, pList);-
875 }
never executed: end of block
0
876 }-
877 }
executed 434 times by 1 test: end of block
Executed by:
  • Self test (438)
434
878}
executed 5128 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
5128
879#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */-
880-
881/*-
882** We already know that pExpr is a binary operator where both operands are-
883** column references. This routine checks to see if pExpr is an equivalence-
884** relation:-
885** 1. The SQLITE_Transitive optimization must be enabled-
886** 2. Must be either an == or an IS operator-
887** 3. Not originating in the ON clause of an OUTER JOIN-
888** 4. The affinities of A and B must be compatible-
889** 5a. Both operands use the same collating sequence OR-
890** 5b. The overall collating sequence is BINARY-
891** If this routine returns TRUE, that means that the RHS can be substituted-
892** for the LHS anyplace else in the WHERE clause where the LHS column occurs.-
893** This is an optimization. No harm comes from returning 0. But if 1 is-
894** returned when it should not be, then incorrect answers might result.-
895*/-
896static int termIsEquivalence(Parse *pParse, Expr *pExpr){-
897 char aff1, aff2;-
898 CollSeq *pColl;-
899 if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • Self test (438)
!(((pParse->db...&(0x0080))==0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9218 times by 1 test
Evaluated by:
  • Self test (438)
3-9218
900 if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;
executed 3635 times by 1 test: return 0;
Executed by:
  • Self test (438)
pExpr->op!=53Description
TRUEevaluated 3656 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5562 times by 1 test
Evaluated by:
  • Self test (438)
pExpr->op!=45Description
TRUEevaluated 3635 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
21-5562
901 if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0;
executed 468 times by 1 test: return 0;
Executed by:
  • Self test (438)
(((pExpr)->fla...0x000001))!=0)Description
TRUEevaluated 468 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5115 times by 1 test
Evaluated by:
  • Self test (438)
468-5115
902 aff1 = sqlite3ExprAffinity(pExpr->pLeft);-
903 aff2 = sqlite3ExprAffinity(pExpr->pRight);-
904 if( aff1!=aff2
aff1!=aff2Description
TRUEevaluated 604 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4511 times by 1 test
Evaluated by:
  • Self test (438)
604-4511
905 && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))
!((aff1)>='C')Description
TRUEevaluated 286 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 318 times by 1 test
Evaluated by:
  • Self test (438)
!((aff2)>='C')Description
TRUEevaluated 297 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
21-318
906 ){-
907 return 0;
executed 583 times by 1 test: return 0;
Executed by:
  • Self test (438)
583
908 }-
909 pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);-
910 if( sqlite3IsBinary(pColl) ) return 1;
executed 4437 times by 1 test: return 1;
Executed by:
  • Self test (438)
sqlite3IsBinary(pColl)Description
TRUEevaluated 4437 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 95 times by 1 test
Evaluated by:
  • Self test (438)
95-4437
911 return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
executed 95 times by 1 test: return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);
Executed by:
  • Self test (438)
95
912}-
913-
914/*-
915** Recursively walk the expressions of a SELECT statement and generate-
916** a bitmask indicating which tables are used in that expression-
917** tree.-
918*/-
919static Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){-
920 Bitmask mask = 0;-
921 while( pS ){
pSDescription
TRUEevaluated 57230 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 103419 times by 1 test
Evaluated by:
  • Self test (438)
57230-103419
922 SrcList *pSrc = pS->pSrc;-
923 mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pEList);-
924 mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pGroupBy);-
925 mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pOrderBy);-
926 mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);-
927 mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);-
928 if( ALWAYS(pSrc!=0) ){
(pSrc!=0)Description
TRUEevaluated 57230 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-57230
929 int i;-
930 for(i=0; i<pSrc->nSrc; i++){
i<pSrc->nSrcDescription
TRUEevaluated 57013 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 57230 times by 1 test
Evaluated by:
  • Self test (438)
57013-57230
931 mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);-
932 mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);-
933 if( pSrc->a[i].fg.isTabFunc ){
pSrc->a[i].fg.isTabFuncDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 56993 times by 1 test
Evaluated by:
  • Self test (438)
20-56993
934 mask |= sqlite3WhereExprListUsage(pMaskSet, pSrc->a[i].u1.pFuncArg);-
935 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test (438)
20
936 }
executed 57013 times by 1 test: end of block
Executed by:
  • Self test (438)
57013
937 }
executed 57230 times by 1 test: end of block
Executed by:
  • Self test (438)
57230
938 pS = pS->pPrior;-
939 }
executed 57230 times by 1 test: end of block
Executed by:
  • Self test (438)
57230
940 return mask;
executed 103419 times by 1 test: return mask;
Executed by:
  • Self test (438)
103419
941}-
942-
943/*-
944** Expression pExpr is one operand of a comparison operator that might-
945** be useful for indexing. This routine checks to see if pExpr appears-
946** in any index. Return TRUE (1) if pExpr is an indexed term and return-
947** FALSE (0) if not. If TRUE is returned, also set aiCurCol[0] to the cursor-
948** number of the table that is indexed and aiCurCol[1] to the column number-
949** of the column that is indexed, or XN_EXPR (-2) if an expression is being-
950** indexed.-
951**-
952** If pExpr is a TK_COLUMN column reference, then this routine always returns-
953** true even if that particular column is not indexed, because the column-
954** might be added to an automatic index later.-
955*/-
956static SQLITE_NOINLINE int exprMightBeIndexed2(-
957 SrcList *pFrom, /* The FROM clause */-
958 Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */-
959 int *aiCurCol, /* Write the referenced table cursor and column here */-
960 Expr *pExpr /* An operand of a comparison operator */-
961){-
962 Index *pIdx;-
963 int i;-
964 int iCur;-
965 for(i=0; mPrereq>1; i++, mPrereq>>=1){}
executed 42192 times by 1 test: end of block
Executed by:
  • Self test (438)
mPrereq>1Description
TRUEevaluated 42192 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10723 times by 334 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
10723-42192
966 iCur = pFrom->a[i].iCursor;-
967 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 3003 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEevaluated 10672 times by 334 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
3003-10672
968 if( pIdx->aColExpr==0 ) continue;
executed 2943 times by 333 tests: continue;
Executed by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
pIdx->aColExpr==0Description
TRUEevaluated 2943 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEevaluated 60 times by 1 test
Evaluated by:
  • Self test (438)
60-2943
969 for(i=0; i<pIdx->nKeyCol; i++){
i<pIdx->nKeyColDescription
TRUEevaluated 69 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
9-69
970 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
executed 9 times by 1 test: continue;
Executed by:
  • Self test (438)
pIdx->aiColumn[i]!=(-2)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 60 times by 1 test
Evaluated by:
  • Self test (438)
9-60
971 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
sqlite3ExprCom...Expr, iCur)==0Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
9-51
972 aiCurCol[0] = iCur;-
973 aiCurCol[1] = XN_EXPR;-
974 return 1;
executed 51 times by 1 test: return 1;
Executed by:
  • Self test (438)
51
975 }-
976 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test (438)
9
977 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test (438)
9
978 return 0;
executed 10672 times by 334 tests: return 0;
Executed by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
10672
979}-
980static int exprMightBeIndexed(-
981 SrcList *pFrom, /* The FROM clause */-
982 Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */-
983 int *aiCurCol, /* Write the referenced table cursor & column here */-
984 Expr *pExpr, /* An operand of a comparison operator */-
985 int op /* The specific comparison operator */-
986){-
987 /* If this expression is a vector to the left or right of a -
988 ** inequality constraint (>, <, >= or <=), perform the processing -
989 ** on the first element of the vector. */-
990 assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );-
991 assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );-
992 assert( op<=TK_GE );-
993 if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
pExpr->op==165Description
TRUEevaluated 6438 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 382843 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
op>=54Description
TRUEevaluated 4310 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2128 times by 1 test
Evaluated by:
  • Self test (438)
(op<=57)Description
TRUEevaluated 4310 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-382843
994 pExpr = pExpr->x.pList->a[0].pExpr;-
995 }
executed 4310 times by 1 test: end of block
Executed by:
  • Self test (438)
4310
996-
997 if( pExpr->op==TK_COLUMN ){
pExpr->op==158Description
TRUEevaluated 199667 times by 36 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
FALSEevaluated 189614 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
189614-199667
998 aiCurCol[0] = pExpr->iTable;-
999 aiCurCol[1] = pExpr->iColumn;-
1000 return 1;
executed 199667 times by 36 tests: return 1;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
199667
1001 }-
1002 if( mPrereq==0 ) return 0; /* No table references */
executed 178886 times by 368 tests: return 0;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
mPrereq==0Description
TRUEevaluated 178886 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 10728 times by 334 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
10728-178886
1003 if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */
executed 5 times by 1 test: return 0;
Executed by:
  • Self test (438)
(mPrereq&(mPrereq-1))!=0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10723 times by 334 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
5-10723
1004 return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);
executed 10723 times by 334 tests: return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);
Executed by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
10723
1005}-
1006-
1007/*-
1008** The input to this routine is an WhereTerm structure with only the-
1009** "pExpr" field filled in. The job of this routine is to analyze the-
1010** subexpression and populate all the other fields of the WhereTerm-
1011** structure.-
1012**-
1013** If the expression is of the form "<expr> <op> X" it gets commuted-
1014** to the standard form of "X <op> <expr>".-
1015**-
1016** If the expression is of the form "X <op> Y" where both X and Y are-
1017** columns, then the original expression is unchanged and a new virtual-
1018** term of the form "Y <op> X" is added to the WHERE clause and-
1019** analyzed separately. The original term is marked with TERM_COPIED-
1020** and the new term is marked with TERM_DYNAMIC (because it's pExpr-
1021** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it-
1022** is a commuted copy of a prior term.) The original term has nChild=1-
1023** and the copy has idxParent set to the index of the original term.-
1024*/-
1025static void exprAnalyze(-
1026 SrcList *pSrc, /* the FROM clause */-
1027 WhereClause *pWC, /* the WHERE clause */-
1028 int idxTerm /* Index of the term to be analyzed */-
1029){-
1030 WhereInfo *pWInfo = pWC->pWInfo; /* WHERE clause processing context */-
1031 WhereTerm *pTerm; /* The term to be analyzed */-
1032 WhereMaskSet *pMaskSet; /* Set of table index masks */-
1033 Expr *pExpr; /* The expression to be analyzed */-
1034 Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */-
1035 Bitmask prereqAll; /* Prerequesites of pExpr */-
1036 Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */-
1037 Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */-
1038 int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */-
1039 int noCase = 0; /* uppercase equivalent to lowercase */-
1040 int op; /* Top-level operator. pExpr->op */-
1041 Parse *pParse = pWInfo->pParse; /* Parsing context */-
1042 sqlite3 *db = pParse->db; /* Database connection */-
1043 unsigned char eOp2 = 0; /* op2 value for LIKE/REGEXP/GLOB */-
1044 int nLeft; /* Number of elements on left side vector */-
1045-
1046 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 272443 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
68-272443
1047 return;
executed 68 times by 1 test: return;
Executed by:
  • Self test (438)
68
1048 }-
1049 pTerm = &pWC->a[idxTerm];-
1050 pMaskSet = &pWInfo->sMaskSet;-
1051 pExpr = pTerm->pExpr;-
1052 assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );-
1053 prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);-
1054 op = pExpr->op;-
1055 if( op==TK_IN ){
op==49Description
TRUEevaluated 5215 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 267228 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
5215-267228
1056 assert( pExpr->pRight==0 );-
1057 if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
executed 6 times by 1 test: return;
Executed by:
  • Self test (438)
sqlite3ExprChe...pParse, pExpr)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5209 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
6-5209
1058 if( ExprHasProperty(pExpr, EP_xIsSelect) ){
(((pExpr)->fla...0x000800))!=0)Description
TRUEevaluated 2537 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2672 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
2537-2672
1059 pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);-
1060 }else{
executed 2537 times by 1 test: end of block
Executed by:
  • Self test (438)
2537
1061 pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);-
1062 }
executed 2672 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
2672
1063 }else if( op==TK_ISNULL ){
op==50Description
TRUEevaluated 494 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 266734 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
494-266734
1064 pTerm->prereqRight = 0;-
1065 }else{
executed 494 times by 1 test: end of block
Executed by:
  • Self test (438)
494
1066 pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);-
1067 }
executed 266734 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
266734
1068 pMaskSet->bVarSelect = 0;-
1069 prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);-
1070 if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
executed 105 times by 1 test: pTerm->wtFlags |= 0x1000;
Executed by:
  • Self test (438)
pMaskSet->bVarSelectDescription
TRUEevaluated 105 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 272332 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
105-272332
1071 if( ExprHasProperty(pExpr, EP_FromJoin) ){
(((pExpr)->fla...0x000001))!=0)Description
TRUEevaluated 732 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 271705 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
732-271705
1072 Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);-
1073 prereqAll |= x;-
1074 extraRight = x-1; /* ON clause terms may not be used with an index-
1075 ** on left table of a LEFT JOIN. Ticket #3015 */-
1076 if( (prereqAll>>1)>=x ){
(prereqAll>>1)>=xDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 731 times by 1 test
Evaluated by:
  • Self test (438)
1-731
1077 sqlite3ErrorMsg(pParse, "ON clause references tables to its right");-
1078 return;
executed 1 time by 1 test: return;
Executed by:
  • Self test (438)
1
1079 }-
1080 }
executed 731 times by 1 test: end of block
Executed by:
  • Self test (438)
731
1081 pTerm->prereqAll = prereqAll;-
1082 pTerm->leftCursor = -1;-
1083 pTerm->iParent = -1;-
1084 pTerm->eOperator = 0;-
1085 if( allowedOp(op) ){
allowedOp(op)Description
TRUEevaluated 197492 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 74944 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
74944-197492
1086 int aiCurCol[2];-
1087 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);-
1088 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);-
1089 u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
(pTerm->prereq...prereqLeft)==0Description
TRUEevaluated 191572 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 5920 times by 1 test
Evaluated by:
  • Self test (438)
5920-191572
1090-
1091 if( pTerm->iField>0 ){
pTerm->iField>0Description
TRUEevaluated 239 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 197253 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
239-197253
1092 assert( op==TK_IN );-
1093 assert( pLeft->op==TK_VECTOR );-
1094 pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;-
1095 }
executed 239 times by 1 test: end of block
Executed by:
  • Self test (438)
239
1096-
1097 if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){
exprMightBeInd...ol, pLeft, op)Description
TRUEevaluated 186990 times by 36 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
FALSEevaluated 10502 times by 334 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
10502-186990
1098 pTerm->leftCursor = aiCurCol[0];-
1099 pTerm->u.leftColumn = aiCurCol[1];-
1100 pTerm->eOperator = operatorMask(op) & opMask;-
1101 }
executed 186990 times by 36 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (4)
  • Self test (40)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (5)
  • Self test (57)
  • Self test (58)
  • ...
186990
1102 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
executed 2990 times by 1 test: pTerm->wtFlags |= 0x800;
Executed by:
  • Self test (438)
op==45Description
TRUEevaluated 2990 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 194502 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
2990-194502
1103 if( pRight
pRightDescription
TRUEevaluated 191789 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 5703 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
5703-191789
1104 && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
exprMightBeInd...l, pRight, op)Description
TRUEevaluated 12728 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 179061 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
12728-179061
1105 ){-
1106 WhereTerm *pNew;-
1107 Expr *pDup;-
1108 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */-
1109 assert( pTerm->iField==0 );-
1110 if( pTerm->leftCursor>=0 ){
pTerm->leftCursor>=0Description
TRUEevaluated 9233 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3495 times by 1 test
Evaluated by:
  • Self test (438)
3495-9233
1111 int idxNew;-
1112 pDup = sqlite3ExprDup(db, pExpr, 0);-
1113 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9221 times by 1 test
Evaluated by:
  • Self test (438)
12-9221
1114 sqlite3ExprDelete(db, pDup);-
1115 return;
executed 12 times by 1 test: return;
Executed by:
  • Self test (438)
12
1116 }-
1117 idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);-
1118 if( idxNew==0 ) return;
never executed: return;
idxNew==0Description
TRUEnever evaluated
FALSEevaluated 9221 times by 1 test
Evaluated by:
  • Self test (438)
0-9221
1119 pNew = &pWC->a[idxNew];-
1120 markTermAsChild(pWC, idxNew, idxTerm);-
1121 if( op==TK_IS ) pNew->wtFlags |= TERM_IS;
executed 21 times by 1 test: pNew->wtFlags |= 0x800;
Executed by:
  • Self test (438)
op==45Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9200 times by 1 test
Evaluated by:
  • Self test (438)
21-9200
1122 pTerm = &pWC->a[idxTerm];-
1123 pTerm->wtFlags |= TERM_COPIED;-
1124-
1125 if( termIsEquivalence(pParse, pDup) ){
termIsEquivale...(pParse, pDup)Description
TRUEevaluated 4452 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4769 times by 1 test
Evaluated by:
  • Self test (438)
4452-4769
1126 pTerm->eOperator |= WO_EQUIV;-
1127 eExtraOp = WO_EQUIV;-
1128 }
executed 4452 times by 1 test: end of block
Executed by:
  • Self test (438)
4452
1129 }else{
executed 9221 times by 1 test: end of block
Executed by:
  • Self test (438)
9221
1130 pDup = pExpr;-
1131 pNew = pTerm;-
1132 }
executed 3495 times by 1 test: end of block
Executed by:
  • Self test (438)
3495
1133 exprCommute(pParse, pDup);-
1134 pNew->leftCursor = aiCurCol[0];-
1135 pNew->u.leftColumn = aiCurCol[1];-
1136 testcase( (prereqLeft | extraRight) != prereqLeft );-
1137 pNew->prereqRight = prereqLeft | extraRight;-
1138 pNew->prereqAll = prereqAll;-
1139 pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;-
1140 }
executed 12716 times by 1 test: end of block
Executed by:
  • Self test (438)
12716
1141 }
executed 197480 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
197480
1142-
1143#ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION-
1144 /* If a term is the BETWEEN operator, create two new virtual terms-
1145 ** that define the range that the BETWEEN implements. For example:-
1146 **-
1147 ** a BETWEEN b AND c-
1148 **-
1149 ** is converted into:-
1150 **-
1151 ** (a BETWEEN b AND c) AND (a>=b) AND (a<=c)-
1152 **-
1153 ** The two new terms are added onto the end of the WhereClause object.-
1154 ** The new terms are "dynamic" and are children of the original BETWEEN-
1155 ** term. That means that if the BETWEEN term is coded, the children are-
1156 ** skipped. Or, if the children are satisfied by an index, the original-
1157 ** BETWEEN term is skipped.-
1158 */-
1159 else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){
pExpr->op==48Description
TRUEevaluated 5644 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 69300 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
pWC->op==44Description
TRUEevaluated 5360 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 284 times by 1 test
Evaluated by:
  • Self test (438)
284-69300
1160 ExprList *pList = pExpr->x.pList;-
1161 int i;-
1162 static const u8 ops[] = {TK_GE, TK_LE};-
1163 assert( pList!=0 );-
1164 assert( pList->nExpr==2 );-
1165 for(i=0; i<2; i++){
i<2Description
TRUEevaluated 10720 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5360 times by 1 test
Evaluated by:
  • Self test (438)
5360-10720
1166 Expr *pNewExpr;-
1167 int idxNew;-
1168 pNewExpr = sqlite3PExpr(pParse, ops[i], -
1169 sqlite3ExprDup(db, pExpr->pLeft, 0),-
1170 sqlite3ExprDup(db, pList->a[i].pExpr, 0));-
1171 transferJoinMarkings(pNewExpr, pExpr);-
1172 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);-
1173 testcase( idxNew==0 );-
1174 exprAnalyze(pSrc, pWC, idxNew);-
1175 pTerm = &pWC->a[idxTerm];-
1176 markTermAsChild(pWC, idxNew, idxTerm);-
1177 }
executed 10720 times by 1 test: end of block
Executed by:
  • Self test (438)
10720
1178 }
executed 5360 times by 1 test: end of block
Executed by:
  • Self test (438)
5360
1179#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */-
1180-
1181#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)-
1182 /* Analyze a term that is composed of two or more subterms connected by-
1183 ** an OR operator.-
1184 */-
1185 else if( pExpr->op==TK_OR ){
pExpr->op==43Description
TRUEevaluated 5128 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 64456 times by 28 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • ...
5128-64456
1186 assert( pWC->op==TK_AND );-
1187 exprAnalyzeOrTerm(pSrc, pWC, idxTerm);-
1188 pTerm = &pWC->a[idxTerm];-
1189 }
executed 5128 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
5128
1190#endif /* SQLITE_OMIT_OR_OPTIMIZATION */-
1191-
1192#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION-
1193 /* Add constraints to reduce the search space on a LIKE or GLOB-
1194 ** operator.-
1195 **-
1196 ** A like pattern of the form "x LIKE 'aBc%'" is changed into constraints-
1197 **-
1198 ** x>='ABC' AND x<'abd' AND x LIKE 'aBc%'-
1199 **-
1200 ** The last character of the prefix "abc" is incremented to form the-
1201 ** termination condition "abd". If case is not significant (the default-
1202 ** for LIKE) then the lower-bound is made all uppercase and the upper--
1203 ** bound is made all lowercase so that the bounds also work when comparing-
1204 ** BLOBs.-
1205 */-
1206 if( pWC->op==TK_AND
pWC->op==44Description
TRUEevaluated 248387 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 24037 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
24037-248387
1207 && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
isLikeOrGlob(p...lete, &noCase)Description
TRUEevaluated 5281 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 243106 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
5281-243106
1208 ){-
1209 Expr *pLeft; /* LHS of LIKE/GLOB operator */-
1210 Expr *pStr2; /* Copy of pStr1 - RHS of LIKE/GLOB operator */-
1211 Expr *pNewExpr1;-
1212 Expr *pNewExpr2;-
1213 int idxNew1;-
1214 int idxNew2;-
1215 const char *zCollSeqName; /* Name of collating sequence */-
1216 const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;-
1217-
1218 pLeft = pExpr->x.pList->a[1].pExpr;-
1219 pStr2 = sqlite3ExprDup(db, pStr1, 0);-
1220-
1221 /* Convert the lower bound to upper-case and the upper bound to-
1222 ** lower-case (upper-case is less than lower-case in ASCII) so that-
1223 ** the range constraints also work for BLOBs-
1224 */-
1225 if( noCase && !pParse->db->mallocFailed ){
noCaseDescription
TRUEevaluated 400 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4881 times by 1 test
Evaluated by:
  • Self test (438)
!pParse->db->mallocFailedDescription
TRUEevaluated 400 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-4881
1226 int i;-
1227 char c;-
1228 pTerm->wtFlags |= TERM_LIKE;-
1229 for(i=0; (c = pStr1->u.zToken[i])!=0; i++){
(c = pStr1->u.zToken[i])!=0Description
TRUEevaluated 982 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 400 times by 1 test
Evaluated by:
  • Self test (438)
400-982
1230 pStr1->u.zToken[i] = sqlite3Toupper(c);-
1231 pStr2->u.zToken[i] = sqlite3Tolower(c);-
1232 }
executed 982 times by 1 test: end of block
Executed by:
  • Self test (438)
982
1233 }
executed 400 times by 1 test: end of block
Executed by:
  • Self test (438)
400
1234-
1235 if( !db->mallocFailed ){
!db->mallocFailedDescription
TRUEevaluated 5281 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-5281
1236 u8 c, *pC; /* Last character before the first wildcard */-
1237 pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];-
1238 c = *pC;-
1239 if( noCase ){
noCaseDescription
TRUEevaluated 400 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4881 times by 1 test
Evaluated by:
  • Self test (438)
400-4881
1240 /* The point is to increment the last character before the first-
1241 ** wildcard. But if we increment '@', that will push it into the-
1242 ** alphabetic range where case conversions will mess up the -
1243 ** inequality. To avoid this, make sure to also run the full-
1244 ** LIKE on all candidate expressions by clearing the isComplete flag-
1245 */-
1246 if( c=='A'-1 ) isComplete = 0;
executed 3 times by 1 test: isComplete = 0;
Executed by:
  • Self test (438)
c=='A'-1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 397 times by 1 test
Evaluated by:
  • Self test (438)
3-397
1247 c = sqlite3UpperToLower[c];-
1248 }
executed 400 times by 1 test: end of block
Executed by:
  • Self test (438)
400
1249 *pC = c + 1;-
1250 }
executed 5281 times by 1 test: end of block
Executed by:
  • Self test (438)
5281
1251 zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
noCaseDescription
TRUEevaluated 400 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4881 times by 1 test
Evaluated by:
  • Self test (438)
400-4881
1252 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);-
1253 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,-
1254 sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),-
1255 pStr1);-
1256 transferJoinMarkings(pNewExpr1, pExpr);-
1257 idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);-
1258 testcase( idxNew1==0 );-
1259 exprAnalyze(pSrc, pWC, idxNew1);-
1260 pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);-
1261 pNewExpr2 = sqlite3PExpr(pParse, TK_LT,-
1262 sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),-
1263 pStr2);-
1264 transferJoinMarkings(pNewExpr2, pExpr);-
1265 idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);-
1266 testcase( idxNew2==0 );-
1267 exprAnalyze(pSrc, pWC, idxNew2);-
1268 pTerm = &pWC->a[idxTerm];-
1269 if( isComplete ){
isCompleteDescription
TRUEevaluated 5238 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test (438)
43-5238
1270 markTermAsChild(pWC, idxNew1, idxTerm);-
1271 markTermAsChild(pWC, idxNew2, idxTerm);-
1272 }
executed 5238 times by 1 test: end of block
Executed by:
  • Self test (438)
5238
1273 }
executed 5281 times by 1 test: end of block
Executed by:
  • Self test (438)
5281
1274#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */-
1275-
1276#ifndef SQLITE_OMIT_VIRTUALTABLE-
1277 /* Add a WO_AUX auxiliary term to the constraint set if the-
1278 ** current expression is of the form "column OP expr" where OP-
1279 ** is an operator that gets passed into virtual tables but which is-
1280 ** not normally optimized for ordinary tables. In other words, OP-
1281 ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.-
1282 ** This information is used by the xBestIndex methods of-
1283 ** virtual tables. The native query optimizer does not attempt-
1284 ** to do anything with MATCH functions.-
1285 */-
1286 if( pWC->op==TK_AND ){
pWC->op==44Description
TRUEevaluated 248387 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 24037 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
24037-248387
1287 Expr *pRight = 0, *pLeft = 0;-
1288 int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight);-
1289 while( res-- > 0 ){
res-- > 0Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 248387 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
140-248387
1290 int idxNew;-
1291 WhereTerm *pNewTerm;-
1292 Bitmask prereqColumn, prereqExpr;-
1293-
1294 prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight);-
1295 prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);-
1296 if( (prereqExpr & prereqColumn)==0 ){
(prereqExpr & prereqColumn)==0Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-140
1297 Expr *pNewExpr;-
1298 pNewExpr = sqlite3PExpr(pParse, TK_MATCH, -
1299 0, sqlite3ExprDup(db, pRight, 0));-
1300 if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
(((pExpr)->fla...0x000001))!=0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 139 times by 1 test
Evaluated by:
  • Self test (438)
pNewExprDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-139
1301 ExprSetProperty(pNewExpr, EP_FromJoin);-
1302 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
1303 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);-
1304 testcase( idxNew==0 );-
1305 pNewTerm = &pWC->a[idxNew];-
1306 pNewTerm->prereqRight = prereqExpr;-
1307 pNewTerm->leftCursor = pLeft->iTable;-
1308 pNewTerm->u.leftColumn = pLeft->iColumn;-
1309 pNewTerm->eOperator = WO_AUX;-
1310 pNewTerm->eMatchOp = eOp2;-
1311 markTermAsChild(pWC, idxNew, idxTerm);-
1312 pTerm = &pWC->a[idxTerm];-
1313 pTerm->wtFlags |= TERM_COPIED;-
1314 pNewTerm->prereqAll = pTerm->prereqAll;-
1315 }
executed 140 times by 1 test: end of block
Executed by:
  • Self test (438)
140
1316 SWAP(Expr*, pLeft, pRight);-
1317 }
executed 140 times by 1 test: end of block
Executed by:
  • Self test (438)
140
1318 }
executed 248387 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
248387
1319#endif /* SQLITE_OMIT_VIRTUALTABLE */-
1320-
1321 /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create-
1322 ** new terms for each component comparison - "a = ?" and "b = ?". The-
1323 ** new terms completely replace the original vector comparison, which is-
1324 ** no longer used.-
1325 **-
1326 ** This is only required if at least one side of the comparison operation-
1327 ** is not a sub-select. */-
1328 if( pWC->op==TK_AND
pWC->op==44Description
TRUEevaluated 248387 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 24037 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
24037-248387
1329 && (pExpr->op==TK_EQ || pExpr->op==TK_IS)
pExpr->op==53Description
TRUEevaluated 125884 times by 367 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 122503 times by 29 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (40)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • ...
pExpr->op==45Description
TRUEevaluated 2990 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 119513 times by 29 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (40)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • ...
2990-125884
1330 && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
(nLeft = sqlit...xpr->pLeft))>1Description
TRUEevaluated 1317 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 127557 times by 367 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
1317-127557
1331 && sqlite3ExprVectorSize(pExpr->pRight)==nLeft
sqlite3ExprVec...pRight)==nLeftDescription
TRUEevaluated 1317 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-1317
1332 && ( (pExpr->pLeft->flags & EP_xIsSelect)==0
(pExpr->pLeft-...& 0x000800)==0Description
TRUEevaluated 1317 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-1317
1333 || (pExpr->pRight->flags & EP_xIsSelect)==0)
(pExpr->pRight...& 0x000800)==0Description
TRUEnever evaluated
FALSEnever evaluated
0
1334 ){-
1335 int i;-
1336 for(i=0; i<nLeft; i++){
i<nLeftDescription
TRUEevaluated 3908 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1317 times by 1 test
Evaluated by:
  • Self test (438)
1317-3908
1337 int idxNew;-
1338 Expr *pNew;-
1339 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);-
1340 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);-
1341-
1342 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);-
1343 transferJoinMarkings(pNew, pExpr);-
1344 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);-
1345 exprAnalyze(pSrc, pWC, idxNew);-
1346 }
executed 3908 times by 1 test: end of block
Executed by:
  • Self test (438)
3908
1347 pTerm = &pWC->a[idxTerm];-
1348 pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL; /* Disable the original */-
1349 pTerm->eOperator = 0;-
1350 }
executed 1317 times by 1 test: end of block
Executed by:
  • Self test (438)
1317
1351-
1352 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create-
1353 ** a virtual term for each vector component. The expression object-
1354 ** used by each such virtual term is pExpr (the full vector IN(...) -
1355 ** expression). The WhereTerm.iField variable identifies the index within-
1356 ** the vector on the LHS that the virtual term represents.-
1357 **-
1358 ** This only works if the RHS is a simple SELECT, not a compound-
1359 */-
1360 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
pWC->op==44Description
TRUEevaluated 248387 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 24037 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
pExpr->op==49Description
TRUEevaluated 4241 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 244146 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
pTerm->iField==0Description
TRUEevaluated 4002 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 239 times by 1 test
Evaluated by:
  • Self test (438)
239-248387
1361 && pExpr->pLeft->op==TK_VECTOR
pExpr->pLeft->op==165Description
TRUEevaluated 121 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3881 times by 1 test
Evaluated by:
  • Self test (438)
121-3881
1362 && pExpr->x.pSelect->pPrior==0
pExpr->x.pSelect->pPrior==0Description
TRUEevaluated 119 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-119
1363 ){-
1364 int i;-
1365 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
i<sqlite3ExprV...(pExpr->pLeft)Description
TRUEevaluated 239 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 119 times by 1 test
Evaluated by:
  • Self test (438)
119-239
1366 int idxNew;-
1367 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);-
1368 pWC->a[idxNew].iField = i+1;-
1369 exprAnalyze(pSrc, pWC, idxNew);-
1370 markTermAsChild(pWC, idxNew, idxTerm);-
1371 }
executed 239 times by 1 test: end of block
Executed by:
  • Self test (438)
239
1372 }
executed 119 times by 1 test: end of block
Executed by:
  • Self test (438)
119
1373-
1374#ifdef SQLITE_ENABLE_STAT3_OR_STAT4-
1375 /* When sqlite_stat3 histogram data is available an operator of the-
1376 ** form "x IS NOT NULL" can sometimes be evaluated more efficiently-
1377 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a-
1378 ** virtual term of that form.-
1379 **-
1380 ** Note that the virtual term must be tagged with TERM_VNULL.-
1381 */-
1382 if( pExpr->op==TK_NOTNULL-
1383 && pExpr->pLeft->op==TK_COLUMN-
1384 && pExpr->pLeft->iColumn>=0-
1385 && OptimizationEnabled(db, SQLITE_Stat34)-
1386 ){-
1387 Expr *pNewExpr;-
1388 Expr *pLeft = pExpr->pLeft;-
1389 int idxNew;-
1390 WhereTerm *pNewTerm;-
1391-
1392 pNewExpr = sqlite3PExpr(pParse, TK_GT,-
1393 sqlite3ExprDup(db, pLeft, 0),-
1394 sqlite3ExprAlloc(db, TK_NULL, 0, 0));-
1395-
1396 idxNew = whereClauseInsert(pWC, pNewExpr,-
1397 TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);-
1398 if( idxNew ){-
1399 pNewTerm = &pWC->a[idxNew];-
1400 pNewTerm->prereqRight = 0;-
1401 pNewTerm->leftCursor = pLeft->iTable;-
1402 pNewTerm->u.leftColumn = pLeft->iColumn;-
1403 pNewTerm->eOperator = WO_GT;-
1404 markTermAsChild(pWC, idxNew, idxTerm);-
1405 pTerm = &pWC->a[idxTerm];-
1406 pTerm->wtFlags |= TERM_COPIED;-
1407 pNewTerm->prereqAll = pTerm->prereqAll;-
1408 }-
1409 }-
1410#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */-
1411-
1412 /* Prevent ON clause terms of a LEFT JOIN from being used to drive-
1413 ** an index for tables to the left of the join.-
1414 */-
1415 testcase( pTerm!=&pWC->a[idxTerm] );-
1416 pTerm = &pWC->a[idxTerm];-
1417 pTerm->prereqRight |= extraRight;-
1418}
executed 272424 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
272424
1419-
1420/***************************************************************************-
1421** Routines with file scope above. Interface to the rest of the where.c-
1422** subsystem follows.-
1423***************************************************************************/-
1424-
1425/*-
1426** This routine identifies subexpressions in the WHERE clause where-
1427** each subexpression is separated by the AND operator or some other-
1428** operator specified in the op parameter. The WhereClause structure-
1429** is filled with pointers to subexpressions. For example:-
1430**-
1431** WHERE a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)-
1432** \________/ \_______________/ \________________/-
1433** slot[0] slot[1] slot[2]-
1434**-
1435** The original WHERE clause in pExpr is unaltered. All this routine-
1436** does is make slot[] entries point to substructure within pExpr.-
1437**-
1438** In the previous sentence and in the diagram, "slot[]" refers to-
1439** the WhereClause.a[] array. The slot[] array grows as needed to contain-
1440** all terms of the WHERE clause.-
1441*/-
1442void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){-
1443 Expr *pE2 = sqlite3ExprSkipCollate(pExpr);-
1444 pWC->op = op;-
1445 if( pE2==0 ) return;
executed 206362 times by 435 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pE2==0Description
TRUEevaluated 206362 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 316315 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
206362-316315
1446 if( pE2->op!=op ){
pE2->op!=opDescription
TRUEevaluated 229450 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 86865 times by 31 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • ...
86865-229450
1447 whereClauseInsert(pWC, pExpr, 0);-
1448 }else{
executed 229450 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
229450
1449 sqlite3WhereSplit(pWC, pE2->pLeft, op);-
1450 sqlite3WhereSplit(pWC, pE2->pRight, op);-
1451 }
executed 86865 times by 31 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • ...
86865
1452}-
1453-
1454/*-
1455** Initialize a preallocated WhereClause structure.-
1456*/-
1457void sqlite3WhereClauseInit(-
1458 WhereClause *pWC, /* The WhereClause to be initialized */-
1459 WhereInfo *pWInfo /* The WHERE processing context */-
1460){-
1461 pWC->pWInfo = pWInfo;-
1462 pWC->hasOr = 0;-
1463 pWC->pOuter = 0;-
1464 pWC->nTerm = 0;-
1465 pWC->nSlot = ArraySize(pWC->aStatic);-
1466 pWC->a = pWC->aStatic;-
1467}
executed 348947 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
348947
1468-
1469/*-
1470** Deallocate a WhereClause structure. The WhereClause structure-
1471** itself is not freed. This routine is the inverse of-
1472** sqlite3WhereClauseInit().-
1473*/-
1474void sqlite3WhereClauseClear(WhereClause *pWC){-
1475 int i;-
1476 WhereTerm *a;-
1477 sqlite3 *db = pWC->pWInfo->pParse->db;-
1478 for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){
i>=0Description
TRUEevaluated 281872 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 348947 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
281872-348947
1479 if( a->wtFlags & TERM_DYNAMIC ){
a->wtFlags & 0x01Description
TRUEevaluated 52183 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 229689 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
52183-229689
1480 sqlite3ExprDelete(db, a->pExpr);-
1481 }
executed 52183 times by 1 test: end of block
Executed by:
  • Self test (438)
52183
1482 if( a->wtFlags & TERM_ORINFO ){
a->wtFlags & 0x10Description
TRUEevaluated 5128 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 276744 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
5128-276744
1483 whereOrInfoDelete(db, a->u.pOrInfo);-
1484 }else if( a->wtFlags & TERM_ANDINFO ){
executed 5128 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
a->wtFlags & 0x20Description
TRUEevaluated 11304 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 265440 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
5128-265440
1485 whereAndInfoDelete(db, a->u.pAndInfo);-
1486 }
executed 11304 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
11304
1487 }
executed 281872 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
281872
1488 if( pWC->a!=pWC->aStatic ){
pWC->a!=pWC->aStaticDescription
TRUEevaluated 724 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 348223 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
724-348223
1489 sqlite3DbFree(db, pWC->a);-
1490 }
executed 724 times by 1 test: end of block
Executed by:
  • Self test (438)
724
1491}
executed 348947 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
348947
1492-
1493-
1494/*-
1495** These routines walk (recursively) an expression tree and generate-
1496** a bitmask indicating which tables are used in that expression-
1497** tree.-
1498*/-
1499Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){-
1500 Bitmask mask;-
1501 if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
p->op==158Description
TRUEevaluated 911015 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 1487089 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
!(((p)->flags&(0x000008))!=0)Description
TRUEevaluated 910899 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 116 times by 1 test
Evaluated by:
  • Self test (438)
116-1487089
1502 return sqlite3WhereGetMask(pMaskSet, p->iTable);
executed 910899 times by 368 tests: return sqlite3WhereGetMask(pMaskSet, p->iTable);
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
910899
1503 }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
(((p)->flags&(...0x800000))!=0)Description
TRUEevaluated 561752 times by 366 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 925453 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
561752-925453
1504 assert( p->op!=TK_IF_NULL_ROW );-
1505 return 0;
executed 561752 times by 366 tests: return 0;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
561752
1506 }-
1507 mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
(p->op==167)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 925445 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
8-925445
1508 if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
executed 674440 times by 368 tests: mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
p->pLeftDescription
TRUEevaluated 674440 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 251013 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
251013-674440
1509 if( p->pRight ){
p->pRightDescription
TRUEevaluated 490167 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 435286 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
435286-490167
1510 mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);-
1511 assert( p->x.pList==0 );-
1512 }else if( ExprHasProperty(p, EP_xIsSelect) ){
executed 490167 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
(((p)->flags&(0x000800))!=0)Description
TRUEevaluated 43869 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 391417 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
43869-490167
1513 if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;
executed 187 times by 1 test: pMaskSet->bVarSelect = 1;
Executed by:
  • Self test (438)
(((p)->flags&(0x000020))!=0)Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 43682 times by 1 test
Evaluated by:
  • Self test (438)
187-43682
1514 mask |= exprSelectUsage(pMaskSet, p->x.pSelect);-
1515 }else if( p->x.pList ){
executed 43869 times by 1 test: end of block
Executed by:
  • Self test (438)
p->x.pListDescription
TRUEevaluated 166308 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 225109 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
43869-225109
1516 mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);-
1517 }
executed 166308 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
166308
1518 return mask;
executed 925453 times by 368 tests: return mask;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
925453
1519}-
1520Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){-
1521 return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
executed 1158185 times by 368 tests: return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
pDescription
TRUEevaluated 961060 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 197125 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
197125-1158185
1522}-
1523Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){-
1524 int i;-
1525 Bitmask mask = 0;-
1526 if( pList ){
pListDescription
TRUEevaluated 235083 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 114310 times by 1 test
Evaluated by:
  • Self test (438)
114310-235083
1527 for(i=0; i<pList->nExpr; i++){
i<pList->nExprDescription
TRUEevaluated 444920 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
FALSEevaluated 235083 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
235083-444920
1528 mask |= sqlite3WhereExprUsage(pMaskSet, pList->a[i].pExpr);-
1529 }
executed 444920 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
444920
1530 }
executed 235083 times by 2 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
235083
1531 return mask;
executed 349393 times by 2 tests: return mask;
Executed by:
  • Self test (34)
  • Self test (438)
349393
1532}-
1533-
1534-
1535/*-
1536** Call exprAnalyze on all terms in a WHERE clause. -
1537**-
1538** Note that exprAnalyze() might add new virtual terms onto the-
1539** end of the WHERE clause. We do not want to analyze these new-
1540** virtual terms, so start analyzing at the end and work forward-
1541** so that the added virtual terms are never processed.-
1542*/-
1543void sqlite3WhereExprAnalyze(-
1544 SrcList *pTabList, /* the FROM clause */-
1545 WhereClause *pWC /* the WHERE clause to be analyzed */-
1546){-
1547 int i;-
1548 for(i=pWC->nTerm-1; i>=0; i--){
i>=0Description
TRUEevaluated 246840 times by 368 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 348947 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
246840-348947
1549 exprAnalyze(pTabList, pWC, i);-
1550 }
executed 246840 times by 368 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
246840
1551}
executed 348947 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
348947
1552-
1553/*-
1554** For table-valued-functions, transform the function arguments into-
1555** new WHERE clause terms. -
1556**-
1557** Each function argument translates into an equality constraint against-
1558** a HIDDEN column in the table.-
1559*/-
1560void sqlite3WhereTabFuncArgs(-
1561 Parse *pParse, /* Parsing context */-
1562 struct SrcList_item *pItem, /* The FROM clause term to process */-
1563 WhereClause *pWC /* Xfer function arguments to here */-
1564){-
1565 Table *pTab;-
1566 int j, k;-
1567 ExprList *pArgs;-
1568 Expr *pColRef;-
1569 Expr *pTerm;-
1570 if( pItem->fg.isTabFunc==0 ) return;
executed 270755 times by 435 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pItem->fg.isTabFunc==0Description
TRUEevaluated 270755 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 8782 times by 1 test
Evaluated by:
  • Self test (438)
8782-270755
1571 pTab = pItem->pTab;-
1572 assert( pTab!=0 );-
1573 pArgs = pItem->u1.pFuncArg;-
1574 if( pArgs==0 ) return;
executed 2 times by 1 test: return;
Executed by:
  • Self test (438)
pArgs==0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8780 times by 1 test
Evaluated by:
  • Self test (438)
2-8780
1575 for(j=k=0; j<pArgs->nExpr; j++){
j<pArgs->nExprDescription
TRUEevaluated 17391 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8779 times by 1 test
Evaluated by:
  • Self test (438)
8779-17391
1576 while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}
executed 52490 times by 1 test: end of block
Executed by:
  • Self test (438)
k<pTab->nColDescription
TRUEevaluated 69880 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
(pTab->aCol[k]...s & 0x0002)==0Description
TRUEevaluated 52490 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 17390 times by 1 test
Evaluated by:
  • Self test (438)
1-69880
1577 if( k>=pTab->nCol ){
k>=pTab->nColDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 17390 times by 1 test
Evaluated by:
  • Self test (438)