| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/select.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | typedef struct DistinctCtx DistinctCtx; | - | ||||||||||||||||||||||||
| 2 | struct DistinctCtx { | - | ||||||||||||||||||||||||
| 3 | u8 isTnct; | - | ||||||||||||||||||||||||
| 4 | u8 eTnctType; | - | ||||||||||||||||||||||||
| 5 | int tabTnct; | - | ||||||||||||||||||||||||
| 6 | int addrTnct; | - | ||||||||||||||||||||||||
| 7 | }; | - | ||||||||||||||||||||||||
| 8 | typedef struct SortCtx SortCtx; | - | ||||||||||||||||||||||||
| 9 | struct SortCtx { | - | ||||||||||||||||||||||||
| 10 | ExprList *pOrderBy; | - | ||||||||||||||||||||||||
| 11 | int nOBSat; | - | ||||||||||||||||||||||||
| 12 | int iECursor; | - | ||||||||||||||||||||||||
| 13 | int regReturn; | - | ||||||||||||||||||||||||
| 14 | int labelBkOut; | - | ||||||||||||||||||||||||
| 15 | int addrSortIndex; | - | ||||||||||||||||||||||||
| 16 | int labelDone; | - | ||||||||||||||||||||||||
| 17 | int labelOBLopt; | - | ||||||||||||||||||||||||
| 18 | u8 sortFlags; | - | ||||||||||||||||||||||||
| 19 | struct RowLoadInfo *pDeferredRowLoad; | - | ||||||||||||||||||||||||
| 20 | }; | - | ||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | static void clearSelect(sqlite3 *db, Select *p, int bFree){ | - | ||||||||||||||||||||||||
| 28 | while( p
| 646948-1123277 | ||||||||||||||||||||||||
| 29 | Select *pPrior = p->pPrior; | - | ||||||||||||||||||||||||
| 30 | sqlite3ExprListDelete(db, p->pEList); | - | ||||||||||||||||||||||||
| 31 | sqlite3SrcListDelete(db, p->pSrc); | - | ||||||||||||||||||||||||
| 32 | sqlite3ExprDelete(db, p->pWhere); | - | ||||||||||||||||||||||||
| 33 | sqlite3ExprListDelete(db, p->pGroupBy); | - | ||||||||||||||||||||||||
| 34 | sqlite3ExprDelete(db, p->pHaving); | - | ||||||||||||||||||||||||
| 35 | sqlite3ExprListDelete(db, p->pOrderBy); | - | ||||||||||||||||||||||||
| 36 | sqlite3ExprDelete(db, p->pLimit); | - | ||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | if( (
| 125-1123152 | ||||||||||||||||||||||||
| 39 | sqlite3WindowListDelete(db, p->pWinDefn); | - | ||||||||||||||||||||||||
| 40 | } executed 125 times by 1 test: end of blockExecuted by:
| 125 | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | if( (
executed 1847 times by 1 test: sqlite3WithDelete(db, p->pWith);Executed by:
| 1847-1121430 | ||||||||||||||||||||||||
| 43 | if( bFree
executed 1123125 times by 436 tests: sqlite3DbFreeNN(db, p);Executed by:
| 152-1123125 | ||||||||||||||||||||||||
| 44 | p = pPrior; | - | ||||||||||||||||||||||||
| 45 | bFree = 1; | - | ||||||||||||||||||||||||
| 46 | } executed 1123277 times by 436 tests: end of blockExecuted by:
| 1123277 | ||||||||||||||||||||||||
| 47 | } executed 646948 times by 436 tests: end of blockExecuted by:
| 646948 | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){ | - | ||||||||||||||||||||||||
| 53 | pDest->eDest = (u8)eDest; | - | ||||||||||||||||||||||||
| 54 | pDest->iSDParm = iParm; | - | ||||||||||||||||||||||||
| 55 | pDest->zAffSdst = 0; | - | ||||||||||||||||||||||||
| 56 | pDest->iSdst = 0; | - | ||||||||||||||||||||||||
| 57 | pDest->nSdst = 0; | - | ||||||||||||||||||||||||
| 58 | } executed 97671 times by 9 tests: end of blockExecuted by:
| 97671 | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | Select *sqlite3SelectNew( | - | ||||||||||||||||||||||||
| 66 | Parse *pParse, | - | ||||||||||||||||||||||||
| 67 | ExprList *pEList, | - | ||||||||||||||||||||||||
| 68 | SrcList *pSrc, | - | ||||||||||||||||||||||||
| 69 | Expr *pWhere, | - | ||||||||||||||||||||||||
| 70 | ExprList *pGroupBy, | - | ||||||||||||||||||||||||
| 71 | Expr *pHaving, | - | ||||||||||||||||||||||||
| 72 | ExprList *pOrderBy, | - | ||||||||||||||||||||||||
| 73 | u32 selFlags, | - | ||||||||||||||||||||||||
| 74 | Expr *pLimit | - | ||||||||||||||||||||||||
| 75 | ){ | - | ||||||||||||||||||||||||
| 76 | Select *pNew; | - | ||||||||||||||||||||||||
| 77 | Select standin; | - | ||||||||||||||||||||||||
| 78 | pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) ); | - | ||||||||||||||||||||||||
| 79 | if( pNew==0
| 152-599397 | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | ((void) (0)) | - | ||||||||||||||||||||||||
| 82 | ; | - | ||||||||||||||||||||||||
| 83 | pNew = &standin; | - | ||||||||||||||||||||||||
| 84 | } executed 152 times by 1 test: end of blockExecuted by:
| 152 | ||||||||||||||||||||||||
| 85 | if( pEList==0
| 1197-598352 | ||||||||||||||||||||||||
| 86 | pEList = sqlite3ExprListAppend(pParse, 0, | - | ||||||||||||||||||||||||
| 87 | sqlite3Expr(pParse->db,168,0)); | - | ||||||||||||||||||||||||
| 88 | } executed 1197 times by 1 test: end of blockExecuted by:
| 1197 | ||||||||||||||||||||||||
| 89 | pNew->pEList = pEList; | - | ||||||||||||||||||||||||
| 90 | pNew->op = 127; | - | ||||||||||||||||||||||||
| 91 | pNew->selFlags = selFlags; | - | ||||||||||||||||||||||||
| 92 | pNew->iLimit = 0; | - | ||||||||||||||||||||||||
| 93 | pNew->iOffset = 0; | - | ||||||||||||||||||||||||
| 94 | pNew->selId = ++pParse->nSelect; | - | ||||||||||||||||||||||||
| 95 | pNew->addrOpenEphm[0] = -1; | - | ||||||||||||||||||||||||
| 96 | pNew->addrOpenEphm[1] = -1; | - | ||||||||||||||||||||||||
| 97 | pNew->nSelectRow = 0; | - | ||||||||||||||||||||||||
| 98 | if( pSrc==0
executed 376566 times by 59 tests: pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));Executed by:
| 222983-376566 | ||||||||||||||||||||||||
| 99 | pNew->pSrc = pSrc; | - | ||||||||||||||||||||||||
| 100 | pNew->pWhere = pWhere; | - | ||||||||||||||||||||||||
| 101 | pNew->pGroupBy = pGroupBy; | - | ||||||||||||||||||||||||
| 102 | pNew->pHaving = pHaving; | - | ||||||||||||||||||||||||
| 103 | pNew->pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 104 | pNew->pPrior = 0; | - | ||||||||||||||||||||||||
| 105 | pNew->pNext = 0; | - | ||||||||||||||||||||||||
| 106 | pNew->pLimit = pLimit; | - | ||||||||||||||||||||||||
| 107 | pNew->pWith = 0; | - | ||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | pNew->pWin = 0; | - | ||||||||||||||||||||||||
| 110 | pNew->pWinDefn = 0; | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | if( pParse->db->mallocFailed
| 160-599389 | ||||||||||||||||||||||||
| 113 | clearSelect(pParse->db, pNew, pNew!=&standin); | - | ||||||||||||||||||||||||
| 114 | pNew = 0; | - | ||||||||||||||||||||||||
| 115 | } executed 160 times by 1 test: else{end of blockExecuted by:
| 160 | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | ((void) (0)) | - | ||||||||||||||||||||||||
| 118 | ; | - | ||||||||||||||||||||||||
| 119 | } executed 599389 times by 436 tests: end of blockExecuted by:
| 599389 | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | ((void) (0)) | - | ||||||||||||||||||||||||
| 122 | ; | - | ||||||||||||||||||||||||
| 123 | return executed 599549 times by 436 tests: pNew;return pNew;Executed by:
executed 599549 times by 436 tests: return pNew;Executed by:
| 599549 | ||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | void sqlite3SelectDelete(sqlite3 *db, Select *p){ | - | ||||||||||||||||||||||||
| 131 | if( (
executed 646788 times by 436 tests: clearSelect(db, p, 1);Executed by:
| 646788-1010929 | ||||||||||||||||||||||||
| 132 | } executed 1657717 times by 436 tests: end of blockExecuted by:
| 1657717 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | static Select *findRightmost(Select *p){ | - | ||||||||||||||||||||||||
| 138 | while( p->pNext
executed 489 times by 1 test: p = p->pNext;Executed by:
| 489-38059 | ||||||||||||||||||||||||
| 139 | return executed 38059 times by 1 test: p;return p;Executed by:
executed 38059 times by 1 test: return p;Executed by:
| 38059 | ||||||||||||||||||||||||
| 140 | } | - | ||||||||||||||||||||||||
| 141 | int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){ | - | ||||||||||||||||||||||||
| 142 | int jointype = 0; | - | ||||||||||||||||||||||||
| 143 | Token *apAll[3]; | - | ||||||||||||||||||||||||
| 144 | Token *p; | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | static const char zKeyText[] = "naturaleftouterightfullinnercross"; | - | ||||||||||||||||||||||||
| 147 | static const struct { | - | ||||||||||||||||||||||||
| 148 | u8 i; | - | ||||||||||||||||||||||||
| 149 | u8 nChar; | - | ||||||||||||||||||||||||
| 150 | u8 code; | - | ||||||||||||||||||||||||
| 151 | } aKeyword[] = { | - | ||||||||||||||||||||||||
| 152 | { 0, 7, 0x0004 }, | - | ||||||||||||||||||||||||
| 153 | { 6, 4, 0x0008|0x0020 }, | - | ||||||||||||||||||||||||
| 154 | { 10, 5, 0x0020 }, | - | ||||||||||||||||||||||||
| 155 | { 14, 5, 0x0010|0x0020 }, | - | ||||||||||||||||||||||||
| 156 | { 19, 4, 0x0008|0x0010|0x0020 }, | - | ||||||||||||||||||||||||
| 157 | { 23, 5, 0x0001 }, | - | ||||||||||||||||||||||||
| 158 | { 28, 5, 0x0001|0x0002 }, | - | ||||||||||||||||||||||||
| 159 | }; | - | ||||||||||||||||||||||||
| 160 | int i, j; | - | ||||||||||||||||||||||||
| 161 | apAll[0] = pA; | - | ||||||||||||||||||||||||
| 162 | apAll[1] = pB; | - | ||||||||||||||||||||||||
| 163 | apAll[2] = pC; | - | ||||||||||||||||||||||||
| 164 | for(i=0; i<3
| 18-2694 | ||||||||||||||||||||||||
| 165 | p = apAll[i]; | - | ||||||||||||||||||||||||
| 166 | for(j=0; j<((int)(sizeof(aKeyword)/sizeof(aKeyword[0])))
| 4-3720 | ||||||||||||||||||||||||
| 167 | if( p->n==aKeyword[j].nChar
| 1506-2214 | ||||||||||||||||||||||||
| 168 | && sqlite3_strnicmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0
| 773-1441 | ||||||||||||||||||||||||
| 169 | jointype |= aKeyword[j].code; | - | ||||||||||||||||||||||||
| 170 | break; executed 1441 times by 1 test: break;Executed by:
| 1441 | ||||||||||||||||||||||||
| 171 | } | - | ||||||||||||||||||||||||
| 172 | } executed 2279 times by 1 test: end of blockExecuted by:
| 2279 | ||||||||||||||||||||||||
| 173 | ; | - | ||||||||||||||||||||||||
| 174 | if( j>=((int)(sizeof(aKeyword)/sizeof(aKeyword[0])))
| 4-1441 | ||||||||||||||||||||||||
| 175 | jointype |= 0x0040; | - | ||||||||||||||||||||||||
| 176 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 177 | } | - | ||||||||||||||||||||||||
| 178 | } executed 1441 times by 1 test: end of blockExecuted by:
| 1441 | ||||||||||||||||||||||||
| 179 | if( | - | ||||||||||||||||||||||||
| 180 | (
| 4-1267 | ||||||||||||||||||||||||
| 181 | (
| 4-1263 | ||||||||||||||||||||||||
| 182 | ){ | - | ||||||||||||||||||||||||
| 183 | const char *zSp = " "; | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | ((void) (0)) | - | ||||||||||||||||||||||||
| 186 | ; | - | ||||||||||||||||||||||||
| 187 | if( pC==0
executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 188 | sqlite3ErrorMsg(pParse, "unknown or unsupported join type: " | - | ||||||||||||||||||||||||
| 189 | "%T %T%s%T", pA, pB, zSp, pC); | - | ||||||||||||||||||||||||
| 190 | jointype = 0x0001; | - | ||||||||||||||||||||||||
| 191 | } executed 8 times by 1 test: else if( (end of blockExecuted by:
| 8-764 | ||||||||||||||||||||||||
| 192 | && (
| 2-497 | ||||||||||||||||||||||||
| 193 | sqlite3ErrorMsg(pParse, | - | ||||||||||||||||||||||||
| 194 | "RIGHT and FULL OUTER JOINs are not currently supported"); | - | ||||||||||||||||||||||||
| 195 | jointype = 0x0001; | - | ||||||||||||||||||||||||
| 196 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 197 | return executed 1271 times by 1 test: jointype;return jointype;Executed by:
executed 1271 times by 1 test: return jointype;Executed by:
| 1271 | ||||||||||||||||||||||||
| 198 | } | - | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | static int columnIndex(Table *pTab, const char *zCol){ | - | ||||||||||||||||||||||||
| 205 | int i; | - | ||||||||||||||||||||||||
| 206 | for(i=0; i<pTab->nCol
| 936-5667 | ||||||||||||||||||||||||
| 207 | if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0
executed 2396 times by 1 test: i;return i;Executed by:
executed 2396 times by 1 test: return i;Executed by:
| 2396-3271 | ||||||||||||||||||||||||
| 208 | } executed 3271 times by 1 test: end of blockExecuted by:
| 3271 | ||||||||||||||||||||||||
| 209 | return executed 936 times by 1 test: -1;return -1;Executed by:
executed 936 times by 1 test: return -1;Executed by:
| 936 | ||||||||||||||||||||||||
| 210 | } | - | ||||||||||||||||||||||||
| 211 | static int tableAndColumnIndex( | - | ||||||||||||||||||||||||
| 212 | SrcList *pSrc, | - | ||||||||||||||||||||||||
| 213 | int N, | - | ||||||||||||||||||||||||
| 214 | const char *zCol, | - | ||||||||||||||||||||||||
| 215 | int *piTab, | - | ||||||||||||||||||||||||
| 216 | int *piCol | - | ||||||||||||||||||||||||
| 217 | ){ | - | ||||||||||||||||||||||||
| 218 | int i; | - | ||||||||||||||||||||||||
| 219 | int iCol; | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | ((void) (0)) | - | ||||||||||||||||||||||||
| 223 | ; | - | ||||||||||||||||||||||||
| 224 | for(i=0; i<N
| 695-2684 | ||||||||||||||||||||||||
| 225 | iCol = columnIndex(pSrc->a[i].pTab, zCol); | - | ||||||||||||||||||||||||
| 226 | if( iCol>=0
| 931-1753 | ||||||||||||||||||||||||
| 227 | if( piTab
| 392-1361 | ||||||||||||||||||||||||
| 228 | *piTab = i; | - | ||||||||||||||||||||||||
| 229 | *piCol = iCol; | - | ||||||||||||||||||||||||
| 230 | } executed 1361 times by 1 test: end of blockExecuted by:
| 1361 | ||||||||||||||||||||||||
| 231 | return executed 1753 times by 1 test: 1;return 1;Executed by:
executed 1753 times by 1 test: return 1;Executed by:
| 1753 | ||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||
| 233 | } executed 931 times by 1 test: end of blockExecuted by:
| 931 | ||||||||||||||||||||||||
| 234 | return executed 695 times by 1 test: 0;return 0;Executed by:
executed 695 times by 1 test: return 0;Executed by:
| 695 | ||||||||||||||||||||||||
| 235 | } | - | ||||||||||||||||||||||||
| 236 | static void addWhereTerm( | - | ||||||||||||||||||||||||
| 237 | Parse *pParse, | - | ||||||||||||||||||||||||
| 238 | SrcList *pSrc, | - | ||||||||||||||||||||||||
| 239 | int iLeft, | - | ||||||||||||||||||||||||
| 240 | int iColLeft, | - | ||||||||||||||||||||||||
| 241 | int iRight, | - | ||||||||||||||||||||||||
| 242 | int iColRight, | - | ||||||||||||||||||||||||
| 243 | int isOuterJoin, | - | ||||||||||||||||||||||||
| 244 | Expr **ppWhere | - | ||||||||||||||||||||||||
| 245 | ){ | - | ||||||||||||||||||||||||
| 246 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 247 | Expr *pE1; | - | ||||||||||||||||||||||||
| 248 | Expr *pE2; | - | ||||||||||||||||||||||||
| 249 | Expr *pEq; | - | ||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | ((void) (0)) | - | ||||||||||||||||||||||||
| 253 | ; | - | ||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | ((void) (0)) | - | ||||||||||||||||||||||||
| 256 | ; | - | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | ((void) (0)) | - | ||||||||||||||||||||||||
| 259 | ; | - | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | ((void) (0)) | - | ||||||||||||||||||||||||
| 262 | ; | - | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft); | - | ||||||||||||||||||||||||
| 265 | pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); | - | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | pEq = sqlite3PExpr(pParse, 53, pE1, pE2); | - | ||||||||||||||||||||||||
| 268 | if( pEq
| 0-1361 | ||||||||||||||||||||||||
| 269 | (pEq)->flags|=(0x000001); | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | ((void) (0)) | - | ||||||||||||||||||||||||
| 272 | ; | - | ||||||||||||||||||||||||
| 273 | ; | - | ||||||||||||||||||||||||
| 274 | pEq->iRightJoinTable = (i16)pE2->iTable; | - | ||||||||||||||||||||||||
| 275 | } executed 138 times by 1 test: end of blockExecuted by:
| 138 | ||||||||||||||||||||||||
| 276 | *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq); | - | ||||||||||||||||||||||||
| 277 | } executed 1361 times by 1 test: end of blockExecuted by:
| 1361 | ||||||||||||||||||||||||
| 278 | static void setJoinExpr(Expr *p, int iTable){ | - | ||||||||||||||||||||||||
| 279 | while( p
| 2288-2664 | ||||||||||||||||||||||||
| 280 | (p)->flags|=(0x000001); | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | ((void) (0)) | - | ||||||||||||||||||||||||
| 283 | ; | - | ||||||||||||||||||||||||
| 284 | ; | - | ||||||||||||||||||||||||
| 285 | p->iRightJoinTable = (i16)iTable; | - | ||||||||||||||||||||||||
| 286 | if( p->op==157
| 0-2284 | ||||||||||||||||||||||||
| 287 | int i; | - | ||||||||||||||||||||||||
| 288 | for(i=0; i<p->x.pList->nExpr
| 4-7 | ||||||||||||||||||||||||
| 289 | setJoinExpr(p->x.pList->a[i].pExpr, iTable); | - | ||||||||||||||||||||||||
| 290 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 291 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 292 | setJoinExpr(p->pLeft, iTable); | - | ||||||||||||||||||||||||
| 293 | p = p->pRight; | - | ||||||||||||||||||||||||
| 294 | } executed 2288 times by 1 test: end of blockExecuted by:
| 2288 | ||||||||||||||||||||||||
| 295 | } executed 2664 times by 1 test: end of blockExecuted by:
| 2664 | ||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | static void unsetJoinExpr(Expr *p, int iTable){ | - | ||||||||||||||||||||||||
| 304 | while( p
| 557-715 | ||||||||||||||||||||||||
| 305 | if( (((
| 62-495 | ||||||||||||||||||||||||
| 306 | && (iTable<0
| 3-59 | ||||||||||||||||||||||||
| 307 | (p)->flags&=~(0x000001); | - | ||||||||||||||||||||||||
| 308 | } executed 59 times by 1 test: end of blockExecuted by:
| 59 | ||||||||||||||||||||||||
| 309 | if( p->op==157
| 0-543 | ||||||||||||||||||||||||
| 310 | int i; | - | ||||||||||||||||||||||||
| 311 | for(i=0; i<p->x.pList->nExpr
| 14-26 | ||||||||||||||||||||||||
| 312 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable); | - | ||||||||||||||||||||||||
| 313 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||
| 314 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||
| 315 | unsetJoinExpr(p->pLeft, iTable); | - | ||||||||||||||||||||||||
| 316 | p = p->pRight; | - | ||||||||||||||||||||||||
| 317 | } executed 557 times by 1 test: end of blockExecuted by:
| 557 | ||||||||||||||||||||||||
| 318 | } executed 715 times by 1 test: end of blockExecuted by:
| 715 | ||||||||||||||||||||||||
| 319 | static int sqliteProcessJoin(Parse *pParse, Select *p){ | - | ||||||||||||||||||||||||
| 320 | SrcList *pSrc; | - | ||||||||||||||||||||||||
| 321 | int i, j; | - | ||||||||||||||||||||||||
| 322 | struct SrcList_item *pLeft; | - | ||||||||||||||||||||||||
| 323 | struct SrcList_item *pRight; | - | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | pSrc = p->pSrc; | - | ||||||||||||||||||||||||
| 326 | pLeft = &pSrc->a[0]; | - | ||||||||||||||||||||||||
| 327 | pRight = &pLeft[1]; | - | ||||||||||||||||||||||||
| 328 | for(i=0; i<pSrc->nSrc-1
| 79439-1006823 | ||||||||||||||||||||||||
| 329 | Table *pRightTab = pRight->pTab; | - | ||||||||||||||||||||||||
| 330 | int isOuter; | - | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | if( (pLeft->pTab==0
never executed: continue; | 0-79439 | ||||||||||||||||||||||||
| 333 | isOuter = (pRight->fg.jointype & 0x0020)!=0; | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | if( pRight->fg.jointype & 0x0004
| 587-78852 | ||||||||||||||||||||||||
| 339 | if( pRight->pOn
| 3-583 | ||||||||||||||||||||||||
| 340 | sqlite3ErrorMsg(pParse, "a NATURAL join may not have " | - | ||||||||||||||||||||||||
| 341 | "an ON or USING clause", 0); | - | ||||||||||||||||||||||||
| 342 | return executed 7 times by 1 test: 1;return 1;Executed by:
executed 7 times by 1 test: return 1;Executed by:
| 7 | ||||||||||||||||||||||||
| 343 | } | - | ||||||||||||||||||||||||
| 344 | for(j=0; j<pRightTab->nCol
| 580-1218 | ||||||||||||||||||||||||
| 345 | char *zName; | - | ||||||||||||||||||||||||
| 346 | int iLeft; | - | ||||||||||||||||||||||||
| 347 | int iLeftCol; | - | ||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | zName = pRightTab->aCol[j].zName; | - | ||||||||||||||||||||||||
| 350 | if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)
| 499-719 | ||||||||||||||||||||||||
| 351 | addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j, | - | ||||||||||||||||||||||||
| 352 | isOuter, &p->pWhere); | - | ||||||||||||||||||||||||
| 353 | } executed 719 times by 1 test: end of blockExecuted by:
| 719 | ||||||||||||||||||||||||
| 354 | } executed 1218 times by 1 test: end of blockExecuted by:
| 1218 | ||||||||||||||||||||||||
| 355 | } executed 580 times by 1 test: end of blockExecuted by:
| 580 | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | if( pRight->pOn
| 3-77547 | ||||||||||||||||||||||||
| 360 | sqlite3ErrorMsg(pParse, "cannot have both ON and USING " | - | ||||||||||||||||||||||||
| 361 | "clauses in the same join"); | - | ||||||||||||||||||||||||
| 362 | return executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | if( pRight->pOn
| 1882-77547 | ||||||||||||||||||||||||
| 369 | if( isOuter
executed 347 times by 1 test: setJoinExpr(pRight->pOn, pRight->iCursor);Executed by:
| 347-1535 | ||||||||||||||||||||||||
| 370 | p->pWhere = sqlite3ExprAnd(pParse->db, p->pWhere, pRight->pOn); | - | ||||||||||||||||||||||||
| 371 | pRight->pOn = 0; | - | ||||||||||||||||||||||||
| 372 | } executed 1882 times by 1 test: end of blockExecuted by:
| 1882 | ||||||||||||||||||||||||
| 373 | if( pRight->pUsing
| 613-78816 | ||||||||||||||||||||||||
| 374 | IdList *pList = pRight->pUsing; | - | ||||||||||||||||||||||||
| 375 | for(j=0; j<pList->nId
| 607-648 | ||||||||||||||||||||||||
| 376 | char *zName; | - | ||||||||||||||||||||||||
| 377 | int iLeft; | - | ||||||||||||||||||||||||
| 378 | int iLeftCol; | - | ||||||||||||||||||||||||
| 379 | int iRightCol; | - | ||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | zName = pList->a[j].zName; | - | ||||||||||||||||||||||||
| 382 | iRightCol = columnIndex(pRightTab, zName); | - | ||||||||||||||||||||||||
| 383 | if( iRightCol<0
| 5-643 | ||||||||||||||||||||||||
| 384 | || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)
| 1-642 | ||||||||||||||||||||||||
| 385 | ){ | - | ||||||||||||||||||||||||
| 386 | sqlite3ErrorMsg(pParse, "cannot join using column %s - column " | - | ||||||||||||||||||||||||
| 387 | "not present in both tables", zName); | - | ||||||||||||||||||||||||
| 388 | return executed 6 times by 1 test: 1;return 1;Executed by:
executed 6 times by 1 test: return 1;Executed by:
| 6 | ||||||||||||||||||||||||
| 389 | } | - | ||||||||||||||||||||||||
| 390 | addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol, | - | ||||||||||||||||||||||||
| 391 | isOuter, &p->pWhere); | - | ||||||||||||||||||||||||
| 392 | } executed 642 times by 1 test: end of blockExecuted by:
| 642 | ||||||||||||||||||||||||
| 393 | } executed 607 times by 1 test: end of blockExecuted by:
| 607 | ||||||||||||||||||||||||
| 394 | } executed 79423 times by 1 test: end of blockExecuted by:
| 79423 | ||||||||||||||||||||||||
| 395 | return executed 1006823 times by 435 tests: 0;return 0;Executed by:
executed 1006823 times by 435 tests: return 0;Executed by:
| 1006823 | ||||||||||||||||||||||||
| 396 | } | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | typedef struct RowLoadInfo RowLoadInfo; | - | ||||||||||||||||||||||||
| 403 | struct RowLoadInfo { | - | ||||||||||||||||||||||||
| 404 | int regResult; | - | ||||||||||||||||||||||||
| 405 | u8 ecelFlags; | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | }; | - | ||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | static void innerLoopLoadRow( | - | ||||||||||||||||||||||||
| 417 | Parse *pParse, | - | ||||||||||||||||||||||||
| 418 | Select *pSelect, | - | ||||||||||||||||||||||||
| 419 | RowLoadInfo *pInfo | - | ||||||||||||||||||||||||
| 420 | ){ | - | ||||||||||||||||||||||||
| 421 | sqlite3ExprCodeExprList(pParse, pSelect->pEList, pInfo->regResult, | - | ||||||||||||||||||||||||
| 422 | 0, pInfo->ecelFlags); | - | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | - | |||||||||||||||||||||||||
| 429 | } executed 374052 times by 435 tests: end of blockExecuted by:
| 374052 | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | static int makeSorterRecord( | - | ||||||||||||||||||||||||
| 438 | Parse *pParse, | - | ||||||||||||||||||||||||
| 439 | SortCtx *pSort, | - | ||||||||||||||||||||||||
| 440 | Select *pSelect, | - | ||||||||||||||||||||||||
| 441 | int regBase, | - | ||||||||||||||||||||||||
| 442 | int nBase | - | ||||||||||||||||||||||||
| 443 | ){ | - | ||||||||||||||||||||||||
| 444 | int nOBSat = pSort->nOBSat; | - | ||||||||||||||||||||||||
| 445 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 446 | int regOut = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 447 | if( pSort->pDeferredRowLoad
| 644-12482 | ||||||||||||||||||||||||
| 448 | innerLoopLoadRow(pParse, pSelect, pSort->pDeferredRowLoad); | - | ||||||||||||||||||||||||
| 449 | } executed 644 times by 1 test: end of blockExecuted by:
| 644 | ||||||||||||||||||||||||
| 450 | sqlite3VdbeAddOp3(v, 102, regBase+nOBSat, nBase-nOBSat, regOut); | - | ||||||||||||||||||||||||
| 451 | return executed 13126 times by 1 test: regOut;return regOut;Executed by:
executed 13126 times by 1 test: return regOut;Executed by:
| 13126 | ||||||||||||||||||||||||
| 452 | } | - | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | static void pushOntoSorter( | - | ||||||||||||||||||||||||
| 459 | Parse *pParse, | - | ||||||||||||||||||||||||
| 460 | SortCtx *pSort, | - | ||||||||||||||||||||||||
| 461 | Select *pSelect, | - | ||||||||||||||||||||||||
| 462 | int regData, | - | ||||||||||||||||||||||||
| 463 | int regOrigData, | - | ||||||||||||||||||||||||
| 464 | int nData, | - | ||||||||||||||||||||||||
| 465 | int nPrefixReg | - | ||||||||||||||||||||||||
| 466 | ){ | - | ||||||||||||||||||||||||
| 467 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 468 | int bSeq = ((pSort->sortFlags & 0x01)==0); | - | ||||||||||||||||||||||||
| 469 | int nExpr = pSort->pOrderBy->nExpr; | - | ||||||||||||||||||||||||
| 470 | int nBase = nExpr + bSeq + nData; | - | ||||||||||||||||||||||||
| 471 | int regBase; | - | ||||||||||||||||||||||||
| 472 | int regRecord = 0; | - | ||||||||||||||||||||||||
| 473 | int nOBSat = pSort->nOBSat; | - | ||||||||||||||||||||||||
| 474 | int op; | - | ||||||||||||||||||||||||
| 475 | int iLimit; | - | ||||||||||||||||||||||||
| 476 | int iSkip = 0; | - | ||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | ((void) (0)) | - | ||||||||||||||||||||||||
| 480 | ; | - | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | ((void) (0)) | - | ||||||||||||||||||||||||
| 483 | ; | - | ||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | if( nPrefixReg
| 147-12979 | ||||||||||||||||||||||||
| 486 | - | |||||||||||||||||||||||||
| 487 | ((void) (0)) | - | ||||||||||||||||||||||||
| 488 | ; | - | ||||||||||||||||||||||||
| 489 | regBase = regData - nPrefixReg; | - | ||||||||||||||||||||||||
| 490 | } executed 12979 times by 1 test: else{end of blockExecuted by:
| 12979 | ||||||||||||||||||||||||
| 491 | regBase = pParse->nMem + 1; | - | ||||||||||||||||||||||||
| 492 | pParse->nMem += nBase; | - | ||||||||||||||||||||||||
| 493 | } executed 147 times by 1 test: end of blockExecuted by:
| 147 | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | ((void) (0)) | - | ||||||||||||||||||||||||
| 496 | ; | - | ||||||||||||||||||||||||
| 497 | iLimit = pSelect->iOffset
| 264-12862 | ||||||||||||||||||||||||
| 498 | pSort->labelDone = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 499 | sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData, | - | ||||||||||||||||||||||||
| 500 | 0x01 | (regOrigData? 0x04 : 0)); | - | ||||||||||||||||||||||||
| 501 | if( bSeq
| 794-12332 | ||||||||||||||||||||||||
| 502 | sqlite3VdbeAddOp2(v, 120, pSort->iECursor, regBase+nExpr); | - | ||||||||||||||||||||||||
| 503 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 504 | if( nPrefixReg==0
| 48-12979 | ||||||||||||||||||||||||
| 505 | sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData); | - | ||||||||||||||||||||||||
| 506 | } executed 99 times by 1 test: end of blockExecuted by:
| 99 | ||||||||||||||||||||||||
| 507 | if( nOBSat>0
| 319-12807 | ||||||||||||||||||||||||
| 508 | int regPrevKey; | - | ||||||||||||||||||||||||
| 509 | int addrFirst; | - | ||||||||||||||||||||||||
| 510 | int addrJmp; | - | ||||||||||||||||||||||||
| 511 | VdbeOp *pOp; | - | ||||||||||||||||||||||||
| 512 | int nKey; | - | ||||||||||||||||||||||||
| 513 | KeyInfo *pKI; | - | ||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase); | - | ||||||||||||||||||||||||
| 516 | regPrevKey = pParse->nMem+1; | - | ||||||||||||||||||||||||
| 517 | pParse->nMem += pSort->nOBSat; | - | ||||||||||||||||||||||||
| 518 | nKey = nExpr - pSort->nOBSat + bSeq; | - | ||||||||||||||||||||||||
| 519 | if( bSeq
| 78-241 | ||||||||||||||||||||||||
| 520 | addrFirst = sqlite3VdbeAddOp1(v, 20, regBase+nExpr); | - | ||||||||||||||||||||||||
| 521 | } executed 78 times by 1 test: else{end of blockExecuted by:
| 78 | ||||||||||||||||||||||||
| 522 | addrFirst = sqlite3VdbeAddOp1(v, 115, pSort->iECursor); | - | ||||||||||||||||||||||||
| 523 | } executed 241 times by 1 test: end of blockExecuted by:
| 241 | ||||||||||||||||||||||||
| 524 | ; | - | ||||||||||||||||||||||||
| 525 | sqlite3VdbeAddOp3(v, 87, regPrevKey, regBase, pSort->nOBSat); | - | ||||||||||||||||||||||||
| 526 | pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex); | - | ||||||||||||||||||||||||
| 527 | if( pParse->db->mallocFailed
never executed: return; | 0-319 | ||||||||||||||||||||||||
| 528 | pOp->p2 = nKey + nData; | - | ||||||||||||||||||||||||
| 529 | pKI = pOp->p4.pKeyInfo; | - | ||||||||||||||||||||||||
| 530 | memset(pKI->aSortOrder, 0, pKI->nKeyField); | - | ||||||||||||||||||||||||
| 531 | sqlite3VdbeChangeP4(v, -1, (char*)pKI, (-9)); | - | ||||||||||||||||||||||||
| 532 | ; | - | ||||||||||||||||||||||||
| 533 | pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat, | - | ||||||||||||||||||||||||
| 534 | pKI->nAllField-pKI->nKeyField-1); | - | ||||||||||||||||||||||||
| 535 | addrJmp = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 536 | sqlite3VdbeAddOp3(v, 16, addrJmp+1, 0, addrJmp+1); ; | - | ||||||||||||||||||||||||
| 537 | pSort->labelBkOut = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 538 | pSort->regReturn = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 539 | sqlite3VdbeAddOp2(v, 12, pSort->regReturn, pSort->labelBkOut); | - | ||||||||||||||||||||||||
| 540 | sqlite3VdbeAddOp1(v, 139, pSort->iECursor); | - | ||||||||||||||||||||||||
| 541 | if( iLimit
| 78-241 | ||||||||||||||||||||||||
| 542 | sqlite3VdbeAddOp2(v, 20, iLimit, pSort->labelDone); | - | ||||||||||||||||||||||||
| 543 | ; | - | ||||||||||||||||||||||||
| 544 | } executed 78 times by 1 test: end of blockExecuted by:
| 78 | ||||||||||||||||||||||||
| 545 | sqlite3VdbeJumpHere(v, addrFirst); | - | ||||||||||||||||||||||||
| 546 | sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat); | - | ||||||||||||||||||||||||
| 547 | sqlite3VdbeJumpHere(v, addrJmp); | - | ||||||||||||||||||||||||
| 548 | } executed 319 times by 1 test: end of blockExecuted by:
| 319 | ||||||||||||||||||||||||
| 549 | if( iLimit
| 794-12332 | ||||||||||||||||||||||||
| 550 | int iCsr = pSort->iECursor; | - | ||||||||||||||||||||||||
| 551 | sqlite3VdbeAddOp2(v, 48, iLimit, sqlite3VdbeCurrentAddr(v)+4); | - | ||||||||||||||||||||||||
| 552 | ; | - | ||||||||||||||||||||||||
| 553 | sqlite3VdbeAddOp2(v, 32, iCsr, 0); | - | ||||||||||||||||||||||||
| 554 | iSkip = sqlite3VdbeAddOp4Int(v, 37, | - | ||||||||||||||||||||||||
| 555 | iCsr, 0, regBase+nOBSat, nExpr-nOBSat); | - | ||||||||||||||||||||||||
| 556 | ; | - | ||||||||||||||||||||||||
| 557 | sqlite3VdbeAddOp1(v, 124, iCsr); | - | ||||||||||||||||||||||||
| 558 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 559 | if( regRecord==0
| 319-12807 | ||||||||||||||||||||||||
| 560 | regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase); | - | ||||||||||||||||||||||||
| 561 | } executed 12807 times by 1 test: end of blockExecuted by:
| 12807 | ||||||||||||||||||||||||
| 562 | if( pSort->sortFlags & 0x01
| 794-12332 | ||||||||||||||||||||||||
| 563 | op = 132; | - | ||||||||||||||||||||||||
| 564 | } executed 12332 times by 1 test: else{end of blockExecuted by:
| 12332 | ||||||||||||||||||||||||
| 565 | op = 133; | - | ||||||||||||||||||||||||
| 566 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 567 | sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord, | - | ||||||||||||||||||||||||
| 568 | regBase+nOBSat, nBase-nOBSat); | - | ||||||||||||||||||||||||
| 569 | if( iSkip
| 794-12332 | ||||||||||||||||||||||||
| 570 | sqlite3VdbeChangeP2(v, iSkip, | - | ||||||||||||||||||||||||
| 571 | pSort->labelOBLopt ? pSort->labelOBLopt : sqlite3VdbeCurrentAddr(v)); | - | ||||||||||||||||||||||||
| 572 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 573 | } executed 13126 times by 1 test: end of blockExecuted by:
| 13126 | ||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | static void codeOffset( | - | ||||||||||||||||||||||||
| 579 | Vdbe *v, | - | ||||||||||||||||||||||||
| 580 | int iOffset, | - | ||||||||||||||||||||||||
| 581 | int iContinue | - | ||||||||||||||||||||||||
| 582 | ){ | - | ||||||||||||||||||||||||
| 583 | if( iOffset>0
| 538-414809 | ||||||||||||||||||||||||
| 584 | sqlite3VdbeAddOp3(v, 47, iOffset, iContinue, 1); ; | - | ||||||||||||||||||||||||
| 585 | ; | - | ||||||||||||||||||||||||
| 586 | } executed 538 times by 1 test: end of blockExecuted by:
| 538 | ||||||||||||||||||||||||
| 587 | } executed 415347 times by 435 tests: end of blockExecuted by:
| 415347 | ||||||||||||||||||||||||
| 588 | static void codeDistinct( | - | ||||||||||||||||||||||||
| 589 | Parse *pParse, | - | ||||||||||||||||||||||||
| 590 | int iTab, | - | ||||||||||||||||||||||||
| 591 | int addrRepeat, | - | ||||||||||||||||||||||||
| 592 | int N, | - | ||||||||||||||||||||||||
| 593 | int iMem | - | ||||||||||||||||||||||||
| 594 | ){ | - | ||||||||||||||||||||||||
| 595 | Vdbe *v; | - | ||||||||||||||||||||||||
| 596 | int r1; | - | ||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||
| 598 | v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 599 | r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 600 | sqlite3VdbeAddOp4Int(v, 29, iTab, addrRepeat, iMem, N); ; | - | ||||||||||||||||||||||||
| 601 | sqlite3VdbeAddOp3(v, 102, iMem, N, r1); | - | ||||||||||||||||||||||||
| 602 | sqlite3VdbeAddOp4Int(v, 133, iTab, r1, iMem, N); | - | ||||||||||||||||||||||||
| 603 | sqlite3VdbeChangeP5(v, 0x10); | - | ||||||||||||||||||||||||
| 604 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 605 | } executed 3416 times by 1 test: end of blockExecuted by:
| 3416 | ||||||||||||||||||||||||
| 606 | static void selectInnerLoop( | - | ||||||||||||||||||||||||
| 607 | Parse *pParse, | - | ||||||||||||||||||||||||
| 608 | Select *p, | - | ||||||||||||||||||||||||
| 609 | int srcTab, | - | ||||||||||||||||||||||||
| 610 | SortCtx *pSort, | - | ||||||||||||||||||||||||
| 611 | DistinctCtx *pDistinct, | - | ||||||||||||||||||||||||
| 612 | SelectDest *pDest, | - | ||||||||||||||||||||||||
| 613 | int iContinue, | - | ||||||||||||||||||||||||
| 614 | int iBreak | - | ||||||||||||||||||||||||
| 615 | ){ | - | ||||||||||||||||||||||||
| 616 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 617 | int i; | - | ||||||||||||||||||||||||
| 618 | int hasDistinct; | - | ||||||||||||||||||||||||
| 619 | int eDest = pDest->eDest; | - | ||||||||||||||||||||||||
| 620 | int iParm = pDest->iSDParm; | - | ||||||||||||||||||||||||
| 621 | int nResultCol; | - | ||||||||||||||||||||||||
| 622 | int nPrefixReg = 0; | - | ||||||||||||||||||||||||
| 623 | RowLoadInfo sRowLoadInfo; | - | ||||||||||||||||||||||||
| 624 | - | |||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | - | |||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | int regResult; | - | ||||||||||||||||||||||||
| 631 | int regOrig; | - | ||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||
| 634 | ((void) (0)) | - | ||||||||||||||||||||||||
| 635 | ; | - | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | ((void) (0)) | - | ||||||||||||||||||||||||
| 638 | ; | - | ||||||||||||||||||||||||
| 639 | hasDistinct = pDistinct
| 161304-252634 | ||||||||||||||||||||||||
| 640 | if( pSort
executed 239508 times by 435 tests: pSort = 0;Executed by:
| 13126-252634 | ||||||||||||||||||||||||
| 641 | if( pSort==0
| 239-400812 | ||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||
| 643 | ((void) (0)) | - | ||||||||||||||||||||||||
| 644 | ; | - | ||||||||||||||||||||||||
| 645 | codeOffset(v, p->iOffset, iContinue); | - | ||||||||||||||||||||||||
| 646 | } executed 400573 times by 435 tests: end of blockExecuted by:
| 400573 | ||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | nResultCol = p->pEList->nExpr; | - | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | if( pDest->iSdst==0
| 155406-258532 | ||||||||||||||||||||||||
| 653 | if( pSort
| 12979-245553 | ||||||||||||||||||||||||
| 654 | nPrefixReg = pSort->pOrderBy->nExpr; | - | ||||||||||||||||||||||||
| 655 | if( !(pSort->sortFlags & 0x01)
executed 653 times by 1 test: nPrefixReg++;Executed by:
| 653-12326 | ||||||||||||||||||||||||
| 656 | pParse->nMem += nPrefixReg; | - | ||||||||||||||||||||||||
| 657 | } executed 12979 times by 1 test: end of blockExecuted by:
| 12979 | ||||||||||||||||||||||||
| 658 | pDest->iSdst = pParse->nMem+1; | - | ||||||||||||||||||||||||
| 659 | pParse->nMem += nResultCol; | - | ||||||||||||||||||||||||
| 660 | } executed 258532 times by 435 tests: else if( pDest->iSdst+nResultCol > pParse->nMemend of blockExecuted by:
| 17751-258532 | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||
| 666 | pParse->nMem += nResultCol; | - | ||||||||||||||||||||||||
| 667 | } executed 17751 times by 1 test: end of blockExecuted by:
| 17751 | ||||||||||||||||||||||||
| 668 | pDest->nSdst = nResultCol; | - | ||||||||||||||||||||||||
| 669 | regOrig = regResult = pDest->iSdst; | - | ||||||||||||||||||||||||
| 670 | if( srcTab>=0
| 36704-377234 | ||||||||||||||||||||||||
| 671 | for(i=0; i<nResultCol
| 36704-37043 | ||||||||||||||||||||||||
| 672 | sqlite3VdbeAddOp3(v, 90, srcTab, i, regResult+i); | - | ||||||||||||||||||||||||
| 673 | ; | - | ||||||||||||||||||||||||
| 674 | } executed 37043 times by 1 test: end of blockExecuted by:
| 37043 | ||||||||||||||||||||||||
| 675 | } executed 36704 times by 1 test: else if( eDest!=3end of blockExecuted by:
| 3182-374052 | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | - | |||||||||||||||||||||||||
| 682 | u8 ecelFlags; | - | ||||||||||||||||||||||||
| 683 | ExprList *pEList; | - | ||||||||||||||||||||||||
| 684 | if( eDest==10
| 12256-361796 | ||||||||||||||||||||||||
| 685 | ecelFlags = 0x01; | - | ||||||||||||||||||||||||
| 686 | } executed 298910 times by 435 tests: else{end of blockExecuted by:
| 298910 | ||||||||||||||||||||||||
| 687 | ecelFlags = 0; | - | ||||||||||||||||||||||||
| 688 | } executed 75142 times by 1 test: end of blockExecuted by:
| 75142 | ||||||||||||||||||||||||
| 689 | if( pSort
| 1-360926 | ||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | ecelFlags |= (0x08|0x04); | - | ||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr
| 13074-15890 | ||||||||||||||||||||||||
| 699 | int j; | - | ||||||||||||||||||||||||
| 700 | if( (
| 7942-7948 | ||||||||||||||||||||||||
| 701 | p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat; | - | ||||||||||||||||||||||||
| 702 | } executed 7948 times by 1 test: end of blockExecuted by:
| 7948 | ||||||||||||||||||||||||
| 703 | } executed 15890 times by 1 test: end of blockExecuted by:
| 15890 | ||||||||||||||||||||||||
| 704 | pEList = p->pEList; | - | ||||||||||||||||||||||||
| 705 | for(i=0; i<pEList->nExpr
| 13074-41075 | ||||||||||||||||||||||||
| 706 | if( pEList->a[i].u.x.iOrderByCol>0
| 7865-33210 | ||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | ){ | - | ||||||||||||||||||||||||
| 711 | nResultCol--; | - | ||||||||||||||||||||||||
| 712 | regOrig = 0; | - | ||||||||||||||||||||||||
| 713 | } executed 7865 times by 1 test: end of blockExecuted by:
| 7865 | ||||||||||||||||||||||||
| 714 | } executed 41075 times by 1 test: end of blockExecuted by:
| 41075 | ||||||||||||||||||||||||
| 715 | - | |||||||||||||||||||||||||
| 716 | ; | - | ||||||||||||||||||||||||
| 717 | ; | - | ||||||||||||||||||||||||
| 718 | ; | - | ||||||||||||||||||||||||
| 719 | ; | - | ||||||||||||||||||||||||
| 720 | ; | - | ||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||
| 722 | ((void) (0)) | - | ||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||
| 724 | ; | - | ||||||||||||||||||||||||
| 725 | } executed 13074 times by 1 test: end of blockExecuted by:
| 13074 | ||||||||||||||||||||||||
| 726 | sRowLoadInfo.regResult = regResult; | - | ||||||||||||||||||||||||
| 727 | sRowLoadInfo.ecelFlags = ecelFlags; | - | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | if( p->iLimit
| 13569-360483 | ||||||||||||||||||||||||
| 734 | && (
| 784-12785 | ||||||||||||||||||||||||
| 735 | && nPrefixReg>0
| 140-644 | ||||||||||||||||||||||||
| 736 | ){ | - | ||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | ((void) (0)) | - | ||||||||||||||||||||||||
| 739 | ; | - | ||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | ((void) (0)) | - | ||||||||||||||||||||||||
| 742 | ; | - | ||||||||||||||||||||||||
| 743 | pSort->pDeferredRowLoad = &sRowLoadInfo; | - | ||||||||||||||||||||||||
| 744 | regOrig = 0; | - | ||||||||||||||||||||||||
| 745 | } executed 644 times by 1 test: else{end of blockExecuted by:
| 644 | ||||||||||||||||||||||||
| 746 | innerLoopLoadRow(pParse, p, &sRowLoadInfo); | - | ||||||||||||||||||||||||
| 747 | } executed 373408 times by 435 tests: end of blockExecuted by:
| 373408 | ||||||||||||||||||||||||
| 748 | } | - | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | if( hasDistinct
| 288-413650 | ||||||||||||||||||||||||
| 755 | switch( pDistinct->eTnctType ){ | - | ||||||||||||||||||||||||
| 756 | case executed 62 times by 1 test: 2:case 2:Executed by:
executed 62 times by 1 test: {case 2:Executed by:
| 62 | ||||||||||||||||||||||||
| 757 | VdbeOp *pOp; | - | ||||||||||||||||||||||||
| 758 | int iJump; | - | ||||||||||||||||||||||||
| 759 | int regPrev; | - | ||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | regPrev = pParse->nMem+1; | - | ||||||||||||||||||||||||
| 763 | pParse->nMem += nResultCol; | - | ||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | - | |||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||
| 771 | sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct); | - | ||||||||||||||||||||||||
| 772 | pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct); | - | ||||||||||||||||||||||||
| 773 | pOp->opcode = 73; | - | ||||||||||||||||||||||||
| 774 | pOp->p1 = 1; | - | ||||||||||||||||||||||||
| 775 | pOp->p2 = regPrev; | - | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | iJump = sqlite3VdbeCurrentAddr(v) + nResultCol; | - | ||||||||||||||||||||||||
| 778 | for(i=0; i<nResultCol
| 62-118 | ||||||||||||||||||||||||
| 779 | CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr); | - | ||||||||||||||||||||||||
| 780 | if( i<nResultCol-1
| 56-62 | ||||||||||||||||||||||||
| 781 | sqlite3VdbeAddOp3(v, 52, regResult+i, iJump, regPrev+i); | - | ||||||||||||||||||||||||
| 782 | ; | - | ||||||||||||||||||||||||
| 783 | } executed 56 times by 1 test: else{end of blockExecuted by:
| 56 | ||||||||||||||||||||||||
| 784 | sqlite3VdbeAddOp3(v, 53, regResult+i, iContinue, regPrev+i); | - | ||||||||||||||||||||||||
| 785 | ; | - | ||||||||||||||||||||||||
| 786 | } executed 62 times by 1 test: end of blockExecuted by:
| 62 | ||||||||||||||||||||||||
| 787 | sqlite3VdbeChangeP4(v, -1, (const char *)pColl, (-2)); | - | ||||||||||||||||||||||||
| 788 | sqlite3VdbeChangeP5(v, 0x80); | - | ||||||||||||||||||||||||
| 789 | } executed 118 times by 1 test: end of blockExecuted by:
| 118 | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | ((void) (0)) | - | ||||||||||||||||||||||||
| 792 | ; | - | ||||||||||||||||||||||||
| 793 | sqlite3VdbeAddOp3(v, 78, regResult, regPrev, nResultCol-1); | - | ||||||||||||||||||||||||
| 794 | break; executed 62 times by 1 test: break;Executed by:
| 62 | ||||||||||||||||||||||||
| 795 | } | - | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | case executed 24 times by 1 test: 1:case 1:Executed by:
executed 24 times by 1 test: {case 1:Executed by:
| 24 | ||||||||||||||||||||||||
| 798 | sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct); | - | ||||||||||||||||||||||||
| 799 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 800 | } | - | ||||||||||||||||||||||||
| 801 | - | |||||||||||||||||||||||||
| 802 | default executed 202 times by 1 test: :default:Executed by:
executed 202 times by 1 test: {default:Executed by:
| 202 | ||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||
| 804 | ((void) (0)) | - | ||||||||||||||||||||||||
| 805 | ; | - | ||||||||||||||||||||||||
| 806 | codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol, | - | ||||||||||||||||||||||||
| 807 | regResult); | - | ||||||||||||||||||||||||
| 808 | break; executed 202 times by 1 test: break;Executed by:
| 202 | ||||||||||||||||||||||||
| 809 | } | - | ||||||||||||||||||||||||
| 810 | } | - | ||||||||||||||||||||||||
| 811 | if( pSort==0
| 49-239 | ||||||||||||||||||||||||
| 812 | codeOffset(v, p->iOffset, iContinue); | - | ||||||||||||||||||||||||
| 813 | } executed 239 times by 1 test: end of blockExecuted by:
| 239 | ||||||||||||||||||||||||
| 814 | } executed 288 times by 1 test: end of blockExecuted by:
| 288 | ||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||
| 816 | switch( eDest ){ | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||
| 821 | case executed 72820 times by 1 test: 1:case 1:Executed by:
executed 72820 times by 1 test: {case 1:Executed by:
| 72820 | ||||||||||||||||||||||||
| 822 | int r1; | - | ||||||||||||||||||||||||
| 823 | r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 824 | sqlite3VdbeAddOp3(v, 102, regResult, nResultCol, r1); | - | ||||||||||||||||||||||||
| 825 | sqlite3VdbeAddOp4Int(v, 133, iParm, r1, regResult, nResultCol); | - | ||||||||||||||||||||||||
| 826 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 827 | break; executed 72820 times by 1 test: break;Executed by:
| 72820 | ||||||||||||||||||||||||
| 828 | } | - | ||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||
| 834 | case executed 126 times by 1 test: 2:case 2:Executed by:
executed 126 times by 1 test: {case 2:Executed by:
| 126 | ||||||||||||||||||||||||
| 835 | sqlite3VdbeAddOp3(v, 134, iParm, regResult, nResultCol); | - | ||||||||||||||||||||||||
| 836 | break; executed 126 times by 1 test: break;Executed by:
| 126 | ||||||||||||||||||||||||
| 837 | } | - | ||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | case executed 470 times by 1 test: 5:case 5:Executed by:
executed 470 times by 1 test: case 5:Executed by:
| 470 | ||||||||||||||||||||||||
| 843 | case executed 49 times by 1 test: 6:case 6:Executed by:
executed 49 times by 1 test: case 6:Executed by:
| 49 | ||||||||||||||||||||||||
| 844 | case executed 48 times by 1 test: 14:case 14:Executed by:
executed 48 times by 1 test: case 14:Executed by:
| 48 | ||||||||||||||||||||||||
| 845 | case executed 866 times by 1 test: 12:case 12:Executed by:
executed 866 times by 1 test: {case 12:Executed by:
| 866 | ||||||||||||||||||||||||
| 846 | int r1 = sqlite3GetTempRange(pParse, nPrefixReg+1); | - | ||||||||||||||||||||||||
| 847 | ; | - | ||||||||||||||||||||||||
| 848 | ; | - | ||||||||||||||||||||||||
| 849 | ; | - | ||||||||||||||||||||||||
| 850 | ; | - | ||||||||||||||||||||||||
| 851 | sqlite3VdbeAddOp3(v, 102, regResult, nResultCol, r1+nPrefixReg); | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | if( eDest==6
| 49-1384 | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | int addr = sqlite3VdbeCurrentAddr(v) + 4; | - | ||||||||||||||||||||||||
| 860 | sqlite3VdbeAddOp4Int(v, 29, iParm+1, addr, r1, 0); | - | ||||||||||||||||||||||||
| 861 | ; | - | ||||||||||||||||||||||||
| 862 | sqlite3VdbeAddOp4Int(v, 133, iParm+1, r1,regResult,nResultCol); | - | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | ((void) (0)) | - | ||||||||||||||||||||||||
| 865 | ; | - | ||||||||||||||||||||||||
| 866 | } executed 49 times by 1 test: end of blockExecuted by:
| 49 | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | if( pSort
| 3-1430 | ||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||
| 870 | ((void) (0)) | - | ||||||||||||||||||||||||
| 871 | ; | - | ||||||||||||||||||||||||
| 872 | pushOntoSorter(pParse, pSort, p, r1+nPrefixReg, regOrig, 1, nPrefixReg); | - | ||||||||||||||||||||||||
| 873 | } executed 3 times by 1 test: else{end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 874 | int r2 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 875 | sqlite3VdbeAddOp2(v, 121, iParm, r2); | - | ||||||||||||||||||||||||
| 876 | sqlite3VdbeAddOp3(v, 122, iParm, r1, r2); | - | ||||||||||||||||||||||||
| 877 | sqlite3VdbeChangeP5(v, 0x08); | - | ||||||||||||||||||||||||
| 878 | sqlite3ReleaseTempReg(pParse, r2); | - | ||||||||||||||||||||||||
| 879 | } executed 1430 times by 1 test: end of blockExecuted by:
| 1430 | ||||||||||||||||||||||||
| 880 | sqlite3ReleaseTempRange(pParse, r1, nPrefixReg+1); | - | ||||||||||||||||||||||||
| 881 | break; executed 1433 times by 1 test: break;Executed by:
| 1433 | ||||||||||||||||||||||||
| 882 | } | - | ||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | case executed 3911 times by 1 test: 11:case 11:Executed by:
executed 3911 times by 1 test: {case 11:Executed by:
| 3911 | ||||||||||||||||||||||||
| 890 | if( pSort
| 51-3860 | ||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | - | |||||||||||||||||||||||||
| 895 | pushOntoSorter( | - | ||||||||||||||||||||||||
| 896 | pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg); | - | ||||||||||||||||||||||||
| 897 | } executed 51 times by 1 test: else{end of blockExecuted by:
| 51 | ||||||||||||||||||||||||
| 898 | int r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 899 | - | |||||||||||||||||||||||||
| 900 | ((void) (0)) | - | ||||||||||||||||||||||||
| 901 | ; | - | ||||||||||||||||||||||||
| 902 | sqlite3VdbeAddOp4(v, 102, regResult, nResultCol, | - | ||||||||||||||||||||||||
| 903 | r1, pDest->zAffSdst, nResultCol); | - | ||||||||||||||||||||||||
| 904 | sqlite3VdbeAddOp4Int(v, 133, iParm, r1, regResult, nResultCol); | - | ||||||||||||||||||||||||
| 905 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 906 | } executed 3860 times by 1 test: end of blockExecuted by:
| 3860 | ||||||||||||||||||||||||
| 907 | break; executed 3911 times by 1 test: break;Executed by:
| 3911 | ||||||||||||||||||||||||
| 908 | } | - | ||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||
| 910 | - | |||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | case executed 3207 times by 1 test: 3:case 3:Executed by:
executed 3207 times by 1 test: {case 3:Executed by:
| 3207 | ||||||||||||||||||||||||
| 913 | sqlite3VdbeAddOp2(v, 70, 1, iParm); | - | ||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | break; executed 3207 times by 1 test: break;Executed by:
| 3207 | ||||||||||||||||||||||||
| 916 | } | - | ||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||
| 922 | case executed 12270 times by 1 test: 10:case 10:Executed by:
executed 12270 times by 1 test: {case 10:Executed by:
| 12270 | ||||||||||||||||||||||||
| 923 | if( pSort
| 112-12158 | ||||||||||||||||||||||||
| 924 | - | |||||||||||||||||||||||||
| 925 | ((void) (0)) | - | ||||||||||||||||||||||||
| 926 | ; | - | ||||||||||||||||||||||||
| 927 | pushOntoSorter( | - | ||||||||||||||||||||||||
| 928 | pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg); | - | ||||||||||||||||||||||||
| 929 | } executed 112 times by 1 test: else{end of blockExecuted by:
| 112 | ||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||
| 931 | ((void) (0)) | - | ||||||||||||||||||||||||
| 932 | ; | - | ||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | ((void) (0)) | - | ||||||||||||||||||||||||
| 935 | ; | - | ||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | } executed 12158 times by 1 test: end of blockExecuted by:
| 12158 | ||||||||||||||||||||||||
| 938 | break; executed 12270 times by 1 test: break;Executed by:
| 12270 | ||||||||||||||||||||||||
| 939 | } | - | ||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||
| 942 | case executed 141993 times by 9 tests: 13:case 13:Executed by:
executed 141993 times by 9 tests: case 13:Executed by:
| 141993 | ||||||||||||||||||||||||
| 943 | case executed 177964 times by 435 tests: 9:case 9:Executed by:
executed 177964 times by 435 tests: {case 9:Executed by:
| 177964 | ||||||||||||||||||||||||
| 944 | ; | - | ||||||||||||||||||||||||
| 945 | ; | - | ||||||||||||||||||||||||
| 946 | if( pSort
| 12960-306997 | ||||||||||||||||||||||||
| 947 | pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol, | - | ||||||||||||||||||||||||
| 948 | nPrefixReg); | - | ||||||||||||||||||||||||
| 949 | } executed 12960 times by 1 test: else if( eDest==13end of blockExecuted by:
| 12960-167408 | ||||||||||||||||||||||||
| 950 | sqlite3VdbeAddOp1(v, 14, pDest->iSDParm); | - | ||||||||||||||||||||||||
| 951 | } executed 139589 times by 9 tests: else{end of blockExecuted by:
| 139589 | ||||||||||||||||||||||||
| 952 | sqlite3VdbeAddOp2(v, 81, regResult, nResultCol); | - | ||||||||||||||||||||||||
| 953 | } executed 167408 times by 435 tests: end of blockExecuted by:
| 167408 | ||||||||||||||||||||||||
| 954 | break; executed 319957 times by 435 tests: break;Executed by:
| 319957 | ||||||||||||||||||||||||
| 955 | } | - | ||||||||||||||||||||||||
| 956 | case executed 6 times by 1 test: 8:case 8:Executed by:
executed 6 times by 1 test: case 8:Executed by:
| 6 | ||||||||||||||||||||||||
| 957 | case executed 28 times by 1 test: 7:case 7:Executed by:
executed 28 times by 1 test: {case 7:Executed by:
| 28 | ||||||||||||||||||||||||
| 958 | int nKey; | - | ||||||||||||||||||||||||
| 959 | int r1, r2, r3; | - | ||||||||||||||||||||||||
| 960 | int addrTest = 0; | - | ||||||||||||||||||||||||
| 961 | ExprList *pSO; | - | ||||||||||||||||||||||||
| 962 | pSO = pDest->pOrderBy; | - | ||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | ((void) (0)) | - | ||||||||||||||||||||||||
| 965 | ; | - | ||||||||||||||||||||||||
| 966 | nKey = pSO->nExpr; | - | ||||||||||||||||||||||||
| 967 | r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 968 | r2 = sqlite3GetTempRange(pParse, nKey+2); | - | ||||||||||||||||||||||||
| 969 | r3 = r2+nKey+1; | - | ||||||||||||||||||||||||
| 970 | if( eDest==8
| 6-28 | ||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | addrTest = sqlite3VdbeAddOp4Int(v, 29, iParm+1, 0, | - | ||||||||||||||||||||||||
| 975 | regResult, nResultCol); | - | ||||||||||||||||||||||||
| 976 | ; | - | ||||||||||||||||||||||||
| 977 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 978 | sqlite3VdbeAddOp3(v, 102, regResult, nResultCol, r3); | - | ||||||||||||||||||||||||
| 979 | if( eDest==8
| 6-28 | ||||||||||||||||||||||||
| 980 | sqlite3VdbeAddOp2(v, 133, iParm+1, r3); | - | ||||||||||||||||||||||||
| 981 | sqlite3VdbeChangeP5(v, 0x10); | - | ||||||||||||||||||||||||
| 982 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 983 | for(i=0; i<nKey
| 34-44 | ||||||||||||||||||||||||
| 984 | sqlite3VdbeAddOp2(v, 79, | - | ||||||||||||||||||||||||
| 985 | regResult + pSO->a[i].u.x.iOrderByCol - 1, | - | ||||||||||||||||||||||||
| 986 | r2+i); | - | ||||||||||||||||||||||||
| 987 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||
| 988 | sqlite3VdbeAddOp2(v, 120, iParm, r2+nKey); | - | ||||||||||||||||||||||||
| 989 | sqlite3VdbeAddOp3(v, 102, r2, nKey+2, r1); | - | ||||||||||||||||||||||||
| 990 | sqlite3VdbeAddOp4Int(v, 133, iParm, r1, r2, nKey+2); | - | ||||||||||||||||||||||||
| 991 | if( addrTest
executed 6 times by 1 test: sqlite3VdbeJumpHere(v, addrTest);Executed by:
| 6-28 | ||||||||||||||||||||||||
| 992 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 993 | sqlite3ReleaseTempRange(pParse, r2, nKey+2); | - | ||||||||||||||||||||||||
| 994 | break; executed 34 times by 1 test: break;Executed by:
| 34 | ||||||||||||||||||||||||
| 995 | } | - | ||||||||||||||||||||||||
| 996 | default executed 180 times by 1 test: :default:Executed by:
executed 180 times by 1 test: {default:Executed by:
| 180 | ||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||
| 998 | ((void) (0)) | - | ||||||||||||||||||||||||
| 999 | ; | - | ||||||||||||||||||||||||
| 1000 | break; executed 180 times by 1 test: break;Executed by:
| 180 | ||||||||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||
| 1003 | } | - | ||||||||||||||||||||||||
| 1004 | - | |||||||||||||||||||||||||
| 1005 | - | |||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | if( pSort==0
| 13126-400812 | ||||||||||||||||||||||||
| 1010 | sqlite3VdbeAddOp2(v, 49, p->iLimit, iBreak); ; | - | ||||||||||||||||||||||||
| 1011 | } executed 16016 times by 1 test: end of blockExecuted by:
| 16016 | ||||||||||||||||||||||||
| 1012 | } executed 413938 times by 435 tests: end of blockExecuted by:
| 413938 | ||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||
| 1018 | KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ | - | ||||||||||||||||||||||||
| 1019 | int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*); | - | ||||||||||||||||||||||||
| 1020 | KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra); | - | ||||||||||||||||||||||||
| 1021 | if( p
| 84-173203 | ||||||||||||||||||||||||
| 1022 | p->aSortOrder = (u8*)&p->aColl[N+X]; | - | ||||||||||||||||||||||||
| 1023 | p->nKeyField = (u16)N; | - | ||||||||||||||||||||||||
| 1024 | p->nAllField = (u16)(N+X); | - | ||||||||||||||||||||||||
| 1025 | p->enc = ((db)->enc); | - | ||||||||||||||||||||||||
| 1026 | p->db = db; | - | ||||||||||||||||||||||||
| 1027 | p->nRef = 1; | - | ||||||||||||||||||||||||
| 1028 | memset(&p[1], 0, nExtra); | - | ||||||||||||||||||||||||
| 1029 | } executed 173203 times by 435 tests: else{end of blockExecuted by:
| 173203 | ||||||||||||||||||||||||
| 1030 | sqlite3OomFault(db); | - | ||||||||||||||||||||||||
| 1031 | } executed 84 times by 1 test: end of blockExecuted by:
| 84 | ||||||||||||||||||||||||
| 1032 | return executed 173287 times by 435 tests: p;return p;Executed by:
executed 173287 times by 435 tests: return p;Executed by:
| 173287 | ||||||||||||||||||||||||
| 1033 | } | - | ||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | void sqlite3KeyInfoUnref(KeyInfo *p){ | - | ||||||||||||||||||||||||
| 1039 | if( p
| 408-214655 | ||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||
| 1041 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1042 | ; | - | ||||||||||||||||||||||||
| 1043 | p->nRef--; | - | ||||||||||||||||||||||||
| 1044 | if( p->nRef==0
executed 172835 times by 435 tests: sqlite3DbFreeNN(p->db, p);Executed by:
| 41820-172835 | ||||||||||||||||||||||||
| 1045 | } executed 214655 times by 435 tests: end of blockExecuted by:
| 214655 | ||||||||||||||||||||||||
| 1046 | } executed 215063 times by 435 tests: end of blockExecuted by:
| 215063 | ||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | KeyInfo *sqlite3KeyInfoRef(KeyInfo *p){ | - | ||||||||||||||||||||||||
| 1052 | if( p
| 14-41820 | ||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||
| 1054 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1055 | ; | - | ||||||||||||||||||||||||
| 1056 | p->nRef++; | - | ||||||||||||||||||||||||
| 1057 | } executed 41820 times by 10 tests: end of blockExecuted by:
| 41820 | ||||||||||||||||||||||||
| 1058 | return executed 41834 times by 10 tests: p;return p;Executed by:
executed 41834 times by 10 tests: return p;Executed by:
| 41834 | ||||||||||||||||||||||||
| 1059 | } | - | ||||||||||||||||||||||||
| 1060 | KeyInfo *sqlite3KeyInfoFromExprList( | - | ||||||||||||||||||||||||
| 1061 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1062 | ExprList *pList, | - | ||||||||||||||||||||||||
| 1063 | int iStart, | - | ||||||||||||||||||||||||
| 1064 | int nExtra | - | ||||||||||||||||||||||||
| 1065 | ){ | - | ||||||||||||||||||||||||
| 1066 | int nExpr; | - | ||||||||||||||||||||||||
| 1067 | KeyInfo *pInfo; | - | ||||||||||||||||||||||||
| 1068 | struct ExprList_item *pItem; | - | ||||||||||||||||||||||||
| 1069 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1070 | int i; | - | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | nExpr = pList->nExpr; | - | ||||||||||||||||||||||||
| 1073 | pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1); | - | ||||||||||||||||||||||||
| 1074 | if( pInfo
| 80-67713 | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1077 | ; | - | ||||||||||||||||||||||||
| 1078 | for(i=iStart, pItem=pList->a+iStart; i<nExpr
| 67713-72197 | ||||||||||||||||||||||||
| 1079 | pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr); | - | ||||||||||||||||||||||||
| 1080 | pInfo->aSortOrder[i-iStart] = pItem->sortOrder; | - | ||||||||||||||||||||||||
| 1081 | } executed 72197 times by 435 tests: end of blockExecuted by:
| 72197 | ||||||||||||||||||||||||
| 1082 | } executed 67713 times by 435 tests: end of blockExecuted by:
| 67713 | ||||||||||||||||||||||||
| 1083 | return executed 67793 times by 435 tests: pInfo;return pInfo;Executed by:
executed 67793 times by 435 tests: return pInfo;Executed by:
| 67793 | ||||||||||||||||||||||||
| 1084 | } | - | ||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | - | |||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | static const char *selectOpName(int id){ | - | ||||||||||||||||||||||||
| 1090 | char *z; | - | ||||||||||||||||||||||||
| 1091 | switch( id ){ | - | ||||||||||||||||||||||||
| 1092 | case executed 362 times by 1 test: 124:case 124:Executed by:
executed 362 times by 1 test: z = "UNION ALL"; break;case 124:Executed by:
executed 362 times by 1 test: break;Executed by:
| 362 | ||||||||||||||||||||||||
| 1093 | case executed 187 times by 1 test: 126:case 126:Executed by:
executed 187 times by 1 test: z = "INTERSECT"; break;case 126:Executed by:
executed 187 times by 1 test: break;Executed by:
| 187 | ||||||||||||||||||||||||
| 1094 | case executed 197 times by 1 test: 125:case 125:Executed by:
executed 197 times by 1 test: z = "EXCEPT"; break;case 125:Executed by:
executed 197 times by 1 test: break;Executed by:
| 197 | ||||||||||||||||||||||||
| 1095 | default executed 36500 times by 1 test: :default:Executed by:
executed 36500 times by 1 test: z = "UNION"; break;default:Executed by:
executed 36500 times by 1 test: break;Executed by:
| 36500 | ||||||||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||||||||
| 1097 | return executed 37246 times by 1 test: z;return z;Executed by:
executed 37246 times by 1 test: return z;Executed by:
| 37246 | ||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||
| 1099 | static void explainTempTable(Parse *pParse, const char *zUsage){ | - | ||||||||||||||||||||||||
| 1100 | sqlite3VdbeExplain (pParse, 0, "USE TEMP B-TREE FOR %s", zUsage); | - | ||||||||||||||||||||||||
| 1101 | } executed 15429 times by 1 test: end of blockExecuted by:
| 15429 | ||||||||||||||||||||||||
| 1102 | static void generateSortTail( | - | ||||||||||||||||||||||||
| 1103 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1104 | Select *p, | - | ||||||||||||||||||||||||
| 1105 | SortCtx *pSort, | - | ||||||||||||||||||||||||
| 1106 | int nColumn, | - | ||||||||||||||||||||||||
| 1107 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 1108 | ){ | - | ||||||||||||||||||||||||
| 1109 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 1110 | int addrBreak = pSort->labelDone; | - | ||||||||||||||||||||||||
| 1111 | int addrContinue = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 1112 | int addr; | - | ||||||||||||||||||||||||
| 1113 | int addrOnce = 0; | - | ||||||||||||||||||||||||
| 1114 | int iTab; | - | ||||||||||||||||||||||||
| 1115 | ExprList *pOrderBy = pSort->pOrderBy; | - | ||||||||||||||||||||||||
| 1116 | int eDest = pDest->eDest; | - | ||||||||||||||||||||||||
| 1117 | int iParm = pDest->iSDParm; | - | ||||||||||||||||||||||||
| 1118 | int regRow; | - | ||||||||||||||||||||||||
| 1119 | int regRowid; | - | ||||||||||||||||||||||||
| 1120 | int iCol; | - | ||||||||||||||||||||||||
| 1121 | int nKey; | - | ||||||||||||||||||||||||
| 1122 | int iSortTab; | - | ||||||||||||||||||||||||
| 1123 | int i; | - | ||||||||||||||||||||||||
| 1124 | int bSeq; | - | ||||||||||||||||||||||||
| 1125 | int nRefKey = 0; | - | ||||||||||||||||||||||||
| 1126 | struct ExprList_item *aOutEx = p->pEList->a; | - | ||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1130 | ; | - | ||||||||||||||||||||||||
| 1131 | if( pSort->labelBkOut
| 319-12807 | ||||||||||||||||||||||||
| 1132 | sqlite3VdbeAddOp2(v, 12, pSort->regReturn, pSort->labelBkOut); | - | ||||||||||||||||||||||||
| 1133 | sqlite3VdbeGoto(v, addrBreak); | - | ||||||||||||||||||||||||
| 1134 | sqlite3VdbeResolveLabel(v, pSort->labelBkOut); | - | ||||||||||||||||||||||||
| 1135 | } executed 319 times by 1 test: end of blockExecuted by:
| 319 | ||||||||||||||||||||||||
| 1136 | iTab = pSort->iECursor; | - | ||||||||||||||||||||||||
| 1137 | if( eDest==9
| 54-10556 | ||||||||||||||||||||||||
| 1138 | regRowid = 0; | - | ||||||||||||||||||||||||
| 1139 | regRow = pDest->iSdst; | - | ||||||||||||||||||||||||
| 1140 | } executed 13072 times by 1 test: else{end of blockExecuted by:
| 13072 | ||||||||||||||||||||||||
| 1141 | regRowid = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 1142 | regRow = sqlite3GetTempRange(pParse, nColumn); | - | ||||||||||||||||||||||||
| 1143 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||
| 1144 | nKey = pOrderBy->nExpr - pSort->nOBSat; | - | ||||||||||||||||||||||||
| 1145 | if( pSort->sortFlags & 0x01
| 794-12332 | ||||||||||||||||||||||||
| 1146 | int regSortOut = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 1147 | iSortTab = pParse->nTab++; | - | ||||||||||||||||||||||||
| 1148 | if( pSort->labelBkOut
| 241-12091 | ||||||||||||||||||||||||
| 1149 | addrOnce = sqlite3VdbeAddOp0(v, 17); ; | - | ||||||||||||||||||||||||
| 1150 | } executed 241 times by 1 test: end of blockExecuted by:
| 241 | ||||||||||||||||||||||||
| 1151 | sqlite3VdbeAddOp3(v, 116, iSortTab, regSortOut, | - | ||||||||||||||||||||||||
| 1152 | nKey+1+nColumn+nRefKey); | - | ||||||||||||||||||||||||
| 1153 | if( addrOnce
executed 241 times by 1 test: sqlite3VdbeJumpHere(v, addrOnce);Executed by:
| 241-12091 | ||||||||||||||||||||||||
| 1154 | addr = 1 + sqlite3VdbeAddOp2(v, 34, iTab, addrBreak); | - | ||||||||||||||||||||||||
| 1155 | ; | - | ||||||||||||||||||||||||
| 1156 | codeOffset(v, p->iOffset, addrContinue); | - | ||||||||||||||||||||||||
| 1157 | sqlite3VdbeAddOp3(v, 127, iTab, regSortOut, iSortTab); | - | ||||||||||||||||||||||||
| 1158 | bSeq = 0; | - | ||||||||||||||||||||||||
| 1159 | } executed 12332 times by 1 test: else{end of blockExecuted by:
| 12332 | ||||||||||||||||||||||||
| 1160 | addr = 1 + sqlite3VdbeAddOp2(v, 35, iTab, addrBreak); ; | - | ||||||||||||||||||||||||
| 1161 | codeOffset(v, p->iOffset, addrContinue); | - | ||||||||||||||||||||||||
| 1162 | iSortTab = iTab; | - | ||||||||||||||||||||||||
| 1163 | bSeq = 1; | - | ||||||||||||||||||||||||
| 1164 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 1165 | for(i=0, iCol=nKey+bSeq-1; i<nColumn
| 13126-41155 | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | if( aOutEx[i].u.x.iOrderByCol==0
executed 33290 times by 1 test: iCol++;Executed by:
| 7865-33290 | ||||||||||||||||||||||||
| 1170 | } executed 41155 times by 1 test: end of blockExecuted by:
| 41155 | ||||||||||||||||||||||||
| 1171 | for(i=nColumn-1; i>=0
| 13126-41155 | ||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||
| 1173 | - | |||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||
| 1177 | { | - | ||||||||||||||||||||||||
| 1178 | int iRead; | - | ||||||||||||||||||||||||
| 1179 | if( aOutEx[i].u.x.iOrderByCol
| 7865-33290 | ||||||||||||||||||||||||
| 1180 | iRead = aOutEx[i].u.x.iOrderByCol-1; | - | ||||||||||||||||||||||||
| 1181 | } executed 7865 times by 1 test: else{end of blockExecuted by:
| 7865 | ||||||||||||||||||||||||
| 1182 | iRead = iCol--; | - | ||||||||||||||||||||||||
| 1183 | } executed 33290 times by 1 test: end of blockExecuted by:
| 33290 | ||||||||||||||||||||||||
| 1184 | sqlite3VdbeAddOp3(v, 90, iSortTab, iRead, regRow+i); | - | ||||||||||||||||||||||||
| 1185 | ; | - | ||||||||||||||||||||||||
| 1186 | } | - | ||||||||||||||||||||||||
| 1187 | } executed 41155 times by 1 test: end of blockExecuted by:
| 41155 | ||||||||||||||||||||||||
| 1188 | switch( eDest ){ | - | ||||||||||||||||||||||||
| 1189 | case executed 1 time by 1 test: 14:case 14:Executed by:
executed 1 time by 1 test: case 14:Executed by:
| 1 | ||||||||||||||||||||||||
| 1190 | case executed 2 times by 1 test: 12:case 12:Executed by:
executed 2 times by 1 test: {case 12:Executed by:
| 2 | ||||||||||||||||||||||||
| 1191 | sqlite3VdbeAddOp2(v, 121, iParm, regRowid); | - | ||||||||||||||||||||||||
| 1192 | sqlite3VdbeAddOp3(v, 122, iParm, regRow, regRowid); | - | ||||||||||||||||||||||||
| 1193 | sqlite3VdbeChangeP5(v, 0x08); | - | ||||||||||||||||||||||||
| 1194 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 1195 | } | - | ||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | case executed 51 times by 1 test: 11:case 11:Executed by:
executed 51 times by 1 test: {case 11:Executed by:
| 51 | ||||||||||||||||||||||||
| 1198 | - | |||||||||||||||||||||||||
| 1199 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1200 | ; | - | ||||||||||||||||||||||||
| 1201 | sqlite3VdbeAddOp4(v, 102, regRow, nColumn, regRowid, | - | ||||||||||||||||||||||||
| 1202 | pDest->zAffSdst, nColumn); | - | ||||||||||||||||||||||||
| 1203 | sqlite3VdbeAddOp4Int(v, 133, iParm, regRowid, regRow, nColumn); | - | ||||||||||||||||||||||||
| 1204 | break; executed 51 times by 1 test: break;Executed by:
| 51 | ||||||||||||||||||||||||
| 1205 | } | - | ||||||||||||||||||||||||
| 1206 | case executed 112 times by 1 test: 10:case 10:Executed by:
executed 112 times by 1 test: {case 10:Executed by:
| 112 | ||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | break; executed 112 times by 1 test: break;Executed by:
| 112 | ||||||||||||||||||||||||
| 1209 | } | - | ||||||||||||||||||||||||
| 1210 | - | |||||||||||||||||||||||||
| 1211 | default executed 12960 times by 1 test: :default:Executed by:
executed 12960 times by 1 test: {default:Executed by:
| 12960 | ||||||||||||||||||||||||
| 1212 | - | |||||||||||||||||||||||||
| 1213 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1214 | ; | - | ||||||||||||||||||||||||
| 1215 | ; | - | ||||||||||||||||||||||||
| 1216 | ; | - | ||||||||||||||||||||||||
| 1217 | if( eDest==9
| 2404-10556 | ||||||||||||||||||||||||
| 1218 | sqlite3VdbeAddOp2(v, 81, pDest->iSdst, nColumn); | - | ||||||||||||||||||||||||
| 1219 | } executed 10556 times by 1 test: else{end of blockExecuted by:
| 10556 | ||||||||||||||||||||||||
| 1220 | sqlite3VdbeAddOp1(v, 14, pDest->iSDParm); | - | ||||||||||||||||||||||||
| 1221 | } executed 2404 times by 1 test: end of blockExecuted by:
| 2404 | ||||||||||||||||||||||||
| 1222 | break; executed 12960 times by 1 test: break;Executed by:
| 12960 | ||||||||||||||||||||||||
| 1223 | } | - | ||||||||||||||||||||||||
| 1224 | } | - | ||||||||||||||||||||||||
| 1225 | if( regRowid
| 54-13072 | ||||||||||||||||||||||||
| 1226 | if( eDest==11
| 3-51 | ||||||||||||||||||||||||
| 1227 | sqlite3ReleaseTempRange(pParse, regRow, nColumn); | - | ||||||||||||||||||||||||
| 1228 | } executed 51 times by 1 test: else{end of blockExecuted by:
| 51 | ||||||||||||||||||||||||
| 1229 | sqlite3ReleaseTempReg(pParse, regRow); | - | ||||||||||||||||||||||||
| 1230 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 1231 | sqlite3ReleaseTempReg(pParse, regRowid); | - | ||||||||||||||||||||||||
| 1232 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||
| 1233 | - | |||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | sqlite3VdbeResolveLabel(v, addrContinue); | - | ||||||||||||||||||||||||
| 1236 | if( pSort->sortFlags & 0x01
| 794-12332 | ||||||||||||||||||||||||
| 1237 | sqlite3VdbeAddOp2(v, 3, iTab, addr); ; | - | ||||||||||||||||||||||||
| 1238 | } executed 12332 times by 1 test: else{end of blockExecuted by:
| 12332 | ||||||||||||||||||||||||
| 1239 | sqlite3VdbeAddOp2(v, 5, iTab, addr); ; | - | ||||||||||||||||||||||||
| 1240 | } executed 794 times by 1 test: end of blockExecuted by:
| 794 | ||||||||||||||||||||||||
| 1241 | if( pSort->regReturn
executed 319 times by 1 test: sqlite3VdbeAddOp1(v, 66, pSort->regReturn);Executed by:
| 319-12807 | ||||||||||||||||||||||||
| 1242 | sqlite3VdbeResolveLabel(v, addrBreak); | - | ||||||||||||||||||||||||
| 1243 | } executed 13126 times by 1 test: end of blockExecuted by:
| 13126 | ||||||||||||||||||||||||
| 1244 | static const char *columnTypeImpl( | - | ||||||||||||||||||||||||
| 1245 | NameContext *pNC, | - | ||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | Expr *pExpr | - | ||||||||||||||||||||||||
| 1248 | - | |||||||||||||||||||||||||
| 1249 | - | |||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||
| 1251 | - | |||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||
| 1254 | ){ | - | ||||||||||||||||||||||||
| 1255 | char const *zType = 0; | - | ||||||||||||||||||||||||
| 1256 | int j; | - | ||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||
| 1260 | - | |||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||
| 1263 | - | |||||||||||||||||||||||||
| 1264 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1265 | ; | - | ||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||
| 1267 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1268 | ; | - | ||||||||||||||||||||||||
| 1269 | - | |||||||||||||||||||||||||
| 1270 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1271 | ; | - | ||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||
| 1273 | switch( pExpr->op ){ | - | ||||||||||||||||||||||||
| 1274 | case executed 230681 times by 435 tests: 158:case 158:Executed by:
executed 230681 times by 435 tests: {case 158:Executed by:
| 230681 | ||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||
| 1279 | Table *pTab = 0; | - | ||||||||||||||||||||||||
| 1280 | Select *pS = 0; | - | ||||||||||||||||||||||||
| 1281 | int iCol = pExpr->iColumn; | - | ||||||||||||||||||||||||
| 1282 | while( pNC
| 8-461367 | ||||||||||||||||||||||||
| 1283 | SrcList *pTabList = pNC->pSrcList; | - | ||||||||||||||||||||||||
| 1284 | for(j=0;j<pTabList->nSrc
executed 96337 times by 1 test: ;Executed by:
| 21-327010 | ||||||||||||||||||||||||
| 1285 | if( j<pTabList->nSrc
| 21-230673 | ||||||||||||||||||||||||
| 1286 | pTab = pTabList->a[j].pTab; | - | ||||||||||||||||||||||||
| 1287 | pS = pTabList->a[j].pSelect; | - | ||||||||||||||||||||||||
| 1288 | } executed 230673 times by 435 tests: else{end of blockExecuted by:
| 230673 | ||||||||||||||||||||||||
| 1289 | pNC = pNC->pNext; | - | ||||||||||||||||||||||||
| 1290 | } executed 21 times by 1 test: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||
| 1291 | } | - | ||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | if( pTab==0
| 8-230673 | ||||||||||||||||||||||||
| 1294 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||
| 1295 | } | - | ||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||
| 1298 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1299 | ; | - | ||||||||||||||||||||||||
| 1300 | if( pS
| 4706-225967 | ||||||||||||||||||||||||
| 1301 | - | |||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||
| 1305 | if( iCol>=0
| 1-4704 | ||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | - | |||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | NameContext sNC; | - | ||||||||||||||||||||||||
| 1311 | Expr *p = pS->pEList->a[iCol].pExpr; | - | ||||||||||||||||||||||||
| 1312 | sNC.pSrcList = pS->pSrc; | - | ||||||||||||||||||||||||
| 1313 | sNC.pNext = pNC; | - | ||||||||||||||||||||||||
| 1314 | sNC.pParse = pNC->pParse; | - | ||||||||||||||||||||||||
| 1315 | zType = columnTypeImpl(&sNC,p); | - | ||||||||||||||||||||||||
| 1316 | } executed 4703 times by 2 tests: end of blockExecuted by:
| 4703 | ||||||||||||||||||||||||
| 1317 | } executed 4706 times by 2 tests: else{end of blockExecuted by:
| 4706 | ||||||||||||||||||||||||
| 1318 | - | |||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1321 | ; | - | ||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1324 | ; | - | ||||||||||||||||||||||||
| 1325 | if( iCol<0
| 34924-191043 | ||||||||||||||||||||||||
| 1326 | zType = "INTEGER"; | - | ||||||||||||||||||||||||
| 1327 | } executed 34924 times by 1 test: else{end of blockExecuted by:
| 34924 | ||||||||||||||||||||||||
| 1328 | zType = sqlite3ColumnType(&pTab->aCol[iCol],0); | - | ||||||||||||||||||||||||
| 1329 | } executed 191043 times by 435 tests: end of blockExecuted by:
| 191043 | ||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | } | - | ||||||||||||||||||||||||
| 1332 | break; executed 230673 times by 435 tests: break;Executed by:
| 230673 | ||||||||||||||||||||||||
| 1333 | } | - | ||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||
| 1335 | case executed 283 times by 1 test: 127:case 127:Executed by:
executed 283 times by 1 test: {case 127:Executed by:
| 283 | ||||||||||||||||||||||||
| 1336 | - | |||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||
| 1338 | - | |||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||
| 1340 | NameContext sNC; | - | ||||||||||||||||||||||||
| 1341 | Select *pS = pExpr->x.pSelect; | - | ||||||||||||||||||||||||
| 1342 | Expr *p = pS->pEList->a[0].pExpr; | - | ||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||
| 1344 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1345 | ; | - | ||||||||||||||||||||||||
| 1346 | sNC.pSrcList = pS->pSrc; | - | ||||||||||||||||||||||||
| 1347 | sNC.pNext = pNC; | - | ||||||||||||||||||||||||
| 1348 | sNC.pParse = pNC->pParse; | - | ||||||||||||||||||||||||
| 1349 | zType = columnTypeImpl(&sNC,p); | - | ||||||||||||||||||||||||
| 1350 | break; executed 283 times by 1 test: break;Executed by:
| 283 | ||||||||||||||||||||||||
| 1351 | } | - | ||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | } | - | ||||||||||||||||||||||||
| 1354 | return executed 352134 times by 435 tests: zType;return zType;Executed by:
executed 352134 times by 435 tests: return zType;Executed by:
| 352134 | ||||||||||||||||||||||||
| 1355 | } | - | ||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||
| 1357 | - | |||||||||||||||||||||||||
| 1358 | - | |||||||||||||||||||||||||
| 1359 | - | |||||||||||||||||||||||||
| 1360 | - | |||||||||||||||||||||||||
| 1361 | static void generateColumnTypes( | - | ||||||||||||||||||||||||
| 1362 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1363 | SrcList *pTabList, | - | ||||||||||||||||||||||||
| 1364 | ExprList *pEList | - | ||||||||||||||||||||||||
| 1365 | ){ | - | ||||||||||||||||||||||||
| 1366 | - | |||||||||||||||||||||||||
| 1367 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 1368 | int i; | - | ||||||||||||||||||||||||
| 1369 | NameContext sNC; | - | ||||||||||||||||||||||||
| 1370 | sNC.pSrcList = pTabList; | - | ||||||||||||||||||||||||
| 1371 | sNC.pParse = pParse; | - | ||||||||||||||||||||||||
| 1372 | sNC.pNext = 0; | - | ||||||||||||||||||||||||
| 1373 | for(i=0; i<pEList->nExpr
| 177049-337405 | ||||||||||||||||||||||||
| 1374 | Expr *p = pEList->a[i].pExpr; | - | ||||||||||||||||||||||||
| 1375 | const char *zType; | - | ||||||||||||||||||||||||
| 1376 | zType = columnTypeImpl(&sNC,p); | - | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | sqlite3VdbeSetColName(v, i, 1, zType, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||
| 1379 | } executed 337405 times by 435 tests: end of blockExecuted by:
| 337405 | ||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||
| 1381 | } executed 177049 times by 435 tests: end of blockExecuted by:
| 177049 | ||||||||||||||||||||||||
| 1382 | static void generateColumnNames( | - | ||||||||||||||||||||||||
| 1383 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1384 | Select *pSelect | - | ||||||||||||||||||||||||
| 1385 | ){ | - | ||||||||||||||||||||||||
| 1386 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 1387 | int i; | - | ||||||||||||||||||||||||
| 1388 | Table *pTab; | - | ||||||||||||||||||||||||
| 1389 | SrcList *pTabList; | - | ||||||||||||||||||||||||
| 1390 | ExprList *pEList; | - | ||||||||||||||||||||||||
| 1391 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1392 | int fullName; | - | ||||||||||||||||||||||||
| 1393 | int srcName; | - | ||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||
| 1395 | - | |||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||
| 1397 | if( pParse->explain
| 909-179402 | ||||||||||||||||||||||||
| 1398 | return; executed 909 times by 1 test: return;Executed by:
| 909 | ||||||||||||||||||||||||
| 1399 | } | - | ||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||
| 1401 | - | |||||||||||||||||||||||||
| 1402 | if( pParse->colNamesSet
executed 2353 times by 1 test: return;Executed by:
| 2353-177049 | ||||||||||||||||||||||||
| 1403 | - | |||||||||||||||||||||||||
| 1404 | while( pSelect->pPrior
executed 1644 times by 1 test: pSelect = pSelect->pPrior;Executed by:
| 1644-177049 | ||||||||||||||||||||||||
| 1405 | ; | - | ||||||||||||||||||||||||
| 1406 | pTabList = pSelect->pSrc; | - | ||||||||||||||||||||||||
| 1407 | pEList = pSelect->pEList; | - | ||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1410 | ; | - | ||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||
| 1412 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1413 | ; | - | ||||||||||||||||||||||||
| 1414 | pParse->colNamesSet = 1; | - | ||||||||||||||||||||||||
| 1415 | fullName = (db->flags & 0x00000004)!=0; | - | ||||||||||||||||||||||||
| 1416 | srcName = (
| 14-177010 | ||||||||||||||||||||||||
| 1417 | sqlite3VdbeSetNumCols(v, pEList->nExpr); | - | ||||||||||||||||||||||||
| 1418 | for(i=0; i<pEList->nExpr
| 177049-337405 | ||||||||||||||||||||||||
| 1419 | Expr *p = pEList->a[i].pExpr; | - | ||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||
| 1422 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1423 | ; | - | ||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||
| 1425 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1426 | ; | - | ||||||||||||||||||||||||
| 1427 | - | |||||||||||||||||||||||||
| 1428 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1429 | ; | - | ||||||||||||||||||||||||
| 1430 | if( pEList->a[i].zName
| 55015-282390 | ||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||
| 1432 | char *zName = pEList->a[i].zName; | - | ||||||||||||||||||||||||
| 1433 | sqlite3VdbeSetColName(v, i, 0, zName, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||
| 1434 | } executed 55015 times by 54 tests: else if( srcNameend of blockExecuted by:
| 17-282373 | ||||||||||||||||||||||||
| 1435 | char *zCol; | - | ||||||||||||||||||||||||
| 1436 | int iCol = p->iColumn; | - | ||||||||||||||||||||||||
| 1437 | pTab = p->y.pTab; | - | ||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||
| 1439 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1440 | ; | - | ||||||||||||||||||||||||
| 1441 | if( iCol<0
executed 23161 times by 1 test: iCol = pTab->iPKey;Executed by:
| 23161-144659 | ||||||||||||||||||||||||
| 1442 | - | |||||||||||||||||||||||||
| 1443 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1444 | ; | - | ||||||||||||||||||||||||
| 1445 | if( iCol<0
| 8630-159190 | ||||||||||||||||||||||||
| 1446 | zCol = "rowid"; | - | ||||||||||||||||||||||||
| 1447 | } executed 8630 times by 1 test: else{end of blockExecuted by:
| 8630 | ||||||||||||||||||||||||
| 1448 | zCol = pTab->aCol[iCol].zName; | - | ||||||||||||||||||||||||
| 1449 | } executed 159190 times by 435 tests: end of blockExecuted by:
| 159190 | ||||||||||||||||||||||||
| 1450 | if( fullName
| 62-167758 | ||||||||||||||||||||||||
| 1451 | char *zName = 0; | - | ||||||||||||||||||||||||
| 1452 | zName = sqlite3MPrintf(db, "%s.%s", pTab->zName, zCol); | - | ||||||||||||||||||||||||
| 1453 | sqlite3VdbeSetColName(v, i, 0, zName, ((sqlite3_destructor_type)sqlite3MallocSize)); | - | ||||||||||||||||||||||||
| 1454 | } executed 62 times by 1 test: else{end of blockExecuted by:
| 62 | ||||||||||||||||||||||||
| 1455 | sqlite3VdbeSetColName(v, i, 0, zCol, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||
| 1456 | } executed 167758 times by 435 tests: end of blockExecuted by:
| 167758 | ||||||||||||||||||||||||
| 1457 | }else{ | - | ||||||||||||||||||||||||
| 1458 | const char *z = pEList->a[i].zSpan; | - | ||||||||||||||||||||||||
| 1459 | z = z==0
| 6-114564 | ||||||||||||||||||||||||
| 1460 | sqlite3VdbeSetColName(v, i, 0, z, ((sqlite3_destructor_type)sqlite3MallocSize)); | - | ||||||||||||||||||||||||
| 1461 | } executed 114570 times by 4 tests: end of blockExecuted by:
| 114570 | ||||||||||||||||||||||||
| 1462 | } | - | ||||||||||||||||||||||||
| 1463 | generateColumnTypes(pParse, pTabList, pEList); | - | ||||||||||||||||||||||||
| 1464 | } executed 177049 times by 435 tests: end of blockExecuted by:
| 177049 | ||||||||||||||||||||||||
| 1465 | int sqlite3ColumnsFromExprList( | - | ||||||||||||||||||||||||
| 1466 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1467 | ExprList *pEList, | - | ||||||||||||||||||||||||
| 1468 | i16 *pnCol, | - | ||||||||||||||||||||||||
| 1469 | Column **paCol | - | ||||||||||||||||||||||||
| 1470 | ){ | - | ||||||||||||||||||||||||
| 1471 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1472 | int i, j; | - | ||||||||||||||||||||||||
| 1473 | u32 cnt; | - | ||||||||||||||||||||||||
| 1474 | Column *aCol, *pCol; | - | ||||||||||||||||||||||||
| 1475 | int nCol; | - | ||||||||||||||||||||||||
| 1476 | char *zName; | - | ||||||||||||||||||||||||
| 1477 | int nName; | - | ||||||||||||||||||||||||
| 1478 | Hash ht; | - | ||||||||||||||||||||||||
| 1479 | - | |||||||||||||||||||||||||
| 1480 | sqlite3HashInit(&ht); | - | ||||||||||||||||||||||||
| 1481 | if( pEList
| 41-5418 | ||||||||||||||||||||||||
| 1482 | nCol = pEList->nExpr; | - | ||||||||||||||||||||||||
| 1483 | aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); | - | ||||||||||||||||||||||||
| 1484 | ; | - | ||||||||||||||||||||||||
| 1485 | if( nCol>32767
never executed: nCol = 32767; | 0-5418 | ||||||||||||||||||||||||
| 1486 | } executed 5418 times by 5 tests: else{end of blockExecuted by:
| 5418 | ||||||||||||||||||||||||
| 1487 | nCol = 0; | - | ||||||||||||||||||||||||
| 1488 | aCol = 0; | - | ||||||||||||||||||||||||
| 1489 | } executed 41 times by 1 test: end of blockExecuted by:
| 41 | ||||||||||||||||||||||||
| 1490 | - | |||||||||||||||||||||||||
| 1491 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1492 | ; | - | ||||||||||||||||||||||||
| 1493 | *pnCol = nCol; | - | ||||||||||||||||||||||||
| 1494 | *paCol = aCol; | - | ||||||||||||||||||||||||
| 1495 | - | |||||||||||||||||||||||||
| 1496 | for(i=0, pCol=aCol; i<nCol
| 758-19150 | ||||||||||||||||||||||||
| 1497 | - | |||||||||||||||||||||||||
| 1498 | - | |||||||||||||||||||||||||
| 1499 | if( (
| 8619-9773 | ||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | } executed 9773 times by 5 tests: else{end of blockExecuted by:
| 9773 | ||||||||||||||||||||||||
| 1502 | Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr); | - | ||||||||||||||||||||||||
| 1503 | while( pColExpr->op==130
| 20-8619 | ||||||||||||||||||||||||
| 1504 | pColExpr = pColExpr->pRight; | - | ||||||||||||||||||||||||
| 1505 | - | |||||||||||||||||||||||||
| 1506 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1507 | ; | - | ||||||||||||||||||||||||
| 1508 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 1509 | - | |||||||||||||||||||||||||
| 1510 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1511 | ; | - | ||||||||||||||||||||||||
| 1512 | if( pColExpr->op==158
| 3068-5551 | ||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||
| 1514 | int iCol = pColExpr->iColumn; | - | ||||||||||||||||||||||||
| 1515 | Table *pTab = pColExpr->y.pTab; | - | ||||||||||||||||||||||||
| 1516 | - | |||||||||||||||||||||||||
| 1517 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1518 | ; | - | ||||||||||||||||||||||||
| 1519 | if( iCol<0
executed 2349 times by 1 test: iCol = pTab->iPKey;Executed by:
| 2349-3202 | ||||||||||||||||||||||||
| 1520 | zName = iCol>=0
| 5-5546 | ||||||||||||||||||||||||
| 1521 | } executed 5551 times by 1 test: else if( pColExpr->op==59end of blockExecuted by:
| 670-5551 | ||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||
| 1523 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1524 | ; | - | ||||||||||||||||||||||||
| 1525 | zName = pColExpr->u.zToken; | - | ||||||||||||||||||||||||
| 1526 | } executed 670 times by 1 test: else{end of blockExecuted by:
| 670 | ||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||
| 1528 | zName = pEList->a[i].zSpan; | - | ||||||||||||||||||||||||
| 1529 | } executed 2398 times by 1 test: end of blockExecuted by:
| 2398 | ||||||||||||||||||||||||
| 1530 | } | - | ||||||||||||||||||||||||
| 1531 | if( zName
| 2160-16232 | ||||||||||||||||||||||||
| 1532 | zName = sqlite3DbStrDup(db, zName); | - | ||||||||||||||||||||||||
| 1533 | } executed 16232 times by 5 tests: else{end of blockExecuted by:
| 16232 | ||||||||||||||||||||||||
| 1534 | zName = sqlite3MPrintf(db,"column%d",i+1); | - | ||||||||||||||||||||||||
| 1535 | } executed 2160 times by 1 test: end of blockExecuted by:
| 2160 | ||||||||||||||||||||||||
| 1536 | - | |||||||||||||||||||||||||
| 1537 | - | |||||||||||||||||||||||||
| 1538 | - | |||||||||||||||||||||||||
| 1539 | - | |||||||||||||||||||||||||
| 1540 | cnt = 0; | - | ||||||||||||||||||||||||
| 1541 | while( zName
| 21-20540 | ||||||||||||||||||||||||
| 1542 | nName = sqlite3Strlen30(zName); | - | ||||||||||||||||||||||||
| 1543 | if( nName>0
| 4-2165 | ||||||||||||||||||||||||
| 1544 | for(j=nName-1; j>0
executed 658 times by 1 test: end of blockExecuted by:
| 658-1475 | ||||||||||||||||||||||||
| 1545 | if( zName[j]==':'
executed 655 times by 1 test: nName = j;Executed by:
| 655-1510 | ||||||||||||||||||||||||
| 1546 | } executed 2165 times by 1 test: end of blockExecuted by:
| 2165 | ||||||||||||||||||||||||
| 1547 | zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt); | - | ||||||||||||||||||||||||
| 1548 | if( cnt>3
executed 65 times by 1 test: sqlite3_randomness(sizeof(cnt), &cnt);Executed by:
| 65-2104 | ||||||||||||||||||||||||
| 1549 | } executed 2169 times by 1 test: end of blockExecuted by:
| 2169 | ||||||||||||||||||||||||
| 1550 | pCol->zName = zName; | - | ||||||||||||||||||||||||
| 1551 | ; | - | ||||||||||||||||||||||||
| 1552 | if( zName
| 19-18371 | ||||||||||||||||||||||||
| 1553 | sqlite3OomFault(db); | - | ||||||||||||||||||||||||
| 1554 | } executed 19 times by 1 test: end of blockExecuted by:
| 19 | ||||||||||||||||||||||||
| 1555 | } executed 18392 times by 5 tests: end of blockExecuted by:
| 18392 | ||||||||||||||||||||||||
| 1556 | sqlite3HashClear(&ht); | - | ||||||||||||||||||||||||
| 1557 | if( db->mallocFailed
| 818-4641 | ||||||||||||||||||||||||
| 1558 | for(j=0; j<i
| 60-818 | ||||||||||||||||||||||||
| 1559 | sqlite3DbFree(db, aCol[j].zName); | - | ||||||||||||||||||||||||
| 1560 | } executed 60 times by 1 test: end of blockExecuted by:
| 60 | ||||||||||||||||||||||||
| 1561 | sqlite3DbFree(db, aCol); | - | ||||||||||||||||||||||||
| 1562 | *paCol = 0; | - | ||||||||||||||||||||||||
| 1563 | *pnCol = 0; | - | ||||||||||||||||||||||||
| 1564 | return executed 818 times by 1 test: 7;return 7;Executed by:
executed 818 times by 1 test: return 7;Executed by:
| 818 | ||||||||||||||||||||||||
| 1565 | } | - | ||||||||||||||||||||||||
| 1566 | return executed 4641 times by 5 tests: 0;return 0;Executed by:
executed 4641 times by 5 tests: return 0;Executed by:
| 4641 | ||||||||||||||||||||||||
| 1567 | } | - | ||||||||||||||||||||||||
| 1568 | void sqlite3SelectAddColumnTypeAndCollation( | - | ||||||||||||||||||||||||
| 1569 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1570 | Table *pTab, | - | ||||||||||||||||||||||||
| 1571 | Select *pSelect | - | ||||||||||||||||||||||||
| 1572 | ){ | - | ||||||||||||||||||||||||
| 1573 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1574 | NameContext sNC; | - | ||||||||||||||||||||||||
| 1575 | Column *pCol; | - | ||||||||||||||||||||||||
| 1576 | CollSeq *pColl; | - | ||||||||||||||||||||||||
| 1577 | int i; | - | ||||||||||||||||||||||||
| 1578 | Expr *p; | - | ||||||||||||||||||||||||
| 1579 | struct ExprList_item *a; | - | ||||||||||||||||||||||||
| 1580 | - | |||||||||||||||||||||||||
| 1581 | - | |||||||||||||||||||||||||
| 1582 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1583 | ; | - | ||||||||||||||||||||||||
| 1584 | - | |||||||||||||||||||||||||
| 1585 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1586 | ; | - | ||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1589 | ; | - | ||||||||||||||||||||||||
| 1590 | if( db->mallocFailed
executed 24 times by 1 test: return;Executed by:
| 24-2628 | ||||||||||||||||||||||||
| 1591 | memset(&sNC, 0, sizeof(sNC)); | - | ||||||||||||||||||||||||
| 1592 | sNC.pSrcList = pSelect->pSrc; | - | ||||||||||||||||||||||||
| 1593 | a = pSelect->pEList->a; | - | ||||||||||||||||||||||||
| 1594 | for(i=0, pCol=pTab->aCol; i<pTab->nCol
| 2628-9743 | ||||||||||||||||||||||||
| 1595 | const char *zType; | - | ||||||||||||||||||||||||
| 1596 | int n, m; | - | ||||||||||||||||||||||||
| 1597 | p = a[i].pExpr; | - | ||||||||||||||||||||||||
| 1598 | zType = columnTypeImpl(&sNC,p); | - | ||||||||||||||||||||||||
| 1599 | - | |||||||||||||||||||||||||
| 1600 | pCol->affinity = sqlite3ExprAffinity(p); | - | ||||||||||||||||||||||||
| 1601 | if( zType
| 2582-7161 | ||||||||||||||||||||||||
| 1602 | m = sqlite3Strlen30(zType); | - | ||||||||||||||||||||||||
| 1603 | n = sqlite3Strlen30(pCol->zName); | - | ||||||||||||||||||||||||
| 1604 | pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2); | - | ||||||||||||||||||||||||
| 1605 | if( pCol->zName
| 33-2549 | ||||||||||||||||||||||||
| 1606 | memcpy(&pCol->zName[n+1], zType, m+1); | - | ||||||||||||||||||||||||
| 1607 | pCol->colFlags |= 0x0004; | - | ||||||||||||||||||||||||
| 1608 | } executed 2549 times by 4 tests: end of blockExecuted by:
| 2549 | ||||||||||||||||||||||||
| 1609 | } executed 2582 times by 4 tests: end of blockExecuted by:
| 2582 | ||||||||||||||||||||||||
| 1610 | if( pCol->affinity==0
executed 5539 times by 1 test: pCol->affinity = 'A';Executed by:
| 4204-5539 | ||||||||||||||||||||||||
| 1611 | pColl = sqlite3ExprCollSeq(pParse, p); | - | ||||||||||||||||||||||||
| 1612 | if( pColl
| 5-6266 | ||||||||||||||||||||||||
| 1613 | pCol->zColl = sqlite3DbStrDup(db, pColl->zName); | - | ||||||||||||||||||||||||
| 1614 | } executed 3472 times by 5 tests: end of blockExecuted by:
| 3472 | ||||||||||||||||||||||||
| 1615 | } executed 9743 times by 5 tests: end of blockExecuted by:
| 9743 | ||||||||||||||||||||||||
| 1616 | pTab->szTabRow = 1; | - | ||||||||||||||||||||||||
| 1617 | } executed 2628 times by 5 tests: end of blockExecuted by:
| 2628 | ||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||
| 1620 | - | |||||||||||||||||||||||||
| 1621 | - | |||||||||||||||||||||||||
| 1622 | - | |||||||||||||||||||||||||
| 1623 | Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){ | - | ||||||||||||||||||||||||
| 1624 | Table *pTab; | - | ||||||||||||||||||||||||
| 1625 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1626 | int savedFlags; | - | ||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||
| 1628 | savedFlags = db->flags; | - | ||||||||||||||||||||||||
| 1629 | db->flags &= ~0x00000004; | - | ||||||||||||||||||||||||
| 1630 | db->flags |= 0x00000040; | - | ||||||||||||||||||||||||
| 1631 | sqlite3SelectPrep(pParse, pSelect, 0); | - | ||||||||||||||||||||||||
| 1632 | if( pParse->nErr
executed 16 times by 1 test: 0;return 0;Executed by:
executed 16 times by 1 test: return 0;Executed by:
| 16-980 | ||||||||||||||||||||||||
| 1633 | while( pSelect->pPrior
executed 49 times by 1 test: pSelect = pSelect->pPrior;Executed by:
| 49-980 | ||||||||||||||||||||||||
| 1634 | db->flags = savedFlags; | - | ||||||||||||||||||||||||
| 1635 | pTab = sqlite3DbMallocZero(db, sizeof(Table) ); | - | ||||||||||||||||||||||||
| 1636 | if( pTab==0
| 0-980 | ||||||||||||||||||||||||
| 1637 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1638 | } | - | ||||||||||||||||||||||||
| 1639 | - | |||||||||||||||||||||||||
| 1640 | - | |||||||||||||||||||||||||
| 1641 | - | |||||||||||||||||||||||||
| 1642 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1643 | ; | - | ||||||||||||||||||||||||
| 1644 | pTab->nTabRef = 1; | - | ||||||||||||||||||||||||
| 1645 | pTab->zName = 0; | - | ||||||||||||||||||||||||
| 1646 | pTab->nRowLogEst = 200; | - | ||||||||||||||||||||||||
| 1647 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1648 | ; | - | ||||||||||||||||||||||||
| 1649 | sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol); | - | ||||||||||||||||||||||||
| 1650 | sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect); | - | ||||||||||||||||||||||||
| 1651 | pTab->iPKey = -1; | - | ||||||||||||||||||||||||
| 1652 | if( db->mallocFailed
| 0-980 | ||||||||||||||||||||||||
| 1653 | sqlite3DeleteTable(db, pTab); | - | ||||||||||||||||||||||||
| 1654 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1655 | } | - | ||||||||||||||||||||||||
| 1656 | return executed 980 times by 5 tests: pTab;return pTab;Executed by:
executed 980 times by 5 tests: return pTab;Executed by:
| 980 | ||||||||||||||||||||||||
| 1657 | } | - | ||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||
| 1659 | - | |||||||||||||||||||||||||
| 1660 | - | |||||||||||||||||||||||||
| 1661 | - | |||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||
| 1663 | Vdbe *sqlite3GetVdbe(Parse *pParse){ | - | ||||||||||||||||||||||||
| 1664 | if( pParse->pVdbe
| 460643-1696704 | ||||||||||||||||||||||||
| 1665 | return executed 1696704 times by 435 tests: pParse->pVdbe;return pParse->pVdbe;Executed by:
executed 1696704 times by 435 tests: return pParse->pVdbe;Executed by:
| 1696704 | ||||||||||||||||||||||||
| 1666 | } | - | ||||||||||||||||||||||||
| 1667 | if( pParse->pToplevel==0
| 6024-454619 | ||||||||||||||||||||||||
| 1668 | && (((
| 165-454454 | ||||||||||||||||||||||||
| 1669 | ){ | - | ||||||||||||||||||||||||
| 1670 | pParse->okConstFactor = 1; | - | ||||||||||||||||||||||||
| 1671 | } executed 454454 times by 436 tests: end of blockExecuted by:
| 454454 | ||||||||||||||||||||||||
| 1672 | return executed 460643 times by 436 tests: sqlite3VdbeCreate(pParse);return sqlite3VdbeCreate(pParse);Executed by:
executed 460643 times by 436 tests: return sqlite3VdbeCreate(pParse);Executed by:
| 460643 | ||||||||||||||||||||||||
| 1673 | } | - | ||||||||||||||||||||||||
| 1674 | static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){ | - | ||||||||||||||||||||||||
| 1675 | Vdbe *v = 0; | - | ||||||||||||||||||||||||
| 1676 | int iLimit = 0; | - | ||||||||||||||||||||||||
| 1677 | int iOffset; | - | ||||||||||||||||||||||||
| 1678 | int n; | - | ||||||||||||||||||||||||
| 1679 | Expr *pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||
| 1681 | if( p->iLimit
executed 403 times by 1 test: return;Executed by:
| 403-312751 | ||||||||||||||||||||||||
| 1682 | - | |||||||||||||||||||||||||
| 1683 | - | |||||||||||||||||||||||||
| 1684 | - | |||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||
| 1686 | - | |||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||
| 1688 | - | |||||||||||||||||||||||||
| 1689 | if( pLimit
| 16521-296230 | ||||||||||||||||||||||||
| 1690 | - | |||||||||||||||||||||||||
| 1691 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1692 | ; | - | ||||||||||||||||||||||||
| 1693 | - | |||||||||||||||||||||||||
| 1694 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1695 | ; | - | ||||||||||||||||||||||||
| 1696 | p->iLimit = iLimit = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 1697 | v = sqlite3GetVdbe(pParse); | - | ||||||||||||||||||||||||
| 1698 | - | |||||||||||||||||||||||||
| 1699 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1700 | ; | - | ||||||||||||||||||||||||
| 1701 | if( sqlite3ExprIsInteger(pLimit->pLeft, &n)
| 64-16457 | ||||||||||||||||||||||||
| 1702 | sqlite3VdbeAddOp2(v, 70, n, iLimit); | - | ||||||||||||||||||||||||
| 1703 | ; | - | ||||||||||||||||||||||||
| 1704 | if( n==0
| 17-16440 | ||||||||||||||||||||||||
| 1705 | sqlite3VdbeGoto(v, iBreak); | - | ||||||||||||||||||||||||
| 1706 | } executed 17 times by 1 test: else if( n>=0end of blockExecuted by:
| 17-16222 | ||||||||||||||||||||||||
| 1707 | p->nSelectRow = sqlite3LogEst((u64)n); | - | ||||||||||||||||||||||||
| 1708 | p->selFlags |= 0x04000; | - | ||||||||||||||||||||||||
| 1709 | } executed 15257 times by 1 test: end of blockExecuted by:
| 15257 | ||||||||||||||||||||||||
| 1710 | } executed 16457 times by 1 test: else{end of blockExecuted by:
| 16457 | ||||||||||||||||||||||||
| 1711 | sqlite3ExprCode(pParse, pLimit->pLeft, iLimit); | - | ||||||||||||||||||||||||
| 1712 | sqlite3VdbeAddOp1(v, 15, iLimit); ; | - | ||||||||||||||||||||||||
| 1713 | ; | - | ||||||||||||||||||||||||
| 1714 | sqlite3VdbeAddOp2(v, 20, iLimit, iBreak); ; | - | ||||||||||||||||||||||||
| 1715 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 1716 | if( pLimit->pRight
| 388-16133 | ||||||||||||||||||||||||
| 1717 | p->iOffset = iOffset = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 1718 | pParse->nMem++; | - | ||||||||||||||||||||||||
| 1719 | sqlite3ExprCode(pParse, pLimit->pRight, iOffset); | - | ||||||||||||||||||||||||
| 1720 | sqlite3VdbeAddOp1(v, 15, iOffset); ; | - | ||||||||||||||||||||||||
| 1721 | ; | - | ||||||||||||||||||||||||
| 1722 | sqlite3VdbeAddOp3(v, 153, iLimit, iOffset+1, iOffset); | - | ||||||||||||||||||||||||
| 1723 | ; | - | ||||||||||||||||||||||||
| 1724 | } executed 388 times by 1 test: end of blockExecuted by:
| 388 | ||||||||||||||||||||||||
| 1725 | } executed 16521 times by 1 test: end of blockExecuted by:
| 16521 | ||||||||||||||||||||||||
| 1726 | } executed 312751 times by 435 tests: end of blockExecuted by:
| 312751 | ||||||||||||||||||||||||
| 1727 | static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){ | - | ||||||||||||||||||||||||
| 1728 | CollSeq *pRet; | - | ||||||||||||||||||||||||
| 1729 | if( p->pPrior
| 38366-38982 | ||||||||||||||||||||||||
| 1730 | pRet = multiSelectCollSeq(pParse, p->pPrior, iCol); | - | ||||||||||||||||||||||||
| 1731 | } executed 38982 times by 1 test: else{end of blockExecuted by:
| 38982 | ||||||||||||||||||||||||
| 1732 | pRet = 0; | - | ||||||||||||||||||||||||
| 1733 | } executed 38366 times by 1 test: end of blockExecuted by:
| 38366 | ||||||||||||||||||||||||
| 1734 | - | |||||||||||||||||||||||||
| 1735 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1736 | ; | - | ||||||||||||||||||||||||
| 1737 | - | |||||||||||||||||||||||||
| 1738 | - | |||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||
| 1740 | if( pRet==0
| 0-57644 | ||||||||||||||||||||||||
| 1741 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); | - | ||||||||||||||||||||||||
| 1742 | } executed 57644 times by 1 test: end of blockExecuted by:
| 57644 | ||||||||||||||||||||||||
| 1743 | return executed 77348 times by 1 test: pRet;return pRet;Executed by:
executed 77348 times by 1 test: return pRet;Executed by:
| 77348 | ||||||||||||||||||||||||
| 1744 | } | - | ||||||||||||||||||||||||
| 1745 | static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ | - | ||||||||||||||||||||||||
| 1746 | ExprList *pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 1747 | int nOrderBy = p->pOrderBy->nExpr; | - | ||||||||||||||||||||||||
| 1748 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 1749 | KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); | - | ||||||||||||||||||||||||
| 1750 | if( pRet
| 0-658 | ||||||||||||||||||||||||
| 1751 | int i; | - | ||||||||||||||||||||||||
| 1752 | for(i=0; i<nOrderBy
| 658-1196 | ||||||||||||||||||||||||
| 1753 | struct ExprList_item *pItem = &pOrderBy->a[i]; | - | ||||||||||||||||||||||||
| 1754 | Expr *pTerm = pItem->pExpr; | - | ||||||||||||||||||||||||
| 1755 | CollSeq *pColl; | - | ||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||
| 1757 | if( pTerm->flags & 0x000100
| 176-1020 | ||||||||||||||||||||||||
| 1758 | pColl = sqlite3ExprCollSeq(pParse, pTerm); | - | ||||||||||||||||||||||||
| 1759 | } executed 176 times by 1 test: else{end of blockExecuted by:
| 176 | ||||||||||||||||||||||||
| 1760 | pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); | - | ||||||||||||||||||||||||
| 1761 | if( pColl==0
executed 94 times by 1 test: pColl = db->pDfltColl;Executed by:
| 94-926 | ||||||||||||||||||||||||
| 1762 | pOrderBy->a[i].pExpr = | - | ||||||||||||||||||||||||
| 1763 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); | - | ||||||||||||||||||||||||
| 1764 | } executed 1020 times by 1 test: end of blockExecuted by:
| 1020 | ||||||||||||||||||||||||
| 1765 | - | |||||||||||||||||||||||||
| 1766 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1767 | ; | - | ||||||||||||||||||||||||
| 1768 | pRet->aColl[i] = pColl; | - | ||||||||||||||||||||||||
| 1769 | pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; | - | ||||||||||||||||||||||||
| 1770 | } executed 1196 times by 1 test: end of blockExecuted by:
| 1196 | ||||||||||||||||||||||||
| 1771 | } executed 658 times by 1 test: end of blockExecuted by:
| 658 | ||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||
| 1773 | return executed 658 times by 1 test: pRet;return pRet;Executed by:
executed 658 times by 1 test: return pRet;Executed by:
| 658 | ||||||||||||||||||||||||
| 1774 | } | - | ||||||||||||||||||||||||
| 1775 | static void generateWithRecursiveQuery( | - | ||||||||||||||||||||||||
| 1776 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1777 | Select *p, | - | ||||||||||||||||||||||||
| 1778 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 1779 | ){ | - | ||||||||||||||||||||||||
| 1780 | SrcList *pSrc = p->pSrc; | - | ||||||||||||||||||||||||
| 1781 | int nCol = p->pEList->nExpr; | - | ||||||||||||||||||||||||
| 1782 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 1783 | Select *pSetup = p->pPrior; | - | ||||||||||||||||||||||||
| 1784 | int addrTop; | - | ||||||||||||||||||||||||
| 1785 | int addrCont, addrBreak; | - | ||||||||||||||||||||||||
| 1786 | int iCurrent = 0; | - | ||||||||||||||||||||||||
| 1787 | int regCurrent; | - | ||||||||||||||||||||||||
| 1788 | int iQueue; | - | ||||||||||||||||||||||||
| 1789 | int iDistinct = 0; | - | ||||||||||||||||||||||||
| 1790 | int eDest = 5; | - | ||||||||||||||||||||||||
| 1791 | SelectDest destQueue; | - | ||||||||||||||||||||||||
| 1792 | int i; | - | ||||||||||||||||||||||||
| 1793 | int rc; | - | ||||||||||||||||||||||||
| 1794 | ExprList *pOrderBy; | - | ||||||||||||||||||||||||
| 1795 | Expr *pLimit; | - | ||||||||||||||||||||||||
| 1796 | int regLimit, regOffset; | - | ||||||||||||||||||||||||
| 1797 | - | |||||||||||||||||||||||||
| 1798 | - | |||||||||||||||||||||||||
| 1799 | if( sqlite3AuthCheck(pParse, 33, 0, 0, 0)
executed 1 time by 1 test: return;Executed by:
| 1-289 | ||||||||||||||||||||||||
| 1800 | - | |||||||||||||||||||||||||
| 1801 | - | |||||||||||||||||||||||||
| 1802 | addrBreak = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 1803 | p->nSelectRow = 320; | - | ||||||||||||||||||||||||
| 1804 | computeLimitRegisters(pParse, p, addrBreak); | - | ||||||||||||||||||||||||
| 1805 | pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 1806 | regLimit = p->iLimit; | - | ||||||||||||||||||||||||
| 1807 | regOffset = p->iOffset; | - | ||||||||||||||||||||||||
| 1808 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 1809 | p->iLimit = p->iOffset = 0; | - | ||||||||||||||||||||||||
| 1810 | pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||
| 1813 | for(i=0; (
| 0-306 | ||||||||||||||||||||||||
| 1814 | if( pSrc->a[i].fg.isRecursive
| 17-289 | ||||||||||||||||||||||||
| 1815 | iCurrent = pSrc->a[i].iCursor; | - | ||||||||||||||||||||||||
| 1816 | break; executed 289 times by 1 test: break;Executed by:
| 289 | ||||||||||||||||||||||||
| 1817 | } | - | ||||||||||||||||||||||||
| 1818 | } executed 17 times by 1 test: end of blockExecuted by:
| 17 | ||||||||||||||||||||||||
| 1819 | - | |||||||||||||||||||||||||
| 1820 | - | |||||||||||||||||||||||||
| 1821 | - | |||||||||||||||||||||||||
| 1822 | - | |||||||||||||||||||||||||
| 1823 | iQueue = pParse->nTab++; | - | ||||||||||||||||||||||||
| 1824 | if( p->op==123
| 28-261 | ||||||||||||||||||||||||
| 1825 | eDest = pOrderBy
| 3-25 | ||||||||||||||||||||||||
| 1826 | iDistinct = pParse->nTab++; | - | ||||||||||||||||||||||||
| 1827 | } executed 28 times by 1 test: else{end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 1828 | eDest = pOrderBy
| 14-247 | ||||||||||||||||||||||||
| 1829 | } executed 261 times by 1 test: end of blockExecuted by:
| 261 | ||||||||||||||||||||||||
| 1830 | sqlite3SelectDestInit(&destQueue, eDest, iQueue); | - | ||||||||||||||||||||||||
| 1831 | - | |||||||||||||||||||||||||
| 1832 | - | |||||||||||||||||||||||||
| 1833 | regCurrent = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 1834 | sqlite3VdbeAddOp3(v, 116, iCurrent, regCurrent, nCol); | - | ||||||||||||||||||||||||
| 1835 | if( pOrderBy
| 17-272 | ||||||||||||||||||||||||
| 1836 | KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); | - | ||||||||||||||||||||||||
| 1837 | sqlite3VdbeAddOp4(v, 113, iQueue, pOrderBy->nExpr+2, 0, | - | ||||||||||||||||||||||||
| 1838 | (char*)pKeyInfo, (-9)); | - | ||||||||||||||||||||||||
| 1839 | destQueue.pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 1840 | } executed 17 times by 1 test: else{end of blockExecuted by:
| 17 | ||||||||||||||||||||||||
| 1841 | sqlite3VdbeAddOp2(v, 113, iQueue, nCol); | - | ||||||||||||||||||||||||
| 1842 | } executed 272 times by 1 test: end of blockExecuted by:
| 272 | ||||||||||||||||||||||||
| 1843 | ; | - | ||||||||||||||||||||||||
| 1844 | if( iDistinct
| 28-261 | ||||||||||||||||||||||||
| 1845 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, 113, iDistinct, 0); | - | ||||||||||||||||||||||||
| 1846 | p->selFlags |= 0x00020; | - | ||||||||||||||||||||||||
| 1847 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 1848 | - | |||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||
| 1850 | p->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 1851 | - | |||||||||||||||||||||||||
| 1852 | - | |||||||||||||||||||||||||
| 1853 | pSetup->pNext = 0; | - | ||||||||||||||||||||||||
| 1854 | sqlite3VdbeExplain (pParse, 1, "SETUP"); | - | ||||||||||||||||||||||||
| 1855 | rc = sqlite3Select(pParse, pSetup, &destQueue); | - | ||||||||||||||||||||||||
| 1856 | pSetup->pNext = p; | - | ||||||||||||||||||||||||
| 1857 | if( rc
executed 8 times by 1 test: end_of_recursive_query;goto end_of_recursive_query;Executed by:
executed 8 times by 1 test: goto end_of_recursive_query;Executed by:
| 8-281 | ||||||||||||||||||||||||
| 1858 | - | |||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||
| 1860 | addrTop = sqlite3VdbeAddOp2(v, 36, iQueue, addrBreak); ; | - | ||||||||||||||||||||||||
| 1861 | - | |||||||||||||||||||||||||
| 1862 | - | |||||||||||||||||||||||||
| 1863 | sqlite3VdbeAddOp1(v, 130, iCurrent); | - | ||||||||||||||||||||||||
| 1864 | if( pOrderBy
| 17-264 | ||||||||||||||||||||||||
| 1865 | sqlite3VdbeAddOp3(v, 90, iQueue, pOrderBy->nExpr+1, regCurrent); | - | ||||||||||||||||||||||||
| 1866 | } executed 17 times by 1 test: else{end of blockExecuted by:
| 17 | ||||||||||||||||||||||||
| 1867 | sqlite3VdbeAddOp2(v, 128, iQueue, regCurrent); | - | ||||||||||||||||||||||||
| 1868 | } executed 264 times by 1 test: end of blockExecuted by:
| 264 | ||||||||||||||||||||||||
| 1869 | sqlite3VdbeAddOp1(v, 124, iQueue); | - | ||||||||||||||||||||||||
| 1870 | - | |||||||||||||||||||||||||
| 1871 | - | |||||||||||||||||||||||||
| 1872 | addrCont = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 1873 | codeOffset(v, regOffset, addrCont); | - | ||||||||||||||||||||||||
| 1874 | selectInnerLoop(pParse, p, iCurrent, | - | ||||||||||||||||||||||||
| 1875 | 0, 0, pDest, addrCont, addrBreak); | - | ||||||||||||||||||||||||
| 1876 | if( regLimit
| 17-264 | ||||||||||||||||||||||||
| 1877 | sqlite3VdbeAddOp2(v, 49, regLimit, addrBreak); | - | ||||||||||||||||||||||||
| 1878 | ; | - | ||||||||||||||||||||||||
| 1879 | } executed 17 times by 1 test: end of blockExecuted by:
| 17 | ||||||||||||||||||||||||
| 1880 | sqlite3VdbeResolveLabel(v, addrCont); | - | ||||||||||||||||||||||||
| 1881 | - | |||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||
| 1884 | - | |||||||||||||||||||||||||
| 1885 | if( p->selFlags & 0x00008
| 1-280 | ||||||||||||||||||||||||
| 1886 | sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported"); | - | ||||||||||||||||||||||||
| 1887 | } executed 1 time by 1 test: else{end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1888 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 1889 | sqlite3VdbeExplain (pParse, 1, "RECURSIVE STEP"); | - | ||||||||||||||||||||||||
| 1890 | sqlite3Select(pParse, p, &destQueue); | - | ||||||||||||||||||||||||
| 1891 | - | |||||||||||||||||||||||||
| 1892 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1893 | ; | - | ||||||||||||||||||||||||
| 1894 | p->pPrior = pSetup; | - | ||||||||||||||||||||||||
| 1895 | } executed 280 times by 1 test: end of blockExecuted by:
| 280 | ||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||
| 1897 | - | |||||||||||||||||||||||||
| 1898 | sqlite3VdbeGoto(v, addrTop); | - | ||||||||||||||||||||||||
| 1899 | sqlite3VdbeResolveLabel(v, addrBreak); | - | ||||||||||||||||||||||||
| 1900 | - | |||||||||||||||||||||||||
| 1901 | end_of_recursive_query: code before this statement executed 281 times by 1 test: end_of_recursive_query:Executed by:
| 281 | ||||||||||||||||||||||||
| 1902 | sqlite3ExprListDelete(pParse->db, p->pOrderBy); | - | ||||||||||||||||||||||||
| 1903 | p->pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 1904 | p->pLimit = pLimit; | - | ||||||||||||||||||||||||
| 1905 | return; executed 289 times by 1 test: return;Executed by:
| 289 | ||||||||||||||||||||||||
| 1906 | } | - | ||||||||||||||||||||||||
| 1907 | - | |||||||||||||||||||||||||
| 1908 | - | |||||||||||||||||||||||||
| 1909 | - | |||||||||||||||||||||||||
| 1910 | static int multiSelectOrderBy( | - | ||||||||||||||||||||||||
| 1911 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1912 | Select *p, | - | ||||||||||||||||||||||||
| 1913 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 1914 | ); | - | ||||||||||||||||||||||||
| 1915 | static int multiSelectValues( | - | ||||||||||||||||||||||||
| 1916 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1917 | Select *p, | - | ||||||||||||||||||||||||
| 1918 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 1919 | ){ | - | ||||||||||||||||||||||||
| 1920 | int nRow = 1; | - | ||||||||||||||||||||||||
| 1921 | int rc = 0; | - | ||||||||||||||||||||||||
| 1922 | int bShowAll = p->pLimit==0; | - | ||||||||||||||||||||||||
| 1923 | - | |||||||||||||||||||||||||
| 1924 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1925 | ; | - | ||||||||||||||||||||||||
| 1926 | do{ | - | ||||||||||||||||||||||||
| 1927 | - | |||||||||||||||||||||||||
| 1928 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1929 | ; | - | ||||||||||||||||||||||||
| 1930 | - | |||||||||||||||||||||||||
| 1931 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1932 | ; | - | ||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||
| 1934 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1935 | ; | - | ||||||||||||||||||||||||
| 1936 | if( p->pPrior==0
executed 441 times by 1 test: break;Executed by:
| 441-301684 | ||||||||||||||||||||||||
| 1937 | - | |||||||||||||||||||||||||
| 1938 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1939 | ; | - | ||||||||||||||||||||||||
| 1940 | p = p->pPrior; | - | ||||||||||||||||||||||||
| 1941 | nRow += bShowAll; | - | ||||||||||||||||||||||||
| 1942 | } executed 301684 times by 1 test: while(1);end of blockExecuted by:
| 301684 | ||||||||||||||||||||||||
| 1943 | sqlite3VdbeExplain (pParse, 0, "SCAN %d CONSTANT ROW%s", nRow, nRow==1 ? "" : "S") | - | ||||||||||||||||||||||||
| 1944 | ; | - | ||||||||||||||||||||||||
| 1945 | while( p
| 438-102124 | ||||||||||||||||||||||||
| 1946 | selectInnerLoop(pParse, p, -1, 0, 0, pDest, 1, 1); | - | ||||||||||||||||||||||||
| 1947 | if( !bShowAll
executed 3 times by 1 test: break;Executed by:
| 3-102121 | ||||||||||||||||||||||||
| 1948 | p->nSelectRow = nRow; | - | ||||||||||||||||||||||||
| 1949 | p = p->pNext; | - | ||||||||||||||||||||||||
| 1950 | } executed 102121 times by 1 test: end of blockExecuted by:
| 102121 | ||||||||||||||||||||||||
| 1951 | return executed 441 times by 1 test: rc;return rc;Executed by:
executed 441 times by 1 test: return rc;Executed by:
| 441 | ||||||||||||||||||||||||
| 1952 | } | - | ||||||||||||||||||||||||
| 1953 | static int multiSelect( | - | ||||||||||||||||||||||||
| 1954 | Parse *pParse, | - | ||||||||||||||||||||||||
| 1955 | Select *p, | - | ||||||||||||||||||||||||
| 1956 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 1957 | ){ | - | ||||||||||||||||||||||||
| 1958 | int rc = 0; | - | ||||||||||||||||||||||||
| 1959 | Select *pPrior; | - | ||||||||||||||||||||||||
| 1960 | Vdbe *v; | - | ||||||||||||||||||||||||
| 1961 | SelectDest dest; | - | ||||||||||||||||||||||||
| 1962 | Select *pDelete = 0; | - | ||||||||||||||||||||||||
| 1963 | sqlite3 *db; | - | ||||||||||||||||||||||||
| 1964 | - | |||||||||||||||||||||||||
| 1965 | - | |||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||
| 1967 | - | |||||||||||||||||||||||||
| 1968 | - | |||||||||||||||||||||||||
| 1969 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1970 | ; | - | ||||||||||||||||||||||||
| 1971 | - | |||||||||||||||||||||||||
| 1972 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1973 | ; | - | ||||||||||||||||||||||||
| 1974 | db = pParse->db; | - | ||||||||||||||||||||||||
| 1975 | pPrior = p->pPrior; | - | ||||||||||||||||||||||||
| 1976 | dest = *pDest; | - | ||||||||||||||||||||||||
| 1977 | if( pPrior->pOrderBy
| 19-39327 | ||||||||||||||||||||||||
| 1978 | sqlite3ErrorMsg(pParse,"%s clause should come after %s not before", | - | ||||||||||||||||||||||||
| 1979 | pPrior->pOrderBy!=0 ? "ORDER BY" : "LIMIT", selectOpName(p->op)); | - | ||||||||||||||||||||||||
| 1980 | rc = 1; | - | ||||||||||||||||||||||||
| 1981 | goto executed 44 times by 1 test: multi_select_end;goto multi_select_end;Executed by:
executed 44 times by 1 test: goto multi_select_end;Executed by:
| 44 | ||||||||||||||||||||||||
| 1982 | } | - | ||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | v = sqlite3GetVdbe(pParse); | - | ||||||||||||||||||||||||
| 1985 | - | |||||||||||||||||||||||||
| 1986 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1987 | ; | - | ||||||||||||||||||||||||
| 1988 | - | |||||||||||||||||||||||||
| 1989 | - | |||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||
| 1991 | if( dest.eDest==12
| 39-39269 | ||||||||||||||||||||||||
| 1992 | - | |||||||||||||||||||||||||
| 1993 | ((void) (0)) | - | ||||||||||||||||||||||||
| 1994 | ; | - | ||||||||||||||||||||||||
| 1995 | sqlite3VdbeAddOp2(v, 113, dest.iSDParm, p->pEList->nExpr); | - | ||||||||||||||||||||||||
| 1996 | dest.eDest = 14; | - | ||||||||||||||||||||||||
| 1997 | } executed 39 times by 1 test: end of blockExecuted by:
| 39 | ||||||||||||||||||||||||
| 1998 | - | |||||||||||||||||||||||||
| 1999 | - | |||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||
| 2001 | if( p->selFlags & 0x00400
| 441-38867 | ||||||||||||||||||||||||
| 2002 | rc = multiSelectValues(pParse, p, &dest); | - | ||||||||||||||||||||||||
| 2003 | goto executed 441 times by 1 test: multi_select_end;goto multi_select_end;Executed by:
executed 441 times by 1 test: goto multi_select_end;Executed by:
| 441 | ||||||||||||||||||||||||
| 2004 | } | - | ||||||||||||||||||||||||
| 2005 | - | |||||||||||||||||||||||||
| 2006 | - | |||||||||||||||||||||||||
| 2007 | - | |||||||||||||||||||||||||
| 2008 | - | |||||||||||||||||||||||||
| 2009 | - | |||||||||||||||||||||||||
| 2010 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2011 | ; | - | ||||||||||||||||||||||||
| 2012 | - | |||||||||||||||||||||||||
| 2013 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2014 | ; | - | ||||||||||||||||||||||||
| 2015 | - | |||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||
| 2017 | if( p->selFlags & 0x02000
| 290-38577 | ||||||||||||||||||||||||
| 2018 | generateWithRecursiveQuery(pParse, p, &dest); | - | ||||||||||||||||||||||||
| 2019 | } executed 290 times by 1 test: elseend of blockExecuted by:
| 290 | ||||||||||||||||||||||||
| 2020 | - | |||||||||||||||||||||||||
| 2021 | - | |||||||||||||||||||||||||
| 2022 | - | |||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | if( p->pOrderBy
| 641-37936 | ||||||||||||||||||||||||
| 2025 | return executed 641 times by 1 test: multiSelectOrderBy(pParse, p, pDest);return multiSelectOrderBy(pParse, p, pDest);Executed by:
executed 641 times by 1 test: return multiSelectOrderBy(pParse, p, pDest);Executed by:
| 641 | ||||||||||||||||||||||||
| 2026 | }else{ | - | ||||||||||||||||||||||||
| 2027 | - | |||||||||||||||||||||||||
| 2028 | - | |||||||||||||||||||||||||
| 2029 | if( pPrior->pPrior==0
| 875-37061 | ||||||||||||||||||||||||
| 2030 | sqlite3VdbeExplain (pParse, 1, "COMPOUND QUERY"); | - | ||||||||||||||||||||||||
| 2031 | sqlite3VdbeExplain (pParse, 1, "LEFT-MOST SUBQUERY"); | - | ||||||||||||||||||||||||
| 2032 | } executed 37061 times by 1 test: end of blockExecuted by:
| 37061 | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||
| 2037 | switch( p->op ){ | - | ||||||||||||||||||||||||
| 2038 | case executed 1431 times by 1 test: 124:case 124:Executed by:
executed 1431 times by 1 test: {case 124:Executed by:
| 1431 | ||||||||||||||||||||||||
| 2039 | int addr = 0; | - | ||||||||||||||||||||||||
| 2040 | int nLimit; | - | ||||||||||||||||||||||||
| 2041 | - | |||||||||||||||||||||||||
| 2042 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2043 | ; | - | ||||||||||||||||||||||||
| 2044 | pPrior->iLimit = p->iLimit; | - | ||||||||||||||||||||||||
| 2045 | pPrior->iOffset = p->iOffset; | - | ||||||||||||||||||||||||
| 2046 | pPrior->pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 2047 | rc = sqlite3Select(pParse, pPrior, &dest); | - | ||||||||||||||||||||||||
| 2048 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 2049 | if( rc
| 0-1431 | ||||||||||||||||||||||||
| 2050 | goto never executed: multi_select_end;goto multi_select_end;never executed: goto multi_select_end; | 0 | ||||||||||||||||||||||||
| 2051 | } | - | ||||||||||||||||||||||||
| 2052 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 2053 | p->iLimit = pPrior->iLimit; | - | ||||||||||||||||||||||||
| 2054 | p->iOffset = pPrior->iOffset; | - | ||||||||||||||||||||||||
| 2055 | if( p->iLimit
| 297-1134 | ||||||||||||||||||||||||
| 2056 | addr = sqlite3VdbeAddOp1(v, 20, p->iLimit); ; | - | ||||||||||||||||||||||||
| 2057 | ; | - | ||||||||||||||||||||||||
| 2058 | if( p->iOffset
| 136-161 | ||||||||||||||||||||||||
| 2059 | sqlite3VdbeAddOp3(v, 153, | - | ||||||||||||||||||||||||
| 2060 | p->iLimit, p->iOffset+1, p->iOffset); | - | ||||||||||||||||||||||||
| 2061 | } executed 136 times by 1 test: end of blockExecuted by:
| 136 | ||||||||||||||||||||||||
| 2062 | } executed 297 times by 1 test: end of blockExecuted by:
| 297 | ||||||||||||||||||||||||
| 2063 | sqlite3VdbeExplain (pParse, 1, "UNION ALL"); | - | ||||||||||||||||||||||||
| 2064 | rc = sqlite3Select(pParse, p, &dest); | - | ||||||||||||||||||||||||
| 2065 | ; | - | ||||||||||||||||||||||||
| 2066 | pDelete = p->pPrior; | - | ||||||||||||||||||||||||
| 2067 | p->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 2068 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); | - | ||||||||||||||||||||||||
| 2069 | if( pPrior->pLimit
| 119-1312 | ||||||||||||||||||||||||
| 2070 | && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)
| 9-110 | ||||||||||||||||||||||||
| 2071 | && nLimit>0
| 1-109 | ||||||||||||||||||||||||
| 2072 | ){ | - | ||||||||||||||||||||||||
| 2073 | p->nSelectRow = sqlite3LogEst((u64)nLimit); | - | ||||||||||||||||||||||||
| 2074 | } executed 107 times by 1 test: end of blockExecuted by:
| 107 | ||||||||||||||||||||||||
| 2075 | if( addr
| 297-1134 | ||||||||||||||||||||||||
| 2076 | sqlite3VdbeJumpHere(v, addr); | - | ||||||||||||||||||||||||
| 2077 | } executed 297 times by 1 test: end of blockExecuted by:
| 297 | ||||||||||||||||||||||||
| 2078 | break; executed 1431 times by 1 test: break;Executed by:
| 1431 | ||||||||||||||||||||||||
| 2079 | } | - | ||||||||||||||||||||||||
| 2080 | case executed 120 times by 1 test: 125:case 125:Executed by:
executed 120 times by 1 test: case 125:Executed by:
| 120 | ||||||||||||||||||||||||
| 2081 | case executed 36313 times by 1 test: 123:case 123:Executed by:
executed 36313 times by 1 test: {case 123:Executed by:
| 36313 | ||||||||||||||||||||||||
| 2082 | int unionTab; | - | ||||||||||||||||||||||||
| 2083 | u8 op = 0; | - | ||||||||||||||||||||||||
| 2084 | int priorOp; | - | ||||||||||||||||||||||||
| 2085 | Expr *pLimit; | - | ||||||||||||||||||||||||
| 2086 | int addr; | - | ||||||||||||||||||||||||
| 2087 | SelectDest uniondest; | - | ||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||
| 2089 | ; | - | ||||||||||||||||||||||||
| 2090 | ; | - | ||||||||||||||||||||||||
| 2091 | priorOp = 1; | - | ||||||||||||||||||||||||
| 2092 | if( dest.eDest==priorOp
| 82-36351 | ||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||
| 2094 | - | |||||||||||||||||||||||||
| 2095 | - | |||||||||||||||||||||||||
| 2096 | - | |||||||||||||||||||||||||
| 2097 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2098 | ; | - | ||||||||||||||||||||||||
| 2099 | unionTab = dest.iSDParm; | - | ||||||||||||||||||||||||
| 2100 | } executed 82 times by 1 test: else{end of blockExecuted by:
| 82 | ||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||
| 2102 | - | |||||||||||||||||||||||||
| 2103 | - | |||||||||||||||||||||||||
| 2104 | unionTab = pParse->nTab++; | - | ||||||||||||||||||||||||
| 2105 | - | |||||||||||||||||||||||||
| 2106 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2107 | ; | - | ||||||||||||||||||||||||
| 2108 | addr = sqlite3VdbeAddOp2(v, 113, unionTab, 0); | - | ||||||||||||||||||||||||
| 2109 | - | |||||||||||||||||||||||||
| 2110 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2111 | ; | - | ||||||||||||||||||||||||
| 2112 | p->addrOpenEphm[0] = addr; | - | ||||||||||||||||||||||||
| 2113 | findRightmost(p)->selFlags |= 0x00020; | - | ||||||||||||||||||||||||
| 2114 | - | |||||||||||||||||||||||||
| 2115 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2116 | ; | - | ||||||||||||||||||||||||
| 2117 | } executed 36351 times by 1 test: end of blockExecuted by:
| 36351 | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | - | |||||||||||||||||||||||||
| 2120 | - | |||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2123 | ; | - | ||||||||||||||||||||||||
| 2124 | sqlite3SelectDestInit(&uniondest, priorOp, unionTab); | - | ||||||||||||||||||||||||
| 2125 | rc = sqlite3Select(pParse, pPrior, &uniondest); | - | ||||||||||||||||||||||||
| 2126 | if( rc
| 0-36433 | ||||||||||||||||||||||||
| 2127 | goto never executed: multi_select_end;goto multi_select_end;never executed: goto multi_select_end; | 0 | ||||||||||||||||||||||||
| 2128 | } | - | ||||||||||||||||||||||||
| 2129 | - | |||||||||||||||||||||||||
| 2130 | - | |||||||||||||||||||||||||
| 2131 | - | |||||||||||||||||||||||||
| 2132 | if( p->op==125
| 120-36313 | ||||||||||||||||||||||||
| 2133 | op = 2; | - | ||||||||||||||||||||||||
| 2134 | } executed 120 times by 1 test: else{end of blockExecuted by:
| 120 | ||||||||||||||||||||||||
| 2135 | - | |||||||||||||||||||||||||
| 2136 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2137 | ; | - | ||||||||||||||||||||||||
| 2138 | op = 1; | - | ||||||||||||||||||||||||
| 2139 | } executed 36313 times by 1 test: end of blockExecuted by:
| 36313 | ||||||||||||||||||||||||
| 2140 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 2141 | pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 2142 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 2143 | uniondest.eDest = op; | - | ||||||||||||||||||||||||
| 2144 | sqlite3VdbeExplain (pParse, 1, "%s USING TEMP B-TREE", selectOpName(p->op)) | - | ||||||||||||||||||||||||
| 2145 | ; | - | ||||||||||||||||||||||||
| 2146 | rc = sqlite3Select(pParse, p, &uniondest); | - | ||||||||||||||||||||||||
| 2147 | ; | - | ||||||||||||||||||||||||
| 2148 | - | |||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||
| 2150 | sqlite3ExprListDelete(db, p->pOrderBy); | - | ||||||||||||||||||||||||
| 2151 | pDelete = p->pPrior; | - | ||||||||||||||||||||||||
| 2152 | p->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 2153 | p->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 2154 | if( p->op==123
| 120-36313 | ||||||||||||||||||||||||
| 2155 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); | - | ||||||||||||||||||||||||
| 2156 | } executed 36313 times by 1 test: end of blockExecuted by:
| 36313 | ||||||||||||||||||||||||
| 2157 | sqlite3ExprDelete(db, p->pLimit); | - | ||||||||||||||||||||||||
| 2158 | p->pLimit = pLimit; | - | ||||||||||||||||||||||||
| 2159 | p->iLimit = 0; | - | ||||||||||||||||||||||||
| 2160 | p->iOffset = 0; | - | ||||||||||||||||||||||||
| 2161 | - | |||||||||||||||||||||||||
| 2162 | - | |||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||
| 2164 | - | |||||||||||||||||||||||||
| 2165 | - | |||||||||||||||||||||||||
| 2166 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2167 | ; | - | ||||||||||||||||||||||||
| 2168 | if( dest.eDest!=priorOp
| 82-36351 | ||||||||||||||||||||||||
| 2169 | int iCont, iBreak, iStart; | - | ||||||||||||||||||||||||
| 2170 | - | |||||||||||||||||||||||||
| 2171 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2172 | ; | - | ||||||||||||||||||||||||
| 2173 | iBreak = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2174 | iCont = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2175 | computeLimitRegisters(pParse, p, iBreak); | - | ||||||||||||||||||||||||
| 2176 | sqlite3VdbeAddOp2(v, 36, unionTab, iBreak); ; | - | ||||||||||||||||||||||||
| 2177 | iStart = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 2178 | selectInnerLoop(pParse, p, unionTab, | - | ||||||||||||||||||||||||
| 2179 | 0, 0, &dest, iCont, iBreak); | - | ||||||||||||||||||||||||
| 2180 | sqlite3VdbeResolveLabel(v, iCont); | - | ||||||||||||||||||||||||
| 2181 | sqlite3VdbeAddOp2(v, 5, unionTab, iStart); ; | - | ||||||||||||||||||||||||
| 2182 | sqlite3VdbeResolveLabel(v, iBreak); | - | ||||||||||||||||||||||||
| 2183 | sqlite3VdbeAddOp2(v, 117, unionTab, 0); | - | ||||||||||||||||||||||||
| 2184 | } executed 36351 times by 1 test: end of blockExecuted by:
| 36351 | ||||||||||||||||||||||||
| 2185 | break; executed 36433 times by 1 test: break;Executed by:
| 36433 | ||||||||||||||||||||||||
| 2186 | } | - | ||||||||||||||||||||||||
| 2187 | default executed 72 times by 1 test: :default:Executed by:
executed 72 times by 1 test: default:Executed by:
| 72 | ||||||||||||||||||||||||
| 2188 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2189 | ; { | - | ||||||||||||||||||||||||
| 2190 | int tab1, tab2; | - | ||||||||||||||||||||||||
| 2191 | int iCont, iBreak, iStart; | - | ||||||||||||||||||||||||
| 2192 | Expr *pLimit; | - | ||||||||||||||||||||||||
| 2193 | int addr; | - | ||||||||||||||||||||||||
| 2194 | SelectDest intersectdest; | - | ||||||||||||||||||||||||
| 2195 | int r1; | - | ||||||||||||||||||||||||
| 2196 | - | |||||||||||||||||||||||||
| 2197 | - | |||||||||||||||||||||||||
| 2198 | - | |||||||||||||||||||||||||
| 2199 | - | |||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||
| 2201 | tab1 = pParse->nTab++; | - | ||||||||||||||||||||||||
| 2202 | tab2 = pParse->nTab++; | - | ||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||
| 2204 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2205 | ; | - | ||||||||||||||||||||||||
| 2206 | - | |||||||||||||||||||||||||
| 2207 | addr = sqlite3VdbeAddOp2(v, 113, tab1, 0); | - | ||||||||||||||||||||||||
| 2208 | - | |||||||||||||||||||||||||
| 2209 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2210 | ; | - | ||||||||||||||||||||||||
| 2211 | p->addrOpenEphm[0] = addr; | - | ||||||||||||||||||||||||
| 2212 | findRightmost(p)->selFlags |= 0x00020; | - | ||||||||||||||||||||||||
| 2213 | - | |||||||||||||||||||||||||
| 2214 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2215 | ; | - | ||||||||||||||||||||||||
| 2216 | - | |||||||||||||||||||||||||
| 2217 | - | |||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||
| 2219 | sqlite3SelectDestInit(&intersectdest, 1, tab1); | - | ||||||||||||||||||||||||
| 2220 | rc = sqlite3Select(pParse, pPrior, &intersectdest); | - | ||||||||||||||||||||||||
| 2221 | if( rc
| 0-72 | ||||||||||||||||||||||||
| 2222 | goto never executed: multi_select_end;goto multi_select_end;never executed: goto multi_select_end; | 0 | ||||||||||||||||||||||||
| 2223 | } | - | ||||||||||||||||||||||||
| 2224 | - | |||||||||||||||||||||||||
| 2225 | - | |||||||||||||||||||||||||
| 2226 | - | |||||||||||||||||||||||||
| 2227 | addr = sqlite3VdbeAddOp2(v, 113, tab2, 0); | - | ||||||||||||||||||||||||
| 2228 | - | |||||||||||||||||||||||||
| 2229 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2230 | ; | - | ||||||||||||||||||||||||
| 2231 | p->addrOpenEphm[1] = addr; | - | ||||||||||||||||||||||||
| 2232 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 2233 | pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 2234 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 2235 | intersectdest.iSDParm = tab2; | - | ||||||||||||||||||||||||
| 2236 | sqlite3VdbeExplain (pParse, 1, "%s USING TEMP B-TREE", selectOpName(p->op)) | - | ||||||||||||||||||||||||
| 2237 | ; | - | ||||||||||||||||||||||||
| 2238 | rc = sqlite3Select(pParse, p, &intersectdest); | - | ||||||||||||||||||||||||
| 2239 | ; | - | ||||||||||||||||||||||||
| 2240 | pDelete = p->pPrior; | - | ||||||||||||||||||||||||
| 2241 | p->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 2242 | if( p->nSelectRow>pPrior->nSelectRow
| 9-63 | ||||||||||||||||||||||||
| 2243 | p->nSelectRow = pPrior->nSelectRow; | - | ||||||||||||||||||||||||
| 2244 | } executed 9 times by 1 test: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||
| 2245 | sqlite3ExprDelete(db, p->pLimit); | - | ||||||||||||||||||||||||
| 2246 | p->pLimit = pLimit; | - | ||||||||||||||||||||||||
| 2247 | - | |||||||||||||||||||||||||
| 2248 | - | |||||||||||||||||||||||||
| 2249 | - | |||||||||||||||||||||||||
| 2250 | - | |||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||
| 2252 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2253 | ; | - | ||||||||||||||||||||||||
| 2254 | iBreak = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2255 | iCont = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2256 | computeLimitRegisters(pParse, p, iBreak); | - | ||||||||||||||||||||||||
| 2257 | sqlite3VdbeAddOp2(v, 36, tab1, iBreak); ; | - | ||||||||||||||||||||||||
| 2258 | r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 2259 | iStart = sqlite3VdbeAddOp2(v, 128, tab1, r1); | - | ||||||||||||||||||||||||
| 2260 | sqlite3VdbeAddOp4Int(v, 28, tab2, iCont, r1, 0); | - | ||||||||||||||||||||||||
| 2261 | ; | - | ||||||||||||||||||||||||
| 2262 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 2263 | selectInnerLoop(pParse, p, tab1, | - | ||||||||||||||||||||||||
| 2264 | 0, 0, &dest, iCont, iBreak); | - | ||||||||||||||||||||||||
| 2265 | sqlite3VdbeResolveLabel(v, iCont); | - | ||||||||||||||||||||||||
| 2266 | sqlite3VdbeAddOp2(v, 5, tab1, iStart); ; | - | ||||||||||||||||||||||||
| 2267 | sqlite3VdbeResolveLabel(v, iBreak); | - | ||||||||||||||||||||||||
| 2268 | sqlite3VdbeAddOp2(v, 117, tab2, 0); | - | ||||||||||||||||||||||||
| 2269 | sqlite3VdbeAddOp2(v, 117, tab1, 0); | - | ||||||||||||||||||||||||
| 2270 | break; executed 72 times by 1 test: break;Executed by:
| 72 | ||||||||||||||||||||||||
| 2271 | } | - | ||||||||||||||||||||||||
| 2272 | } | - | ||||||||||||||||||||||||
| 2273 | - | |||||||||||||||||||||||||
| 2274 | - | |||||||||||||||||||||||||
| 2275 | if( p->pNext==0
| 924-37012 | ||||||||||||||||||||||||
| 2276 | sqlite3VdbeExplainPop(pParse); | - | ||||||||||||||||||||||||
| 2277 | } executed 37012 times by 1 test: end of blockExecuted by:
| 37012 | ||||||||||||||||||||||||
| 2278 | - | |||||||||||||||||||||||||
| 2279 | } executed 37936 times by 1 test: end of blockExecuted by:
| 37936 | ||||||||||||||||||||||||
| 2280 | if( p->selFlags & 0x00020
| 1782-36444 | ||||||||||||||||||||||||
| 2281 | int i; | - | ||||||||||||||||||||||||
| 2282 | KeyInfo *pKeyInfo; | - | ||||||||||||||||||||||||
| 2283 | Select *pLoop; | - | ||||||||||||||||||||||||
| 2284 | CollSeq **apColl; | - | ||||||||||||||||||||||||
| 2285 | int nCol; | - | ||||||||||||||||||||||||
| 2286 | - | |||||||||||||||||||||||||
| 2287 | - | |||||||||||||||||||||||||
| 2288 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2289 | ; | - | ||||||||||||||||||||||||
| 2290 | nCol = p->pEList->nExpr; | - | ||||||||||||||||||||||||
| 2291 | pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1); | - | ||||||||||||||||||||||||
| 2292 | if( !pKeyInfo
| 0-36444 | ||||||||||||||||||||||||
| 2293 | rc = 7; | - | ||||||||||||||||||||||||
| 2294 | goto never executed: multi_select_end;goto multi_select_end;never executed: goto multi_select_end; | 0 | ||||||||||||||||||||||||
| 2295 | } | - | ||||||||||||||||||||||||
| 2296 | for(i=0, apColl=pKeyInfo->aColl; i<nCol
| 36444-36656 | ||||||||||||||||||||||||
| 2297 | *apColl = multiSelectCollSeq(pParse, p, i); | - | ||||||||||||||||||||||||
| 2298 | if( 0==*apColl
| 18155-18501 | ||||||||||||||||||||||||
| 2299 | *apColl = db->pDfltColl; | - | ||||||||||||||||||||||||
| 2300 | } executed 18501 times by 1 test: end of blockExecuted by:
| 18501 | ||||||||||||||||||||||||
| 2301 | } executed 36656 times by 1 test: end of blockExecuted by:
| 36656 | ||||||||||||||||||||||||
| 2302 | - | |||||||||||||||||||||||||
| 2303 | for(pLoop=p; pLoop
| 36444-72998 | ||||||||||||||||||||||||
| 2304 | for(i=0; i<2
| 72-109449 | ||||||||||||||||||||||||
| 2305 | int addr = pLoop->addrOpenEphm[i]; | - | ||||||||||||||||||||||||
| 2306 | if( addr<0
| 36523-72926 | ||||||||||||||||||||||||
| 2307 | - | |||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||
| 2310 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2311 | ; | - | ||||||||||||||||||||||||
| 2312 | break; executed 72926 times by 1 test: break;Executed by:
| 72926 | ||||||||||||||||||||||||
| 2313 | } | - | ||||||||||||||||||||||||
| 2314 | sqlite3VdbeChangeP2(v, addr, nCol); | - | ||||||||||||||||||||||||
| 2315 | sqlite3VdbeChangeP4(v, addr, (char*)sqlite3KeyInfoRef(pKeyInfo), | - | ||||||||||||||||||||||||
| 2316 | (-9)); | - | ||||||||||||||||||||||||
| 2317 | pLoop->addrOpenEphm[i] = -1; | - | ||||||||||||||||||||||||
| 2318 | } executed 36523 times by 1 test: end of blockExecuted by:
| 36523 | ||||||||||||||||||||||||
| 2319 | } executed 72998 times by 1 test: end of blockExecuted by:
| 72998 | ||||||||||||||||||||||||
| 2320 | sqlite3KeyInfoUnref(pKeyInfo); | - | ||||||||||||||||||||||||
| 2321 | } executed 36444 times by 1 test: end of blockExecuted by:
| 36444 | ||||||||||||||||||||||||
| 2322 | - | |||||||||||||||||||||||||
| 2323 | multi_select_end: code before this statement executed 38226 times by 1 test: multi_select_end:Executed by:
| 38226 | ||||||||||||||||||||||||
| 2324 | pDest->iSdst = dest.iSdst; | - | ||||||||||||||||||||||||
| 2325 | pDest->nSdst = dest.nSdst; | - | ||||||||||||||||||||||||
| 2326 | sqlite3SelectDelete(db, pDelete); | - | ||||||||||||||||||||||||
| 2327 | return executed 38711 times by 1 test: rc;return rc;Executed by:
executed 38711 times by 1 test: return rc;Executed by:
| 38711 | ||||||||||||||||||||||||
| 2328 | } | - | ||||||||||||||||||||||||
| 2329 | - | |||||||||||||||||||||||||
| 2330 | - | |||||||||||||||||||||||||
| 2331 | - | |||||||||||||||||||||||||
| 2332 | - | |||||||||||||||||||||||||
| 2333 | - | |||||||||||||||||||||||||
| 2334 | - | |||||||||||||||||||||||||
| 2335 | void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ | - | ||||||||||||||||||||||||
| 2336 | if( p->selFlags & 0x00200
| 1-56 | ||||||||||||||||||||||||
| 2337 | sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); | - | ||||||||||||||||||||||||
| 2338 | } executed 1 time by 1 test: else{end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 2339 | sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" | - | ||||||||||||||||||||||||
| 2340 | " do not have the same number of result columns", selectOpName(p->op)); | - | ||||||||||||||||||||||||
| 2341 | } executed 56 times by 1 test: end of blockExecuted by:
| 56 | ||||||||||||||||||||||||
| 2342 | } | - | ||||||||||||||||||||||||
| 2343 | static int generateOutputSubroutine( | - | ||||||||||||||||||||||||
| 2344 | Parse *pParse, | - | ||||||||||||||||||||||||
| 2345 | Select *p, | - | ||||||||||||||||||||||||
| 2346 | SelectDest *pIn, | - | ||||||||||||||||||||||||
| 2347 | SelectDest *pDest, | - | ||||||||||||||||||||||||
| 2348 | int regReturn, | - | ||||||||||||||||||||||||
| 2349 | int regPrev, | - | ||||||||||||||||||||||||
| 2350 | KeyInfo *pKeyInfo, | - | ||||||||||||||||||||||||
| 2351 | int iBreak | - | ||||||||||||||||||||||||
| 2352 | ){ | - | ||||||||||||||||||||||||
| 2353 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 2354 | int iContinue; | - | ||||||||||||||||||||||||
| 2355 | int addr; | - | ||||||||||||||||||||||||
| 2356 | - | |||||||||||||||||||||||||
| 2357 | addr = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 2358 | iContinue = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2359 | - | |||||||||||||||||||||||||
| 2360 | - | |||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | if( regPrev
| 472-656 | ||||||||||||||||||||||||
| 2363 | int addr1, addr2; | - | ||||||||||||||||||||||||
| 2364 | addr1 = sqlite3VdbeAddOp1(v, 20, regPrev); ; | - | ||||||||||||||||||||||||
| 2365 | addr2 = sqlite3VdbeAddOp4(v, 87, pIn->iSdst, regPrev+1, pIn->nSdst, | - | ||||||||||||||||||||||||
| 2366 | (char*)sqlite3KeyInfoRef(pKeyInfo), (-9)); | - | ||||||||||||||||||||||||
| 2367 | sqlite3VdbeAddOp3(v, 16, addr2+2, iContinue, addr2+2); ; | - | ||||||||||||||||||||||||
| 2368 | sqlite3VdbeJumpHere(v, addr1); | - | ||||||||||||||||||||||||
| 2369 | sqlite3VdbeAddOp3(v, 78, pIn->iSdst, regPrev+1, pIn->nSdst-1); | - | ||||||||||||||||||||||||
| 2370 | sqlite3VdbeAddOp2(v, 70, 1, regPrev); | - | ||||||||||||||||||||||||
| 2371 | } executed 472 times by 1 test: end of blockExecuted by:
| 472 | ||||||||||||||||||||||||
| 2372 | if( pParse->db->mallocFailed
never executed: 0;return 0;never executed: return 0; | 0-1128 | ||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||
| 2376 | codeOffset(v, p->iOffset, iContinue); | - | ||||||||||||||||||||||||
| 2377 | - | |||||||||||||||||||||||||
| 2378 | - | |||||||||||||||||||||||||
| 2379 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2380 | ; | - | ||||||||||||||||||||||||
| 2381 | - | |||||||||||||||||||||||||
| 2382 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2383 | ; | - | ||||||||||||||||||||||||
| 2384 | switch( pDest->eDest ){ | - | ||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||
| 2386 | - | |||||||||||||||||||||||||
| 2387 | case executed 4 times by 1 test: 12:case 12:Executed by:
executed 4 times by 1 test: {case 12:Executed by:
| 4 | ||||||||||||||||||||||||
| 2388 | int r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 2389 | int r2 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 2390 | sqlite3VdbeAddOp3(v, 102, pIn->iSdst, pIn->nSdst, r1); | - | ||||||||||||||||||||||||
| 2391 | sqlite3VdbeAddOp2(v, 121, pDest->iSDParm, r2); | - | ||||||||||||||||||||||||
| 2392 | sqlite3VdbeAddOp3(v, 122, pDest->iSDParm, r1, r2); | - | ||||||||||||||||||||||||
| 2393 | sqlite3VdbeChangeP5(v, 0x08); | - | ||||||||||||||||||||||||
| 2394 | sqlite3ReleaseTempReg(pParse, r2); | - | ||||||||||||||||||||||||
| 2395 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 2396 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 2397 | } | - | ||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||
| 2399 | - | |||||||||||||||||||||||||
| 2400 | - | |||||||||||||||||||||||||
| 2401 | - | |||||||||||||||||||||||||
| 2402 | case executed 9 times by 1 test: 11:case 11:Executed by:
executed 9 times by 1 test: {case 11:Executed by:
| 9 | ||||||||||||||||||||||||
| 2403 | int r1; | - | ||||||||||||||||||||||||
| 2404 | ; | - | ||||||||||||||||||||||||
| 2405 | r1 = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 2406 | sqlite3VdbeAddOp4(v, 102, pIn->iSdst, pIn->nSdst, | - | ||||||||||||||||||||||||
| 2407 | r1, pDest->zAffSdst, pIn->nSdst); | - | ||||||||||||||||||||||||
| 2408 | sqlite3VdbeAddOp4Int(v, 133, pDest->iSDParm, r1, | - | ||||||||||||||||||||||||
| 2409 | pIn->iSdst, pIn->nSdst); | - | ||||||||||||||||||||||||
| 2410 | sqlite3ReleaseTempReg(pParse, r1); | - | ||||||||||||||||||||||||
| 2411 | break; executed 9 times by 1 test: break;Executed by:
| 9 | ||||||||||||||||||||||||
| 2412 | } | - | ||||||||||||||||||||||||
| 2413 | - | |||||||||||||||||||||||||
| 2414 | - | |||||||||||||||||||||||||
| 2415 | - | |||||||||||||||||||||||||
| 2416 | - | |||||||||||||||||||||||||
| 2417 | - | |||||||||||||||||||||||||
| 2418 | case executed 24 times by 1 test: 10:case 10:Executed by:
executed 24 times by 1 test: {case 10:Executed by:
| 24 | ||||||||||||||||||||||||
| 2419 | - | |||||||||||||||||||||||||
| 2420 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2421 | ; ; | - | ||||||||||||||||||||||||
| 2422 | sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1); | - | ||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||
| 2424 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 2425 | } | - | ||||||||||||||||||||||||
| 2426 | - | |||||||||||||||||||||||||
| 2427 | - | |||||||||||||||||||||||||
| 2428 | - | |||||||||||||||||||||||||
| 2429 | - | |||||||||||||||||||||||||
| 2430 | - | |||||||||||||||||||||||||
| 2431 | case executed 194 times by 1 test: 13:case 13:Executed by:
executed 194 times by 1 test: {case 13:Executed by:
| 194 | ||||||||||||||||||||||||
| 2432 | if( pDest->iSdst==0
| 83-111 | ||||||||||||||||||||||||
| 2433 | pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst); | - | ||||||||||||||||||||||||
| 2434 | pDest->nSdst = pIn->nSdst; | - | ||||||||||||||||||||||||
| 2435 | } executed 111 times by 1 test: end of blockExecuted by:
| 111 | ||||||||||||||||||||||||
| 2436 | sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst); | - | ||||||||||||||||||||||||
| 2437 | sqlite3VdbeAddOp1(v, 14, pDest->iSDParm); | - | ||||||||||||||||||||||||
| 2438 | break; executed 194 times by 1 test: break;Executed by:
| 194 | ||||||||||||||||||||||||
| 2439 | } | - | ||||||||||||||||||||||||
| 2440 | default executed 897 times by 1 test: :default:Executed by:
executed 897 times by 1 test: {default:Executed by:
| 897 | ||||||||||||||||||||||||
| 2441 | - | |||||||||||||||||||||||||
| 2442 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2443 | ; | - | ||||||||||||||||||||||||
| 2444 | sqlite3VdbeAddOp2(v, 81, pIn->iSdst, pIn->nSdst); | - | ||||||||||||||||||||||||
| 2445 | break; executed 897 times by 1 test: break;Executed by:
| 897 | ||||||||||||||||||||||||
| 2446 | } | - | ||||||||||||||||||||||||
| 2447 | } | - | ||||||||||||||||||||||||
| 2448 | - | |||||||||||||||||||||||||
| 2449 | - | |||||||||||||||||||||||||
| 2450 | - | |||||||||||||||||||||||||
| 2451 | if( p->iLimit
| 165-963 | ||||||||||||||||||||||||
| 2452 | sqlite3VdbeAddOp2(v, 49, p->iLimit, iBreak); ; | - | ||||||||||||||||||||||||
| 2453 | } executed 165 times by 1 test: end of blockExecuted by:
| 165 | ||||||||||||||||||||||||
| 2454 | - | |||||||||||||||||||||||||
| 2455 | - | |||||||||||||||||||||||||
| 2456 | - | |||||||||||||||||||||||||
| 2457 | sqlite3VdbeResolveLabel(v, iContinue); | - | ||||||||||||||||||||||||
| 2458 | sqlite3VdbeAddOp1(v, 66, regReturn); | - | ||||||||||||||||||||||||
| 2459 | - | |||||||||||||||||||||||||
| 2460 | return executed 1128 times by 1 test: addr;return addr;Executed by:
executed 1128 times by 1 test: return addr;Executed by:
| 1128 | ||||||||||||||||||||||||
| 2461 | } | - | ||||||||||||||||||||||||
| 2462 | static int multiSelectOrderBy( | - | ||||||||||||||||||||||||
| 2463 | Parse *pParse, | - | ||||||||||||||||||||||||
| 2464 | Select *p, | - | ||||||||||||||||||||||||
| 2465 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 2466 | ){ | - | ||||||||||||||||||||||||
| 2467 | int i, j; | - | ||||||||||||||||||||||||
| 2468 | Select *pPrior; | - | ||||||||||||||||||||||||
| 2469 | Vdbe *v; | - | ||||||||||||||||||||||||
| 2470 | SelectDest destA; | - | ||||||||||||||||||||||||
| 2471 | SelectDest destB; | - | ||||||||||||||||||||||||
| 2472 | int regAddrA; | - | ||||||||||||||||||||||||
| 2473 | int regAddrB; | - | ||||||||||||||||||||||||
| 2474 | int addrSelectA; | - | ||||||||||||||||||||||||
| 2475 | int addrSelectB; | - | ||||||||||||||||||||||||
| 2476 | int regOutA; | - | ||||||||||||||||||||||||
| 2477 | int regOutB; | - | ||||||||||||||||||||||||
| 2478 | int addrOutA; | - | ||||||||||||||||||||||||
| 2479 | int addrOutB = 0; | - | ||||||||||||||||||||||||
| 2480 | int addrEofA; | - | ||||||||||||||||||||||||
| 2481 | int addrEofA_noB; | - | ||||||||||||||||||||||||
| 2482 | int addrEofB; | - | ||||||||||||||||||||||||
| 2483 | int addrAltB; | - | ||||||||||||||||||||||||
| 2484 | int addrAeqB; | - | ||||||||||||||||||||||||
| 2485 | int addrAgtB; | - | ||||||||||||||||||||||||
| 2486 | int regLimitA; | - | ||||||||||||||||||||||||
| 2487 | int regLimitB; | - | ||||||||||||||||||||||||
| 2488 | int regPrev; | - | ||||||||||||||||||||||||
| 2489 | int savedLimit; | - | ||||||||||||||||||||||||
| 2490 | int savedOffset; | - | ||||||||||||||||||||||||
| 2491 | int labelCmpr; | - | ||||||||||||||||||||||||
| 2492 | int labelEnd; | - | ||||||||||||||||||||||||
| 2493 | int addr1; | - | ||||||||||||||||||||||||
| 2494 | int op; | - | ||||||||||||||||||||||||
| 2495 | KeyInfo *pKeyDup = 0; | - | ||||||||||||||||||||||||
| 2496 | KeyInfo *pKeyMerge; | - | ||||||||||||||||||||||||
| 2497 | sqlite3 *db; | - | ||||||||||||||||||||||||
| 2498 | ExprList *pOrderBy; | - | ||||||||||||||||||||||||
| 2499 | int nOrderBy; | - | ||||||||||||||||||||||||
| 2500 | int *aPermute; | - | ||||||||||||||||||||||||
| 2501 | - | |||||||||||||||||||||||||
| 2502 | - | |||||||||||||||||||||||||
| 2503 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2504 | ; | - | ||||||||||||||||||||||||
| 2505 | - | |||||||||||||||||||||||||
| 2506 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2507 | ; | - | ||||||||||||||||||||||||
| 2508 | db = pParse->db; | - | ||||||||||||||||||||||||
| 2509 | v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 2510 | - | |||||||||||||||||||||||||
| 2511 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2512 | ; | - | ||||||||||||||||||||||||
| 2513 | labelEnd = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2514 | labelCmpr = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 2515 | - | |||||||||||||||||||||||||
| 2516 | - | |||||||||||||||||||||||||
| 2517 | - | |||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | op = p->op; | - | ||||||||||||||||||||||||
| 2520 | pPrior = p->pPrior; | - | ||||||||||||||||||||||||
| 2521 | - | |||||||||||||||||||||||||
| 2522 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2523 | ; | - | ||||||||||||||||||||||||
| 2524 | pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 2525 | - | |||||||||||||||||||||||||
| 2526 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2527 | ; | - | ||||||||||||||||||||||||
| 2528 | nOrderBy = pOrderBy->nExpr; | - | ||||||||||||||||||||||||
| 2529 | - | |||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||
| 2531 | - | |||||||||||||||||||||||||
| 2532 | - | |||||||||||||||||||||||||
| 2533 | - | |||||||||||||||||||||||||
| 2534 | if( op!=124
| 313-328 | ||||||||||||||||||||||||
| 2535 | for(i=1; db->mallocFailed==0
| 0-1003 | ||||||||||||||||||||||||
| 2536 | struct ExprList_item *pItem; | - | ||||||||||||||||||||||||
| 2537 | for(j=0, pItem=pOrderBy->a; j<nOrderBy
| 139-1091 | ||||||||||||||||||||||||
| 2538 | - | |||||||||||||||||||||||||
| 2539 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2540 | ; | - | ||||||||||||||||||||||||
| 2541 | if( pItem->u.x.iOrderByCol==i
executed 551 times by 1 test: break;Executed by:
| 540-551 | ||||||||||||||||||||||||
| 2542 | } executed 540 times by 1 test: end of blockExecuted by:
| 540 | ||||||||||||||||||||||||
| 2543 | if( j==nOrderBy
| 139-551 | ||||||||||||||||||||||||
| 2544 | Expr *pNew = sqlite3Expr(db, 143, 0); | - | ||||||||||||||||||||||||
| 2545 | if( pNew==0
never executed: 7;return 7;never executed: return 7; | 0-139 | ||||||||||||||||||||||||
| 2546 | pNew->flags |= 0x000400; | - | ||||||||||||||||||||||||
| 2547 | pNew->u.iValue = i; | - | ||||||||||||||||||||||||
| 2548 | p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); | - | ||||||||||||||||||||||||
| 2549 | if( pOrderBy
executed 139 times by 1 test: pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i;Executed by:
| 0-139 | ||||||||||||||||||||||||
| 2550 | } executed 139 times by 1 test: end of blockExecuted by:
| 139 | ||||||||||||||||||||||||
| 2551 | } executed 690 times by 1 test: end of blockExecuted by:
| 690 | ||||||||||||||||||||||||
| 2552 | } executed 313 times by 1 test: end of blockExecuted by:
| 313 | ||||||||||||||||||||||||
| 2553 | aPermute = sqlite3DbMallocRawNN(db, sizeof(int)*(nOrderBy + 1)); | - | ||||||||||||||||||||||||
| 2554 | if( aPermute
| 0-641 | ||||||||||||||||||||||||
| 2555 | struct ExprList_item *pItem; | - | ||||||||||||||||||||||||
| 2556 | aPermute[0] = nOrderBy; | - | ||||||||||||||||||||||||
| 2557 | for(i=1, pItem=pOrderBy->a; i<=nOrderBy
| 641-1174 | ||||||||||||||||||||||||
| 2558 | - | |||||||||||||||||||||||||
| 2559 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2560 | ; | - | ||||||||||||||||||||||||
| 2561 | - | |||||||||||||||||||||||||
| 2562 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2563 | ; | - | ||||||||||||||||||||||||
| 2564 | aPermute[i] = pItem->u.x.iOrderByCol - 1; | - | ||||||||||||||||||||||||
| 2565 | } executed 1174 times by 1 test: end of blockExecuted by:
| 1174 | ||||||||||||||||||||||||
| 2566 | pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); | - | ||||||||||||||||||||||||
| 2567 | } executed 641 times by 1 test: else{end of blockExecuted by:
| 641 | ||||||||||||||||||||||||
| 2568 | pKeyMerge = 0; | - | ||||||||||||||||||||||||
| 2569 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||
| 2571 | - | |||||||||||||||||||||||||
| 2572 | - | |||||||||||||||||||||||||
| 2573 | p->pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 2574 | pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0); | - | ||||||||||||||||||||||||
| 2575 | - | |||||||||||||||||||||||||
| 2576 | - | |||||||||||||||||||||||||
| 2577 | - | |||||||||||||||||||||||||
| 2578 | - | |||||||||||||||||||||||||
| 2579 | - | |||||||||||||||||||||||||
| 2580 | if( op==124
| 313-328 | ||||||||||||||||||||||||
| 2581 | regPrev = 0; | - | ||||||||||||||||||||||||
| 2582 | } executed 328 times by 1 test: else{end of blockExecuted by:
| 328 | ||||||||||||||||||||||||
| 2583 | int nExpr = p->pEList->nExpr; | - | ||||||||||||||||||||||||
| 2584 | - | |||||||||||||||||||||||||
| 2585 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2586 | ; | - | ||||||||||||||||||||||||
| 2587 | regPrev = pParse->nMem+1; | - | ||||||||||||||||||||||||
| 2588 | pParse->nMem += nExpr+1; | - | ||||||||||||||||||||||||
| 2589 | sqlite3VdbeAddOp2(v, 70, 0, regPrev); | - | ||||||||||||||||||||||||
| 2590 | pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1); | - | ||||||||||||||||||||||||
| 2591 | if( pKeyDup
| 0-313 | ||||||||||||||||||||||||
| 2592 | - | |||||||||||||||||||||||||
| 2593 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2594 | ; | - | ||||||||||||||||||||||||
| 2595 | for(i=0; i<nExpr
| 313-690 | ||||||||||||||||||||||||
| 2596 | pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i); | - | ||||||||||||||||||||||||
| 2597 | pKeyDup->aSortOrder[i] = 0; | - | ||||||||||||||||||||||||
| 2598 | } executed 690 times by 1 test: end of blockExecuted by:
| 690 | ||||||||||||||||||||||||
| 2599 | } executed 313 times by 1 test: end of blockExecuted by:
| 313 | ||||||||||||||||||||||||
| 2600 | } executed 313 times by 1 test: end of blockExecuted by:
| 313 | ||||||||||||||||||||||||
| 2601 | - | |||||||||||||||||||||||||
| 2602 | - | |||||||||||||||||||||||||
| 2603 | - | |||||||||||||||||||||||||
| 2604 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 2605 | pPrior->pNext = 0; | - | ||||||||||||||||||||||||
| 2606 | sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER"); | - | ||||||||||||||||||||||||
| 2607 | if( pPrior->pPrior==0
| 78-563 | ||||||||||||||||||||||||
| 2608 | sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER"); | - | ||||||||||||||||||||||||
| 2609 | } executed 563 times by 1 test: end of blockExecuted by:
| 563 | ||||||||||||||||||||||||
| 2610 | - | |||||||||||||||||||||||||
| 2611 | - | |||||||||||||||||||||||||
| 2612 | computeLimitRegisters(pParse, p, labelEnd); | - | ||||||||||||||||||||||||
| 2613 | if( p->iLimit
| 35-553 | ||||||||||||||||||||||||
| 2614 | regLimitA = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2615 | regLimitB = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2616 | sqlite3VdbeAddOp2(v, 78, p->iOffset ? p->iOffset+1 : p->iLimit, | - | ||||||||||||||||||||||||
| 2617 | regLimitA); | - | ||||||||||||||||||||||||
| 2618 | sqlite3VdbeAddOp2(v, 78, regLimitA, regLimitB); | - | ||||||||||||||||||||||||
| 2619 | } executed 53 times by 1 test: else{end of blockExecuted by:
| 53 | ||||||||||||||||||||||||
| 2620 | regLimitA = regLimitB = 0; | - | ||||||||||||||||||||||||
| 2621 | } executed 588 times by 1 test: end of blockExecuted by:
| 588 | ||||||||||||||||||||||||
| 2622 | sqlite3ExprDelete(db, p->pLimit); | - | ||||||||||||||||||||||||
| 2623 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 2624 | - | |||||||||||||||||||||||||
| 2625 | regAddrA = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2626 | regAddrB = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2627 | regOutA = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2628 | regOutB = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 2629 | sqlite3SelectDestInit(&destA, 13, regAddrA); | - | ||||||||||||||||||||||||
| 2630 | sqlite3SelectDestInit(&destB, 13, regAddrB); | - | ||||||||||||||||||||||||
| 2631 | - | |||||||||||||||||||||||||
| 2632 | sqlite3VdbeExplain (pParse, 1, "MERGE (%s)", selectOpName(p->op)); | - | ||||||||||||||||||||||||
| 2633 | - | |||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | - | |||||||||||||||||||||||||
| 2636 | - | |||||||||||||||||||||||||
| 2637 | addrSelectA = sqlite3VdbeCurrentAddr(v) + 1; | - | ||||||||||||||||||||||||
| 2638 | addr1 = sqlite3VdbeAddOp3(v, 13, regAddrA, 0, addrSelectA); | - | ||||||||||||||||||||||||
| 2639 | ; | - | ||||||||||||||||||||||||
| 2640 | pPrior->iLimit = regLimitA; | - | ||||||||||||||||||||||||
| 2641 | sqlite3VdbeExplain (pParse, 1, "LEFT"); | - | ||||||||||||||||||||||||
| 2642 | sqlite3Select(pParse, pPrior, &destA); | - | ||||||||||||||||||||||||
| 2643 | sqlite3VdbeEndCoroutine(v, regAddrA); | - | ||||||||||||||||||||||||
| 2644 | sqlite3VdbeJumpHere(v, addr1); | - | ||||||||||||||||||||||||
| 2645 | - | |||||||||||||||||||||||||
| 2646 | - | |||||||||||||||||||||||||
| 2647 | - | |||||||||||||||||||||||||
| 2648 | - | |||||||||||||||||||||||||
| 2649 | addrSelectB = sqlite3VdbeCurrentAddr(v) + 1; | - | ||||||||||||||||||||||||
| 2650 | addr1 = sqlite3VdbeAddOp3(v, 13, regAddrB, 0, addrSelectB); | - | ||||||||||||||||||||||||
| 2651 | ; | - | ||||||||||||||||||||||||
| 2652 | savedLimit = p->iLimit; | - | ||||||||||||||||||||||||
| 2653 | savedOffset = p->iOffset; | - | ||||||||||||||||||||||||
| 2654 | p->iLimit = regLimitB; | - | ||||||||||||||||||||||||
| 2655 | p->iOffset = 0; | - | ||||||||||||||||||||||||
| 2656 | sqlite3VdbeExplain (pParse, 1, "RIGHT"); | - | ||||||||||||||||||||||||
| 2657 | sqlite3Select(pParse, p, &destB); | - | ||||||||||||||||||||||||
| 2658 | p->iLimit = savedLimit; | - | ||||||||||||||||||||||||
| 2659 | p->iOffset = savedOffset; | - | ||||||||||||||||||||||||
| 2660 | sqlite3VdbeEndCoroutine(v, regAddrB); | - | ||||||||||||||||||||||||
| 2661 | - | |||||||||||||||||||||||||
| 2662 | - | |||||||||||||||||||||||||
| 2663 | - | |||||||||||||||||||||||||
| 2664 | - | |||||||||||||||||||||||||
| 2665 | ; | - | ||||||||||||||||||||||||
| 2666 | addrOutA = generateOutputSubroutine(pParse, | - | ||||||||||||||||||||||||
| 2667 | p, &destA, pDest, regOutA, | - | ||||||||||||||||||||||||
| 2668 | regPrev, pKeyDup, labelEnd); | - | ||||||||||||||||||||||||
| 2669 | - | |||||||||||||||||||||||||
| 2670 | - | |||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | - | |||||||||||||||||||||||||
| 2673 | if( op==124
| 154-328 | ||||||||||||||||||||||||
| 2674 | ; | - | ||||||||||||||||||||||||
| 2675 | addrOutB = generateOutputSubroutine(pParse, | - | ||||||||||||||||||||||||
| 2676 | p, &destB, pDest, regOutB, | - | ||||||||||||||||||||||||
| 2677 | regPrev, pKeyDup, labelEnd); | - | ||||||||||||||||||||||||
| 2678 | } executed 487 times by 1 test: end of blockExecuted by:
| 487 | ||||||||||||||||||||||||
| 2679 | sqlite3KeyInfoUnref(pKeyDup); | - | ||||||||||||||||||||||||
| 2680 | - | |||||||||||||||||||||||||
| 2681 | - | |||||||||||||||||||||||||
| 2682 | - | |||||||||||||||||||||||||
| 2683 | - | |||||||||||||||||||||||||
| 2684 | if( op==125
| 58-583 | ||||||||||||||||||||||||
| 2685 | addrEofA_noB = addrEofA = labelEnd; | - | ||||||||||||||||||||||||
| 2686 | } executed 154 times by 1 test: else{end of blockExecuted by:
| 154 | ||||||||||||||||||||||||
| 2687 | ; | - | ||||||||||||||||||||||||
| 2688 | addrEofA = sqlite3VdbeAddOp2(v, 12, regOutB, addrOutB); | - | ||||||||||||||||||||||||
| 2689 | addrEofA_noB = sqlite3VdbeAddOp2(v, 14, regAddrB, labelEnd); | - | ||||||||||||||||||||||||
| 2690 | ; | - | ||||||||||||||||||||||||
| 2691 | sqlite3VdbeGoto(v, addrEofA); | - | ||||||||||||||||||||||||
| 2692 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); | - | ||||||||||||||||||||||||
| 2693 | } executed 487 times by 1 test: end of blockExecuted by:
| 487 | ||||||||||||||||||||||||
| 2694 | - | |||||||||||||||||||||||||
| 2695 | - | |||||||||||||||||||||||||
| 2696 | - | |||||||||||||||||||||||||
| 2697 | - | |||||||||||||||||||||||||
| 2698 | if( op==126
| 96-545 | ||||||||||||||||||||||||
| 2699 | addrEofB = addrEofA; | - | ||||||||||||||||||||||||
| 2700 | if( p->nSelectRow > pPrior->nSelectRow
executed 32 times by 1 test: p->nSelectRow = pPrior->nSelectRow;Executed by:
| 32-64 | ||||||||||||||||||||||||
| 2701 | } executed 96 times by 1 test: else{end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 2702 | ; | - | ||||||||||||||||||||||||
| 2703 | addrEofB = sqlite3VdbeAddOp2(v, 12, regOutA, addrOutA); | - | ||||||||||||||||||||||||
| 2704 | sqlite3VdbeAddOp2(v, 14, regAddrA, labelEnd); ; | - | ||||||||||||||||||||||||
| 2705 | sqlite3VdbeGoto(v, addrEofB); | - | ||||||||||||||||||||||||
| 2706 | } executed 545 times by 1 test: end of blockExecuted by:
| 545 | ||||||||||||||||||||||||
| 2707 | - | |||||||||||||||||||||||||
| 2708 | - | |||||||||||||||||||||||||
| 2709 | - | |||||||||||||||||||||||||
| 2710 | ; | - | ||||||||||||||||||||||||
| 2711 | addrAltB = sqlite3VdbeAddOp2(v, 12, regOutA, addrOutA); | - | ||||||||||||||||||||||||
| 2712 | sqlite3VdbeAddOp2(v, 14, regAddrA, addrEofA); ; | - | ||||||||||||||||||||||||
| 2713 | sqlite3VdbeGoto(v, labelCmpr); | - | ||||||||||||||||||||||||
| 2714 | - | |||||||||||||||||||||||||
| 2715 | - | |||||||||||||||||||||||||
| 2716 | - | |||||||||||||||||||||||||
| 2717 | if( op==124
| 313-328 | ||||||||||||||||||||||||
| 2718 | addrAeqB = addrAltB; | - | ||||||||||||||||||||||||
| 2719 | } executed 328 times by 1 test: else if( op==126end of blockExecuted by:
| 96-328 | ||||||||||||||||||||||||
| 2720 | addrAeqB = addrAltB; | - | ||||||||||||||||||||||||
| 2721 | addrAltB++; | - | ||||||||||||||||||||||||
| 2722 | } executed 96 times by 1 test: else{end of blockExecuted by:
| 96 | ||||||||||||||||||||||||
| 2723 | ; | - | ||||||||||||||||||||||||
| 2724 | addrAeqB = | - | ||||||||||||||||||||||||
| 2725 | sqlite3VdbeAddOp2(v, 14, regAddrA, addrEofA); ; | - | ||||||||||||||||||||||||
| 2726 | sqlite3VdbeGoto(v, labelCmpr); | - | ||||||||||||||||||||||||
| 2727 | } executed 217 times by 1 test: end of blockExecuted by:
| 217 | ||||||||||||||||||||||||
| 2728 | - | |||||||||||||||||||||||||
| 2729 | - | |||||||||||||||||||||||||
| 2730 | - | |||||||||||||||||||||||||
| 2731 | ; | - | ||||||||||||||||||||||||
| 2732 | addrAgtB = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 2733 | if( op==124
| 154-328 | ||||||||||||||||||||||||
| 2734 | sqlite3VdbeAddOp2(v, 12, regOutB, addrOutB); | - | ||||||||||||||||||||||||
| 2735 | } executed 487 times by 1 test: end of blockExecuted by:
| 487 | ||||||||||||||||||||||||
| 2736 | sqlite3VdbeAddOp2(v, 14, regAddrB, addrEofB); ; | - | ||||||||||||||||||||||||
| 2737 | sqlite3VdbeGoto(v, labelCmpr); | - | ||||||||||||||||||||||||
| 2738 | - | |||||||||||||||||||||||||
| 2739 | - | |||||||||||||||||||||||||
| 2740 | - | |||||||||||||||||||||||||
| 2741 | sqlite3VdbeJumpHere(v, addr1); | - | ||||||||||||||||||||||||
| 2742 | sqlite3VdbeAddOp2(v, 14, regAddrA, addrEofA_noB); ; | - | ||||||||||||||||||||||||
| 2743 | sqlite3VdbeAddOp2(v, 14, regAddrB, addrEofB); ; | - | ||||||||||||||||||||||||
| 2744 | - | |||||||||||||||||||||||||
| 2745 | - | |||||||||||||||||||||||||
| 2746 | - | |||||||||||||||||||||||||
| 2747 | sqlite3VdbeResolveLabel(v, labelCmpr); | - | ||||||||||||||||||||||||
| 2748 | sqlite3VdbeAddOp4(v, 86, 0, 0, 0, (char*)aPermute, (-15)); | - | ||||||||||||||||||||||||
| 2749 | sqlite3VdbeAddOp4(v, 87, destA.iSdst, destB.iSdst, nOrderBy, | - | ||||||||||||||||||||||||
| 2750 | (char*)pKeyMerge, (-9)); | - | ||||||||||||||||||||||||
| 2751 | sqlite3VdbeChangeP5(v, 0x01); | - | ||||||||||||||||||||||||
| 2752 | sqlite3VdbeAddOp3(v, 16, addrAltB, addrAeqB, addrAgtB); ; | - | ||||||||||||||||||||||||
| 2753 | - | |||||||||||||||||||||||||
| 2754 | - | |||||||||||||||||||||||||
| 2755 | - | |||||||||||||||||||||||||
| 2756 | sqlite3VdbeResolveLabel(v, labelEnd); | - | ||||||||||||||||||||||||
| 2757 | - | |||||||||||||||||||||||||
| 2758 | - | |||||||||||||||||||||||||
| 2759 | - | |||||||||||||||||||||||||
| 2760 | if( p->pPrior
| 8-633 | ||||||||||||||||||||||||
| 2761 | sqlite3SelectDelete(db, p->pPrior); | - | ||||||||||||||||||||||||
| 2762 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 2763 | p->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 2764 | pPrior->pNext = p; | - | ||||||||||||||||||||||||
| 2765 | - | |||||||||||||||||||||||||
| 2766 | - | |||||||||||||||||||||||||
| 2767 | - | |||||||||||||||||||||||||
| 2768 | sqlite3VdbeExplainPop(pParse); | - | ||||||||||||||||||||||||
| 2769 | return executed 641 times by 1 test: pParse->nErr!=0;return pParse->nErr!=0;Executed by:
executed 641 times by 1 test: return pParse->nErr!=0;Executed by:
| 641 | ||||||||||||||||||||||||
| 2770 | } | - | ||||||||||||||||||||||||
| 2771 | typedef struct SubstContext { | - | ||||||||||||||||||||||||
| 2772 | Parse *pParse; | - | ||||||||||||||||||||||||
| 2773 | int iTable; | - | ||||||||||||||||||||||||
| 2774 | int iNewTable; | - | ||||||||||||||||||||||||
| 2775 | int isLeftJoin; | - | ||||||||||||||||||||||||
| 2776 | ExprList *pEList; | - | ||||||||||||||||||||||||
| 2777 | } SubstContext; | - | ||||||||||||||||||||||||
| 2778 | - | |||||||||||||||||||||||||
| 2779 | - | |||||||||||||||||||||||||
| 2780 | static void substExprList(SubstContext*, ExprList*); | - | ||||||||||||||||||||||||
| 2781 | static void substSelect(SubstContext*, Select*, int); | - | ||||||||||||||||||||||||
| 2782 | static Expr *substExpr( | - | ||||||||||||||||||||||||
| 2783 | SubstContext *pSubst, | - | ||||||||||||||||||||||||
| 2784 | Expr *pExpr | - | ||||||||||||||||||||||||
| 2785 | ){ | - | ||||||||||||||||||||||||
| 2786 | if( pExpr==0
executed 90626 times by 2 tests: 0;return 0;Executed by:
executed 90626 times by 2 tests: return 0;Executed by:
| 53177-90626 | ||||||||||||||||||||||||
| 2787 | if( (((
| 415-52762 | ||||||||||||||||||||||||
| 2788 | && pExpr->iRightJoinTable==pSubst->iTable
| 59-356 | ||||||||||||||||||||||||
| 2789 | ){ | - | ||||||||||||||||||||||||
| 2790 | pExpr->iRightJoinTable = pSubst->iNewTable; | - | ||||||||||||||||||||||||
| 2791 | } executed 59 times by 1 test: end of blockExecuted by:
| 59 | ||||||||||||||||||||||||
| 2792 | if( pExpr->op==158
| 6245-45217 | ||||||||||||||||||||||||
| 2793 | if( pExpr->iColumn<0
| 4-38968 | ||||||||||||||||||||||||
| 2794 | pExpr->op = 110; | - | ||||||||||||||||||||||||
| 2795 | } executed 4 times by 1 test: else{end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 2796 | Expr *pNew; | - | ||||||||||||||||||||||||
| 2797 | Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr; | - | ||||||||||||||||||||||||
| 2798 | Expr ifNullRow; | - | ||||||||||||||||||||||||
| 2799 | - | |||||||||||||||||||||||||
| 2800 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2801 | ; | - | ||||||||||||||||||||||||
| 2802 | - | |||||||||||||||||||||||||
| 2803 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2804 | ; | - | ||||||||||||||||||||||||
| 2805 | if( sqlite3ExprIsVector(pCopy)
| 8-38960 | ||||||||||||||||||||||||
| 2806 | sqlite3VectorErrorMsg(pSubst->pParse, pCopy); | - | ||||||||||||||||||||||||
| 2807 | } executed 8 times by 1 test: else{end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 2808 | sqlite3 *db = pSubst->pParse->db; | - | ||||||||||||||||||||||||
| 2809 | if( pSubst->isLeftJoin
| 8-38896 | ||||||||||||||||||||||||
| 2810 | memset(&ifNullRow, 0, sizeof(ifNullRow)); | - | ||||||||||||||||||||||||
| 2811 | ifNullRow.op = 167; | - | ||||||||||||||||||||||||
| 2812 | ifNullRow.pLeft = pCopy; | - | ||||||||||||||||||||||||
| 2813 | ifNullRow.iTable = pSubst->iNewTable; | - | ||||||||||||||||||||||||
| 2814 | pCopy = &ifNullRow; | - | ||||||||||||||||||||||||
| 2815 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 2816 | pNew = sqlite3ExprDup(db, pCopy, 0); | - | ||||||||||||||||||||||||
| 2817 | if( pNew
| 46-38914 | ||||||||||||||||||||||||
| 2818 | (pNew)->flags|=(0x100000); | - | ||||||||||||||||||||||||
| 2819 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 2820 | if( pNew
| 33-38914 | ||||||||||||||||||||||||
| 2821 | pNew->iRightJoinTable = pExpr->iRightJoinTable; | - | ||||||||||||||||||||||||
| 2822 | (pNew)->flags|=(0x000001); | - | ||||||||||||||||||||||||
| 2823 | } executed 33 times by 1 test: end of blockExecuted by:
| 33 | ||||||||||||||||||||||||
| 2824 | sqlite3ExprDelete(db, pExpr); | - | ||||||||||||||||||||||||
| 2825 | pExpr = pNew; | - | ||||||||||||||||||||||||
| 2826 | } executed 38960 times by 2 tests: end of blockExecuted by:
| 38960 | ||||||||||||||||||||||||
| 2827 | } | - | ||||||||||||||||||||||||
| 2828 | }else{ | - | ||||||||||||||||||||||||
| 2829 | if( pExpr->op==167
| 1-14200 | ||||||||||||||||||||||||
| 2830 | pExpr->iTable = pSubst->iNewTable; | - | ||||||||||||||||||||||||
| 2831 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 2832 | pExpr->pLeft = substExpr(pSubst, pExpr->pLeft); | - | ||||||||||||||||||||||||
| 2833 | pExpr->pRight = substExpr(pSubst, pExpr->pRight); | - | ||||||||||||||||||||||||
| 2834 | if( (((
| 114-14091 | ||||||||||||||||||||||||
| 2835 | substSelect(pSubst, pExpr->x.pSelect, 1); | - | ||||||||||||||||||||||||
| 2836 | } executed 114 times by 1 test: else{end of blockExecuted by:
| 114 | ||||||||||||||||||||||||
| 2837 | substExprList(pSubst, pExpr->x.pList); | - | ||||||||||||||||||||||||
| 2838 | } executed 14091 times by 1 test: end of blockExecuted by:
| 14091 | ||||||||||||||||||||||||
| 2839 | } | - | ||||||||||||||||||||||||
| 2840 | return executed 53177 times by 2 tests: pExpr;return pExpr;Executed by:
executed 53177 times by 2 tests: return pExpr;Executed by:
| 53177 | ||||||||||||||||||||||||
| 2841 | } | - | ||||||||||||||||||||||||
| 2842 | static void substExprList( | - | ||||||||||||||||||||||||
| 2843 | SubstContext *pSubst, | - | ||||||||||||||||||||||||
| 2844 | ExprList *pList | - | ||||||||||||||||||||||||
| 2845 | ){ | - | ||||||||||||||||||||||||
| 2846 | int i; | - | ||||||||||||||||||||||||
| 2847 | if( pList==0
executed 86678 times by 2 tests: return;Executed by:
| 37605-86678 | ||||||||||||||||||||||||
| 2848 | for(i=0; i<pList->nExpr
| 37605-41834 | ||||||||||||||||||||||||
| 2849 | pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr); | - | ||||||||||||||||||||||||
| 2850 | } executed 41834 times by 2 tests: end of blockExecuted by:
| 41834 | ||||||||||||||||||||||||
| 2851 | } executed 37605 times by 2 tests: end of blockExecuted by:
| 37605 | ||||||||||||||||||||||||
| 2852 | static void substSelect( | - | ||||||||||||||||||||||||
| 2853 | SubstContext *pSubst, | - | ||||||||||||||||||||||||
| 2854 | Select *p, | - | ||||||||||||||||||||||||
| 2855 | int doPrior | - | ||||||||||||||||||||||||
| 2856 | ){ | - | ||||||||||||||||||||||||
| 2857 | SrcList *pSrc; | - | ||||||||||||||||||||||||
| 2858 | struct SrcList_item *pItem; | - | ||||||||||||||||||||||||
| 2859 | int i; | - | ||||||||||||||||||||||||
| 2860 | if( !p
executed 37543 times by 2 tests: return;Executed by:
| 36612-37543 | ||||||||||||||||||||||||
| 2861 | do{ | - | ||||||||||||||||||||||||
| 2862 | substExprList(pSubst, p->pEList); | - | ||||||||||||||||||||||||
| 2863 | substExprList(pSubst, p->pGroupBy); | - | ||||||||||||||||||||||||
| 2864 | substExprList(pSubst, p->pOrderBy); | - | ||||||||||||||||||||||||
| 2865 | p->pHaving = substExpr(pSubst, p->pHaving); | - | ||||||||||||||||||||||||
| 2866 | p->pWhere = substExpr(pSubst, p->pWhere); | - | ||||||||||||||||||||||||
| 2867 | pSrc = p->pSrc; | - | ||||||||||||||||||||||||
| 2868 | - | |||||||||||||||||||||||||
| 2869 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2870 | ; | - | ||||||||||||||||||||||||
| 2871 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0
| 36730-38460 | ||||||||||||||||||||||||
| 2872 | substSelect(pSubst, pItem->pSelect, 1); | - | ||||||||||||||||||||||||
| 2873 | if( pItem->fg.isTabFunc
| 2-38458 | ||||||||||||||||||||||||
| 2874 | substExprList(pSubst, pItem->u1.pFuncArg); | - | ||||||||||||||||||||||||
| 2875 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 2876 | } executed 38460 times by 2 tests: end of blockExecuted by:
| 38460 | ||||||||||||||||||||||||
| 2877 | } executed 36730 times by 2 tests: while( doPriorend of blockExecuted by:
| 118-36730 | ||||||||||||||||||||||||
| 2878 | } executed 36612 times by 2 tests: end of blockExecuted by:
| 36612 | ||||||||||||||||||||||||
| 2879 | static int flattenSubquery( | - | ||||||||||||||||||||||||
| 2880 | Parse *pParse, | - | ||||||||||||||||||||||||
| 2881 | Select *p, | - | ||||||||||||||||||||||||
| 2882 | int iFrom, | - | ||||||||||||||||||||||||
| 2883 | int isAgg | - | ||||||||||||||||||||||||
| 2884 | ){ | - | ||||||||||||||||||||||||
| 2885 | const char *zSavedAuthContext = pParse->zAuthContext; | - | ||||||||||||||||||||||||
| 2886 | Select *pParent; | - | ||||||||||||||||||||||||
| 2887 | Select *pSub; | - | ||||||||||||||||||||||||
| 2888 | Select *pSub1; | - | ||||||||||||||||||||||||
| 2889 | SrcList *pSrc; | - | ||||||||||||||||||||||||
| 2890 | SrcList *pSubSrc; | - | ||||||||||||||||||||||||
| 2891 | int iParent; | - | ||||||||||||||||||||||||
| 2892 | int iNewParent = -1; | - | ||||||||||||||||||||||||
| 2893 | int isLeftJoin = 0; | - | ||||||||||||||||||||||||
| 2894 | int i; | - | ||||||||||||||||||||||||
| 2895 | Expr *pWhere; | - | ||||||||||||||||||||||||
| 2896 | struct SrcList_item *pSubitem; | - | ||||||||||||||||||||||||
| 2897 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 2898 | - | |||||||||||||||||||||||||
| 2899 | - | |||||||||||||||||||||||||
| 2900 | - | |||||||||||||||||||||||||
| 2901 | - | |||||||||||||||||||||||||
| 2902 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2903 | ; | - | ||||||||||||||||||||||||
| 2904 | - | |||||||||||||||||||||||||
| 2905 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2906 | ; | - | ||||||||||||||||||||||||
| 2907 | if( (((
executed 75 times by 1 test: 0;return 0;Executed by:
executed 75 times by 1 test: return 0;Executed by:
| 75-69143 | ||||||||||||||||||||||||
| 2908 | pSrc = p->pSrc; | - | ||||||||||||||||||||||||
| 2909 | - | |||||||||||||||||||||||||
| 2910 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2911 | ; | - | ||||||||||||||||||||||||
| 2912 | pSubitem = &pSrc->a[iFrom]; | - | ||||||||||||||||||||||||
| 2913 | iParent = pSubitem->iCursor; | - | ||||||||||||||||||||||||
| 2914 | pSub = pSubitem->pSelect; | - | ||||||||||||||||||||||||
| 2915 | - | |||||||||||||||||||||||||
| 2916 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2917 | ; | - | ||||||||||||||||||||||||
| 2918 | - | |||||||||||||||||||||||||
| 2919 | - | |||||||||||||||||||||||||
| 2920 | if( p->pWin
executed 206 times by 1 test: 0;return 0;Executed by:
executed 206 times by 1 test: return 0;Executed by:
| 8-68945 | ||||||||||||||||||||||||
| 2921 | - | |||||||||||||||||||||||||
| 2922 | - | |||||||||||||||||||||||||
| 2923 | pSubSrc = pSub->pSrc; | - | ||||||||||||||||||||||||
| 2924 | - | |||||||||||||||||||||||||
| 2925 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2926 | ; | - | ||||||||||||||||||||||||
| 2927 | - | |||||||||||||||||||||||||
| 2928 | - | |||||||||||||||||||||||||
| 2929 | - | |||||||||||||||||||||||||
| 2930 | - | |||||||||||||||||||||||||
| 2931 | - | |||||||||||||||||||||||||
| 2932 | if( pSub->pLimit
executed 29 times by 1 test: 0;return 0;Executed by:
executed 29 times by 1 test: return 0;Executed by:
| 29-68789 | ||||||||||||||||||||||||
| 2933 | if( pSub->pLimit
executed 14 times by 1 test: 0;return 0;Executed by:
executed 14 times by 1 test: return 0;Executed by:
| 14-68789 | ||||||||||||||||||||||||
| 2934 | if( (
| 54-65705 | ||||||||||||||||||||||||
| 2935 | return executed 54 times by 1 test: 0;return 0;Executed by:
executed 54 times by 1 test: return 0;Executed by:
| 54 | ||||||||||||||||||||||||
| 2936 | } | - | ||||||||||||||||||||||||
| 2937 | if( pSubSrc->nSrc==0
executed 219 times by 1 test: 0;return 0;Executed by:
executed 219 times by 1 test: return 0;Executed by:
| 219-68621 | ||||||||||||||||||||||||
| 2938 | if( pSub->selFlags & 0x00001
executed 28 times by 1 test: 0;return 0;Executed by:
executed 28 times by 1 test: return 0;Executed by:
| 28-68593 | ||||||||||||||||||||||||
| 2939 | if( pSub->pLimit
| 7-68542 | ||||||||||||||||||||||||
| 2940 | return executed 17 times by 1 test: 0;return 0;Executed by:
executed 17 times by 1 test: return 0;Executed by:
| 17 | ||||||||||||||||||||||||
| 2941 | } | - | ||||||||||||||||||||||||
| 2942 | if( p->pOrderBy
| 27-68320 | ||||||||||||||||||||||||
| 2943 | return executed 27 times by 1 test: 0;return 0;Executed by:
executed 27 times by 1 test: return 0;Executed by:
| 27 | ||||||||||||||||||||||||
| 2944 | } | - | ||||||||||||||||||||||||
| 2945 | if( isAgg
never executed: 0;return 0;never executed: return 0; | 0-68480 | ||||||||||||||||||||||||
| 2946 | if( pSub->pLimit
executed 6 times by 1 test: 0;return 0;Executed by:
executed 6 times by 1 test: return 0;Executed by:
| 6-68529 | ||||||||||||||||||||||||
| 2947 | if( pSub->pLimit
| 1-68529 | ||||||||||||||||||||||||
| 2948 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 2949 | } | - | ||||||||||||||||||||||||
| 2950 | if( pSub->selFlags & (0x02000)
| 280-68262 | ||||||||||||||||||||||||
| 2951 | return executed 280 times by 1 test: 0;return 0;Executed by:
executed 280 times by 1 test: return 0;Executed by:
| 280 | ||||||||||||||||||||||||
| 2952 | } | - | ||||||||||||||||||||||||
| 2953 | if( (
| 46-68216 | ||||||||||||||||||||||||
| 2954 | isLeftJoin = 1; | - | ||||||||||||||||||||||||
| 2955 | if( pSubSrc->nSrc>1
| 2-26 | ||||||||||||||||||||||||
| 2956 | - | |||||||||||||||||||||||||
| 2957 | return executed 24 times by 1 test: 0;return 0;Executed by:
executed 24 times by 1 test: return 0;Executed by:
| 24 | ||||||||||||||||||||||||
| 2958 | } | - | ||||||||||||||||||||||||
| 2959 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 2960 | if( pSub->pPrior
| 33102-35136 | ||||||||||||||||||||||||
| 2961 | if( pSub->pOrderBy
| 5-33097 | ||||||||||||||||||||||||
| 2962 | return executed 5 times by 1 test: 0;return 0;Executed by:
executed 5 times by 1 test: return 0;Executed by:
| 5 | ||||||||||||||||||||||||
| 2963 | } | - | ||||||||||||||||||||||||
| 2964 | if( isAgg
| 2-33088 | ||||||||||||||||||||||||
| 2965 | return executed 25 times by 1 test: 0;return 0;Executed by:
executed 25 times by 1 test: return 0;Executed by:
| 25 | ||||||||||||||||||||||||
| 2966 | } | - | ||||||||||||||||||||||||
| 2967 | for(pSub1=pSub; pSub1
| 235-33337 | ||||||||||||||||||||||||
| 2968 | ; | - | ||||||||||||||||||||||||
| 2969 | ; | - | ||||||||||||||||||||||||
| 2970 | - | |||||||||||||||||||||||||
| 2971 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2972 | ; | - | ||||||||||||||||||||||||
| 2973 | - | |||||||||||||||||||||||||
| 2974 | ((void) (0)) | - | ||||||||||||||||||||||||
| 2975 | ; | - | ||||||||||||||||||||||||
| 2976 | if( (
| 0-33337 | ||||||||||||||||||||||||
| 2977 | || (pSub1->pPrior
| 239-33098 | ||||||||||||||||||||||||
| 2978 | || pSub1->pSrc->nSrc<1
| 4-500 | ||||||||||||||||||||||||
| 2979 | ){ | - | ||||||||||||||||||||||||
| 2980 | return executed 32837 times by 1 test: 0;return 0;Executed by:
executed 32837 times by 1 test: return 0;Executed by:
| 32837 | ||||||||||||||||||||||||
| 2981 | } | - | ||||||||||||||||||||||||
| 2982 | ; | - | ||||||||||||||||||||||||
| 2983 | } executed 500 times by 1 test: end of blockExecuted by:
| 500 | ||||||||||||||||||||||||
| 2984 | - | |||||||||||||||||||||||||
| 2985 | - | |||||||||||||||||||||||||
| 2986 | if( p->pOrderBy
| 66-169 | ||||||||||||||||||||||||
| 2987 | int ii; | - | ||||||||||||||||||||||||
| 2988 | for(ii=0; ii<p->pOrderBy->nExpr
| 61-68 | ||||||||||||||||||||||||
| 2989 | if( p->pOrderBy->a[ii].u.x.iOrderByCol==0
executed 5 times by 1 test: 0;return 0;Executed by:
executed 5 times by 1 test: return 0;Executed by:
| 5-63 | ||||||||||||||||||||||||
| 2990 | } executed 63 times by 1 test: end of blockExecuted by:
| 63 | ||||||||||||||||||||||||
| 2991 | } executed 61 times by 1 test: end of blockExecuted by:
| 61 | ||||||||||||||||||||||||
| 2992 | } executed 230 times by 1 test: end of blockExecuted by:
| 230 | ||||||||||||||||||||||||
| 2993 | - | |||||||||||||||||||||||||
| 2994 | - | |||||||||||||||||||||||||
| 2995 | - | |||||||||||||||||||||||||
| 2996 | - | |||||||||||||||||||||||||
| 2997 | - | |||||||||||||||||||||||||
| 2998 | - | |||||||||||||||||||||||||
| 2999 | - | |||||||||||||||||||||||||
| 3000 | - | |||||||||||||||||||||||||
| 3001 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3002 | ; | - | ||||||||||||||||||||||||
| 3003 | - | |||||||||||||||||||||||||
| 3004 | - | |||||||||||||||||||||||||
| 3005 | - | |||||||||||||||||||||||||
| 3006 | ; | - | ||||||||||||||||||||||||
| 3007 | - | |||||||||||||||||||||||||
| 3008 | - | |||||||||||||||||||||||||
| 3009 | pParse->zAuthContext = pSubitem->zName; | - | ||||||||||||||||||||||||
| 3010 | sqlite3AuthCheck(pParse, 21, 0, 0, 0); | - | ||||||||||||||||||||||||
| 3011 | ; | - | ||||||||||||||||||||||||
| 3012 | pParse->zAuthContext = zSavedAuthContext; | - | ||||||||||||||||||||||||
| 3013 | for(pSub=pSub->pPrior; pSub
| 256-35366 | ||||||||||||||||||||||||
| 3014 | Select *pNew; | - | ||||||||||||||||||||||||
| 3015 | ExprList *pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 3016 | Expr *pLimit = p->pLimit; | - | ||||||||||||||||||||||||
| 3017 | Select *pPrior = p->pPrior; | - | ||||||||||||||||||||||||
| 3018 | p->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 3019 | p->pSrc = 0; | - | ||||||||||||||||||||||||
| 3020 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 3021 | p->pLimit = 0; | - | ||||||||||||||||||||||||
| 3022 | pNew = sqlite3SelectDup(db, p, 0); | - | ||||||||||||||||||||||||
| 3023 | p->pLimit = pLimit; | - | ||||||||||||||||||||||||
| 3024 | p->pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 3025 | p->pSrc = pSrc; | - | ||||||||||||||||||||||||
| 3026 | p->op = 124; | - | ||||||||||||||||||||||||
| 3027 | if( pNew==0
| 0-256 | ||||||||||||||||||||||||
| 3028 | p->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 3029 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||
| 3030 | pNew->pPrior = pPrior; | - | ||||||||||||||||||||||||
| 3031 | if( pPrior
executed 26 times by 1 test: pPrior->pNext = pNew;Executed by:
| 26-230 | ||||||||||||||||||||||||
| 3032 | pNew->pNext = p; | - | ||||||||||||||||||||||||
| 3033 | p->pPrior = pNew; | - | ||||||||||||||||||||||||
| 3034 | - | |||||||||||||||||||||||||
| 3035 | ; | - | ||||||||||||||||||||||||
| 3036 | } executed 256 times by 1 test: end of blockExecuted by:
| 256 | ||||||||||||||||||||||||
| 3037 | if( db->mallocFailed
never executed: 1;return 1;never executed: return 1; | 0-256 | ||||||||||||||||||||||||
| 3038 | } executed 256 times by 1 test: end of blockExecuted by:
| 256 | ||||||||||||||||||||||||
| 3039 | - | |||||||||||||||||||||||||
| 3040 | - | |||||||||||||||||||||||||
| 3041 | - | |||||||||||||||||||||||||
| 3042 | - | |||||||||||||||||||||||||
| 3043 | pSub = pSub1 = pSubitem->pSelect; | - | ||||||||||||||||||||||||
| 3044 | - | |||||||||||||||||||||||||
| 3045 | - | |||||||||||||||||||||||||
| 3046 | - | |||||||||||||||||||||||||
| 3047 | - | |||||||||||||||||||||||||
| 3048 | sqlite3DbFree(db, pSubitem->zDatabase); | - | ||||||||||||||||||||||||
| 3049 | sqlite3DbFree(db, pSubitem->zName); | - | ||||||||||||||||||||||||
| 3050 | sqlite3DbFree(db, pSubitem->zAlias); | - | ||||||||||||||||||||||||
| 3051 | pSubitem->zDatabase = 0; | - | ||||||||||||||||||||||||
| 3052 | pSubitem->zName = 0; | - | ||||||||||||||||||||||||
| 3053 | pSubitem->zAlias = 0; | - | ||||||||||||||||||||||||
| 3054 | pSubitem->pSelect = 0; | - | ||||||||||||||||||||||||
| 3055 | if( (
| 0-35366 | ||||||||||||||||||||||||
| 3056 | Table *pTabToDel = pSubitem->pTab; | - | ||||||||||||||||||||||||
| 3057 | if( pTabToDel->nTabRef==1
| 612-34754 | ||||||||||||||||||||||||
| 3058 | Parse *pToplevel = ((
| 4-608 | ||||||||||||||||||||||||
| 3059 | pTabToDel->pNextZombie = pToplevel->pZombieTab; | - | ||||||||||||||||||||||||
| 3060 | pToplevel->pZombieTab = pTabToDel; | - | ||||||||||||||||||||||||
| 3061 | } executed 612 times by 1 test: else{end of blockExecuted by:
| 612 | ||||||||||||||||||||||||
| 3062 | pTabToDel->nTabRef--; | - | ||||||||||||||||||||||||
| 3063 | } executed 34754 times by 2 tests: end of blockExecuted by:
| 34754 | ||||||||||||||||||||||||
| 3064 | pSubitem->pTab = 0; | - | ||||||||||||||||||||||||
| 3065 | } executed 35366 times by 2 tests: end of blockExecuted by:
| 35366 | ||||||||||||||||||||||||
| 3066 | for(pParent=p; pParent
| 35362-35622 | ||||||||||||||||||||||||
| 3067 | int nSubSrc; | - | ||||||||||||||||||||||||
| 3068 | u8 jointype = 0; | - | ||||||||||||||||||||||||
| 3069 | pSubSrc = pSub->pSrc; | - | ||||||||||||||||||||||||
| 3070 | nSubSrc = pSubSrc->nSrc; | - | ||||||||||||||||||||||||
| 3071 | pSrc = pParent->pSrc; | - | ||||||||||||||||||||||||
| 3072 | - | |||||||||||||||||||||||||
| 3073 | if( pSrc
| 256-35366 | ||||||||||||||||||||||||
| 3074 | - | |||||||||||||||||||||||||
| 3075 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3076 | ; | - | ||||||||||||||||||||||||
| 3077 | jointype = pSubitem->fg.jointype; | - | ||||||||||||||||||||||||
| 3078 | } executed 35366 times by 2 tests: else{end of blockExecuted by:
| 35366 | ||||||||||||||||||||||||
| 3079 | - | |||||||||||||||||||||||||
| 3080 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3081 | ; | - | ||||||||||||||||||||||||
| 3082 | pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0); | - | ||||||||||||||||||||||||
| 3083 | if( pSrc==0
| 0-256 | ||||||||||||||||||||||||
| 3084 | - | |||||||||||||||||||||||||
| 3085 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3086 | ; | - | ||||||||||||||||||||||||
| 3087 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3088 | } | - | ||||||||||||||||||||||||
| 3089 | } executed 256 times by 1 test: end of blockExecuted by:
| 256 | ||||||||||||||||||||||||
| 3090 | if( nSubSrc>1
| 1521-34101 | ||||||||||||||||||||||||
| 3091 | pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1); | - | ||||||||||||||||||||||||
| 3092 | if( db->mallocFailed
| 4-1517 | ||||||||||||||||||||||||
| 3093 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 3094 | } | - | ||||||||||||||||||||||||
| 3095 | } executed 1517 times by 1 test: end of blockExecuted by:
| 1517 | ||||||||||||||||||||||||
| 3096 | - | |||||||||||||||||||||||||
| 3097 | - | |||||||||||||||||||||||||
| 3098 | - | |||||||||||||||||||||||||
| 3099 | - | |||||||||||||||||||||||||
| 3100 | for(i=0; i<nSubSrc
| 35618-37149 | ||||||||||||||||||||||||
| 3101 | sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing); | - | ||||||||||||||||||||||||
| 3102 | - | |||||||||||||||||||||||||
| 3103 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3104 | ; | - | ||||||||||||||||||||||||
| 3105 | pSrc->a[i+iFrom] = pSubSrc->a[i]; | - | ||||||||||||||||||||||||
| 3106 | iNewParent = pSubSrc->a[i].iCursor; | - | ||||||||||||||||||||||||
| 3107 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); | - | ||||||||||||||||||||||||
| 3108 | } executed 37149 times by 2 tests: end of blockExecuted by:
| 37149 | ||||||||||||||||||||||||
| 3109 | pSrc->a[iFrom].fg.jointype = jointype; | - | ||||||||||||||||||||||||
| 3110 | if( pSub->pOrderBy
| 50-35568 | ||||||||||||||||||||||||
| 3111 | ExprList *pOrderBy = pSub->pOrderBy; | - | ||||||||||||||||||||||||
| 3112 | for(i=0; i<pOrderBy->nExpr
| 50-54 | ||||||||||||||||||||||||
| 3113 | pOrderBy->a[i].u.x.iOrderByCol = 0; | - | ||||||||||||||||||||||||
| 3114 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||
| 3115 | - | |||||||||||||||||||||||||
| 3116 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3117 | ; | - | ||||||||||||||||||||||||
| 3118 | pParent->pOrderBy = pOrderBy; | - | ||||||||||||||||||||||||
| 3119 | pSub->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 3120 | } executed 50 times by 1 test: end of blockExecuted by:
| 50 | ||||||||||||||||||||||||
| 3121 | pWhere = sqlite3ExprDup(db, pSub->pWhere, 0); | - | ||||||||||||||||||||||||
| 3122 | if( isLeftJoin>0
| 22-35596 | ||||||||||||||||||||||||
| 3123 | setJoinExpr(pWhere, iNewParent); | - | ||||||||||||||||||||||||
| 3124 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 3125 | pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere); | - | ||||||||||||||||||||||||
| 3126 | if( db->mallocFailed==0
| 37-35581 | ||||||||||||||||||||||||
| 3127 | SubstContext x; | - | ||||||||||||||||||||||||
| 3128 | x.pParse = pParse; | - | ||||||||||||||||||||||||
| 3129 | x.iTable = iParent; | - | ||||||||||||||||||||||||
| 3130 | x.iNewTable = iNewParent; | - | ||||||||||||||||||||||||
| 3131 | x.isLeftJoin = isLeftJoin; | - | ||||||||||||||||||||||||
| 3132 | x.pEList = pSub->pEList; | - | ||||||||||||||||||||||||
| 3133 | substSelect(&x, pParent, 0); | - | ||||||||||||||||||||||||
| 3134 | } executed 35581 times by 2 tests: end of blockExecuted by:
| 35581 | ||||||||||||||||||||||||
| 3135 | - | |||||||||||||||||||||||||
| 3136 | - | |||||||||||||||||||||||||
| 3137 | - | |||||||||||||||||||||||||
| 3138 | - | |||||||||||||||||||||||||
| 3139 | pParent->selFlags |= pSub->selFlags & 0x00001; | - | ||||||||||||||||||||||||
| 3140 | - | |||||||||||||||||||||||||
| 3141 | - | |||||||||||||||||||||||||
| 3142 | - | |||||||||||||||||||||||||
| 3143 | - | |||||||||||||||||||||||||
| 3144 | - | |||||||||||||||||||||||||
| 3145 | - | |||||||||||||||||||||||||
| 3146 | - | |||||||||||||||||||||||||
| 3147 | if( pSub->pLimit
| 8-35610 | ||||||||||||||||||||||||
| 3148 | pParent->pLimit = pSub->pLimit; | - | ||||||||||||||||||||||||
| 3149 | pSub->pLimit = 0; | - | ||||||||||||||||||||||||
| 3150 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 3151 | } executed 35618 times by 2 tests: end of blockExecuted by:
| 35618 | ||||||||||||||||||||||||
| 3152 | - | |||||||||||||||||||||||||
| 3153 | - | |||||||||||||||||||||||||
| 3154 | - | |||||||||||||||||||||||||
| 3155 | - | |||||||||||||||||||||||||
| 3156 | sqlite3SelectDelete(db, pSub1); | - | ||||||||||||||||||||||||
| 3157 | return executed 35366 times by 2 tests: 1;return 1;Executed by:
executed 35366 times by 2 tests: return 1;Executed by:
| 35366 | ||||||||||||||||||||||||
| 3158 | } | - | ||||||||||||||||||||||||
| 3159 | - | |||||||||||||||||||||||||
| 3160 | - | |||||||||||||||||||||||||
| 3161 | - | |||||||||||||||||||||||||
| 3162 | - | |||||||||||||||||||||||||
| 3163 | - | |||||||||||||||||||||||||
| 3164 | - | |||||||||||||||||||||||||
| 3165 | typedef struct WhereConst WhereConst; | - | ||||||||||||||||||||||||
| 3166 | struct WhereConst { | - | ||||||||||||||||||||||||
| 3167 | Parse *pParse; | - | ||||||||||||||||||||||||
| 3168 | int nConst; | - | ||||||||||||||||||||||||
| 3169 | int nChng; | - | ||||||||||||||||||||||||
| 3170 | Expr **apExpr; | - | ||||||||||||||||||||||||
| 3171 | }; | - | ||||||||||||||||||||||||
| 3172 | - | |||||||||||||||||||||||||
| 3173 | - | |||||||||||||||||||||||||
| 3174 | - | |||||||||||||||||||||||||
| 3175 | - | |||||||||||||||||||||||||
| 3176 | static void constInsert( | - | ||||||||||||||||||||||||
| 3177 | WhereConst *pConst, | - | ||||||||||||||||||||||||
| 3178 | Expr *pColumn, | - | ||||||||||||||||||||||||
| 3179 | Expr *pValue | - | ||||||||||||||||||||||||
| 3180 | ){ | - | ||||||||||||||||||||||||
| 3181 | - | |||||||||||||||||||||||||
| 3182 | pConst->nConst++; | - | ||||||||||||||||||||||||
| 3183 | pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr, | - | ||||||||||||||||||||||||
| 3184 | pConst->nConst*2*sizeof(Expr*)); | - | ||||||||||||||||||||||||
| 3185 | if( pConst->apExpr==0
| 102-3748 | ||||||||||||||||||||||||
| 3186 | pConst->nConst = 0; | - | ||||||||||||||||||||||||
| 3187 | } executed 102 times by 1 test: else{end of blockExecuted by:
| 102 | ||||||||||||||||||||||||
| 3188 | if( (((
executed 39 times by 1 test: pValue = pValue->pLeft;Executed by:
| 39-3709 | ||||||||||||||||||||||||
| 3189 | pConst->apExpr[pConst->nConst*2-2] = pColumn; | - | ||||||||||||||||||||||||
| 3190 | pConst->apExpr[pConst->nConst*2-1] = pValue; | - | ||||||||||||||||||||||||
| 3191 | } executed 3748 times by 1 test: end of blockExecuted by:
| 3748 | ||||||||||||||||||||||||
| 3192 | } | - | ||||||||||||||||||||||||
| 3193 | - | |||||||||||||||||||||||||
| 3194 | - | |||||||||||||||||||||||||
| 3195 | - | |||||||||||||||||||||||||
| 3196 | - | |||||||||||||||||||||||||
| 3197 | - | |||||||||||||||||||||||||
| 3198 | - | |||||||||||||||||||||||||
| 3199 | - | |||||||||||||||||||||||||
| 3200 | static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ | - | ||||||||||||||||||||||||
| 3201 | Expr *pRight, *pLeft; | - | ||||||||||||||||||||||||
| 3202 | if( pExpr==0
executed 411 times by 1 test: return;Executed by:
| 411-21556 | ||||||||||||||||||||||||
| 3203 | if( (((
executed 457 times by 1 test: return;Executed by:
| 457-21099 | ||||||||||||||||||||||||
| 3204 | if( pExpr->op==44
| 7497-13602 | ||||||||||||||||||||||||
| 3205 | findConstInWhere(pConst, pExpr->pRight); | - | ||||||||||||||||||||||||
| 3206 | findConstInWhere(pConst, pExpr->pLeft); | - | ||||||||||||||||||||||||
| 3207 | return; executed 7497 times by 1 test: return;Executed by:
| 7497 | ||||||||||||||||||||||||
| 3208 | } | - | ||||||||||||||||||||||||
| 3209 | if( pExpr->op!=53
executed 3265 times by 1 test: return;Executed by:
| 3265-10337 | ||||||||||||||||||||||||
| 3210 | pRight = pExpr->pRight; | - | ||||||||||||||||||||||||
| 3211 | pLeft = pExpr->pLeft; | - | ||||||||||||||||||||||||
| 3212 | - | |||||||||||||||||||||||||
| 3213 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3214 | ; | - | ||||||||||||||||||||||||
| 3215 | - | |||||||||||||||||||||||||
| 3216 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3217 | ; | - | ||||||||||||||||||||||||
| 3218 | if( pRight->op==158
| 4424-5913 | ||||||||||||||||||||||||
| 3219 | && !(((pRight)->flags&(0x000008))!=0)
| 39-4385 | ||||||||||||||||||||||||
| 3220 | && sqlite3ExprIsConstant(pLeft)
| 47-4338 | ||||||||||||||||||||||||
| 3221 | && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
| 5-42 | ||||||||||||||||||||||||
| 3222 | ){ | - | ||||||||||||||||||||||||
| 3223 | constInsert(pConst, pRight, pLeft); | - | ||||||||||||||||||||||||
| 3224 | } executed 42 times by 1 test: elseend of blockExecuted by:
| 42 | ||||||||||||||||||||||||
| 3225 | if( pLeft->op==158
| 59-10236 | ||||||||||||||||||||||||
| 3226 | && !(((pLeft)->flags&(0x000008))!=0)
| 5-10231 | ||||||||||||||||||||||||
| 3227 | && sqlite3ExprIsConstant(pRight)
| 3815-6416 | ||||||||||||||||||||||||
| 3228 | && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))
| 7-3808 | ||||||||||||||||||||||||
| 3229 | ){ | - | ||||||||||||||||||||||||
| 3230 | constInsert(pConst, pLeft, pRight); | - | ||||||||||||||||||||||||
| 3231 | } executed 3808 times by 1 test: end of blockExecuted by:
| 3808 | ||||||||||||||||||||||||
| 3232 | } executed 10337 times by 1 test: end of blockExecuted by:
| 10337 | ||||||||||||||||||||||||
| 3233 | - | |||||||||||||||||||||||||
| 3234 | - | |||||||||||||||||||||||||
| 3235 | - | |||||||||||||||||||||||||
| 3236 | - | |||||||||||||||||||||||||
| 3237 | - | |||||||||||||||||||||||||
| 3238 | - | |||||||||||||||||||||||||
| 3239 | - | |||||||||||||||||||||||||
| 3240 | static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ | - | ||||||||||||||||||||||||
| 3241 | int i; | - | ||||||||||||||||||||||||
| 3242 | WhereConst *pConst; | - | ||||||||||||||||||||||||
| 3243 | if( pExpr->op!=158
executed 15343 times by 1 test: 0;return 0;Executed by:
executed 15343 times by 1 test: return 0;Executed by:
| 10230-15343 | ||||||||||||||||||||||||
| 3244 | if( (((
executed 58 times by 1 test: 0;return 0;Executed by:
executed 58 times by 1 test: return 0;Executed by:
| 58-10172 | ||||||||||||||||||||||||
| 3245 | pConst = pWalker->u.pConst; | - | ||||||||||||||||||||||||
| 3246 | for(i=0; i<pConst->nConst
| 10118-12294 | ||||||||||||||||||||||||
| 3247 | Expr *pColumn = pConst->apExpr[i*2]; | - | ||||||||||||||||||||||||
| 3248 | if( pColumn==pExpr
executed 3728 times by 1 test: continue;Executed by:
| 3728-8566 | ||||||||||||||||||||||||
| 3249 | if( pColumn->iTable!=pExpr->iTable
executed 4430 times by 1 test: continue;Executed by:
| 4136-4430 | ||||||||||||||||||||||||
| 3250 | if( pColumn->iColumn!=pExpr->iColumn
executed 4082 times by 1 test: continue;Executed by:
| 54-4082 | ||||||||||||||||||||||||
| 3251 | - | |||||||||||||||||||||||||
| 3252 | pConst->nChng++; | - | ||||||||||||||||||||||||
| 3253 | (pExpr)->flags&=~(0x800000); | - | ||||||||||||||||||||||||
| 3254 | (pExpr)->flags|=(0x000008); | - | ||||||||||||||||||||||||
| 3255 | - | |||||||||||||||||||||||||
| 3256 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3257 | ; | - | ||||||||||||||||||||||||
| 3258 | pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0); | - | ||||||||||||||||||||||||
| 3259 | break; executed 54 times by 1 test: break;Executed by:
| 54 | ||||||||||||||||||||||||
| 3260 | } | - | ||||||||||||||||||||||||
| 3261 | return executed 10172 times by 1 test: 1;return 1;Executed by:
executed 10172 times by 1 test: return 1;Executed by:
| 10172 | ||||||||||||||||||||||||
| 3262 | } | - | ||||||||||||||||||||||||
| 3263 | static int propagateConstants( | - | ||||||||||||||||||||||||
| 3264 | Parse *pParse, | - | ||||||||||||||||||||||||
| 3265 | Select *p | - | ||||||||||||||||||||||||
| 3266 | ){ | - | ||||||||||||||||||||||||
| 3267 | WhereConst x; | - | ||||||||||||||||||||||||
| 3268 | Walker w; | - | ||||||||||||||||||||||||
| 3269 | int nChng = 0; | - | ||||||||||||||||||||||||
| 3270 | x.pParse = pParse; | - | ||||||||||||||||||||||||
| 3271 | do{ | - | ||||||||||||||||||||||||
| 3272 | x.nConst = 0; | - | ||||||||||||||||||||||||
| 3273 | x.nChng = 0; | - | ||||||||||||||||||||||||
| 3274 | x.apExpr = 0; | - | ||||||||||||||||||||||||
| 3275 | findConstInWhere(&x, p->pWhere); | - | ||||||||||||||||||||||||
| 3276 | if( x.nConst
| 3258-3715 | ||||||||||||||||||||||||
| 3277 | memset(&w, 0, sizeof(w)); | - | ||||||||||||||||||||||||
| 3278 | w.pParse = pParse; | - | ||||||||||||||||||||||||
| 3279 | w.xExprCallback = propagateConstantExprRewrite; | - | ||||||||||||||||||||||||
| 3280 | w.xSelectCallback = sqlite3SelectWalkNoop; | - | ||||||||||||||||||||||||
| 3281 | w.xSelectCallback2 = 0; | - | ||||||||||||||||||||||||
| 3282 | w.walkerDepth = 0; | - | ||||||||||||||||||||||||
| 3283 | w.u.pConst = &x; | - | ||||||||||||||||||||||||
| 3284 | sqlite3WalkExpr(&w, p->pWhere); | - | ||||||||||||||||||||||||
| 3285 | sqlite3DbFree(x.pParse->db, x.apExpr); | - | ||||||||||||||||||||||||
| 3286 | nChng += x.nChng; | - | ||||||||||||||||||||||||
| 3287 | } executed 3258 times by 1 test: end of blockExecuted by:
| 3258 | ||||||||||||||||||||||||
| 3288 | } executed 6973 times by 1 test: while( x.nChngend of blockExecuted by:
| 49-6973 | ||||||||||||||||||||||||
| 3289 | return executed 6924 times by 1 test: nChng;return nChng;Executed by:
executed 6924 times by 1 test: return nChng;Executed by:
| 6924 | ||||||||||||||||||||||||
| 3290 | } | - | ||||||||||||||||||||||||
| 3291 | static int pushDownWhereTerms( | - | ||||||||||||||||||||||||
| 3292 | Parse *pParse, | - | ||||||||||||||||||||||||
| 3293 | Select *pSubq, | - | ||||||||||||||||||||||||
| 3294 | Expr *pWhere, | - | ||||||||||||||||||||||||
| 3295 | int iCursor, | - | ||||||||||||||||||||||||
| 3296 | int isLeftJoin | - | ||||||||||||||||||||||||
| 3297 | ){ | - | ||||||||||||||||||||||||
| 3298 | Expr *pNew; | - | ||||||||||||||||||||||||
| 3299 | int nChng = 0; | - | ||||||||||||||||||||||||
| 3300 | if( pWhere==0
executed 35358 times by 1 test: 0;return 0;Executed by:
executed 35358 times by 1 test: return 0;Executed by:
| 244-35358 | ||||||||||||||||||||||||
| 3301 | if( pSubq->selFlags & 0x02000
executed 14 times by 1 test: 0;return 0;Executed by:
executed 14 times by 1 test: return 0;Executed by:
| 14-230 | ||||||||||||||||||||||||
| 3302 | - | |||||||||||||||||||||||||
| 3303 | - | |||||||||||||||||||||||||
| 3304 | if( pSubq->pWin
executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1-229 | ||||||||||||||||||||||||
| 3305 | if( pSubq->pLimit!=0
| 22-207 | ||||||||||||||||||||||||
| 3306 | return executed 22 times by 1 test: 0;return 0;Executed by:
executed 22 times by 1 test: return 0;Executed by:
| 22 | ||||||||||||||||||||||||
| 3307 | } | - | ||||||||||||||||||||||||
| 3308 | while( pWhere->op==44
| 51-207 | ||||||||||||||||||||||||
| 3309 | nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, | - | ||||||||||||||||||||||||
| 3310 | iCursor, isLeftJoin); | - | ||||||||||||||||||||||||
| 3311 | pWhere = pWhere->pLeft; | - | ||||||||||||||||||||||||
| 3312 | } executed 51 times by 1 test: end of blockExecuted by:
| 51 | ||||||||||||||||||||||||
| 3313 | if( isLeftJoin
| 43-164 | ||||||||||||||||||||||||
| 3314 | && ((((
| 7-36 | ||||||||||||||||||||||||
| 3315 | || pWhere->iRightJoinTable!=iCursor
| 4-32 | ||||||||||||||||||||||||
| 3316 | ){ | - | ||||||||||||||||||||||||
| 3317 | return executed 11 times by 1 test: 0;return 0;Executed by:
executed 11 times by 1 test: return 0;Executed by:
| 11 | ||||||||||||||||||||||||
| 3318 | } | - | ||||||||||||||||||||||||
| 3319 | if( (((
| 11-153 | ||||||||||||||||||||||||
| 3320 | return executed 11 times by 1 test: 0;return 0;Executed by:
executed 11 times by 1 test: return 0;Executed by:
| 11 | ||||||||||||||||||||||||
| 3321 | } | - | ||||||||||||||||||||||||
| 3322 | if( sqlite3ExprIsTableConstant(pWhere, iCursor)
| 53-132 | ||||||||||||||||||||||||
| 3323 | nChng++; | - | ||||||||||||||||||||||||
| 3324 | while( pSubq
| 53-99 | ||||||||||||||||||||||||
| 3325 | SubstContext x; | - | ||||||||||||||||||||||||
| 3326 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); | - | ||||||||||||||||||||||||
| 3327 | unsetJoinExpr(pNew, -1); | - | ||||||||||||||||||||||||
| 3328 | x.pParse = pParse; | - | ||||||||||||||||||||||||
| 3329 | x.iTable = iCursor; | - | ||||||||||||||||||||||||
| 3330 | x.iNewTable = iCursor; | - | ||||||||||||||||||||||||
| 3331 | x.isLeftJoin = 0; | - | ||||||||||||||||||||||||
| 3332 | x.pEList = pSubq->pEList; | - | ||||||||||||||||||||||||
| 3333 | pNew = substExpr(&x, pNew); | - | ||||||||||||||||||||||||
| 3334 | if( pSubq->selFlags & 0x00008
| 20-79 | ||||||||||||||||||||||||
| 3335 | pSubq->pHaving = sqlite3ExprAnd(pParse->db, pSubq->pHaving, pNew); | - | ||||||||||||||||||||||||
| 3336 | } executed 20 times by 1 test: else{end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 3337 | pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew); | - | ||||||||||||||||||||||||
| 3338 | } executed 79 times by 1 test: end of blockExecuted by:
| 79 | ||||||||||||||||||||||||
| 3339 | pSubq = pSubq->pPrior; | - | ||||||||||||||||||||||||
| 3340 | } executed 99 times by 1 test: end of blockExecuted by:
| 99 | ||||||||||||||||||||||||
| 3341 | } executed 53 times by 1 test: end of blockExecuted by:
| 53 | ||||||||||||||||||||||||
| 3342 | return executed 185 times by 1 test: nChng;return nChng;Executed by:
executed 185 times by 1 test: return nChng;Executed by:
| 185 | ||||||||||||||||||||||||
| 3343 | } | - | ||||||||||||||||||||||||
| 3344 | static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | - | ||||||||||||||||||||||||
| 3345 | int eRet = 0x0000; | - | ||||||||||||||||||||||||
| 3346 | ExprList *pEList = pFunc->x.pList; | - | ||||||||||||||||||||||||
| 3347 | const char *zFunc; | - | ||||||||||||||||||||||||
| 3348 | ExprList *pOrderBy; | - | ||||||||||||||||||||||||
| 3349 | u8 sortOrder; | - | ||||||||||||||||||||||||
| 3350 | - | |||||||||||||||||||||||||
| 3351 | - | |||||||||||||||||||||||||
| 3352 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3353 | ; | - | ||||||||||||||||||||||||
| 3354 | - | |||||||||||||||||||||||||
| 3355 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3356 | ; | - | ||||||||||||||||||||||||
| 3357 | if( pEList==0
executed 2726 times by 4 tests: eRet;return eRet;Executed by:
executed 2726 times by 4 tests: return eRet;Executed by:
| 257-17296 | ||||||||||||||||||||||||
| 3358 | zFunc = pFunc->u.zToken; | - | ||||||||||||||||||||||||
| 3359 | if( sqlite3StrICmp(zFunc, "min")==0
| 837-16202 | ||||||||||||||||||||||||
| 3360 | eRet = 0x0001; | - | ||||||||||||||||||||||||
| 3361 | sortOrder = 0; | - | ||||||||||||||||||||||||
| 3362 | } executed 837 times by 1 test: else if( sqlite3StrICmp(zFunc, "max")==0end of blockExecuted by:
| 837-11400 | ||||||||||||||||||||||||
| 3363 | eRet = 0x0002; | - | ||||||||||||||||||||||||
| 3364 | sortOrder = 1; | - | ||||||||||||||||||||||||
| 3365 | } executed 4802 times by 1 test: else{end of blockExecuted by:
| 4802 | ||||||||||||||||||||||||
| 3366 | return executed 11400 times by 1 test: eRet;return eRet;Executed by:
executed 11400 times by 1 test: return eRet;Executed by:
| 11400 | ||||||||||||||||||||||||
| 3367 | } | - | ||||||||||||||||||||||||
| 3368 | *ppMinMax = pOrderBy = sqlite3ExprListDup(db, pEList, 0); | - | ||||||||||||||||||||||||
| 3369 | - | |||||||||||||||||||||||||
| 3370 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3371 | ; | - | ||||||||||||||||||||||||
| 3372 | if( pOrderBy
executed 5639 times by 1 test: pOrderBy->a[0].sortOrder = sortOrder;Executed by:
| 0-5639 | ||||||||||||||||||||||||
| 3373 | return executed 5639 times by 1 test: eRet;return eRet;Executed by:
executed 5639 times by 1 test: return eRet;Executed by:
| 5639 | ||||||||||||||||||||||||
| 3374 | } | - | ||||||||||||||||||||||||
| 3375 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ | - | ||||||||||||||||||||||||
| 3376 | Table *pTab; | - | ||||||||||||||||||||||||
| 3377 | Expr *pExpr; | - | ||||||||||||||||||||||||
| 3378 | - | |||||||||||||||||||||||||
| 3379 | - | |||||||||||||||||||||||||
| 3380 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3381 | ; | - | ||||||||||||||||||||||||
| 3382 | - | |||||||||||||||||||||||||
| 3383 | if( p->pWhere
| 204-19229 | ||||||||||||||||||||||||
| 3384 | || p->pSrc->nSrc!=1
| 25-19000 | ||||||||||||||||||||||||
| 3385 | ){ | - | ||||||||||||||||||||||||
| 3386 | return executed 3542 times by 1 test: 0;return 0;Executed by:
executed 3542 times by 1 test: return 0;Executed by:
| 3542 | ||||||||||||||||||||||||
| 3387 | } | - | ||||||||||||||||||||||||
| 3388 | pTab = p->pSrc->a[0].pTab; | - | ||||||||||||||||||||||||
| 3389 | pExpr = p->pEList->a[0].pExpr; | - | ||||||||||||||||||||||||
| 3390 | - | |||||||||||||||||||||||||
| 3391 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3392 | ; | - | ||||||||||||||||||||||||
| 3393 | - | |||||||||||||||||||||||||
| 3394 | if( ((
executed 8572 times by 1 test: 0;return 0;Executed by:
executed 8572 times by 1 test: return 0;Executed by:
| 8572-10365 | ||||||||||||||||||||||||
| 3395 | if( pExpr->op!=159
executed 5254 times by 1 test: 0;return 0;Executed by:
executed 5254 times by 1 test: return 0;Executed by:
| 5111-5254 | ||||||||||||||||||||||||
| 3396 | if( (
never executed: 0;return 0;never executed: return 0; | 0-5111 | ||||||||||||||||||||||||
| 3397 | if( (
executed 3114 times by 1 test: 0;return 0;Executed by:
executed 3114 times by 1 test: return 0;Executed by:
| 1997-3114 | ||||||||||||||||||||||||
| 3398 | if( pExpr->flags&0x000010
executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2-1995 | ||||||||||||||||||||||||
| 3399 | - | |||||||||||||||||||||||||
| 3400 | return executed 1995 times by 4 tests: pTab;return pTab;Executed by:
executed 1995 times by 4 tests: return pTab;Executed by:
| 1995 | ||||||||||||||||||||||||
| 3401 | } | - | ||||||||||||||||||||||||
| 3402 | int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){ | - | ||||||||||||||||||||||||
| 3403 | if( pFrom->pTab
| 126-1056133 | ||||||||||||||||||||||||
| 3404 | Table *pTab = pFrom->pTab; | - | ||||||||||||||||||||||||
| 3405 | char *zIndexedBy = pFrom->u1.zIndexedBy; | - | ||||||||||||||||||||||||
| 3406 | Index *pIdx; | - | ||||||||||||||||||||||||
| 3407 | for(pIdx=pTab->pIndex; | - | ||||||||||||||||||||||||
| 3408 | pIdx
| 7-183 | ||||||||||||||||||||||||
| 3409 | pIdx=pIdx->pNext | - | ||||||||||||||||||||||||
| 3410 | ); executed 64 times by 1 test: ;Executed by:
| 64 | ||||||||||||||||||||||||
| 3411 | if( !pIdx
| 7-119 | ||||||||||||||||||||||||
| 3412 | sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0); | - | ||||||||||||||||||||||||
| 3413 | pParse->checkSchema = 1; | - | ||||||||||||||||||||||||
| 3414 | return executed 7 times by 2 tests: 1;return 1;Executed by:
executed 7 times by 2 tests: return 1;Executed by:
| 7 | ||||||||||||||||||||||||
| 3415 | } | - | ||||||||||||||||||||||||
| 3416 | pFrom->pIBIndex = pIdx; | - | ||||||||||||||||||||||||
| 3417 | } executed 119 times by 2 tests: end of blockExecuted by:
| 119 | ||||||||||||||||||||||||
| 3418 | return executed 1056537 times by 435 tests: 0;return 0;Executed by:
executed 1056537 times by 435 tests: return 0;Executed by:
| 1056537 | ||||||||||||||||||||||||
| 3419 | } | - | ||||||||||||||||||||||||
| 3420 | static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ | - | ||||||||||||||||||||||||
| 3421 | int i; | - | ||||||||||||||||||||||||
| 3422 | Select *pNew; | - | ||||||||||||||||||||||||
| 3423 | Select *pX; | - | ||||||||||||||||||||||||
| 3424 | sqlite3 *db; | - | ||||||||||||||||||||||||
| 3425 | struct ExprList_item *a; | - | ||||||||||||||||||||||||
| 3426 | SrcList *pNewSrc; | - | ||||||||||||||||||||||||
| 3427 | Parse *pParse; | - | ||||||||||||||||||||||||
| 3428 | Token dummy; | - | ||||||||||||||||||||||||
| 3429 | - | |||||||||||||||||||||||||
| 3430 | if( p->pPrior==0
executed 15015 times by 1 test: 0;return 0;Executed by:
executed 15015 times by 1 test: return 0;Executed by:
| 4295-15015 | ||||||||||||||||||||||||
| 3431 | if( p->pOrderBy==0
executed 3938 times by 1 test: 0;return 0;Executed by:
executed 3938 times by 1 test: return 0;Executed by:
| 357-3938 | ||||||||||||||||||||||||
| 3432 | for(pX=p; pX
executed 7 times by 1 test: end of blockExecuted by:
| 1-363 | ||||||||||||||||||||||||
| 3433 | if( pX==0
executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1-356 | ||||||||||||||||||||||||
| 3434 | a = p->pOrderBy->a; | - | ||||||||||||||||||||||||
| 3435 | for(i=p->pOrderBy->nExpr-1; i>=0
| 295-626 | ||||||||||||||||||||||||
| 3436 | if( a[i].pExpr->flags & 0x000100
executed 61 times by 1 test: break;Executed by:
| 61-565 | ||||||||||||||||||||||||
| 3437 | } executed 565 times by 1 test: end of blockExecuted by:
| 565 | ||||||||||||||||||||||||
| 3438 | if( i<0
executed 295 times by 1 test: 0;return 0;Executed by:
executed 295 times by 1 test: return 0;Executed by:
| 61-295 | ||||||||||||||||||||||||
| 3439 | - | |||||||||||||||||||||||||
| 3440 | - | |||||||||||||||||||||||||
| 3441 | - | |||||||||||||||||||||||||
| 3442 | pParse = pWalker->pParse; | - | ||||||||||||||||||||||||
| 3443 | db = pParse->db; | - | ||||||||||||||||||||||||
| 3444 | pNew = sqlite3DbMallocZero(db, sizeof(*pNew) ); | - | ||||||||||||||||||||||||
| 3445 | if( pNew==0
never executed: 2;return 2;never executed: return 2; | 0-61 | ||||||||||||||||||||||||
| 3446 | memset(&dummy, 0, sizeof(dummy)); | - | ||||||||||||||||||||||||
| 3447 | pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0); | - | ||||||||||||||||||||||||
| 3448 | if( pNewSrc==0
never executed: 2;return 2;never executed: return 2; | 0-61 | ||||||||||||||||||||||||
| 3449 | *pNew = *p; | - | ||||||||||||||||||||||||
| 3450 | p->pSrc = pNewSrc; | - | ||||||||||||||||||||||||
| 3451 | p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, 168, 0)); | - | ||||||||||||||||||||||||
| 3452 | p->op = 127; | - | ||||||||||||||||||||||||
| 3453 | p->pWhere = 0; | - | ||||||||||||||||||||||||
| 3454 | pNew->pGroupBy = 0; | - | ||||||||||||||||||||||||
| 3455 | pNew->pHaving = 0; | - | ||||||||||||||||||||||||
| 3456 | pNew->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 3457 | p->pPrior = 0; | - | ||||||||||||||||||||||||
| 3458 | p->pNext = 0; | - | ||||||||||||||||||||||||
| 3459 | p->pWith = 0; | - | ||||||||||||||||||||||||
| 3460 | p->selFlags &= ~0x00100; | - | ||||||||||||||||||||||||
| 3461 | - | |||||||||||||||||||||||||
| 3462 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3463 | ; | - | ||||||||||||||||||||||||
| 3464 | p->selFlags |= 0x10000; | - | ||||||||||||||||||||||||
| 3465 | - | |||||||||||||||||||||||||
| 3466 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3467 | ; | - | ||||||||||||||||||||||||
| 3468 | pNew->pPrior->pNext = pNew; | - | ||||||||||||||||||||||||
| 3469 | pNew->pLimit = 0; | - | ||||||||||||||||||||||||
| 3470 | return executed 61 times by 1 test: 0;return 0;Executed by:
executed 61 times by 1 test: return 0;Executed by:
| 61 | ||||||||||||||||||||||||
| 3471 | } | - | ||||||||||||||||||||||||
| 3472 | - | |||||||||||||||||||||||||
| 3473 | - | |||||||||||||||||||||||||
| 3474 | - | |||||||||||||||||||||||||
| 3475 | - | |||||||||||||||||||||||||
| 3476 | - | |||||||||||||||||||||||||
| 3477 | - | |||||||||||||||||||||||||
| 3478 | static int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){ | - | ||||||||||||||||||||||||
| 3479 | if( pFrom->fg.isTabFunc
| 7-904172 | ||||||||||||||||||||||||
| 3480 | sqlite3ErrorMsg(pParse, "'%s' is not a function", pFrom->zName); | - | ||||||||||||||||||||||||
| 3481 | return executed 7 times by 1 test: 1;return 1;Executed by:
executed 7 times by 1 test: return 1;Executed by:
| 7 | ||||||||||||||||||||||||
| 3482 | } | - | ||||||||||||||||||||||||
| 3483 | return executed 904172 times by 435 tests: 0;return 0;Executed by:
executed 904172 times by 435 tests: return 0;Executed by:
| 904172 | ||||||||||||||||||||||||
| 3484 | } | - | ||||||||||||||||||||||||
| 3485 | static struct Cte *searchWith( | - | ||||||||||||||||||||||||
| 3486 | With *pWith, | - | ||||||||||||||||||||||||
| 3487 | struct SrcList_item *pItem, | - | ||||||||||||||||||||||||
| 3488 | With **ppContext | - | ||||||||||||||||||||||||
| 3489 | ){ | - | ||||||||||||||||||||||||
| 3490 | const char *zName; | - | ||||||||||||||||||||||||
| 3491 | if( pItem->zDatabase==0
| 881-873100 | ||||||||||||||||||||||||
| 3492 | With *p; | - | ||||||||||||||||||||||||
| 3493 | for(p=pWith; p
| 3014-870292 | ||||||||||||||||||||||||
| 3494 | int i; | - | ||||||||||||||||||||||||
| 3495 | for(i=0; i<p->nCte
| 1087-3816 | ||||||||||||||||||||||||
| 3496 | if( sqlite3StrICmp(zName, p->a[i].zName)==0
| 1889-1927 | ||||||||||||||||||||||||
| 3497 | *ppContext = p; | - | ||||||||||||||||||||||||
| 3498 | return executed 1927 times by 1 test: &p->a[i];return &p->a[i];Executed by:
executed 1927 times by 1 test: return &p->a[i];Executed by:
| 1927 | ||||||||||||||||||||||||
| 3499 | } | - | ||||||||||||||||||||||||
| 3500 | } executed 1889 times by 1 test: end of blockExecuted by:
| 1889 | ||||||||||||||||||||||||
| 3501 | } executed 1087 times by 1 test: end of blockExecuted by:
| 1087 | ||||||||||||||||||||||||
| 3502 | } executed 870292 times by 68 tests: end of blockExecuted by:
| 870292 | ||||||||||||||||||||||||
| 3503 | return executed 915342 times by 436 tests: 0;return 0;Executed by:
executed 915342 times by 436 tests: return 0;Executed by:
| 915342 | ||||||||||||||||||||||||
| 3504 | } | - | ||||||||||||||||||||||||
| 3505 | void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ | - | ||||||||||||||||||||||||
| 3506 | - | |||||||||||||||||||||||||
| 3507 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3508 | ; | - | ||||||||||||||||||||||||
| 3509 | if( pWith
| 1555-1007174 | ||||||||||||||||||||||||
| 3510 | - | |||||||||||||||||||||||||
| 3511 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3512 | ; | - | ||||||||||||||||||||||||
| 3513 | pWith->pOuter = pParse->pWith; | - | ||||||||||||||||||||||||
| 3514 | pParse->pWith = pWith; | - | ||||||||||||||||||||||||
| 3515 | if( bFree
executed 167 times by 1 test: pParse->pWithToFree = pWith;Executed by:
| 167-1388 | ||||||||||||||||||||||||
| 3516 | } executed 1555 times by 1 test: end of blockExecuted by:
| 1555 | ||||||||||||||||||||||||
| 3517 | } executed 1008729 times by 436 tests: end of blockExecuted by:
| 1008729 | ||||||||||||||||||||||||
| 3518 | static int withExpand( | - | ||||||||||||||||||||||||
| 3519 | Walker *pWalker, | - | ||||||||||||||||||||||||
| 3520 | struct SrcList_item *pFrom | - | ||||||||||||||||||||||||
| 3521 | ){ | - | ||||||||||||||||||||||||
| 3522 | Parse *pParse = pWalker->pParse; | - | ||||||||||||||||||||||||
| 3523 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 3524 | struct Cte *pCte; | - | ||||||||||||||||||||||||
| 3525 | With *pWith; | - | ||||||||||||||||||||||||
| 3526 | - | |||||||||||||||||||||||||
| 3527 | - | |||||||||||||||||||||||||
| 3528 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3529 | ; | - | ||||||||||||||||||||||||
| 3530 | - | |||||||||||||||||||||||||
| 3531 | pCte = searchWith(pParse->pWith, pFrom, &pWith); | - | ||||||||||||||||||||||||
| 3532 | if( pCte
| 1927-915342 | ||||||||||||||||||||||||
| 3533 | Table *pTab; | - | ||||||||||||||||||||||||
| 3534 | ExprList *pEList; | - | ||||||||||||||||||||||||
| 3535 | Select *pSel; | - | ||||||||||||||||||||||||
| 3536 | Select *pLeft; | - | ||||||||||||||||||||||||
| 3537 | int bMayRecursive; | - | ||||||||||||||||||||||||
| 3538 | With *pSavedWith; | - | ||||||||||||||||||||||||
| 3539 | - | |||||||||||||||||||||||||
| 3540 | - | |||||||||||||||||||||||||
| 3541 | - | |||||||||||||||||||||||||
| 3542 | - | |||||||||||||||||||||||||
| 3543 | - | |||||||||||||||||||||||||
| 3544 | if( pCte->zCteErr
| 10-1917 | ||||||||||||||||||||||||
| 3545 | sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName); | - | ||||||||||||||||||||||||
| 3546 | return executed 10 times by 1 test: 1;return 1;Executed by:
executed 10 times by 1 test: return 1;Executed by:
| 10 | ||||||||||||||||||||||||
| 3547 | } | - | ||||||||||||||||||||||||
| 3548 | if( cannotBeFunction(pParse, pFrom)
executed 2 times by 1 test: 1;return 1;Executed by:
executed 2 times by 1 test: return 1;Executed by:
| 2-1915 | ||||||||||||||||||||||||
| 3549 | - | |||||||||||||||||||||||||
| 3550 | - | |||||||||||||||||||||||||
| 3551 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3552 | ; | - | ||||||||||||||||||||||||
| 3553 | pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table)); | - | ||||||||||||||||||||||||
| 3554 | if( pTab==0
executed 10 times by 1 test: 2;return 2;Executed by:
executed 10 times by 1 test: return 2;Executed by:
| 10-1905 | ||||||||||||||||||||||||
| 3555 | pTab->nTabRef = 1; | - | ||||||||||||||||||||||||
| 3556 | pTab->zName = sqlite3DbStrDup(db, pCte->zName); | - | ||||||||||||||||||||||||
| 3557 | pTab->iPKey = -1; | - | ||||||||||||||||||||||||
| 3558 | pTab->nRowLogEst = 200; | - | ||||||||||||||||||||||||
| 3559 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3560 | ; | - | ||||||||||||||||||||||||
| 3561 | pTab->tabFlags |= 0x0002 | 0x0040; | - | ||||||||||||||||||||||||
| 3562 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); | - | ||||||||||||||||||||||||
| 3563 | if( db->mallocFailed
executed 110 times by 1 test: 7;return 7;Executed by:
executed 110 times by 1 test: return 7;Executed by:
| 110-1795 | ||||||||||||||||||||||||
| 3564 | - | |||||||||||||||||||||||||
| 3565 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3566 | ; | - | ||||||||||||||||||||||||
| 3567 | - | |||||||||||||||||||||||||
| 3568 | - | |||||||||||||||||||||||||
| 3569 | pSel = pFrom->pSelect; | - | ||||||||||||||||||||||||
| 3570 | bMayRecursive = ( pSel->op==124
| 35-1443 | ||||||||||||||||||||||||
| 3571 | if( bMayRecursive
| 387-1408 | ||||||||||||||||||||||||
| 3572 | int i; | - | ||||||||||||||||||||||||
| 3573 | SrcList *pSrc = pFrom->pSelect->pSrc; | - | ||||||||||||||||||||||||
| 3574 | for(i=0; i<pSrc->nSrc
| 382-387 | ||||||||||||||||||||||||
| 3575 | struct SrcList_item *pItem = &pSrc->a[i]; | - | ||||||||||||||||||||||||
| 3576 | if( pItem->zDatabase==0
| 2-380 | ||||||||||||||||||||||||
| 3577 | && pItem->zName!=0
| 2-378 | ||||||||||||||||||||||||
| 3578 | && 0==sqlite3StrICmp(pItem->zName, pCte->zName)
| 47-331 | ||||||||||||||||||||||||
| 3579 | ){ | - | ||||||||||||||||||||||||
| 3580 | pItem->pTab = pTab; | - | ||||||||||||||||||||||||
| 3581 | pItem->fg.isRecursive = 1; | - | ||||||||||||||||||||||||
| 3582 | pTab->nTabRef++; | - | ||||||||||||||||||||||||
| 3583 | pSel->selFlags |= 0x02000; | - | ||||||||||||||||||||||||
| 3584 | } executed 331 times by 1 test: end of blockExecuted by:
| 331 | ||||||||||||||||||||||||
| 3585 | } executed 382 times by 1 test: end of blockExecuted by:
| 382 | ||||||||||||||||||||||||
| 3586 | } executed 387 times by 1 test: end of blockExecuted by:
| 387 | ||||||||||||||||||||||||
| 3587 | - | |||||||||||||||||||||||||
| 3588 | - | |||||||||||||||||||||||||
| 3589 | if( pTab->nTabRef>2
| 1-1794 | ||||||||||||||||||||||||
| 3590 | sqlite3ErrorMsg( | - | ||||||||||||||||||||||||
| 3591 | pParse, "multiple references to recursive table: %s", pCte->zName | - | ||||||||||||||||||||||||
| 3592 | ); | - | ||||||||||||||||||||||||
| 3593 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 3594 | } | - | ||||||||||||||||||||||||
| 3595 | - | |||||||||||||||||||||||||
| 3596 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3597 | - | |||||||||||||||||||||||||
| 3598 | ; | - | ||||||||||||||||||||||||
| 3599 | - | |||||||||||||||||||||||||
| 3600 | pCte->zCteErr = "circular reference: %s"; | - | ||||||||||||||||||||||||
| 3601 | pSavedWith = pParse->pWith; | - | ||||||||||||||||||||||||
| 3602 | pParse->pWith = pWith; | - | ||||||||||||||||||||||||
| 3603 | if( bMayRecursive
| 386-1408 | ||||||||||||||||||||||||
| 3604 | Select *pPrior = pSel->pPrior; | - | ||||||||||||||||||||||||
| 3605 | - | |||||||||||||||||||||||||
| 3606 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3607 | ; | - | ||||||||||||||||||||||||
| 3608 | pPrior->pWith = pSel->pWith; | - | ||||||||||||||||||||||||
| 3609 | sqlite3WalkSelect(pWalker, pPrior); | - | ||||||||||||||||||||||||
| 3610 | pPrior->pWith = 0; | - | ||||||||||||||||||||||||
| 3611 | } executed 386 times by 1 test: else{end of blockExecuted by:
| 386 | ||||||||||||||||||||||||
| 3612 | sqlite3WalkSelect(pWalker, pSel); | - | ||||||||||||||||||||||||
| 3613 | } executed 1408 times by 1 test: end of blockExecuted by:
| 1408 | ||||||||||||||||||||||||
| 3614 | pParse->pWith = pWith; | - | ||||||||||||||||||||||||
| 3615 | - | |||||||||||||||||||||||||
| 3616 | for(pLeft=pSel; pLeft->pPrior
executed 450 times by 1 test: ;Executed by:
| 450-1794 | ||||||||||||||||||||||||
| 3617 | pEList = pLeft->pEList; | - | ||||||||||||||||||||||||
| 3618 | if( pCte->pCols
| 419-1375 | ||||||||||||||||||||||||
| 3619 | if( pEList
| 1-418 | ||||||||||||||||||||||||
| 3620 | sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns", | - | ||||||||||||||||||||||||
| 3621 | pCte->zName, pEList->nExpr, pCte->pCols->nExpr | - | ||||||||||||||||||||||||
| 3622 | ); | - | ||||||||||||||||||||||||
| 3623 | pParse->pWith = pSavedWith; | - | ||||||||||||||||||||||||
| 3624 | return executed 6 times by 1 test: 1;return 1;Executed by:
executed 6 times by 1 test: return 1;Executed by:
| 6 | ||||||||||||||||||||||||
| 3625 | } | - | ||||||||||||||||||||||||
| 3626 | pEList = pCte->pCols; | - | ||||||||||||||||||||||||
| 3627 | } executed 413 times by 1 test: end of blockExecuted by:
| 413 | ||||||||||||||||||||||||
| 3628 | - | |||||||||||||||||||||||||
| 3629 | sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol); | - | ||||||||||||||||||||||||
| 3630 | if( bMayRecursive
| 383-1405 | ||||||||||||||||||||||||
| 3631 | if( pSel->selFlags & 0x02000
| 56-327 | ||||||||||||||||||||||||
| 3632 | pCte->zCteErr = "multiple recursive references: %s"; | - | ||||||||||||||||||||||||
| 3633 | } executed 327 times by 1 test: else{end of blockExecuted by:
| 327 | ||||||||||||||||||||||||
| 3634 | pCte->zCteErr = "recursive reference in a subquery: %s"; | - | ||||||||||||||||||||||||
| 3635 | } executed 56 times by 1 test: end of blockExecuted by:
| 56 | ||||||||||||||||||||||||
| 3636 | sqlite3WalkSelect(pWalker, pSel); | - | ||||||||||||||||||||||||
| 3637 | } executed 383 times by 1 test: end of blockExecuted by:
| 383 | ||||||||||||||||||||||||
| 3638 | pCte->zCteErr = 0; | - | ||||||||||||||||||||||||
| 3639 | pParse->pWith = pSavedWith; | - | ||||||||||||||||||||||||
| 3640 | } executed 1788 times by 1 test: end of blockExecuted by:
| 1788 | ||||||||||||||||||||||||
| 3641 | - | |||||||||||||||||||||||||
| 3642 | return executed 917130 times by 436 tests: 0;return 0;Executed by:
executed 917130 times by 436 tests: return 0;Executed by:
| 917130 | ||||||||||||||||||||||||
| 3643 | } | - | ||||||||||||||||||||||||
| 3644 | static void selectPopWith(Walker *pWalker, Select *p){ | - | ||||||||||||||||||||||||
| 3645 | Parse *pParse = pWalker->pParse; | - | ||||||||||||||||||||||||
| 3646 | if( (
| 442-1004653 | ||||||||||||||||||||||||
| 3647 | With *pWith = findRightmost(p)->pWith; | - | ||||||||||||||||||||||||
| 3648 | if( pWith!=0
| 572-1064 | ||||||||||||||||||||||||
| 3649 | - | |||||||||||||||||||||||||
| 3650 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3651 | ; | - | ||||||||||||||||||||||||
| 3652 | pParse->pWith = pWith->pOuter; | - | ||||||||||||||||||||||||
| 3653 | } executed 572 times by 1 test: end of blockExecuted by:
| 572 | ||||||||||||||||||||||||
| 3654 | } executed 1636 times by 1 test: end of blockExecuted by:
| 1636 | ||||||||||||||||||||||||
| 3655 | } executed 1006731 times by 435 tests: end of blockExecuted by:
| 1006731 | ||||||||||||||||||||||||
| 3656 | int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){ | - | ||||||||||||||||||||||||
| 3657 | Select *pSel = pFrom->pSelect; | - | ||||||||||||||||||||||||
| 3658 | Table *pTab; | - | ||||||||||||||||||||||||
| 3659 | - | |||||||||||||||||||||||||
| 3660 | - | |||||||||||||||||||||||||
| 3661 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3662 | ; | - | ||||||||||||||||||||||||
| 3663 | pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table)); | - | ||||||||||||||||||||||||
| 3664 | if( pTab==0
never executed: 7;return 7;never executed: return 7; | 0-2680 | ||||||||||||||||||||||||
| 3665 | pTab->nTabRef = 1; | - | ||||||||||||||||||||||||
| 3666 | if( pFrom->zAlias
| 121-2559 | ||||||||||||||||||||||||
| 3667 | pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias); | - | ||||||||||||||||||||||||
| 3668 | } executed 121 times by 1 test: else{end of blockExecuted by:
| 121 | ||||||||||||||||||||||||
| 3669 | pTab->zName = sqlite3MPrintf(pParse->db, "subquery_%u", pSel->selId); | - | ||||||||||||||||||||||||
| 3670 | } executed 2559 times by 1 test: end of blockExecuted by:
| 2559 | ||||||||||||||||||||||||
| 3671 | while( pSel->pPrior
executed 400 times by 1 test: end of blockExecuted by:
| 400-2680 | ||||||||||||||||||||||||
| 3672 | sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); | - | ||||||||||||||||||||||||
| 3673 | pTab->iPKey = -1; | - | ||||||||||||||||||||||||
| 3674 | pTab->nRowLogEst = 200; | - | ||||||||||||||||||||||||
| 3675 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3676 | ; | - | ||||||||||||||||||||||||
| 3677 | pTab->tabFlags |= 0x0002; | - | ||||||||||||||||||||||||
| 3678 | - | |||||||||||||||||||||||||
| 3679 | return executed 2680 times by 1 test: 0;return 0;Executed by:
executed 2680 times by 1 test: return 0;Executed by:
| 2680 | ||||||||||||||||||||||||
| 3680 | } | - | ||||||||||||||||||||||||
| 3681 | static int selectExpander(Walker *pWalker, Select *p){ | - | ||||||||||||||||||||||||
| 3682 | Parse *pParse = pWalker->pParse; | - | ||||||||||||||||||||||||
| 3683 | int i, j, k; | - | ||||||||||||||||||||||||
| 3684 | SrcList *pTabList; | - | ||||||||||||||||||||||||
| 3685 | ExprList *pEList; | - | ||||||||||||||||||||||||
| 3686 | struct SrcList_item *pFrom; | - | ||||||||||||||||||||||||
| 3687 | sqlite3 *db = pParse->db; | - | ||||||||||||||||||||||||
| 3688 | Expr *pE, *pRight, *pExpr; | - | ||||||||||||||||||||||||
| 3689 | u16 selFlags = p->selFlags; | - | ||||||||||||||||||||||||
| 3690 | u32 elistFlags = 0; | - | ||||||||||||||||||||||||
| 3691 | - | |||||||||||||||||||||||||
| 3692 | p->selFlags |= 0x00040; | - | ||||||||||||||||||||||||
| 3693 | if( db->mallocFailed
| 138-1342351 | ||||||||||||||||||||||||
| 3694 | return executed 138 times by 1 test: 2;return 2;Executed by:
executed 138 times by 1 test: return 2;Executed by:
| 138 | ||||||||||||||||||||||||
| 3695 | } | - | ||||||||||||||||||||||||
| 3696 | - | |||||||||||||||||||||||||
| 3697 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3698 | ; | - | ||||||||||||||||||||||||
| 3699 | if( (
| 333789-1008562 | ||||||||||||||||||||||||
| 3700 | return executed 333789 times by 2 tests: 1;return 1;Executed by:
executed 333789 times by 2 tests: return 1;Executed by:
| 333789 | ||||||||||||||||||||||||
| 3701 | } | - | ||||||||||||||||||||||||
| 3702 | pTabList = p->pSrc; | - | ||||||||||||||||||||||||
| 3703 | pEList = p->pEList; | - | ||||||||||||||||||||||||
| 3704 | sqlite3WithPush(pParse, p->pWith, 0); | - | ||||||||||||||||||||||||
| 3705 | - | |||||||||||||||||||||||||
| 3706 | - | |||||||||||||||||||||||||
| 3707 | - | |||||||||||||||||||||||||
| 3708 | - | |||||||||||||||||||||||||
| 3709 | sqlite3SrcListAssignCursors(pParse, pTabList); | - | ||||||||||||||||||||||||
| 3710 | - | |||||||||||||||||||||||||
| 3711 | - | |||||||||||||||||||||||||
| 3712 | - | |||||||||||||||||||||||||
| 3713 | - | |||||||||||||||||||||||||
| 3714 | - | |||||||||||||||||||||||||
| 3715 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc
| 917586-1007705 | ||||||||||||||||||||||||
| 3716 | Table *pTab; | - | ||||||||||||||||||||||||
| 3717 | - | |||||||||||||||||||||||||
| 3718 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3719 | ; | - | ||||||||||||||||||||||||
| 3720 | if( pFrom->fg.isRecursive
executed 317 times by 1 test: continue;Executed by:
| 317-917269 | ||||||||||||||||||||||||
| 3721 | - | |||||||||||||||||||||||||
| 3722 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3723 | ; | - | ||||||||||||||||||||||||
| 3724 | - | |||||||||||||||||||||||||
| 3725 | if( withExpand(pWalker, pFrom)
executed 139 times by 1 test: 2;return 2;Executed by:
executed 139 times by 1 test: return 2;Executed by:
| 139-917130 | ||||||||||||||||||||||||
| 3726 | if( pFrom->pTab
executed 1788 times by 1 test: elseend of blockExecuted by:
| 1788-915342 | ||||||||||||||||||||||||
| 3727 | - | |||||||||||||||||||||||||
| 3728 | if( pFrom->zName==0
| 881-914461 | ||||||||||||||||||||||||
| 3729 | - | |||||||||||||||||||||||||
| 3730 | Select *pSel = pFrom->pSelect; | - | ||||||||||||||||||||||||
| 3731 | - | |||||||||||||||||||||||||
| 3732 | - | |||||||||||||||||||||||||
| 3733 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3734 | ; | - | ||||||||||||||||||||||||
| 3735 | - | |||||||||||||||||||||||||
| 3736 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3737 | ; | - | ||||||||||||||||||||||||
| 3738 | if( sqlite3WalkSelect(pWalker, pSel)
executed 10 times by 1 test: 2;return 2;Executed by:
executed 10 times by 1 test: return 2;Executed by:
| 10-871 | ||||||||||||||||||||||||
| 3739 | if( sqlite3ExpandSubquery(pParse, pFrom)
never executed: 2;return 2;never executed: return 2; | 0-871 | ||||||||||||||||||||||||
| 3740 | - | |||||||||||||||||||||||||
| 3741 | } executed 871 times by 1 test: else{end of blockExecuted by:
| 871 | ||||||||||||||||||||||||
| 3742 | - | |||||||||||||||||||||||||
| 3743 | - | |||||||||||||||||||||||||
| 3744 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3745 | ; | - | ||||||||||||||||||||||||
| 3746 | pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom); | - | ||||||||||||||||||||||||
| 3747 | if( pTab==0
executed 677 times by 6 tests: 2;return 2;Executed by:
executed 677 times by 6 tests: return 2;Executed by:
| 677-913784 | ||||||||||||||||||||||||
| 3748 | if( pTab->nTabRef>=0xffff
| 4-913780 | ||||||||||||||||||||||||
| 3749 | sqlite3ErrorMsg(pParse, "too many references to \"%s\": max 65535", | - | ||||||||||||||||||||||||
| 3750 | pTab->zName); | - | ||||||||||||||||||||||||
| 3751 | pFrom->pTab = 0; | - | ||||||||||||||||||||||||
| 3752 | return executed 4 times by 1 test: 2;return 2;Executed by:
executed 4 times by 1 test: return 2;Executed by:
| 4 | ||||||||||||||||||||||||
| 3753 | } | - | ||||||||||||||||||||||||
| 3754 | pTab->nTabRef++; | - | ||||||||||||||||||||||||
| 3755 | if( !((pTab)->nModuleArg)
| 5-902262 | ||||||||||||||||||||||||
| 3756 | return executed 5 times by 1 test: 2;return 2;Executed by:
executed 5 times by 1 test: return 2;Executed by:
| 5 | ||||||||||||||||||||||||
| 3757 | } | - | ||||||||||||||||||||||||
| 3758 | - | |||||||||||||||||||||||||
| 3759 | if( ((
| 11518-902257 | ||||||||||||||||||||||||
| 3760 | i16 nCol; | - | ||||||||||||||||||||||||
| 3761 | if( sqlite3ViewGetColumnNames(pParse, pTab)
executed 15 times by 1 test: 2;return 2;Executed by:
executed 15 times by 1 test: return 2;Executed by:
| 15-341418 | ||||||||||||||||||||||||
| 3762 | - | |||||||||||||||||||||||||
| 3763 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3764 | ; | - | ||||||||||||||||||||||||
| 3765 | pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); | - | ||||||||||||||||||||||||
| 3766 | nCol = pTab->nCol; | - | ||||||||||||||||||||||||
| 3767 | pTab->nCol = -1; | - | ||||||||||||||||||||||||
| 3768 | sqlite3WalkSelect(pWalker, pFrom->pSelect); | - | ||||||||||||||||||||||||
| 3769 | pTab->nCol = nCol; | - | ||||||||||||||||||||||||
| 3770 | } executed 341418 times by 2 tests: end of blockExecuted by:
| 341418 | ||||||||||||||||||||||||
| 3771 | - | |||||||||||||||||||||||||
| 3772 | } executed 913760 times by 435 tests: end of blockExecuted by:
| 913760 | ||||||||||||||||||||||||
| 3773 | - | |||||||||||||||||||||||||
| 3774 | - | |||||||||||||||||||||||||
| 3775 | if( sqlite3IndexedByLookup(pParse, pFrom)
| 7-916412 | ||||||||||||||||||||||||
| 3776 | return executed 7 times by 2 tests: 2;return 2;Executed by:
executed 7 times by 2 tests: return 2;Executed by:
| 7 | ||||||||||||||||||||||||
| 3777 | } | - | ||||||||||||||||||||||||
| 3778 | } executed 916412 times by 435 tests: end of blockExecuted by:
| 916412 | ||||||||||||||||||||||||
| 3779 | - | |||||||||||||||||||||||||
| 3780 | - | |||||||||||||||||||||||||
| 3781 | - | |||||||||||||||||||||||||
| 3782 | if( db->mallocFailed
| 16-1006839 | ||||||||||||||||||||||||
| 3783 | return executed 882 times by 1 test: 2;return 2;Executed by:
executed 882 times by 1 test: return 2;Executed by:
| 882 | ||||||||||||||||||||||||
| 3784 | } | - | ||||||||||||||||||||||||
| 3785 | for(k=0; k<pEList->nExpr
| 653299-1155061 | ||||||||||||||||||||||||
| 3786 | pE = pEList->a[k].pExpr; | - | ||||||||||||||||||||||||
| 3787 | if( pE->op==168
executed 353340 times by 58 tests: break;Executed by:
| 353340-801721 | ||||||||||||||||||||||||
| 3788 | - | |||||||||||||||||||||||||
| 3789 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3790 | ; | - | ||||||||||||||||||||||||
| 3791 | - | |||||||||||||||||||||||||
| 3792 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3793 | ; | - | ||||||||||||||||||||||||
| 3794 | if( pE->op==130
executed 184 times by 1 test: break;Executed by:
| 184-796041 | ||||||||||||||||||||||||
| 3795 | elistFlags |= pE->flags; | - | ||||||||||||||||||||||||
| 3796 | } executed 801537 times by 435 tests: end of blockExecuted by:
| 801537 | ||||||||||||||||||||||||
| 3797 | if( k<pEList->nExpr
| 353524-653299 | ||||||||||||||||||||||||
| 3798 | - | |||||||||||||||||||||||||
| 3799 | - | |||||||||||||||||||||||||
| 3800 | - | |||||||||||||||||||||||||
| 3801 | - | |||||||||||||||||||||||||
| 3802 | - | |||||||||||||||||||||||||
| 3803 | struct ExprList_item *a = pEList->a; | - | ||||||||||||||||||||||||
| 3804 | ExprList *pNew = 0; | - | ||||||||||||||||||||||||
| 3805 | int flags = pParse->db->flags; | - | ||||||||||||||||||||||||
| 3806 | int longNames = (
| 30-353494 | ||||||||||||||||||||||||
| 3807 | && (
| 10-20 | ||||||||||||||||||||||||
| 3808 | - | |||||||||||||||||||||||||
| 3809 | for(k=0; k<pEList->nExpr
| 353524-365175 | ||||||||||||||||||||||||
| 3810 | pE = a[k].pExpr; | - | ||||||||||||||||||||||||
| 3811 | elistFlags |= pE->flags; | - | ||||||||||||||||||||||||
| 3812 | pRight = pE->pRight; | - | ||||||||||||||||||||||||
| 3813 | - | |||||||||||||||||||||||||
| 3814 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3815 | ; | - | ||||||||||||||||||||||||
| 3816 | if( pE->op!=168
| 11817-353358 | ||||||||||||||||||||||||
| 3817 | && (pE->op!=130
| 121-11496 | ||||||||||||||||||||||||
| 3818 | ){ | - | ||||||||||||||||||||||||
| 3819 | - | |||||||||||||||||||||||||
| 3820 | - | |||||||||||||||||||||||||
| 3821 | pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr); | - | ||||||||||||||||||||||||
| 3822 | if( pNew
| 0-11617 | ||||||||||||||||||||||||
| 3823 | pNew->a[pNew->nExpr-1].zName = a[k].zName; | - | ||||||||||||||||||||||||
| 3824 | pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan; | - | ||||||||||||||||||||||||
| 3825 | a[k].zName = 0; | - | ||||||||||||||||||||||||
| 3826 | a[k].zSpan = 0; | - | ||||||||||||||||||||||||
| 3827 | } executed 11617 times by 1 test: end of blockExecuted by:
| 11617 | ||||||||||||||||||||||||
| 3828 | a[k].pExpr = 0; | - | ||||||||||||||||||||||||
| 3829 | } executed 11617 times by 1 test: else{end of blockExecuted by:
| 11617 | ||||||||||||||||||||||||
| 3830 | - | |||||||||||||||||||||||||
| 3831 | - | |||||||||||||||||||||||||
| 3832 | int tableSeen = 0; | - | ||||||||||||||||||||||||
| 3833 | char *zTName = 0; | - | ||||||||||||||||||||||||
| 3834 | if( pE->op==130
| 200-353358 | ||||||||||||||||||||||||
| 3835 | - | |||||||||||||||||||||||||
| 3836 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3837 | ; | - | ||||||||||||||||||||||||
| 3838 | - | |||||||||||||||||||||||||
| 3839 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3840 | ; | - | ||||||||||||||||||||||||
| 3841 | zTName = pE->pLeft->u.zToken; | - | ||||||||||||||||||||||||
| 3842 | } executed 200 times by 1 test: end of blockExecuted by:
| 200 | ||||||||||||||||||||||||
| 3843 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc
| 353490-359886 | ||||||||||||||||||||||||
| 3844 | Table *pTab = pFrom->pTab; | - | ||||||||||||||||||||||||
| 3845 | Select *pSub = pFrom->pSelect; | - | ||||||||||||||||||||||||
| 3846 | char *zTabName = pFrom->zAlias; | - | ||||||||||||||||||||||||
| 3847 | const char *zSchemaName = 0; | - | ||||||||||||||||||||||||
| 3848 | int iDb; | - | ||||||||||||||||||||||||
| 3849 | if( zTabName==0
| 205-359681 | ||||||||||||||||||||||||
| 3850 | zTabName = pTab->zName; | - | ||||||||||||||||||||||||
| 3851 | } executed 359681 times by 58 tests: end of blockExecuted by:
| 359681 | ||||||||||||||||||||||||
| 3852 | if( db->mallocFailed
executed 68 times by 1 test: break;Executed by:
| 68-359818 | ||||||||||||||||||||||||
| 3853 | if( pSub==0
| 53-330574 | ||||||||||||||||||||||||
| 3854 | pSub = 0; | - | ||||||||||||||||||||||||
| 3855 | if( zTName
| 188-359366 | ||||||||||||||||||||||||
| 3856 | continue; executed 211 times by 1 test: continue;Executed by:
| 211 | ||||||||||||||||||||||||
| 3857 | } | - | ||||||||||||||||||||||||
| 3858 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | - | ||||||||||||||||||||||||
| 3859 | zSchemaName = iDb>=0
| 1166-358388 | ||||||||||||||||||||||||
| 3860 | } executed 359554 times by 58 tests: end of blockExecuted by:
| 359554 | ||||||||||||||||||||||||
| 3861 | for(j=0; j<pTab->nCol
| 359607-395740 | ||||||||||||||||||||||||
| 3862 | char *zName = pTab->aCol[j].zName; | - | ||||||||||||||||||||||||
| 3863 | char *zColname; | - | ||||||||||||||||||||||||
| 3864 | char *zToFree; | - | ||||||||||||||||||||||||
| 3865 | Token sColname; | - | ||||||||||||||||||||||||
| 3866 | - | |||||||||||||||||||||||||
| 3867 | - | |||||||||||||||||||||||||
| 3868 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3869 | ; | - | ||||||||||||||||||||||||
| 3870 | if( zTName
| 54-395174 | ||||||||||||||||||||||||
| 3871 | && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0
| 16-38 | ||||||||||||||||||||||||
| 3872 | ){ | - | ||||||||||||||||||||||||
| 3873 | continue; executed 38 times by 1 test: continue;Executed by:
| 38 | ||||||||||||||||||||||||
| 3874 | } | - | ||||||||||||||||||||||||
| 3875 | - | |||||||||||||||||||||||||
| 3876 | - | |||||||||||||||||||||||||
| 3877 | - | |||||||||||||||||||||||||
| 3878 | - | |||||||||||||||||||||||||
| 3879 | - | |||||||||||||||||||||||||
| 3880 | if( (
| 1751-393951 | ||||||||||||||||||||||||
| 3881 | && (((
| 84-393867 | ||||||||||||||||||||||||
| 3882 | ){ | - | ||||||||||||||||||||||||
| 3883 | continue; executed 84 times by 1 test: continue;Executed by:
| 84 | ||||||||||||||||||||||||
| 3884 | } | - | ||||||||||||||||||||||||
| 3885 | tableSeen = 1; | - | ||||||||||||||||||||||||
| 3886 | - | |||||||||||||||||||||||||
| 3887 | if( i>0
| 221-386723 | ||||||||||||||||||||||||
| 3888 | if( (
| 587-8087 | ||||||||||||||||||||||||
| 3889 | && tableAndColumnIndex(pTabList, i, zName, 0, 0)
| 195-392 | ||||||||||||||||||||||||
| 3890 | ){ | - | ||||||||||||||||||||||||
| 3891 | - | |||||||||||||||||||||||||
| 3892 | - | |||||||||||||||||||||||||
| 3893 | continue; executed 392 times by 1 test: continue;Executed by:
| 392 | ||||||||||||||||||||||||
| 3894 | } | - | ||||||||||||||||||||||||
| 3895 | if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0
| 220-8062 | ||||||||||||||||||||||||
| 3896 | - | |||||||||||||||||||||||||
| 3897 | - | |||||||||||||||||||||||||
| 3898 | continue; executed 220 times by 1 test: continue;Executed by:
| 220 | ||||||||||||||||||||||||
| 3899 | } | - | ||||||||||||||||||||||||
| 3900 | } executed 8062 times by 1 test: end of blockExecuted by:
| 8062 | ||||||||||||||||||||||||
| 3901 | pRight = sqlite3Expr(db, 59, zName); | - | ||||||||||||||||||||||||
| 3902 | zColname = zName; | - | ||||||||||||||||||||||||
| 3903 | zToFree = 0; | - | ||||||||||||||||||||||||
| 3904 | if( longNames
| 170-394836 | ||||||||||||||||||||||||
| 3905 | Expr *pLeft; | - | ||||||||||||||||||||||||
| 3906 | pLeft = sqlite3Expr(db, 59, zTabName); | - | ||||||||||||||||||||||||
| 3907 | pExpr = sqlite3PExpr(pParse, 130, pLeft, pRight); | - | ||||||||||||||||||||||||
| 3908 | if( zSchemaName
| 149-13293 | ||||||||||||||||||||||||
| 3909 | pLeft = sqlite3Expr(db, 59, zSchemaName); | - | ||||||||||||||||||||||||
| 3910 | pExpr = sqlite3PExpr(pParse, 130, pLeft, pExpr); | - | ||||||||||||||||||||||||
| 3911 | } executed 13293 times by 1 test: end of blockExecuted by:
| 13293 | ||||||||||||||||||||||||
| 3912 | if( longNames
| 170-13272 | ||||||||||||||||||||||||
| 3913 | zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName); | - | ||||||||||||||||||||||||
| 3914 | zToFree = zColname; | - | ||||||||||||||||||||||||
| 3915 | } executed 170 times by 1 test: end of blockExecuted by:
| 170 | ||||||||||||||||||||||||
| 3916 | } executed 13442 times by 1 test: else{end of blockExecuted by:
| 13442 | ||||||||||||||||||||||||
| 3917 | pExpr = pRight; | - | ||||||||||||||||||||||||
| 3918 | } executed 381564 times by 58 tests: end of blockExecuted by:
| 381564 | ||||||||||||||||||||||||
| 3919 | pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); | - | ||||||||||||||||||||||||
| 3920 | sqlite3TokenInit(&sColname, zColname); | - | ||||||||||||||||||||||||
| 3921 | sqlite3ExprListSetName(pParse, pNew, &sColname, 0); | - | ||||||||||||||||||||||||
| 3922 | if( pNew
| 216-394624 | ||||||||||||||||||||||||
| 3923 | struct ExprList_item *pX = &pNew->a[pNew->nExpr-1]; | - | ||||||||||||||||||||||||
| 3924 | if( pSub
| 67-149 | ||||||||||||||||||||||||
| 3925 | pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan); | - | ||||||||||||||||||||||||
| 3926 | ; | - | ||||||||||||||||||||||||
| 3927 | } executed 67 times by 1 test: else{end of blockExecuted by:
| 67 | ||||||||||||||||||||||||
| 3928 | pX->zSpan = sqlite3MPrintf(db, "%s.%s.%s", | - | ||||||||||||||||||||||||
| 3929 | zSchemaName, zTabName, zColname); | - | ||||||||||||||||||||||||
| 3930 | ; | - | ||||||||||||||||||||||||
| 3931 | } executed 149 times by 1 test: end of blockExecuted by:
| 149 | ||||||||||||||||||||||||
| 3932 | pX->bSpanIsTab = 1; | - | ||||||||||||||||||||||||
| 3933 | } executed 216 times by 1 test: end of blockExecuted by:
| 216 | ||||||||||||||||||||||||
| 3934 | sqlite3DbFree(db, zToFree); | - | ||||||||||||||||||||||||
| 3935 | } executed 395006 times by 58 tests: end of blockExecuted by:
| 395006 | ||||||||||||||||||||||||
| 3936 | } executed 359607 times by 58 tests: end of blockExecuted by:
| 359607 | ||||||||||||||||||||||||
| 3937 | if( !tableSeen
| 14-353544 | ||||||||||||||||||||||||
| 3938 | if( zTName
| 4-10 | ||||||||||||||||||||||||
| 3939 | sqlite3ErrorMsg(pParse, "no such table: %s", zTName); | - | ||||||||||||||||||||||||
| 3940 | } executed 4 times by 1 test: else{end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 3941 | sqlite3ErrorMsg(pParse, "no tables specified"); | - | ||||||||||||||||||||||||
| 3942 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 3943 | } | - | ||||||||||||||||||||||||
| 3944 | } executed 353558 times by 58 tests: end of blockExecuted by:
| 353558 | ||||||||||||||||||||||||
| 3945 | } | - | ||||||||||||||||||||||||
| 3946 | sqlite3ExprListDelete(db, pEList); | - | ||||||||||||||||||||||||
| 3947 | p->pEList = pNew; | - | ||||||||||||||||||||||||
| 3948 | } executed 353524 times by 58 tests: end of blockExecuted by:
| 353524 | ||||||||||||||||||||||||
| 3949 | if( p->pEList
| 193-1006630 | ||||||||||||||||||||||||
| 3950 | if( p->pEList->nExpr>db->aLimit[2]
| 1-1006629 | ||||||||||||||||||||||||
| 3951 | sqlite3ErrorMsg(pParse, "too many columns in result set"); | - | ||||||||||||||||||||||||
| 3952 | return executed 1 time by 1 test: 2;return 2;Executed by:
executed 1 time by 1 test: return 2;Executed by:
| 1 | ||||||||||||||||||||||||
| 3953 | } | - | ||||||||||||||||||||||||
| 3954 | if( (
| 50367-956262 | ||||||||||||||||||||||||
| 3955 | p->selFlags |= 0x40000; | - | ||||||||||||||||||||||||
| 3956 | } executed 50367 times by 7 tests: end of blockExecuted by:
| 50367 | ||||||||||||||||||||||||
| 3957 | } executed 1006629 times by 435 tests: end of blockExecuted by:
| 1006629 | ||||||||||||||||||||||||
| 3958 | return executed 1006822 times by 435 tests: 0;return 0;Executed by:
executed 1006822 times by 435 tests: return 0;Executed by:
| 1006822 | ||||||||||||||||||||||||
| 3959 | } | - | ||||||||||||||||||||||||
| 3960 | int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){ | - | ||||||||||||||||||||||||
| 3961 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||
| 3962 | return executed 5521392 times by 435 tests: 0;return 0;Executed by:
executed 5521392 times by 435 tests: return 0;Executed by:
| 5521392 | ||||||||||||||||||||||||
| 3963 | } | - | ||||||||||||||||||||||||
| 3964 | - | |||||||||||||||||||||||||
| 3965 | - | |||||||||||||||||||||||||
| 3966 | - | |||||||||||||||||||||||||
| 3967 | - | |||||||||||||||||||||||||
| 3968 | - | |||||||||||||||||||||||||
| 3969 | int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){ | - | ||||||||||||||||||||||||
| 3970 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||
| 3971 | return executed 811272 times by 435 tests: 0;return 0;Executed by:
executed 811272 times by 435 tests: return 0;Executed by:
| 811272 | ||||||||||||||||||||||||
| 3972 | } | - | ||||||||||||||||||||||||
| 3973 | static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ | - | ||||||||||||||||||||||||
| 3974 | Walker w; | - | ||||||||||||||||||||||||
| 3975 | w.xExprCallback = sqlite3ExprWalkNoop; | - | ||||||||||||||||||||||||
| 3976 | w.pParse = pParse; | - | ||||||||||||||||||||||||
| 3977 | if( (
| 2630-184820 | ||||||||||||||||||||||||
| 3978 | w.xSelectCallback = convertCompoundSelectToSubquery; | - | ||||||||||||||||||||||||
| 3979 | w.xSelectCallback2 = 0; | - | ||||||||||||||||||||||||
| 3980 | sqlite3WalkSelect(&w, pSelect); | - | ||||||||||||||||||||||||
| 3981 | } executed 2630 times by 1 test: end of blockExecuted by:
| 2630 | ||||||||||||||||||||||||
| 3982 | w.xSelectCallback = selectExpander; | - | ||||||||||||||||||||||||
| 3983 | w.xSelectCallback2 = selectPopWith; | - | ||||||||||||||||||||||||
| 3984 | sqlite3WalkSelect(&w, pSelect); | - | ||||||||||||||||||||||||
| 3985 | } executed 187450 times by 436 tests: end of blockExecuted by:
| 187450 | ||||||||||||||||||||||||
| 3986 | static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ | - | ||||||||||||||||||||||||
| 3987 | Parse *pParse; | - | ||||||||||||||||||||||||
| 3988 | int i; | - | ||||||||||||||||||||||||
| 3989 | SrcList *pTabList; | - | ||||||||||||||||||||||||
| 3990 | struct SrcList_item *pFrom; | - | ||||||||||||||||||||||||
| 3991 | - | |||||||||||||||||||||||||
| 3992 | - | |||||||||||||||||||||||||
| 3993 | ((void) (0)) | - | ||||||||||||||||||||||||
| 3994 | ; | - | ||||||||||||||||||||||||
| 3995 | if( p->selFlags & 0x00080
executed 41 times by 1 test: return;Executed by:
| 41-811098 | ||||||||||||||||||||||||
| 3996 | p->selFlags |= 0x00080; | - | ||||||||||||||||||||||||
| 3997 | pParse = pWalker->pParse; | - | ||||||||||||||||||||||||
| 3998 | pTabList = p->pSrc; | - | ||||||||||||||||||||||||
| 3999 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc
| 523466-811098 | ||||||||||||||||||||||||
| 4000 | Table *pTab = pFrom->pTab; | - | ||||||||||||||||||||||||
| 4001 | - | |||||||||||||||||||||||||
| 4002 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4003 | ; | - | ||||||||||||||||||||||||
| 4004 | if( (
| 1960-521506 | ||||||||||||||||||||||||
| 4005 | - | |||||||||||||||||||||||||
| 4006 | Select *pSel = pFrom->pSelect; | - | ||||||||||||||||||||||||
| 4007 | if( pSel
| 296-1664 | ||||||||||||||||||||||||
| 4008 | while( pSel->pPrior
executed 828 times by 1 test: pSel = pSel->pPrior;Executed by:
| 828-1664 | ||||||||||||||||||||||||
| 4009 | sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel); | - | ||||||||||||||||||||||||
| 4010 | } executed 1664 times by 1 test: end of blockExecuted by:
| 1664 | ||||||||||||||||||||||||
| 4011 | } executed 1960 times by 1 test: end of blockExecuted by:
| 1960 | ||||||||||||||||||||||||
| 4012 | } executed 523466 times by 435 tests: end of blockExecuted by:
| 523466 | ||||||||||||||||||||||||
| 4013 | } executed 811098 times by 435 tests: end of blockExecuted by:
| 811098 | ||||||||||||||||||||||||
| 4014 | static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){ | - | ||||||||||||||||||||||||
| 4015 | - | |||||||||||||||||||||||||
| 4016 | Walker w; | - | ||||||||||||||||||||||||
| 4017 | w.xSelectCallback = sqlite3SelectWalkNoop; | - | ||||||||||||||||||||||||
| 4018 | w.xSelectCallback2 = selectAddSubqueryTypeInfo; | - | ||||||||||||||||||||||||
| 4019 | w.xExprCallback = sqlite3ExprWalkNoop; | - | ||||||||||||||||||||||||
| 4020 | w.pParse = pParse; | - | ||||||||||||||||||||||||
| 4021 | sqlite3WalkSelect(&w, pSelect); | - | ||||||||||||||||||||||||
| 4022 | - | |||||||||||||||||||||||||
| 4023 | } executed 185978 times by 435 tests: end of blockExecuted by:
| 185978 | ||||||||||||||||||||||||
| 4024 | void sqlite3SelectPrep( | - | ||||||||||||||||||||||||
| 4025 | Parse *pParse, | - | ||||||||||||||||||||||||
| 4026 | Select *p, | - | ||||||||||||||||||||||||
| 4027 | NameContext *pOuterNC | - | ||||||||||||||||||||||||
| 4028 | ){ | - | ||||||||||||||||||||||||
| 4029 | - | |||||||||||||||||||||||||
| 4030 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4031 | ; | - | ||||||||||||||||||||||||
| 4032 | if( pParse->db->mallocFailed
never executed: return; | 0-320135 | ||||||||||||||||||||||||
| 4033 | if( p->selFlags & 0x00080
executed 132685 times by 4 tests: return;Executed by:
| 132685-187450 | ||||||||||||||||||||||||
| 4034 | sqlite3SelectExpand(pParse, p); | - | ||||||||||||||||||||||||
| 4035 | if( pParse->nErr
executed 1194 times by 6 tests: return;Executed by:
| 434-186690 | ||||||||||||||||||||||||
| 4036 | sqlite3ResolveSelectNames(pParse, p, pOuterNC); | - | ||||||||||||||||||||||||
| 4037 | if( pParse->nErr
executed 278 times by 2 tests: return;Executed by:
| 0-185978 | ||||||||||||||||||||||||
| 4038 | sqlite3SelectAddTypeInfo(pParse, p); | - | ||||||||||||||||||||||||
| 4039 | } executed 185978 times by 435 tests: end of blockExecuted by:
| 185978 | ||||||||||||||||||||||||
| 4040 | static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ | - | ||||||||||||||||||||||||
| 4041 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 4042 | int i; | - | ||||||||||||||||||||||||
| 4043 | struct AggInfo_func *pFunc; | - | ||||||||||||||||||||||||
| 4044 | int nReg = pAggInfo->nFunc + pAggInfo->nColumn; | - | ||||||||||||||||||||||||
| 4045 | if( nReg==0
executed 10 times by 1 test: return;Executed by:
| 10-22681 | ||||||||||||||||||||||||
| 4046 | sqlite3VdbeAddOp3(v, 73, 0, pAggInfo->mnReg, pAggInfo->mxReg); | - | ||||||||||||||||||||||||
| 4047 | for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc
| 22681-33667 | ||||||||||||||||||||||||
| 4048 | if( pFunc->iDistinct>=0
| 3217-30450 | ||||||||||||||||||||||||
| 4049 | Expr *pE = pFunc->pExpr; | - | ||||||||||||||||||||||||
| 4050 | - | |||||||||||||||||||||||||
| 4051 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4052 | ; | - | ||||||||||||||||||||||||
| 4053 | if( pE->x.pList==0
| 1-3214 | ||||||||||||||||||||||||
| 4054 | sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one " | - | ||||||||||||||||||||||||
| 4055 | "argument"); | - | ||||||||||||||||||||||||
| 4056 | pFunc->iDistinct = -1; | - | ||||||||||||||||||||||||
| 4057 | } executed 4 times by 1 test: else{end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 4058 | KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0); | - | ||||||||||||||||||||||||
| 4059 | sqlite3VdbeAddOp4(v, 113, pFunc->iDistinct, 0, 0, | - | ||||||||||||||||||||||||
| 4060 | (char*)pKeyInfo, (-9)); | - | ||||||||||||||||||||||||
| 4061 | } executed 3213 times by 1 test: end of blockExecuted by:
| 3213 | ||||||||||||||||||||||||
| 4062 | } | - | ||||||||||||||||||||||||
| 4063 | } executed 33667 times by 1 test: end of blockExecuted by:
| 33667 | ||||||||||||||||||||||||
| 4064 | } executed 22681 times by 1 test: end of blockExecuted by:
| 22681 | ||||||||||||||||||||||||
| 4065 | - | |||||||||||||||||||||||||
| 4066 | - | |||||||||||||||||||||||||
| 4067 | - | |||||||||||||||||||||||||
| 4068 | - | |||||||||||||||||||||||||
| 4069 | - | |||||||||||||||||||||||||
| 4070 | static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ | - | ||||||||||||||||||||||||
| 4071 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 4072 | int i; | - | ||||||||||||||||||||||||
| 4073 | struct AggInfo_func *pF; | - | ||||||||||||||||||||||||
| 4074 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc
| 22688-33664 | ||||||||||||||||||||||||
| 4075 | ExprList *pList = pF->pExpr->x.pList; | - | ||||||||||||||||||||||||
| 4076 | - | |||||||||||||||||||||||||
| 4077 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4078 | ; | - | ||||||||||||||||||||||||
| 4079 | sqlite3VdbeAddOp2(v, 158, pF->iMem, pList ? pList->nExpr : 0); | - | ||||||||||||||||||||||||
| 4080 | sqlite3VdbeAppendP4(v, pF->pFunc, (-8)); | - | ||||||||||||||||||||||||
| 4081 | } executed 33664 times by 1 test: end of blockExecuted by:
| 33664 | ||||||||||||||||||||||||
| 4082 | } executed 22688 times by 1 test: end of blockExecuted by:
| 22688 | ||||||||||||||||||||||||
| 4083 | static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){ | - | ||||||||||||||||||||||||
| 4084 | Vdbe *v = pParse->pVdbe; | - | ||||||||||||||||||||||||
| 4085 | int i; | - | ||||||||||||||||||||||||
| 4086 | int regHit = 0; | - | ||||||||||||||||||||||||
| 4087 | int addrHitTest = 0; | - | ||||||||||||||||||||||||
| 4088 | struct AggInfo_func *pF; | - | ||||||||||||||||||||||||
| 4089 | struct AggInfo_col *pC; | - | ||||||||||||||||||||||||
| 4090 | - | |||||||||||||||||||||||||
| 4091 | pAggInfo->directMode = 1; | - | ||||||||||||||||||||||||
| 4092 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc
| 22688-33664 | ||||||||||||||||||||||||
| 4093 | int nArg; | - | ||||||||||||||||||||||||
| 4094 | int addrNext = 0; | - | ||||||||||||||||||||||||
| 4095 | int regAgg; | - | ||||||||||||||||||||||||
| 4096 | ExprList *pList = pF->pExpr->x.pList; | - | ||||||||||||||||||||||||
| 4097 | - | |||||||||||||||||||||||||
| 4098 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4099 | ; | - | ||||||||||||||||||||||||
| 4100 | if( pList
| 2194-31470 | ||||||||||||||||||||||||
| 4101 | nArg = pList->nExpr; | - | ||||||||||||||||||||||||
| 4102 | regAgg = sqlite3GetTempRange(pParse, nArg); | - | ||||||||||||||||||||||||
| 4103 | sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, 0x01); | - | ||||||||||||||||||||||||
| 4104 | } executed 31470 times by 1 test: else{end of blockExecuted by:
| 31470 | ||||||||||||||||||||||||
| 4105 | nArg = 0; | - | ||||||||||||||||||||||||
| 4106 | regAgg = 0; | - | ||||||||||||||||||||||||
| 4107 | } executed 2194 times by 1 test: end of blockExecuted by:
| 2194 | ||||||||||||||||||||||||
| 4108 | if( pF->iDistinct>=0
| 3214-30450 | ||||||||||||||||||||||||
| 4109 | addrNext = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4110 | ; | - | ||||||||||||||||||||||||
| 4111 | ; | - | ||||||||||||||||||||||||
| 4112 | codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg); | - | ||||||||||||||||||||||||
| 4113 | } executed 3214 times by 1 test: end of blockExecuted by:
| 3214 | ||||||||||||||||||||||||
| 4114 | if( pF->pFunc->funcFlags & 0x0020
| 14538-19126 | ||||||||||||||||||||||||
| 4115 | CollSeq *pColl = 0; | - | ||||||||||||||||||||||||
| 4116 | struct ExprList_item *pItem; | - | ||||||||||||||||||||||||
| 4117 | int j; | - | ||||||||||||||||||||||||
| 4118 | - | |||||||||||||||||||||||||
| 4119 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4120 | ; | - | ||||||||||||||||||||||||
| 4121 | for(j=0, pItem=pList->a; !pColl
| 5571-23505 | ||||||||||||||||||||||||
| 4122 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); | - | ||||||||||||||||||||||||
| 4123 | } executed 14538 times by 1 test: end of blockExecuted by:
| 14538 | ||||||||||||||||||||||||
| 4124 | if( !pColl
| 5571-8967 | ||||||||||||||||||||||||
| 4125 | pColl = pParse->db->pDfltColl; | - | ||||||||||||||||||||||||
| 4126 | } executed 8967 times by 1 test: end of blockExecuted by:
| 8967 | ||||||||||||||||||||||||
| 4127 | if( regHit==0
executed 1813 times by 1 test: regHit = ++pParse->nMem;Executed by:
| 1733-12805 | ||||||||||||||||||||||||
| 4128 | sqlite3VdbeAddOp4(v, 82, regHit, 0, 0, (char *)pColl, (-2)); | - | ||||||||||||||||||||||||
| 4129 | } executed 14538 times by 1 test: end of blockExecuted by:
| 14538 | ||||||||||||||||||||||||
| 4130 | sqlite3VdbeAddOp3(v, 155, 0, regAgg, pF->iMem); | - | ||||||||||||||||||||||||
| 4131 | sqlite3VdbeAppendP4(v, pF->pFunc, (-8)); | - | ||||||||||||||||||||||||
| 4132 | sqlite3VdbeChangeP5(v, (u8)nArg); | - | ||||||||||||||||||||||||
| 4133 | sqlite3ReleaseTempRange(pParse, regAgg, nArg); | - | ||||||||||||||||||||||||
| 4134 | if( addrNext
| 3214-30450 | ||||||||||||||||||||||||
| 4135 | sqlite3VdbeResolveLabel(v, addrNext); | - | ||||||||||||||||||||||||
| 4136 | } executed 3214 times by 1 test: end of blockExecuted by:
| 3214 | ||||||||||||||||||||||||
| 4137 | } executed 33664 times by 1 test: end of blockExecuted by:
| 33664 | ||||||||||||||||||||||||
| 4138 | if( regHit==0
| 358-20875 | ||||||||||||||||||||||||
| 4139 | regHit = regAcc; | - | ||||||||||||||||||||||||
| 4140 | } executed 358 times by 1 test: end of blockExecuted by:
| 358 | ||||||||||||||||||||||||
| 4141 | if( regHit
| 2171-20517 | ||||||||||||||||||||||||
| 4142 | addrHitTest = sqlite3VdbeAddOp1(v, 18, regHit); ; | - | ||||||||||||||||||||||||
| 4143 | } executed 2171 times by 1 test: end of blockExecuted by:
| 2171 | ||||||||||||||||||||||||
| 4144 | for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator
| 2355-22688 | ||||||||||||||||||||||||
| 4145 | sqlite3ExprCode(pParse, pC->pExpr, pC->iMem); | - | ||||||||||||||||||||||||
| 4146 | } executed 2355 times by 1 test: end of blockExecuted by:
| 2355 | ||||||||||||||||||||||||
| 4147 | pAggInfo->directMode = 0; | - | ||||||||||||||||||||||||
| 4148 | if( addrHitTest
| 2171-20517 | ||||||||||||||||||||||||
| 4149 | sqlite3VdbeJumpHere(v, addrHitTest); | - | ||||||||||||||||||||||||
| 4150 | } executed 2171 times by 1 test: end of blockExecuted by:
| 2171 | ||||||||||||||||||||||||
| 4151 | } executed 22688 times by 1 test: end of blockExecuted by:
| 22688 | ||||||||||||||||||||||||
| 4152 | - | |||||||||||||||||||||||||
| 4153 | - | |||||||||||||||||||||||||
| 4154 | - | |||||||||||||||||||||||||
| 4155 | - | |||||||||||||||||||||||||
| 4156 | - | |||||||||||||||||||||||||
| 4157 | - | |||||||||||||||||||||||||
| 4158 | static void explainSimpleCount( | - | ||||||||||||||||||||||||
| 4159 | Parse *pParse, | - | ||||||||||||||||||||||||
| 4160 | Table *pTab, | - | ||||||||||||||||||||||||
| 4161 | Index *pIdx | - | ||||||||||||||||||||||||
| 4162 | ){ | - | ||||||||||||||||||||||||
| 4163 | if( pParse->explain==2
| 8-1987 | ||||||||||||||||||||||||
| 4164 | int bCover = (pIdx!=0
| 0-4 | ||||||||||||||||||||||||
| 4165 | sqlite3VdbeExplain(pParse, 0, "SCAN TABLE %s%s%s", | - | ||||||||||||||||||||||||
| 4166 | pTab->zName, | - | ||||||||||||||||||||||||
| 4167 | bCover ? " USING COVERING INDEX " : "", | - | ||||||||||||||||||||||||
| 4168 | bCover ? pIdx->zName : "" | - | ||||||||||||||||||||||||
| 4169 | ); | - | ||||||||||||||||||||||||
| 4170 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 4171 | } executed 1995 times by 4 tests: end of blockExecuted by:
| 1995 | ||||||||||||||||||||||||
| 4172 | static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ | - | ||||||||||||||||||||||||
| 4173 | if( pExpr->op!=44
| 3-94 | ||||||||||||||||||||||||
| 4174 | Select *pS = pWalker->u.pSelect; | - | ||||||||||||||||||||||||
| 4175 | if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy)
| 28-66 | ||||||||||||||||||||||||
| 4176 | sqlite3 *db = pWalker->pParse->db; | - | ||||||||||||||||||||||||
| 4177 | Expr *pNew = sqlite3ExprAlloc(db, 143, &sqlite3IntTokens[1], 0); | - | ||||||||||||||||||||||||
| 4178 | if( pNew
| 0-28 | ||||||||||||||||||||||||
| 4179 | Expr *pWhere = pS->pWhere; | - | ||||||||||||||||||||||||
| 4180 | {Expr t=*pNew; *pNew=*pExpr; *pExpr=t;}; | - | ||||||||||||||||||||||||
| 4181 | pNew = sqlite3ExprAnd(db, pWhere, pNew); | - | ||||||||||||||||||||||||
| 4182 | pS->pWhere = pNew; | - | ||||||||||||||||||||||||
| 4183 | pWalker->eCode = 1; | - | ||||||||||||||||||||||||
| 4184 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 4185 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 4186 | return executed 94 times by 1 test: 1;return 1;Executed by:
executed 94 times by 1 test: return 1;Executed by:
| 94 | ||||||||||||||||||||||||
| 4187 | } | - | ||||||||||||||||||||||||
| 4188 | return executed 3 times by 1 test: 0;return 0;Executed by:
executed 3 times by 1 test: return 0;Executed by:
| 3 | ||||||||||||||||||||||||
| 4189 | } | - | ||||||||||||||||||||||||
| 4190 | static void havingToWhere(Parse *pParse, Select *p){ | - | ||||||||||||||||||||||||
| 4191 | Walker sWalker; | - | ||||||||||||||||||||||||
| 4192 | memset(&sWalker, 0, sizeof(sWalker)); | - | ||||||||||||||||||||||||
| 4193 | sWalker.pParse = pParse; | - | ||||||||||||||||||||||||
| 4194 | sWalker.xExprCallback = havingToWhereExprCb; | - | ||||||||||||||||||||||||
| 4195 | sWalker.u.pSelect = p; | - | ||||||||||||||||||||||||
| 4196 | sqlite3WalkExpr(&sWalker, p->pHaving); | - | ||||||||||||||||||||||||
| 4197 | - | |||||||||||||||||||||||||
| 4198 | - | |||||||||||||||||||||||||
| 4199 | - | |||||||||||||||||||||||||
| 4200 | - | |||||||||||||||||||||||||
| 4201 | - | |||||||||||||||||||||||||
| 4202 | - | |||||||||||||||||||||||||
| 4203 | } executed 91 times by 1 test: end of blockExecuted by:
| 91 | ||||||||||||||||||||||||
| 4204 | - | |||||||||||||||||||||||||
| 4205 | - | |||||||||||||||||||||||||
| 4206 | - | |||||||||||||||||||||||||
| 4207 | - | |||||||||||||||||||||||||
| 4208 | - | |||||||||||||||||||||||||
| 4209 | - | |||||||||||||||||||||||||
| 4210 | static struct SrcList_item *isSelfJoinView( | - | ||||||||||||||||||||||||
| 4211 | SrcList *pTabList, | - | ||||||||||||||||||||||||
| 4212 | struct SrcList_item *pThis | - | ||||||||||||||||||||||||
| 4213 | ){ | - | ||||||||||||||||||||||||
| 4214 | struct SrcList_item *pItem; | - | ||||||||||||||||||||||||
| 4215 | for(pItem = pTabList->a; pItem<pThis
| 130-153 | ||||||||||||||||||||||||
| 4216 | if( pItem->pSelect==0
executed 93 times by 1 test: continue;Executed by:
| 37-93 | ||||||||||||||||||||||||
| 4217 | if( pItem->fg.viaCoroutine
executed 7 times by 1 test: continue;Executed by:
| 7-30 | ||||||||||||||||||||||||
| 4218 | if( pItem->zName==0
executed 22 times by 1 test: continue;Executed by:
| 8-22 | ||||||||||||||||||||||||
| 4219 | if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0
never executed: continue; | 0-8 | ||||||||||||||||||||||||
| 4220 | if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0
executed 1 time by 1 test: continue;Executed by:
| 1-7 | ||||||||||||||||||||||||
| 4221 | if( sqlite3ExprCompare(0,
| 2-5 | ||||||||||||||||||||||||
| 4222 | pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
| 2-5 | ||||||||||||||||||||||||
| 4223 | ){ | - | ||||||||||||||||||||||||
| 4224 | - | |||||||||||||||||||||||||
| 4225 | - | |||||||||||||||||||||||||
| 4226 | continue; executed 5 times by 1 test: continue;Executed by:
| 5 | ||||||||||||||||||||||||
| 4227 | } | - | ||||||||||||||||||||||||
| 4228 | return executed 2 times by 1 test: pItem;return pItem;Executed by:
executed 2 times by 1 test: return pItem;Executed by:
| 2 | ||||||||||||||||||||||||
| 4229 | } | - | ||||||||||||||||||||||||
| 4230 | return executed 153 times by 1 test: 0;return 0;Executed by:
executed 153 times by 1 test: return 0;Executed by:
| 153 | ||||||||||||||||||||||||
| 4231 | } | - | ||||||||||||||||||||||||
| 4232 | int sqlite3Select( | - | ||||||||||||||||||||||||
| 4233 | Parse *pParse, | - | ||||||||||||||||||||||||
| 4234 | Select *p, | - | ||||||||||||||||||||||||
| 4235 | SelectDest *pDest | - | ||||||||||||||||||||||||
| 4236 | ){ | - | ||||||||||||||||||||||||
| 4237 | int i, j; | - | ||||||||||||||||||||||||
| 4238 | WhereInfo *pWInfo; | - | ||||||||||||||||||||||||
| 4239 | Vdbe *v; | - | ||||||||||||||||||||||||
| 4240 | int isAgg; | - | ||||||||||||||||||||||||
| 4241 | ExprList *pEList = 0; | - | ||||||||||||||||||||||||
| 4242 | SrcList *pTabList; | - | ||||||||||||||||||||||||
| 4243 | Expr *pWhere; | - | ||||||||||||||||||||||||
| 4244 | ExprList *pGroupBy; | - | ||||||||||||||||||||||||
| 4245 | Expr *pHaving; | - | ||||||||||||||||||||||||
| 4246 | int rc = 1; | - | ||||||||||||||||||||||||
| 4247 | DistinctCtx sDistinct; | - | ||||||||||||||||||||||||
| 4248 | SortCtx sSort; | - | ||||||||||||||||||||||||
| 4249 | AggInfo sAggInfo; | - | ||||||||||||||||||||||||
| 4250 | int iEnd; | - | ||||||||||||||||||||||||
| 4251 | sqlite3 *db; | - | ||||||||||||||||||||||||
| 4252 | ExprList *pMinMaxOrderBy = 0; | - | ||||||||||||||||||||||||
| 4253 | u8 minMaxFlag; | - | ||||||||||||||||||||||||
| 4254 | - | |||||||||||||||||||||||||
| 4255 | db = pParse->db; | - | ||||||||||||||||||||||||
| 4256 | v = sqlite3GetVdbe(pParse); | - | ||||||||||||||||||||||||
| 4257 | if( p==0
| 48-316827 | ||||||||||||||||||||||||
| 4258 | return executed 218 times by 1 test: 1;return 1;Executed by:
executed 218 times by 1 test: return 1;Executed by:
| 218 | ||||||||||||||||||||||||
| 4259 | } | - | ||||||||||||||||||||||||
| 4260 | if( sqlite3AuthCheck(pParse, 21, 0, 0, 0)
executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3-316726 | ||||||||||||||||||||||||
| 4261 | memset(&sAggInfo, 0, sizeof(sAggInfo)); | - | ||||||||||||||||||||||||
| 4262 | - | |||||||||||||||||||||||||
| 4263 | - | |||||||||||||||||||||||||
| 4264 | - | |||||||||||||||||||||||||
| 4265 | - | |||||||||||||||||||||||||
| 4266 | - | |||||||||||||||||||||||||
| 4267 | - | |||||||||||||||||||||||||
| 4268 | - | |||||||||||||||||||||||||
| 4269 | - | |||||||||||||||||||||||||
| 4270 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4271 | ; | - | ||||||||||||||||||||||||
| 4272 | - | |||||||||||||||||||||||||
| 4273 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4274 | ; | - | ||||||||||||||||||||||||
| 4275 | - | |||||||||||||||||||||||||
| 4276 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4277 | ; | - | ||||||||||||||||||||||||
| 4278 | - | |||||||||||||||||||||||||
| 4279 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4280 | ; | - | ||||||||||||||||||||||||
| 4281 | if( ((
| 77056-239670 | ||||||||||||||||||||||||
| 4282 | - | |||||||||||||||||||||||||
| 4283 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4284 | - | |||||||||||||||||||||||||
| 4285 | - | |||||||||||||||||||||||||
| 4286 | - | |||||||||||||||||||||||||
| 4287 | ; | - | ||||||||||||||||||||||||
| 4288 | - | |||||||||||||||||||||||||
| 4289 | - | |||||||||||||||||||||||||
| 4290 | sqlite3ExprListDelete(db, p->pOrderBy); | - | ||||||||||||||||||||||||
| 4291 | p->pOrderBy = 0; | - | ||||||||||||||||||||||||
| 4292 | p->selFlags &= ~0x00001; | - | ||||||||||||||||||||||||
| 4293 | } executed 77056 times by 1 test: end of blockExecuted by:
| 77056 | ||||||||||||||||||||||||
| 4294 | sqlite3SelectPrep(pParse, p, 0); | - | ||||||||||||||||||||||||
| 4295 | if( pParse->nErr
| 466-315719 | ||||||||||||||||||||||||
| 4296 | goto executed 1473 times by 6 tests: select_end;goto select_end;Executed by:
executed 1473 times by 6 tests: goto select_end;Executed by:
| 1473 | ||||||||||||||||||||||||
| 4297 | } | - | ||||||||||||||||||||||||
| 4298 | - | |||||||||||||||||||||||||
| 4299 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4300 | ; | - | ||||||||||||||||||||||||
| 4301 | - | |||||||||||||||||||||||||
| 4302 | - | |||||||||||||||||||||||||
| 4303 | - | |||||||||||||||||||||||||
| 4304 | - | |||||||||||||||||||||||||
| 4305 | - | |||||||||||||||||||||||||
| 4306 | - | |||||||||||||||||||||||||
| 4307 | - | |||||||||||||||||||||||||
| 4308 | if( pDest->eDest==9
| 134942-180311 | ||||||||||||||||||||||||
| 4309 | generateColumnNames(pParse, p); | - | ||||||||||||||||||||||||
| 4310 | } executed 180311 times by 435 tests: end of blockExecuted by:
| 180311 | ||||||||||||||||||||||||
| 4311 | - | |||||||||||||||||||||||||
| 4312 | - | |||||||||||||||||||||||||
| 4313 | if( sqlite3WindowRewrite(pParse, p)
| 0-315253 | ||||||||||||||||||||||||
| 4314 | goto never executed: select_end;goto select_end;never executed: goto select_end; | 0 | ||||||||||||||||||||||||
| 4315 | } | - | ||||||||||||||||||||||||
| 4316 | - | |||||||||||||||||||||||||
| 4317 | - | |||||||||||||||||||||||||
| 4318 | - | |||||||||||||||||||||||||
| 4319 | - | |||||||||||||||||||||||||
| 4320 | - | |||||||||||||||||||||||||
| 4321 | - | |||||||||||||||||||||||||
| 4322 | - | |||||||||||||||||||||||||
| 4323 | pTabList = p->pSrc; | - | ||||||||||||||||||||||||
| 4324 | isAgg = (p->selFlags & 0x00008)!=0; | - | ||||||||||||||||||||||||
| 4325 | memset(&sSort, 0, sizeof(sSort)); | - | ||||||||||||||||||||||||
| 4326 | sSort.pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 4327 | - | |||||||||||||||||||||||||
| 4328 | - | |||||||||||||||||||||||||
| 4329 | - | |||||||||||||||||||||||||
| 4330 | - | |||||||||||||||||||||||||
| 4331 | - | |||||||||||||||||||||||||
| 4332 | for(i=0; !p->pPrior
| 39352-601030 | ||||||||||||||||||||||||
| 4333 | struct SrcList_item *pItem = &pTabList->a[i]; | - | ||||||||||||||||||||||||
| 4334 | Select *pSub = pItem->pSelect; | - | ||||||||||||||||||||||||
| 4335 | Table *pTab = pItem->pTab; | - | ||||||||||||||||||||||||
| 4336 | - | |||||||||||||||||||||||||
| 4337 | - | |||||||||||||||||||||||||
| 4338 | - | |||||||||||||||||||||||||
| 4339 | - | |||||||||||||||||||||||||
| 4340 | if( (
| 520-324685 | ||||||||||||||||||||||||
| 4341 | && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor)
| 34-486 | ||||||||||||||||||||||||
| 4342 | && (((
| 1-33 | ||||||||||||||||||||||||
| 4343 | ){ | - | ||||||||||||||||||||||||
| 4344 | - | |||||||||||||||||||||||||
| 4345 | ; | - | ||||||||||||||||||||||||
| 4346 | pItem->fg.jointype &= ~(0x0008|0x0020); | - | ||||||||||||||||||||||||
| 4347 | unsetJoinExpr(p->pWhere, pItem->iCursor); | - | ||||||||||||||||||||||||
| 4348 | } executed 33 times by 1 test: end of blockExecuted by:
| 33 | ||||||||||||||||||||||||
| 4349 | - | |||||||||||||||||||||||||
| 4350 | - | |||||||||||||||||||||||||
| 4351 | if( pSub==0
executed 254257 times by 435 tests: continue;Executed by:
| 70948-254257 | ||||||||||||||||||||||||
| 4352 | - | |||||||||||||||||||||||||
| 4353 | - | |||||||||||||||||||||||||
| 4354 | - | |||||||||||||||||||||||||
| 4355 | if( pTab->nCol!=pSub->pEList->nExpr
| 2-70946 | ||||||||||||||||||||||||
| 4356 | sqlite3ErrorMsg(pParse, "expected %d columns for '%s' but got %d", | - | ||||||||||||||||||||||||
| 4357 | pTab->nCol, pTab->zName, pSub->pEList->nExpr); | - | ||||||||||||||||||||||||
| 4358 | goto executed 2 times by 1 test: select_end;goto select_end;Executed by:
executed 2 times by 1 test: goto select_end;Executed by:
| 2 | ||||||||||||||||||||||||
| 4359 | } | - | ||||||||||||||||||||||||
| 4360 | if( (
executed 105 times by 1 test: continue;Executed by:
| 105-70841 | ||||||||||||||||||||||||
| 4361 | - | |||||||||||||||||||||||||
| 4362 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4363 | ; | - | ||||||||||||||||||||||||
| 4364 | if( pSub->pOrderBy!=0
| 1910-68931 | ||||||||||||||||||||||||
| 4365 | && i==0
| 4-1906 | ||||||||||||||||||||||||
| 4366 | && (
| 283-1623 | ||||||||||||||||||||||||
| 4367 | && (pTabList->nSrc==1
| 0-1623 | ||||||||||||||||||||||||
| 4368 | || (
| 0 | ||||||||||||||||||||||||
| 4369 | ){ | - | ||||||||||||||||||||||||
| 4370 | continue; executed 1623 times by 1 test: continue;Executed by:
| 1623 | ||||||||||||||||||||||||
| 4371 | } | - | ||||||||||||||||||||||||
| 4372 | - | |||||||||||||||||||||||||
| 4373 | if( flattenSubquery(pParse, p, i, isAgg)
| 33852-35366 | ||||||||||||||||||||||||
| 4374 | - | |||||||||||||||||||||||||
| 4375 | i = -1; | - | ||||||||||||||||||||||||
| 4376 | } executed 35366 times by 2 tests: end of blockExecuted by:
| 35366 | ||||||||||||||||||||||||
| 4377 | pTabList = p->pSrc; | - | ||||||||||||||||||||||||
| 4378 | if( db->mallocFailed
executed 74 times by 1 test: select_end;goto select_end;Executed by:
executed 74 times by 1 test: goto select_end;Executed by:
| 74-69144 | ||||||||||||||||||||||||
| 4379 | if( !((pDest->eDest)<=8)
| 3551-65593 | ||||||||||||||||||||||||
| 4380 | sSort.pOrderBy = p->pOrderBy; | - | ||||||||||||||||||||||||
| 4381 | } executed 3551 times by 2 tests: end of blockExecuted by:
| 3551 | ||||||||||||||||||||||||
| 4382 | } executed 69144 times by 2 tests: end of blockExecuted by:
| 69144 | ||||||||||||||||||||||||
| 4383 | - | |||||||||||||||||||||||||
| 4384 | - | |||||||||||||||||||||||||
| 4385 | - | |||||||||||||||||||||||||
| 4386 | - | |||||||||||||||||||||||||
| 4387 | - | |||||||||||||||||||||||||
| 4388 | - | |||||||||||||||||||||||||
| 4389 | if( p->pPrior
| 39352-275825 | ||||||||||||||||||||||||
| 4390 | rc = multiSelect(pParse, p, pDest); | - | ||||||||||||||||||||||||
| 4391 | - | |||||||||||||||||||||||||
| 4392 | - | |||||||||||||||||||||||||
| 4393 | - | |||||||||||||||||||||||||
| 4394 | - | |||||||||||||||||||||||||
| 4395 | - | |||||||||||||||||||||||||
| 4396 | - | |||||||||||||||||||||||||
| 4397 | if( p->pNext==0
executed 38428 times by 1 test: sqlite3VdbeExplainPop(pParse);Executed by:
| 924-38428 | ||||||||||||||||||||||||
| 4398 | return executed 39352 times by 1 test: rc;return rc;Executed by:
executed 39352 times by 1 test: return rc;Executed by:
| 39352 | ||||||||||||||||||||||||
| 4399 | } | - | ||||||||||||||||||||||||
| 4400 | - | |||||||||||||||||||||||||
| 4401 | - | |||||||||||||||||||||||||
| 4402 | - | |||||||||||||||||||||||||
| 4403 | - | |||||||||||||||||||||||||
| 4404 | - | |||||||||||||||||||||||||
| 4405 | - | |||||||||||||||||||||||||
| 4406 | - | |||||||||||||||||||||||||
| 4407 | if( pTabList->nSrc>1
| 6929-268896 | ||||||||||||||||||||||||
| 4408 | && (((
| 5-6924 | ||||||||||||||||||||||||
| 4409 | && propagateConstants(pParse, p)
| 47-6877 | ||||||||||||||||||||||||
| 4410 | ){ | - | ||||||||||||||||||||||||
| 4411 | - | |||||||||||||||||||||||||
| 4412 | - | |||||||||||||||||||||||||
| 4413 | - | |||||||||||||||||||||||||
| 4414 | - | |||||||||||||||||||||||||
| 4415 | - | |||||||||||||||||||||||||
| 4416 | - | |||||||||||||||||||||||||
| 4417 | } executed 47 times by 1 test: else{end of blockExecuted by:
| 47 | ||||||||||||||||||||||||
| 4418 | ; | - | ||||||||||||||||||||||||
| 4419 | } executed 275778 times by 435 tests: end of blockExecuted by:
| 275778 | ||||||||||||||||||||||||
| 4420 | for(i=0; i<pTabList->nSrc
| 275801-289689 | ||||||||||||||||||||||||
| 4421 | struct SrcList_item *pItem = &pTabList->a[i]; | - | ||||||||||||||||||||||||
| 4422 | SelectDest dest; | - | ||||||||||||||||||||||||
| 4423 | Select *pSub; | - | ||||||||||||||||||||||||
| 4424 | - | |||||||||||||||||||||||||
| 4425 | const char *zSavedAuthContext; | - | ||||||||||||||||||||||||
| 4426 | if( pItem->colUsed==0
| 78083-211606 | ||||||||||||||||||||||||
| 4427 | sqlite3AuthCheck(pParse, 20, pItem->zName, "", pItem->zDatabase); | - | ||||||||||||||||||||||||
| 4428 | } executed 78083 times by 7 tests: end of blockExecuted by:
| 78083 | ||||||||||||||||||||||||
| 4429 | - | |||||||||||||||||||||||||
| 4430 | - | |||||||||||||||||||||||||
| 4431 | - | |||||||||||||||||||||||||
| 4432 | - | |||||||||||||||||||||||||
| 4433 | pSub = pItem->pSelect; | - | ||||||||||||||||||||||||
| 4434 | if( pSub==0
executed 254127 times by 435 tests: continue;Executed by:
| 35562-254127 | ||||||||||||||||||||||||
| 4435 | - | |||||||||||||||||||||||||
| 4436 | - | |||||||||||||||||||||||||
| 4437 | - | |||||||||||||||||||||||||
| 4438 | - | |||||||||||||||||||||||||
| 4439 | - | |||||||||||||||||||||||||
| 4440 | - | |||||||||||||||||||||||||
| 4441 | - | |||||||||||||||||||||||||
| 4442 | if( pItem->addrFillSub
| 1-35561 | ||||||||||||||||||||||||
| 4443 | if( pItem->fg.viaCoroutine==0
| 0-1 | ||||||||||||||||||||||||
| 4444 | - | |||||||||||||||||||||||||
| 4445 | - | |||||||||||||||||||||||||
| 4446 | - | |||||||||||||||||||||||||
| 4447 | ; | - | ||||||||||||||||||||||||
| 4448 | sqlite3VdbeAddOp2(v, 12, pItem->regReturn, pItem->addrFillSub); | - | ||||||||||||||||||||||||
| 4449 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4450 | continue; executed 1 time by 1 test: continue;Executed by:
| 1 | ||||||||||||||||||||||||
| 4451 | } | - | ||||||||||||||||||||||||
| 4452 | pParse->nHeight += sqlite3SelectExprHeight(p); | - | ||||||||||||||||||||||||
| 4453 | - | |||||||||||||||||||||||||
| 4454 | - | |||||||||||||||||||||||||
| 4455 | - | |||||||||||||||||||||||||
| 4456 | - | |||||||||||||||||||||||||
| 4457 | if( (((
| 10-35551 | ||||||||||||||||||||||||
| 4458 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
| 52-35499 | ||||||||||||||||||||||||
| 4459 | (pItem->fg.jointype & 0x0020)!=0)
| 52-35499 | ||||||||||||||||||||||||
| 4460 | ){ | - | ||||||||||||||||||||||||
| 4461 | - | |||||||||||||||||||||||||
| 4462 | - | |||||||||||||||||||||||||
| 4463 | - | |||||||||||||||||||||||||
| 4464 | - | |||||||||||||||||||||||||
| 4465 | - | |||||||||||||||||||||||||
| 4466 | - | |||||||||||||||||||||||||
| 4467 | - | |||||||||||||||||||||||||
| 4468 | } executed 52 times by 1 test: else{end of blockExecuted by:
| 52 | ||||||||||||||||||||||||
| 4469 | ; | - | ||||||||||||||||||||||||
| 4470 | } executed 35509 times by 1 test: end of blockExecuted by:
| 35509 | ||||||||||||||||||||||||
| 4471 | - | |||||||||||||||||||||||||
| 4472 | zSavedAuthContext = pParse->zAuthContext; | - | ||||||||||||||||||||||||
| 4473 | pParse->zAuthContext = pItem->zName; | - | ||||||||||||||||||||||||
| 4474 | if( i==0
| 113-35448 | ||||||||||||||||||||||||
| 4475 | && (pTabList->nSrc==1
| 52-35396 | ||||||||||||||||||||||||
| 4476 | || (
| 10-42 | ||||||||||||||||||||||||
| 4477 | ){ | - | ||||||||||||||||||||||||
| 4478 | - | |||||||||||||||||||||||||
| 4479 | - | |||||||||||||||||||||||||
| 4480 | - | |||||||||||||||||||||||||
| 4481 | int addrTop = sqlite3VdbeCurrentAddr(v)+1; | - | ||||||||||||||||||||||||
| 4482 | - | |||||||||||||||||||||||||
| 4483 | pItem->regReturn = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4484 | sqlite3VdbeAddOp3(v, 13, pItem->regReturn, 0, addrTop); | - | ||||||||||||||||||||||||
| 4485 | ; | - | ||||||||||||||||||||||||
| 4486 | pItem->addrFillSub = addrTop; | - | ||||||||||||||||||||||||
| 4487 | sqlite3SelectDestInit(&dest, 13, pItem->regReturn); | - | ||||||||||||||||||||||||
| 4488 | sqlite3VdbeExplain (pParse, 1, "CO-ROUTINE %u", pSub->selId); | - | ||||||||||||||||||||||||
| 4489 | sqlite3Select(pParse, pSub, &dest); | - | ||||||||||||||||||||||||
| 4490 | pItem->pTab->nRowLogEst = pSub->nSelectRow; | - | ||||||||||||||||||||||||
| 4491 | pItem->fg.viaCoroutine = 1; | - | ||||||||||||||||||||||||
| 4492 | pItem->regResult = dest.iSdst; | - | ||||||||||||||||||||||||
| 4493 | sqlite3VdbeEndCoroutine(v, pItem->regReturn); | - | ||||||||||||||||||||||||
| 4494 | sqlite3VdbeJumpHere(v, addrTop-1); | - | ||||||||||||||||||||||||
| 4495 | sqlite3ClearTempRegCache(pParse); | - | ||||||||||||||||||||||||
| 4496 | } executed 35406 times by 1 test: else{end of blockExecuted by:
| 35406 | ||||||||||||||||||||||||
| 4497 | - | |||||||||||||||||||||||||
| 4498 | - | |||||||||||||||||||||||||
| 4499 | - | |||||||||||||||||||||||||
| 4500 | - | |||||||||||||||||||||||||
| 4501 | - | |||||||||||||||||||||||||
| 4502 | int topAddr; | - | ||||||||||||||||||||||||
| 4503 | int onceAddr = 0; | - | ||||||||||||||||||||||||
| 4504 | int retAddr; | - | ||||||||||||||||||||||||
| 4505 | struct SrcList_item *pPrior; | - | ||||||||||||||||||||||||
| 4506 | - | |||||||||||||||||||||||||
| 4507 | - | |||||||||||||||||||||||||
| 4508 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4509 | ; | - | ||||||||||||||||||||||||
| 4510 | pItem->regReturn = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4511 | topAddr = sqlite3VdbeAddOp2(v, 70, 0, pItem->regReturn); | - | ||||||||||||||||||||||||
| 4512 | pItem->addrFillSub = topAddr+1; | - | ||||||||||||||||||||||||
| 4513 | if( pItem->fg.isCorrelated==0
| 1-154 | ||||||||||||||||||||||||
| 4514 | - | |||||||||||||||||||||||||
| 4515 | - | |||||||||||||||||||||||||
| 4516 | - | |||||||||||||||||||||||||
| 4517 | onceAddr = sqlite3VdbeAddOp0(v, 17); ; | - | ||||||||||||||||||||||||
| 4518 | ; | - | ||||||||||||||||||||||||
| 4519 | } executed 154 times by 1 test: else{end of blockExecuted by:
| 154 | ||||||||||||||||||||||||
| 4520 | ; | - | ||||||||||||||||||||||||
| 4521 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 4522 | pPrior = isSelfJoinView(pTabList, pItem); | - | ||||||||||||||||||||||||
| 4523 | if( pPrior
| 2-153 | ||||||||||||||||||||||||
| 4524 | sqlite3VdbeAddOp2(v, 111, pItem->iCursor, pPrior->iCursor); | - | ||||||||||||||||||||||||
| 4525 | - | |||||||||||||||||||||||||
| 4526 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4527 | ; | - | ||||||||||||||||||||||||
| 4528 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; | - | ||||||||||||||||||||||||
| 4529 | } executed 2 times by 1 test: else{end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 4530 | sqlite3SelectDestInit(&dest, 12, pItem->iCursor); | - | ||||||||||||||||||||||||
| 4531 | sqlite3VdbeExplain (pParse, 1, "MATERIALIZE %u", pSub->selId); | - | ||||||||||||||||||||||||
| 4532 | sqlite3Select(pParse, pSub, &dest); | - | ||||||||||||||||||||||||
| 4533 | } executed 153 times by 1 test: end of blockExecuted by:
| 153 | ||||||||||||||||||||||||
| 4534 | pItem->pTab->nRowLogEst = pSub->nSelectRow; | - | ||||||||||||||||||||||||
| 4535 | if( onceAddr
executed 154 times by 1 test: sqlite3VdbeJumpHere(v, onceAddr);Executed by:
| 1-154 | ||||||||||||||||||||||||
| 4536 | retAddr = sqlite3VdbeAddOp1(v, 66, pItem->regReturn); | - | ||||||||||||||||||||||||
| 4537 | ; | - | ||||||||||||||||||||||||
| 4538 | sqlite3VdbeChangeP1(v, topAddr, retAddr); | - | ||||||||||||||||||||||||
| 4539 | sqlite3ClearTempRegCache(pParse); | - | ||||||||||||||||||||||||
| 4540 | } executed 155 times by 1 test: end of blockExecuted by:
| 155 | ||||||||||||||||||||||||
| 4541 | if( db->mallocFailed
executed 24 times by 1 test: select_end;goto select_end;Executed by:
executed 24 times by 1 test: goto select_end;Executed by:
| 24-35537 | ||||||||||||||||||||||||
| 4542 | pParse->nHeight -= sqlite3SelectExprHeight(p); | - | ||||||||||||||||||||||||
| 4543 | pParse->zAuthContext = zSavedAuthContext; | - | ||||||||||||||||||||||||
| 4544 | - | |||||||||||||||||||||||||
| 4545 | } executed 35537 times by 1 test: end of blockExecuted by:
| 35537 | ||||||||||||||||||||||||
| 4546 | - | |||||||||||||||||||||||||
| 4547 | - | |||||||||||||||||||||||||
| 4548 | - | |||||||||||||||||||||||||
| 4549 | pEList = p->pEList; | - | ||||||||||||||||||||||||
| 4550 | pWhere = p->pWhere; | - | ||||||||||||||||||||||||
| 4551 | pGroupBy = p->pGroupBy; | - | ||||||||||||||||||||||||
| 4552 | pHaving = p->pHaving; | - | ||||||||||||||||||||||||
| 4553 | sDistinct.isTnct = (p->selFlags & 0x00001)!=0; | - | ||||||||||||||||||||||||
| 4554 | if( (
| 351-275450 | ||||||||||||||||||||||||
| 4555 | && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
| 87-264 | ||||||||||||||||||||||||
| 4556 | ){ | - | ||||||||||||||||||||||||
| 4557 | p->selFlags &= ~0x00001; | - | ||||||||||||||||||||||||
| 4558 | pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); | - | ||||||||||||||||||||||||
| 4559 | - | |||||||||||||||||||||||||
| 4560 | - | |||||||||||||||||||||||||
| 4561 | - | |||||||||||||||||||||||||
| 4562 | - | |||||||||||||||||||||||||
| 4563 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4564 | ; | - | ||||||||||||||||||||||||
| 4565 | - | |||||||||||||||||||||||||
| 4566 | - | |||||||||||||||||||||||||
| 4567 | - | |||||||||||||||||||||||||
| 4568 | - | |||||||||||||||||||||||||
| 4569 | - | |||||||||||||||||||||||||
| 4570 | - | |||||||||||||||||||||||||
| 4571 | - | |||||||||||||||||||||||||
| 4572 | } executed 87 times by 1 test: end of blockExecuted by:
| 87 | ||||||||||||||||||||||||
| 4573 | if( sSort.pOrderBy
| 59933-215868 | ||||||||||||||||||||||||
| 4574 | KeyInfo *pKeyInfo; | - | ||||||||||||||||||||||||
| 4575 | pKeyInfo = sqlite3KeyInfoFromExprList( | - | ||||||||||||||||||||||||
| 4576 | pParse, sSort.pOrderBy, 0, pEList->nExpr); | - | ||||||||||||||||||||||||
| 4577 | sSort.iECursor = pParse->nTab++; | - | ||||||||||||||||||||||||
| 4578 | sSort.addrSortIndex = | - | ||||||||||||||||||||||||
| 4579 | sqlite3VdbeAddOp4(v, 113, | - | ||||||||||||||||||||||||
| 4580 | sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0, | - | ||||||||||||||||||||||||
| 4581 | (char*)pKeyInfo, (-9) | - | ||||||||||||||||||||||||
| 4582 | ); | - | ||||||||||||||||||||||||
| 4583 | } executed 59933 times by 435 tests: else{end of blockExecuted by:
| 59933 | ||||||||||||||||||||||||
| 4584 | sSort.addrSortIndex = -1; | - | ||||||||||||||||||||||||
| 4585 | } executed 215868 times by 68 tests: end of blockExecuted by:
| 215868 | ||||||||||||||||||||||||
| 4586 | - | |||||||||||||||||||||||||
| 4587 | - | |||||||||||||||||||||||||
| 4588 | - | |||||||||||||||||||||||||
| 4589 | if( pDest->eDest==12
| 928-274873 | ||||||||||||||||||||||||
| 4590 | sqlite3VdbeAddOp2(v, 113, pDest->iSDParm, pEList->nExpr); | - | ||||||||||||||||||||||||
| 4591 | } executed 928 times by 1 test: end of blockExecuted by:
| 928 | ||||||||||||||||||||||||
| 4592 | - | |||||||||||||||||||||||||
| 4593 | - | |||||||||||||||||||||||||
| 4594 | - | |||||||||||||||||||||||||
| 4595 | iEnd = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4596 | if( (
| 923-274878 | ||||||||||||||||||||||||
| 4597 | p->nSelectRow = 320; | - | ||||||||||||||||||||||||
| 4598 | } executed 274878 times by 435 tests: end of blockExecuted by:
| 274878 | ||||||||||||||||||||||||
| 4599 | computeLimitRegisters(pParse, p, iEnd); | - | ||||||||||||||||||||||||
| 4600 | if( p->iLimit==0
| 16760-259041 | ||||||||||||||||||||||||
| 4601 | sqlite3VdbeChangeOpcode(v, sSort.addrSortIndex, 114); | - | ||||||||||||||||||||||||
| 4602 | sSort.sortFlags |= 0x01; | - | ||||||||||||||||||||||||
| 4603 | } executed 59024 times by 435 tests: end of blockExecuted by:
| 59024 | ||||||||||||||||||||||||
| 4604 | - | |||||||||||||||||||||||||
| 4605 | - | |||||||||||||||||||||||||
| 4606 | - | |||||||||||||||||||||||||
| 4607 | if( p->selFlags & 0x00001
| 291-275510 | ||||||||||||||||||||||||
| 4608 | sDistinct.tabTnct = pParse->nTab++; | - | ||||||||||||||||||||||||
| 4609 | sDistinct.addrTnct = sqlite3VdbeAddOp4(v, 113, | - | ||||||||||||||||||||||||
| 4610 | sDistinct.tabTnct, 0, 0, | - | ||||||||||||||||||||||||
| 4611 | (char*)sqlite3KeyInfoFromExprList(pParse, p->pEList,0,0), | - | ||||||||||||||||||||||||
| 4612 | (-9)); | - | ||||||||||||||||||||||||
| 4613 | sqlite3VdbeChangeP5(v, 8); | - | ||||||||||||||||||||||||
| 4614 | sDistinct.eTnctType = 3; | - | ||||||||||||||||||||||||
| 4615 | } executed 291 times by 1 test: else{end of blockExecuted by:
| 291 | ||||||||||||||||||||||||
| 4616 | sDistinct.eTnctType = 0; | - | ||||||||||||||||||||||||
| 4617 | } executed 275510 times by 435 tests: end of blockExecuted by:
| 275510 | ||||||||||||||||||||||||
| 4618 | - | |||||||||||||||||||||||||
| 4619 | if( !isAgg
| 87-251200 | ||||||||||||||||||||||||
| 4620 | - | |||||||||||||||||||||||||
| 4621 | u16 wctrlFlags = (sDistinct.isTnct
| 264-250849 | ||||||||||||||||||||||||
| 4622 | | (p->selFlags & 0x04000); | - | ||||||||||||||||||||||||
| 4623 | - | |||||||||||||||||||||||||
| 4624 | Window *pWin = p->pWin; | - | ||||||||||||||||||||||||
| 4625 | if( pWin
| 1809-249304 | ||||||||||||||||||||||||
| 4626 | sqlite3WindowCodeInit(pParse, pWin); | - | ||||||||||||||||||||||||
| 4627 | } executed 1809 times by 1 test: end of blockExecuted by:
| 1809 | ||||||||||||||||||||||||
| 4628 | - | |||||||||||||||||||||||||
| 4629 | - | |||||||||||||||||||||||||
| 4630 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4631 | ; | - | ||||||||||||||||||||||||
| 4632 | - | |||||||||||||||||||||||||
| 4633 | - | |||||||||||||||||||||||||
| 4634 | - | |||||||||||||||||||||||||
| 4635 | ; | - | ||||||||||||||||||||||||
| 4636 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy, | - | ||||||||||||||||||||||||
| 4637 | p->pEList, wctrlFlags, p->nSelectRow); | - | ||||||||||||||||||||||||
| 4638 | if( pWInfo==0
executed 686 times by 1 test: select_end;goto select_end;Executed by:
executed 686 times by 1 test: goto select_end;Executed by:
| 686-250427 | ||||||||||||||||||||||||
| 4639 | if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow
| 11568-238859 | ||||||||||||||||||||||||
| 4640 | p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo); | - | ||||||||||||||||||||||||
| 4641 | } executed 238859 times by 435 tests: end of blockExecuted by:
| 238859 | ||||||||||||||||||||||||
| 4642 | if( sDistinct.isTnct
| 86-250165 | ||||||||||||||||||||||||
| 4643 | sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo); | - | ||||||||||||||||||||||||
| 4644 | } executed 86 times by 1 test: end of blockExecuted by:
| 86 | ||||||||||||||||||||||||
| 4645 | if( sSort.pOrderBy
| 57793-192634 | ||||||||||||||||||||||||
| 4646 | sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo); | - | ||||||||||||||||||||||||
| 4647 | sSort.labelOBLopt = sqlite3WhereOrderByLimitOptLabel(pWInfo); | - | ||||||||||||||||||||||||
| 4648 | if( sSort.nOBSat==sSort.pOrderBy->nExpr
| 13040-44753 | ||||||||||||||||||||||||
| 4649 | sSort.pOrderBy = 0; | - | ||||||||||||||||||||||||
| 4650 | } executed 44753 times by 435 tests: end of blockExecuted by:
| 44753 | ||||||||||||||||||||||||
| 4651 | } executed 57793 times by 435 tests: end of blockExecuted by:
| 57793 | ||||||||||||||||||||||||
| 4652 | - | |||||||||||||||||||||||||
| 4653 | - | |||||||||||||||||||||||||
| 4654 | - | |||||||||||||||||||||||||
| 4655 | - | |||||||||||||||||||||||||
| 4656 | - | |||||||||||||||||||||||||
| 4657 | if( sSort.addrSortIndex>=0
| 13040-192634 | ||||||||||||||||||||||||
| 4658 | sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex); | - | ||||||||||||||||||||||||
| 4659 | } executed 44753 times by 435 tests: end of blockExecuted by:
| 44753 | ||||||||||||||||||||||||
| 4660 | - | |||||||||||||||||||||||||
| 4661 | - | |||||||||||||||||||||||||
| 4662 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4663 | ; | - | ||||||||||||||||||||||||
| 4664 | - | |||||||||||||||||||||||||
| 4665 | if( pWin
| 1809-248618 | ||||||||||||||||||||||||
| 4666 | int addrGosub = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4667 | int iCont = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4668 | int iBreak = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4669 | int regGosub = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4670 | - | |||||||||||||||||||||||||
| 4671 | sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub); | - | ||||||||||||||||||||||||
| 4672 | - | |||||||||||||||||||||||||
| 4673 | sqlite3VdbeAddOp2(v, 11, 0, iBreak); | - | ||||||||||||||||||||||||
| 4674 | sqlite3VdbeResolveLabel(v, addrGosub); | - | ||||||||||||||||||||||||
| 4675 | ; | - | ||||||||||||||||||||||||
| 4676 | sSort.labelOBLopt = 0; | - | ||||||||||||||||||||||||
| 4677 | selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak); | - | ||||||||||||||||||||||||
| 4678 | sqlite3VdbeResolveLabel(v, iCont); | - | ||||||||||||||||||||||||
| 4679 | sqlite3VdbeAddOp1(v, 66, regGosub); | - | ||||||||||||||||||||||||
| 4680 | ; | - | ||||||||||||||||||||||||
| 4681 | sqlite3VdbeResolveLabel(v, iBreak); | - | ||||||||||||||||||||||||
| 4682 | } executed 1809 times by 1 test: elseend of blockExecuted by:
| 1809 | ||||||||||||||||||||||||
| 4683 | - | |||||||||||||||||||||||||
| 4684 | { | - | ||||||||||||||||||||||||
| 4685 | - | |||||||||||||||||||||||||
| 4686 | selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, | - | ||||||||||||||||||||||||
| 4687 | sqlite3WhereContinueLabel(pWInfo), | - | ||||||||||||||||||||||||
| 4688 | sqlite3WhereBreakLabel(pWInfo)); | - | ||||||||||||||||||||||||
| 4689 | - | |||||||||||||||||||||||||
| 4690 | - | |||||||||||||||||||||||||
| 4691 | - | |||||||||||||||||||||||||
| 4692 | sqlite3WhereEnd(pWInfo); | - | ||||||||||||||||||||||||
| 4693 | } executed 248618 times by 435 tests: end of blockExecuted by:
| 248618 | ||||||||||||||||||||||||
| 4694 | }else{ | - | ||||||||||||||||||||||||
| 4695 | - | |||||||||||||||||||||||||
| 4696 | - | |||||||||||||||||||||||||
| 4697 | NameContext sNC; | - | ||||||||||||||||||||||||
| 4698 | int iAMem; | - | ||||||||||||||||||||||||
| 4699 | int iBMem; | - | ||||||||||||||||||||||||
| 4700 | int iUseFlag; | - | ||||||||||||||||||||||||
| 4701 | - | |||||||||||||||||||||||||
| 4702 | - | |||||||||||||||||||||||||
| 4703 | int iAbortFlag; | - | ||||||||||||||||||||||||
| 4704 | int groupBySort; | - | ||||||||||||||||||||||||
| 4705 | int addrEnd; | - | ||||||||||||||||||||||||
| 4706 | int sortPTab = 0; | - | ||||||||||||||||||||||||
| 4707 | int sortOut = 0; | - | ||||||||||||||||||||||||
| 4708 | int orderByGrp = 0; | - | ||||||||||||||||||||||||
| 4709 | - | |||||||||||||||||||||||||
| 4710 | - | |||||||||||||||||||||||||
| 4711 | - | |||||||||||||||||||||||||
| 4712 | - | |||||||||||||||||||||||||
| 4713 | if( pGroupBy
| 2209-22479 | ||||||||||||||||||||||||
| 4714 | int k; | - | ||||||||||||||||||||||||
| 4715 | struct ExprList_item *pItem; | - | ||||||||||||||||||||||||
| 4716 | - | |||||||||||||||||||||||||
| 4717 | for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0
| 2209-6105 | ||||||||||||||||||||||||
| 4718 | pItem->u.x.iAlias = 0; | - | ||||||||||||||||||||||||
| 4719 | } executed 6105 times by 1 test: end of blockExecuted by:
| 6105 | ||||||||||||||||||||||||
| 4720 | for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0
| 2209-2286 | ||||||||||||||||||||||||
| 4721 | pItem->u.x.iAlias = 0; | - | ||||||||||||||||||||||||
| 4722 | } executed 2286 times by 1 test: end of blockExecuted by:
| 2286 | ||||||||||||||||||||||||
| 4723 | - | |||||||||||||||||||||||||
| 4724 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4725 | ; | - | ||||||||||||||||||||||||
| 4726 | if( p->nSelectRow>66
executed 2192 times by 1 test: p->nSelectRow = 66;Executed by:
| 17-2192 | ||||||||||||||||||||||||
| 4727 | } executed 2209 times by 1 test: else{end of blockExecuted by:
| 2209 | ||||||||||||||||||||||||
| 4728 | - | |||||||||||||||||||||||||
| 4729 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4730 | ; | - | ||||||||||||||||||||||||
| 4731 | p->nSelectRow = 0; | - | ||||||||||||||||||||||||
| 4732 | } executed 22479 times by 4 tests: end of blockExecuted by:
| 22479 | ||||||||||||||||||||||||
| 4733 | if( sqlite3ExprListCompare(pGroupBy, sSort.pOrderBy, -1)==0
| 354-24334 | ||||||||||||||||||||||||
| 4734 | orderByGrp = 1; | - | ||||||||||||||||||||||||
| 4735 | } executed 24334 times by 4 tests: end of blockExecuted by:
| 24334 | ||||||||||||||||||||||||
| 4736 | - | |||||||||||||||||||||||||
| 4737 | - | |||||||||||||||||||||||||
| 4738 | addrEnd = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4739 | - | |||||||||||||||||||||||||
| 4740 | - | |||||||||||||||||||||||||
| 4741 | - | |||||||||||||||||||||||||
| 4742 | - | |||||||||||||||||||||||||
| 4743 | - | |||||||||||||||||||||||||
| 4744 | memset(&sNC, 0, sizeof(sNC)); | - | ||||||||||||||||||||||||
| 4745 | sNC.pParse = pParse; | - | ||||||||||||||||||||||||
| 4746 | sNC.pSrcList = pTabList; | - | ||||||||||||||||||||||||
| 4747 | sNC.uNC.pAggInfo = &sAggInfo; | - | ||||||||||||||||||||||||
| 4748 | - | |||||||||||||||||||||||||
| 4749 | sAggInfo.mnReg = pParse->nMem+1; | - | ||||||||||||||||||||||||
| 4750 | sAggInfo.nSortingColumn = pGroupBy
| 2209-22479 | ||||||||||||||||||||||||
| 4751 | sAggInfo.pGroupBy = pGroupBy; | - | ||||||||||||||||||||||||
| 4752 | sqlite3ExprAnalyzeAggList(&sNC, pEList); | - | ||||||||||||||||||||||||
| 4753 | sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy); | - | ||||||||||||||||||||||||
| 4754 | if( pHaving
| 97-24591 | ||||||||||||||||||||||||
| 4755 | if( pGroupBy
| 6-91 | ||||||||||||||||||||||||
| 4756 | - | |||||||||||||||||||||||||
| 4757 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4758 | ; | - | ||||||||||||||||||||||||
| 4759 | - | |||||||||||||||||||||||||
| 4760 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4761 | ; | - | ||||||||||||||||||||||||
| 4762 | - | |||||||||||||||||||||||||
| 4763 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4764 | ; | - | ||||||||||||||||||||||||
| 4765 | havingToWhere(pParse, p); | - | ||||||||||||||||||||||||
| 4766 | pWhere = p->pWhere; | - | ||||||||||||||||||||||||
| 4767 | } executed 91 times by 1 test: end of blockExecuted by:
| 91 | ||||||||||||||||||||||||
| 4768 | sqlite3ExprAnalyzeAggregates(&sNC, pHaving); | - | ||||||||||||||||||||||||
| 4769 | } executed 97 times by 1 test: end of blockExecuted by:
| 97 | ||||||||||||||||||||||||
| 4770 | sAggInfo.nAccumulator = sAggInfo.nColumn; | - | ||||||||||||||||||||||||
| 4771 | if( p->pGroupBy==0
| 6-22479 | ||||||||||||||||||||||||
| 4772 | minMaxFlag = minMaxQuery(db, sAggInfo.aFunc[0].pExpr, &pMinMaxOrderBy); | - | ||||||||||||||||||||||||
| 4773 | } executed 19765 times by 4 tests: else{end of blockExecuted by:
| 19765 | ||||||||||||||||||||||||
| 4774 | minMaxFlag = 0x0000; | - | ||||||||||||||||||||||||
| 4775 | } executed 4923 times by 1 test: end of blockExecuted by:
| 4923 | ||||||||||||||||||||||||
| 4776 | for(i=0; i<sAggInfo.nFunc
| 24688-35663 | ||||||||||||||||||||||||
| 4777 | - | |||||||||||||||||||||||||
| 4778 | ((void) (0)) | - | ||||||||||||||||||||||||
| 4779 | ; | - | ||||||||||||||||||||||||
| 4780 | sNC.ncFlags |= 0x0008; | - | ||||||||||||||||||||||||
| 4781 | sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList); | - | ||||||||||||||||||||||||
| 4782 | sNC.ncFlags &= ~0x0008; | - | ||||||||||||||||||||||||
| 4783 | } executed 35663 times by 4 tests: end of blockExecuted by:
| 35663 | ||||||||||||||||||||||||
| 4784 | sAggInfo.mxReg = pParse->nMem; | - | ||||||||||||||||||||||||
| 4785 | if( db->mallocFailed
never executed: select_end;goto select_end;never executed: goto select_end; | 0-24688 | ||||||||||||||||||||||||
| 4786 | if( pGroupBy
| 2209-22479 | ||||||||||||||||||||||||
| 4787 | KeyInfo *pKeyInfo; | - | ||||||||||||||||||||||||
| 4788 | int addr1; | - | ||||||||||||||||||||||||
| 4789 | int addrOutputRow; | - | ||||||||||||||||||||||||
| 4790 | int regOutputRow; | - | ||||||||||||||||||||||||
| 4791 | int addrSetAbort; | - | ||||||||||||||||||||||||
| 4792 | int addrTopOfLoop; | - | ||||||||||||||||||||||||
| 4793 | int addrSortingIdx; | - | ||||||||||||||||||||||||
| 4794 | int addrReset; | - | ||||||||||||||||||||||||
| 4795 | int regReset; | - | ||||||||||||||||||||||||
| 4796 | - | |||||||||||||||||||||||||
| 4797 | - | |||||||||||||||||||||||||
| 4798 | - | |||||||||||||||||||||||||
| 4799 | - | |||||||||||||||||||||||||
| 4800 | - | |||||||||||||||||||||||||
| 4801 | - | |||||||||||||||||||||||||
| 4802 | sAggInfo.sortingIdx = pParse->nTab++; | - | ||||||||||||||||||||||||
| 4803 | pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pGroupBy,0,sAggInfo.nColumn); | - | ||||||||||||||||||||||||
| 4804 | addrSortingIdx = sqlite3VdbeAddOp4(v, 114, | - | ||||||||||||||||||||||||
| 4805 | sAggInfo.sortingIdx, sAggInfo.nSortingColumn, | - | ||||||||||||||||||||||||
| 4806 | 0, (char*)pKeyInfo, (-9)); | - | ||||||||||||||||||||||||
| 4807 | - | |||||||||||||||||||||||||
| 4808 | - | |||||||||||||||||||||||||
| 4809 | - | |||||||||||||||||||||||||
| 4810 | iUseFlag = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4811 | iAbortFlag = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4812 | regOutputRow = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4813 | addrOutputRow = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4814 | regReset = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 4815 | addrReset = sqlite3VdbeMakeLabel(v); | - | ||||||||||||||||||||||||
| 4816 | iAMem = pParse->nMem + 1; | - | ||||||||||||||||||||||||
| 4817 | pParse->nMem += pGroupBy->nExpr; | - | ||||||||||||||||||||||||
| 4818 | iBMem = pParse->nMem + 1; | - | ||||||||||||||||||||||||
| 4819 | pParse->nMem += pGroupBy->nExpr; | - | ||||||||||||||||||||||||
| 4820 | sqlite3VdbeAddOp2(v, 70, 0, iAbortFlag); | - | ||||||||||||||||||||||||
| 4821 | ; | - | ||||||||||||||||||||||||
| 4822 | sqlite3VdbeAddOp3(v, 73, 0, iAMem, iAMem+pGroupBy->nExpr-1); | - | ||||||||||||||||||||||||
| 4823 | - | |||||||||||||||||||||||||
| 4824 | - | |||||||||||||||||||||||||
| 4825 | - | |||||||||||||||||||||||||
| 4826 | - | |||||||||||||||||||||||||
| 4827 | - | |||||||||||||||||||||||||
| 4828 | - | |||||||||||||||||||||||||
| 4829 | sqlite3VdbeAddOp2(v, 12, regReset, addrReset); | - | ||||||||||||||||||||||||
| 4830 | ; | - | ||||||||||||||||||||||||
| 4831 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0, | - | ||||||||||||||||||||||||
| 4832 | 0x0040 | (orderByGrp ? 0x0200 : 0), 0 | - | ||||||||||||||||||||||||
| 4833 | ); | - | ||||||||||||||||||||||||
| 4834 | if( pWInfo==0
executed 2 times by 1 test: select_end;goto select_end;Executed by:
executed 2 times by 1 test: goto select_end;Executed by:
| 2-2207 | ||||||||||||||||||||||||
| 4835 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr
| 107-2100 | ||||||||||||||||||||||||
| 4836 | - | |||||||||||||||||||||||||
| 4837 | - | |||||||||||||||||||||||||
| 4838 | - | |||||||||||||||||||||||||
| 4839 | - | |||||||||||||||||||||||||
| 4840 | groupBySort = 0; | - | ||||||||||||||||||||||||
| 4841 | } executed 107 times by 1 test: else{end of blockExecuted by:
| 107 | ||||||||||||||||||||||||
| 4842 | - | |||||||||||||||||||||||||
| 4843 | - | |||||||||||||||||||||||||
| 4844 | - | |||||||||||||||||||||||||
| 4845 | - | |||||||||||||||||||||||||
| 4846 | - | |||||||||||||||||||||||||
| 4847 | int regBase; | - | ||||||||||||||||||||||||
| 4848 | int regRecord; | - | ||||||||||||||||||||||||
| 4849 | int nCol; | - | ||||||||||||||||||||||||
| 4850 | int nGroupBy; | - | ||||||||||||||||||||||||
| 4851 | - | |||||||||||||||||||||||||
| 4852 | explainTempTable(pParse, | - | ||||||||||||||||||||||||
| 4853 | (sDistinct.isTnct && (p->selFlags&0x00001)==0) ? | - | ||||||||||||||||||||||||
| 4854 | "DISTINCT" : "GROUP BY"); | - | ||||||||||||||||||||||||
| 4855 | - | |||||||||||||||||||||||||
| 4856 | groupBySort = 1; | - | ||||||||||||||||||||||||
| 4857 | nGroupBy = pGroupBy->nExpr; | - | ||||||||||||||||||||||||
| 4858 | nCol = nGroupBy; | - | ||||||||||||||||||||||||
| 4859 | j = nGroupBy; | - | ||||||||||||||||||||||||
| 4860 | for(i=0; i<sAggInfo.nColumn
| 2100-5716 | ||||||||||||||||||||||||
| 4861 | if( sAggInfo.aCol[i].iSorterColumn>=j
| 2011-3705 | ||||||||||||||||||||||||
| 4862 | nCol++; | - | ||||||||||||||||||||||||
| 4863 | j++; | - | ||||||||||||||||||||||||
| 4864 | } executed 3705 times by 1 test: end of blockExecuted by:
| 3705 | ||||||||||||||||||||||||
| 4865 | } executed 5716 times by 1 test: end of blockExecuted by:
| 5716 | ||||||||||||||||||||||||
| 4866 | regBase = sqlite3GetTempRange(pParse, nCol); | - | ||||||||||||||||||||||||
| 4867 | sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0); | - | ||||||||||||||||||||||||
| 4868 | j = nGroupBy; | - | ||||||||||||||||||||||||
| 4869 | for(i=0; i<sAggInfo.nColumn
| 2100-5716 | ||||||||||||||||||||||||
| 4870 | struct AggInfo_col *pCol = &sAggInfo.aCol[i]; | - | ||||||||||||||||||||||||
| 4871 | if( pCol->iSorterColumn>=j
| 2011-3705 | ||||||||||||||||||||||||
| 4872 | int r1 = j + regBase; | - | ||||||||||||||||||||||||
| 4873 | sqlite3ExprCodeGetColumnOfTable(v, | - | ||||||||||||||||||||||||
| 4874 | pCol->pTab, pCol->iTable, pCol->iColumn, r1); | - | ||||||||||||||||||||||||
| 4875 | j++; | - | ||||||||||||||||||||||||
| 4876 | } executed 3705 times by 1 test: end of blockExecuted by:
| 3705 | ||||||||||||||||||||||||
| 4877 | } executed 5716 times by 1 test: end of blockExecuted by:
| 5716 | ||||||||||||||||||||||||
| 4878 | regRecord = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 4879 | sqlite3VdbeAddOp3(v, 102, regBase, nCol, regRecord); | - | ||||||||||||||||||||||||
| 4880 | sqlite3VdbeAddOp2(v, 132, sAggInfo.sortingIdx, regRecord); | - | ||||||||||||||||||||||||
| 4881 | sqlite3ReleaseTempReg(pParse, regRecord); | - | ||||||||||||||||||||||||
| 4882 | sqlite3ReleaseTempRange(pParse, regBase, nCol); | - | ||||||||||||||||||||||||
| 4883 | sqlite3WhereEnd(pWInfo); | - | ||||||||||||||||||||||||
| 4884 | sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++; | - | ||||||||||||||||||||||||
| 4885 | sortOut = sqlite3GetTempReg(pParse); | - | ||||||||||||||||||||||||
| 4886 | sqlite3VdbeAddOp3(v, 116, sortPTab, sortOut, nCol); | - | ||||||||||||||||||||||||
| 4887 | sqlite3VdbeAddOp2(v, 34, sAggInfo.sortingIdx, addrEnd); | - | ||||||||||||||||||||||||
| 4888 | ; ; | - | ||||||||||||||||||||||||
| 4889 | sAggInfo.useSortingIdx = 1; | - | ||||||||||||||||||||||||
| 4890 | } executed 2100 times by 1 test: end of blockExecuted by:
| 2100 | ||||||||||||||||||||||||
| 4891 | if( orderByGrp
| 2-1875 | ||||||||||||||||||||||||
| 4892 | && (groupBySort
| 5-1850 | ||||||||||||||||||||||||
| 4893 | ){ | - | ||||||||||||||||||||||||
| 4894 | sSort.pOrderBy = 0; | - | ||||||||||||||||||||||||
| 4895 | sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex); | - | ||||||||||||||||||||||||
| 4896 | } executed 1868 times by 1 test: end of blockExecuted by:
| 1868 | ||||||||||||||||||||||||
| 4897 | - | |||||||||||||||||||||||||
| 4898 | - | |||||||||||||||||||||||||
| 4899 | - | |||||||||||||||||||||||||
| 4900 | - | |||||||||||||||||||||||||
| 4901 | - | |||||||||||||||||||||||||
| 4902 | - | |||||||||||||||||||||||||
| 4903 | addrTopOfLoop = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 4904 | if( groupBySort
| 107-2100 | ||||||||||||||||||||||||
| 4905 | sqlite3VdbeAddOp3(v, 127, sAggInfo.sortingIdx, | - | ||||||||||||||||||||||||
| 4906 | sortOut, sortPTab); | - | ||||||||||||||||||||||||
| 4907 | } executed 2100 times by 1 test: end of blockExecuted by:
| 2100 | ||||||||||||||||||||||||
| 4908 | for(j=0; j<pGroupBy->nExpr
| 2207-2284 | ||||||||||||||||||||||||
| 4909 | if( groupBySort
| 138-2146 | ||||||||||||||||||||||||
| 4910 | sqlite3VdbeAddOp3(v, 90, sortPTab, j, iBMem+j); | - | ||||||||||||||||||||||||
| 4911 | } executed 2146 times by 1 test: else{end of blockExecuted by:
| 2146 | ||||||||||||||||||||||||
| 4912 | sAggInfo.directMode = 1; | - | ||||||||||||||||||||||||
| 4913 | sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j); | - | ||||||||||||||||||||||||
| 4914 | } executed 138 times by 1 test: end of blockExecuted by:
| 138 | ||||||||||||||||||||||||
| 4915 | } | - | ||||||||||||||||||||||||
| 4916 | sqlite3VdbeAddOp4(v, 87, iAMem, iBMem, pGroupBy->nExpr, | - | ||||||||||||||||||||||||
| 4917 | (char*)sqlite3KeyInfoRef(pKeyInfo), (-9)); | - | ||||||||||||||||||||||||
| 4918 | addr1 = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 4919 | sqlite3VdbeAddOp3(v, 16, addr1+1, 0, addr1+1); ; | - | ||||||||||||||||||||||||
| 4920 | sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr); | - | ||||||||||||||||||||||||
| 4921 | sqlite3VdbeAddOp2(v, 12, regOutputRow, addrOutputRow); | - | ||||||||||||||||||||||||
| 4922 | ; | - | ||||||||||||||||||||||||
| 4923 | sqlite3VdbeAddOp2(v, 47, iAbortFlag, addrEnd); ; | - | ||||||||||||||||||||||||
| 4924 | ; | - | ||||||||||||||||||||||||
| 4925 | sqlite3VdbeAddOp2(v, 12, regReset, addrReset); | - | ||||||||||||||||||||||||
| 4926 | ; | - | ||||||||||||||||||||||||
| 4927 | - | |||||||||||||||||||||||||
| 4928 | - | |||||||||||||||||||||||||
| 4929 | - | |||||||||||||||||||||||||
| 4930 | - | |||||||||||||||||||||||||
| 4931 | sqlite3VdbeJumpHere(v, addr1); | - | ||||||||||||||||||||||||
| 4932 | updateAccumulator(pParse, iUseFlag, &sAggInfo); | - | ||||||||||||||||||||||||
| 4933 | sqlite3VdbeAddOp2(v, 70, 1, iUseFlag); | - | ||||||||||||||||||||||||
| 4934 | ; | - | ||||||||||||||||||||||||
| 4935 | - | |||||||||||||||||||||||||
| 4936 | - | |||||||||||||||||||||||||
| 4937 | - | |||||||||||||||||||||||||
| 4938 | if( groupBySort
| 107-2100 | ||||||||||||||||||||||||
| 4939 | sqlite3VdbeAddOp2(v, 3, sAggInfo.sortingIdx, addrTopOfLoop); | - | ||||||||||||||||||||||||
| 4940 | ; | - | ||||||||||||||||||||||||
| 4941 | } executed 2100 times by 1 test: else{end of blockExecuted by:
| 2100 | ||||||||||||||||||||||||
| 4942 | sqlite3WhereEnd(pWInfo); | - | ||||||||||||||||||||||||
| 4943 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); | - | ||||||||||||||||||||||||
| 4944 | } executed 107 times by 1 test: end of blockExecuted by:
| 107 | ||||||||||||||||||||||||
| 4945 | - | |||||||||||||||||||||||||
| 4946 | - | |||||||||||||||||||||||||
| 4947 | - | |||||||||||||||||||||||||
| 4948 | sqlite3VdbeAddOp2(v, 12, regOutputRow, addrOutputRow); | - | ||||||||||||||||||||||||
| 4949 | ; | - | ||||||||||||||||||||||||
| 4950 | - | |||||||||||||||||||||||||
| 4951 | - | |||||||||||||||||||||||||
| 4952 | - | |||||||||||||||||||||||||
| 4953 | sqlite3VdbeGoto(v, addrEnd); | - | ||||||||||||||||||||||||
| 4954 | addrSetAbort = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 4955 | sqlite3VdbeAddOp2(v, 70, 1, iAbortFlag); | - | ||||||||||||||||||||||||
| 4956 | ; | - | ||||||||||||||||||||||||
| 4957 | sqlite3VdbeAddOp1(v, 66, regOutputRow); | - | ||||||||||||||||||||||||
| 4958 | sqlite3VdbeResolveLabel(v, addrOutputRow); | - | ||||||||||||||||||||||||
| 4959 | addrOutputRow = sqlite3VdbeCurrentAddr(v); | - | ||||||||||||||||||||||||
| 4960 | sqlite3VdbeAddOp2(v, 47, iUseFlag, addrOutputRow+2); | - | ||||||||||||||||||||||||
| 4961 | ; | - | ||||||||||||||||||||||||
| 4962 | ; | - | ||||||||||||||||||||||||
| 4963 | sqlite3VdbeAddOp1(v, 66, regOutputRow); | - | ||||||||||||||||||||||||
| 4964 | finalizeAggFunctions(pParse, &sAggInfo); | - | ||||||||||||||||||||||||
| 4965 | sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, 0x10); | - | ||||||||||||||||||||||||
| 4966 | selectInnerLoop(pParse, p, -1, &sSort, | - | ||||||||||||||||||||||||
| 4967 | &sDistinct, pDest, | - | ||||||||||||||||||||||||
| 4968 | addrOutputRow+1, addrSetAbort); | - | ||||||||||||||||||||||||
| 4969 | sqlite3VdbeAddOp1(v, 66, regOutputRow); | - | ||||||||||||||||||||||||
| 4970 | ; | - | ||||||||||||||||||||||||
| 4971 | - | |||||||||||||||||||||||||
| 4972 | - | |||||||||||||||||||||||||
| 4973 | - | |||||||||||||||||||||||||
| 4974 | sqlite3VdbeResolveLabel(v, addrReset); | - | ||||||||||||||||||||||||
| 4975 | resetAccumulator(pParse, &sAggInfo); | - | ||||||||||||||||||||||||
| 4976 | sqlite3VdbeAddOp2(v, 70, 0, iUseFlag); | - | ||||||||||||||||||||||||
| 4977 | ; | - | ||||||||||||||||||||||||
| 4978 | sqlite3VdbeAddOp1(v, 66, regReset); | - | ||||||||||||||||||||||||
| 4979 | - | |||||||||||||||||||||||||
| 4980 | } executed 2207 times by 1 test: end of blockExecuted by:
| 2207 | ||||||||||||||||||||||||
| 4981 | else { | - | ||||||||||||||||||||||||
| 4982 | - | |||||||||||||||||||||||||
| 4983 | Table *pTab; | - | ||||||||||||||||||||||||
| 4984 | if( (
| 1995-20484 | ||||||||||||||||||||||||
| 4985 | const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); | - | ||||||||||||||||||||||||
| 4986 | const int iCsr = pParse->nTab++; | - | ||||||||||||||||||||||||
| 4987 | Index *pIdx; | - | ||||||||||||||||||||||||
| 4988 | KeyInfo *pKeyInfo = 0; | - | ||||||||||||||||||||||||
| 4989 | Index *pBest = 0; | - | ||||||||||||||||||||||||
| 4990 | int iRoot = pTab->tnum; | - | ||||||||||||||||||||||||
| 4991 | - | |||||||||||||||||||||||||
| 4992 | sqlite3CodeVerifySchema(pParse, iDb); | - | ||||||||||||||||||||||||
| 4993 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); | - | ||||||||||||||||||||||||
| 4994 | if( !(((pTab)->tabFlags & 0x0020)==0)
executed 19 times by 1 test: pBest = sqlite3PrimaryKeyIndex(pTab);Executed by:
| 19-1976 | ||||||||||||||||||||||||
| 4995 | for(pIdx=pTab->pIndex; pIdx
| 562-1995 | ||||||||||||||||||||||||
| 4996 | if( pIdx->bUnordered==0
| 1-561 | ||||||||||||||||||||||||
| 4997 | && pIdx->szIdxRow<pTab->szTabRow
| 211-350 | ||||||||||||||||||||||||
| 4998 | && pIdx->pPartIdxWhere==0
| 4-346 | ||||||||||||||||||||||||
| 4999 | && (!pBest
| 2-215 | ||||||||||||||||||||||||
| 5000 | ){ | - | ||||||||||||||||||||||||
| 5001 | pBest = pIdx; | - | ||||||||||||||||||||||||
| 5002 | } executed 217 times by 1 test: end of blockExecuted by:
| 217 | ||||||||||||||||||||||||
| 5003 | } executed 562 times by 1 test: end of blockExecuted by:
| 562 | ||||||||||||||||||||||||
| 5004 | if( pBest
| 234-1761 | ||||||||||||||||||||||||
| 5005 | iRoot = pBest->tnum; | - | ||||||||||||||||||||||||
| 5006 | pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pBest); | - | ||||||||||||||||||||||||
| 5007 | } executed 234 times by 1 test: end of blockExecuted by:
| 234 | ||||||||||||||||||||||||
| 5008 | - | |||||||||||||||||||||||||
| 5009 | - | |||||||||||||||||||||||||
| 5010 | sqlite3VdbeAddOp4Int(v, 109, iCsr, iRoot, iDb, 1); | - | ||||||||||||||||||||||||
| 5011 | if( pKeyInfo
| 234-1761 | ||||||||||||||||||||||||
| 5012 | sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, (-9)); | - | ||||||||||||||||||||||||
| 5013 | } executed 234 times by 1 test: end of blockExecuted by:
| 234 | ||||||||||||||||||||||||
| 5014 | sqlite3VdbeAddOp2(v, 104, iCsr, sAggInfo.aFunc[0].iMem); | - | ||||||||||||||||||||||||
| 5015 | sqlite3VdbeAddOp1(v, 117, iCsr); | - | ||||||||||||||||||||||||
| 5016 | explainSimpleCount(pParse, pTab, pBest); | - | ||||||||||||||||||||||||
| 5017 | } executed 1995 times by 4 tests: elseend of blockExecuted by:
| 1995 | ||||||||||||||||||||||||
| 5018 | - | |||||||||||||||||||||||||
| 5019 | { | - | ||||||||||||||||||||||||
| 5020 | int regAcc = 0; | - | ||||||||||||||||||||||||
| 5021 | - | |||||||||||||||||||||||||
| 5022 | - | |||||||||||||||||||||||||
| 5023 | - | |||||||||||||||||||||||||
| 5024 | - | |||||||||||||||||||||||||
| 5025 | - | |||||||||||||||||||||||||
| 5026 | - | |||||||||||||||||||||||||
| 5027 | if( sAggInfo.nAccumulator
| 51-20433 | ||||||||||||||||||||||||
| 5028 | for(i=0; i<sAggInfo.nFunc
| 20-51 | ||||||||||||||||||||||||
| 5029 | if( sAggInfo.aFunc[i].pFunc->funcFlags&0x0020
executed 31 times by 1 test: break;Executed by:
| 20-31 | ||||||||||||||||||||||||
| 5030 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 5031 | if( i==sAggInfo.nFunc
| 20-31 | ||||||||||||||||||||||||
| 5032 | regAcc = ++pParse->nMem; | - | ||||||||||||||||||||||||
| 5033 | sqlite3VdbeAddOp2(v, 70, 0, regAcc); | - | ||||||||||||||||||||||||
| 5034 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 5035 | } executed 51 times by 1 test: end of blockExecuted by:
| 51 | ||||||||||||||||||||||||
| 5036 | - | |||||||||||||||||||||||||
| 5037 | - | |||||||||||||||||||||||||
| 5038 | - | |||||||||||||||||||||||||
| 5039 | - | |||||||||||||||||||||||||
| 5040 | - | |||||||||||||||||||||||||
| 5041 | - | |||||||||||||||||||||||||
| 5042 | ((void) (0)) | - | ||||||||||||||||||||||||
| 5043 | ; | - | ||||||||||||||||||||||||
| 5044 | resetAccumulator(pParse, &sAggInfo); | - | ||||||||||||||||||||||||
| 5045 | - | |||||||||||||||||||||||||
| 5046 | - | |||||||||||||||||||||||||
| 5047 | - | |||||||||||||||||||||||||
| 5048 | - | |||||||||||||||||||||||||
| 5049 | - | |||||||||||||||||||||||||
| 5050 | - | |||||||||||||||||||||||||
| 5051 | - | |||||||||||||||||||||||||
| 5052 | ((void) (0)) | - | ||||||||||||||||||||||||
| 5053 | ; | - | ||||||||||||||||||||||||
| 5054 | - | |||||||||||||||||||||||||
| 5055 | ((void) (0)) | - | ||||||||||||||||||||||||
| 5056 | ; | - | ||||||||||||||||||||||||
| 5057 | - | |||||||||||||||||||||||||
| 5058 | ; | - | ||||||||||||||||||||||||
| 5059 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy, | - | ||||||||||||||||||||||||
| 5060 | 0, minMaxFlag, 0); | - | ||||||||||||||||||||||||
| 5061 | if( pWInfo==0
| 3-20481 | ||||||||||||||||||||||||
| 5062 | goto executed 3 times by 1 test: select_end;goto select_end;Executed by:
executed 3 times by 1 test: goto select_end;Executed by:
| 3 | ||||||||||||||||||||||||
| 5063 | } | - | ||||||||||||||||||||||||
| 5064 | updateAccumulator(pParse, regAcc, &sAggInfo); | - | ||||||||||||||||||||||||
| 5065 | if( regAcc
executed 20 times by 1 test: sqlite3VdbeAddOp2(v, 70, 1, regAcc);Executed by:
| 20-20461 | ||||||||||||||||||||||||
| 5066 | if( sqlite3WhereIsOrdered(pWInfo)>0
| 1065-19416 | ||||||||||||||||||||||||
| 5067 | sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo)); | - | ||||||||||||||||||||||||
| 5068 | - | |||||||||||||||||||||||||
| 5069 | ; | - | ||||||||||||||||||||||||
| 5070 | } executed 1065 times by 1 test: end of blockExecuted by:
| 1065 | ||||||||||||||||||||||||
| 5071 | sqlite3WhereEnd(pWInfo); | - | ||||||||||||||||||||||||
| 5072 | finalizeAggFunctions(pParse, &sAggInfo); | - | ||||||||||||||||||||||||
| 5073 | } executed 20481 times by 1 test: end of blockExecuted by:
| 20481 | ||||||||||||||||||||||||
| 5074 | - | |||||||||||||||||||||||||
| 5075 | sSort.pOrderBy = 0; | - | ||||||||||||||||||||||||
| 5076 | sqlite3ExprIfFalse(pParse, pHaving, addrEnd, 0x10); | - | ||||||||||||||||||||||||
| 5077 | selectInnerLoop(pParse, p, -1, 0, 0, | - | ||||||||||||||||||||||||
| 5078 | pDest, addrEnd, addrEnd); | - | ||||||||||||||||||||||||
| 5079 | } executed 22476 times by 4 tests: end of blockExecuted by:
| 22476 | ||||||||||||||||||||||||
| 5080 | sqlite3VdbeResolveLabel(v, addrEnd); | - | ||||||||||||||||||||||||
| 5081 | - | |||||||||||||||||||||||||
| 5082 | } executed 24683 times by 4 tests: end of blockExecuted by:
| 24683 | ||||||||||||||||||||||||
| 5083 | - | |||||||||||||||||||||||||
| 5084 | if( sDistinct.eTnctType==3
| 203-274907 | ||||||||||||||||||||||||
| 5085 | explainTempTable(pParse, "DISTINCT"); | - | ||||||||||||||||||||||||
| 5086 | } executed 203 times by 1 test: end of blockExecuted by:
| 203 | ||||||||||||||||||||||||
| 5087 | - | |||||||||||||||||||||||||
| 5088 | - | |||||||||||||||||||||||||
| 5089 | - | |||||||||||||||||||||||||
| 5090 | - | |||||||||||||||||||||||||
| 5091 | if( sSort.pOrderBy
| 13126-261984 | ||||||||||||||||||||||||
| 5092 | explainTempTable(pParse, | - | ||||||||||||||||||||||||
| 5093 | sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY"); | - | ||||||||||||||||||||||||
| 5094 | - | |||||||||||||||||||||||||
| 5095 | ((void) (0)) | - | ||||||||||||||||||||||||
| 5096 | ; | - | ||||||||||||||||||||||||
| 5097 | generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest); | - | ||||||||||||||||||||||||
| 5098 | } executed 13126 times by 1 test: end of blockExecuted by:
| 13126 | ||||||||||||||||||||||||
| 5099 | - | |||||||||||||||||||||||||
| 5100 | - | |||||||||||||||||||||||||
| 5101 | - | |||||||||||||||||||||||||
| 5102 | sqlite3VdbeResolveLabel(v, iEnd); | - | ||||||||||||||||||||||||
| 5103 | - | |||||||||||||||||||||||||
| 5104 | - | |||||||||||||||||||||||||
| 5105 | - | |||||||||||||||||||||||||
| 5106 | rc = (pParse->nErr>0); | - | ||||||||||||||||||||||||
| 5107 | - | |||||||||||||||||||||||||
| 5108 | - | |||||||||||||||||||||||||
| 5109 | - | |||||||||||||||||||||||||
| 5110 | - | |||||||||||||||||||||||||
| 5111 | select_end: code before this statement executed 275110 times by 435 tests: select_end:Executed by:
| 275110 | ||||||||||||||||||||||||
| 5112 | sqlite3ExprListDelete(db, pMinMaxOrderBy); | - | ||||||||||||||||||||||||
| 5113 | sqlite3DbFree(db, sAggInfo.aCol); | - | ||||||||||||||||||||||||
| 5114 | sqlite3DbFree(db, sAggInfo.aFunc); | - | ||||||||||||||||||||||||
| 5115 | - | |||||||||||||||||||||||||
| 5116 | - | |||||||||||||||||||||||||
| 5117 | - | |||||||||||||||||||||||||
| 5118 | - | |||||||||||||||||||||||||
| 5119 | - | |||||||||||||||||||||||||
| 5120 | - | |||||||||||||||||||||||||
| 5121 | sqlite3VdbeExplainPop(pParse); | - | ||||||||||||||||||||||||
| 5122 | return executed 277374 times by 436 tests: rc;return rc;Executed by:
executed 277374 times by 436 tests: return rc;Executed by:
| 277374 | ||||||||||||||||||||||||
| 5123 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |