Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch est-count-pragma-vtab Excluding Merge-Ins
This is equivalent to a diff from 546821e29e to 4b73ee33f3
2016-12-16
| ||
18:14 | Built-in PRAGMA statements without side-effects can be invoked as table-valued functions by prefixing their name with "pragma_". (check-in: d66ec5cfb6 user: drh tags: trunk) | |
16:49 | Experimental merge of the est_count_pragma and the pragma-as-vtab branches. (Closed-Leaf check-in: 4b73ee33f3 user: drh tags: est-count-pragma-vtab) | |
16:13 | Merge the pragma-as-vtab change into this branch. (check-in: 4ba45e7223 user: dan tags: fkey-missing-indexes) | |
15:57 | Merge recent trunk enhancements. (check-in: 74a0ca1f15 user: drh tags: est_count_pragma) | |
04:20 | Fix an error in the way the "schema" argument to some pragma virtual tables is handled. (Closed-Leaf check-in: 546821e29e user: drh tags: pragma-as-vtab) | |
02:31 | Simplifications to facilitate full test coverage. (check-in: 01afc51597 user: drh tags: pragma-as-vtab) | |
Changes to main.mk.
︙ | |||
494 495 496 497 498 499 500 501 502 503 504 505 506 507 | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | + + + + | sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB) dbhash$(EXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h $(TCCX) -o dbhash$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/dbhash.c sqlite3.c $(TLIBS) $(THREADLIB) faststat1$(EXE): $(TOP)/tool/faststat1.c sqlite3.c sqlite3.h $(TCCX) -o faststat1$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/faststat1.c sqlite3.c $(TLIBS) $(THREADLIB) scrub$(EXE): $(TOP)/ext/misc/scrub.c sqlite3.o $(TCC) -I. -DSCRUB_STANDALONE -o scrub$(EXE) $(TOP)/ext/misc/scrub.c sqlite3.o $(THREADLIB) srcck1$(EXE): $(TOP)/tool/srcck1.c $(BCC) -o srcck1$(EXE) $(TOP)/tool/srcck1.c |
︙ |
Changes to src/btree.c.
︙ | |||
5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 | 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | pCur->curFlags &= ~BTCF_AtLast; } } } return rc; } /* ** Move the cursor pCur to a location within its b-tree that is ** approximately the x/1e9*nRow entry in the table, assuming the ** table contains nRow entries. So, in other words, if x==0 move ** to the first entry and if x=1e9 move to the last entry and if ** x=5e8 move to the middle entry. The final landing spot is ** approximate. ** ** Write an estimate of the number of entries in the b-tree into ** the *pnRowEst variable. ** ** This routine works by first moving the cursor to the root of the ** b-tree, then following pointers down to a leaf, selecting a pointer ** according to x. ** ** The estimated number of entries is found by multiplying the number of ** entries on the leaf page by the number of pointers at each layer of ** non-leaf pages. ** ** Return SQLITE_OK on success or an error code if problems are encountered. */ int sqlite3BtreeMovetoProportional( BtCursor *pCur, /* Cursor to reposition */ u32 x, /* approximate location to position the cursor */ sqlite3_uint64 *pnRowEst /* Write estimated entry count here */ ){ sqlite3_uint64 n = 1; int rc; Pgno chldPg; u32 mx = 1000000000; u32 perChild; u16 rx; MemPage *pPage; rc = moveToRoot(pCur); if( rc ) return rc; pPage = pCur->apPage[0]; while( !pPage->leaf ){ perChild = (mx+pPage->nCell)/(pPage->nCell+1); if( perChild<1 ) perChild = 1; rx = x/perChild; x %= perChild; mx = perChild; if( rx>=pPage->nCell ){ chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); }else{ chldPg = get4byte(findCell(pPage,rx)); } n *= pPage->nCell+1; pCur->aiIdx[pCur->iPage] = rx; rc = moveToChild(pCur, chldPg); if( rc ) return rc; pPage = pCur->apPage[pCur->iPage]; } *pnRowEst = n*pPage->nCell; if( pPage->nCell==0 ){ rx = 0; }else{ perChild = mx/pPage->nCell; if( perChild<1 ) perChild = 1; rx = x/perChild; if( rx>=pPage->nCell ) rx = pPage->nCell-1; } pCur->aiIdx[pCur->iPage] = rx; return SQLITE_OK; } /* Move the cursor so that it points to an entry near the key ** specified by pIdxKey or intKey. Return a success code. ** ** For INTKEY tables, the intKey parameter is used. pIdxKey ** must be NULL. For index tables, pIdxKey is used and intKey ** is ignored. |
︙ |
Changes to src/btree.h.
︙ | |||
234 235 236 237 238 239 240 241 242 243 244 245 246 247 | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | + | void sqlite3BtreeCursorZero(BtCursor*); void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned); #ifdef SQLITE_ENABLE_CURSOR_HINTS void sqlite3BtreeCursorHint(BtCursor*, int, ...); #endif int sqlite3BtreeCloseCursor(BtCursor*); int sqlite3BtreeMovetoProportional(BtCursor*,u32,u64*); int sqlite3BtreeMovetoUnpacked( BtCursor*, UnpackedRecord *pUnKey, i64 intKey, int bias, int *pRes ); |
︙ |
Changes to src/build.c.
︙ | |||
3580 3581 3582 3583 3584 3585 3586 3587 | 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 | + + + + - + + + + + + - + - + - + + + + + | } /* ** Append a new element to the given IdList. Create a new IdList if ** need be. ** ** A new IdList is returned, or NULL if malloc() fails. ** ** The zName must have been obtained from sqlite3DbMalloc(). This routine ** accepts ownership of the zName string and will ensure that it is freed ** when no longer in use. */ |
︙ |
Changes to src/parse.y.
︙ | |||
200 201 202 203 204 205 206 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | - + + + + + | %left BITAND BITOR LSHIFT RSHIFT. %left PLUS MINUS. %left STAR SLASH REM. %left CONCAT. %left COLLATE. %right BITNOT. |
︙ | |||
250 251 252 253 254 255 256 | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | - - + + | } typetoken(A) ::= typename(A) LP signed COMMA signed RP(Y). { A.n = (int)(&Y.z[Y.n] - A.z); } %type typename {Token} typename(A) ::= ids(A). typename(A) ::= typename(A) ids(Y). {A.n=Y.n+(int)(Y.z-A.z);} |
︙ | |||
803 804 805 806 807 808 809 | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | - + - + + - + | insert_cmd(A) ::= REPLACE. {A = OE_Replace;} %type idlist_opt {IdList*} %destructor idlist_opt {sqlite3IdListDelete(pParse->db, $$);} %type idlist {IdList*} %destructor idlist {sqlite3IdListDelete(pParse->db, $$);} |
︙ | |||
1321 1322 1323 1324 1325 1326 1327 | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 | - + - - - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + - - - - | cmd ::= VACUUM nm(X). {sqlite3Vacuum(pParse,&X);} %endif SQLITE_OMIT_ATTACH %endif SQLITE_OMIT_VACUUM ///////////////////////////// The PRAGMA command ///////////////////////////// // %ifndef SQLITE_OMIT_PRAGMA |
︙ |
Changes to src/pragma.c.
︙ | |||
296 297 298 299 300 301 302 | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | - + - - - - - + - - + - + - + - - - - + - | } /* ** Process a pragma statement. ** ** Pragmas are of this form: ** |
︙ | |||
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | + + + + | } break; case PragTyp_INDEX_INFO: if( zRight ){ Index *pIdx; Table *pTab; pIdx = sqlite3FindIndex(db, zRight, zDb); if( pIdx==0 ){ pTab = sqlite3FindTable(db, zRight, zDb); if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab); } if( pIdx ){ int i; int mx; if( pPragma->iArg ){ /* PRAGMA index_xinfo (newer version with more rows and columns) */ mx = pIdx->nColumn; pParse->nMem = 6; |
︙ | |||
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | case PragTyp_CASE_SENSITIVE_LIKE: { if( zRight ){ sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0)); } } break; /* ** PRAGMA est_row_cnt(<table-or-index>,<fraction>); ** ** Seek in <table-or-index> through the first <fraction> of rows and ** estimate the total number of rows based on the path back up to the ** root. */ case PragTyp_EST_COUNT: { Index *pIdx; Table *pTab = 0; Pgno iRoot = 0; const char *zName = 0; int regResult; double r; if( (pIdx = sqlite3FindIndex(db, zRight, zDb))!=0 ){ iRoot = pIdx->tnum; zName = pIdx->zName; }else if( (pTab = sqlite3FindTable(db, zRight, zDb))!=0 ){ zName = pTab->zName; if( HasRowid(pTab) ){ iRoot = pTab->tnum; }else{ pIdx = sqlite3PrimaryKeyIndex(pTab); iRoot = pIdx->tnum; } }else{ break; } sqlite3TableLock(pParse, iDb, iRoot, 0, zName); regResult = ++pParse->nMem; if( pValues->nId>=2 ){ const char *z = pValues->a[1].zName; sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); }else{ r = 0.5; } if( r<0.0 ) r = 0.0; if( r>1.0 ) r = 1.0; sqlite3CodeVerifySchema(pParse, iDb); pParse->nTab++; sqlite3VdbeAddOp4Int(v, OP_OpenRead, 0, iRoot, iDb, 1); if( pIdx ) sqlite3VdbeSetP4KeyInfo(pParse, pIdx); sqlite3VdbeAddOp3(v, OP_EstRowCnt, 0, regResult, (int)(r*1000000000)); sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 1); } break; /* ** PRAGMA btree_sample(<table-or-index>,<fraction>,<limit>); ** ** Seek in <table-or-index> through the first <fraction> of rows and ** then begin returning rows, one by one. A max of <limit> rows will ** be returned. */ case PragTyp_BTREE_SAMPLE: { Index *pIdx; Table *pTab = 0; Pgno iRoot = 0; Pgno iLock = 0; int nCol = 0; const char *zName = 0; int iLimit = 10; int i; int regResult; int regLimit; int addrTop; int addrJmp; int addrSkip; double r; if( (pIdx = sqlite3FindIndex(db, zRight, zDb))!=0 ){ iRoot = pIdx->tnum; iLock = pIdx->pTable->tnum; zName = pIdx->zName; nCol = pIdx->nColumn; }else if( (pTab = sqlite3FindTable(db, zRight, zDb))!=0 ){ zName = pTab->zName; if( HasRowid(pTab) ){ iLock = iRoot = pTab->tnum; nCol = pTab->nCol; }else{ pIdx = sqlite3PrimaryKeyIndex(pTab); iLock = iRoot = pIdx->tnum; nCol = pIdx->nColumn; } }else{ break; } sqlite3VdbeSetNumCols(v, nCol); for(i=0; i<nCol; i++){ char zCol[30]; sqlite3_snprintf(sizeof(zCol),zCol,"c%06d",i); sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT); } if( pValues->nId>=2 ){ const char *z = pValues->a[1].zName; sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); }else{ r = 0.5; } if( r<0.0 ) r = 0.0; if( r>1.0 ) r = 1.0; if( pValues->nId>=3 ){ iLimit = sqlite3Atoi(pValues->a[2].zName); } pParse->nTab++; sqlite3TableLock(pParse, iDb, iLock, 0, zName); sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeAddOp4Int(v, OP_OpenRead, 0, iRoot, iDb, nCol); if( pIdx ) sqlite3VdbeSetP4KeyInfo(pParse, pIdx); regLimit = ++pParse->nMem; regResult = pParse->nMem+1; pParse->nMem += nCol; sqlite3VdbeAddOp2(v, OP_Integer, iLimit, regLimit); addrSkip = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_EstRowCnt, 0, regResult, (int)(r*1000000000)); addrTop = sqlite3VdbeCurrentAddr(v); for(i=0; i<nCol; i++){ sqlite3VdbeAddOp3(v, OP_Column, 0, i, regResult+i); } sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nCol); addrJmp = sqlite3VdbeAddOp1(v, OP_DecrJumpZero, regLimit); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop); VdbeCoverage(v); sqlite3VdbeJumpHere(v, addrJmp); sqlite3VdbeJumpHere(v, addrSkip); } break; #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 #endif #ifndef SQLITE_OMIT_INTEGRITY_CHECK /* Pragma "quick_check" is reduced version of ** integrity_check designed to detect most database corruption |
︙ | |||
1951 1952 1953 1954 1955 1956 1957 | 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 | - + | break; #endif } /* End of the PRAGMA switch */ pragma_out: sqlite3DbFree(db, zLeft); |
︙ |
Changes to src/pragma.h.
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /* DO NOT EDIT! ** This file is automatically generated by the script at ** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit ** that script and rerun it. */ /* The various pragma types */ #define PragTyp_HEADER_VALUE 0 #define PragTyp_AUTO_VACUUM 1 #define PragTyp_FLAG 2 #define PragTyp_BTREE_SAMPLE 3 |
︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | + + + + + | {/* zName: */ "automatic_index", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_AutoIndex }, #endif #endif {/* zName: */ "btree_sample", /* ePragTyp: */ PragTyp_BTREE_SAMPLE, /* ePragFlg: */ PragFlg_NeedSchema, /* ColNames: */ 0, 0, /* iArg: */ 0 }, {/* zName: */ "busy_timeout", /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, /* ePragFlg: */ PragFlg_Result0, /* ColNames: */ 45, 1, /* iArg: */ 0 }, #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) {/* zName: */ "cache_size", |
︙ | |||
257 258 259 260 261 262 263 264 265 266 267 268 269 270 | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | + + + + + | #if !defined(SQLITE_OMIT_UTF16) {/* zName: */ "encoding", /* ePragTyp: */ PragTyp_ENCODING, /* ePragFlg: */ PragFlg_Result0, /* ColNames: */ 0, 0, /* iArg: */ 0 }, #endif {/* zName: */ "est_count", /* ePragTyp: */ PragTyp_EST_COUNT, /* ePragFlg: */ PragFlg_NeedSchema, /* ColNames: */ 0, 0, /* iArg: */ 0 }, #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) {/* zName: */ "foreign_key_check", /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, /* ePragFlg: */ PragFlg_NeedSchema, /* ColNames: */ 38, 4, /* iArg: */ 0 }, #endif |
︙ | |||
599 600 601 602 603 604 605 | 611 612 613 614 615 616 617 618 | - + | {/* zName: */ "writable_schema", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, #endif }; |
Changes to src/select.c.
︙ | |||
2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 | 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 | + | int regLimit, regOffset; /* Registers used by LIMIT and OFFSET */ /* Obtain authorization to do a recursive query */ if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return; /* Process the LIMIT and OFFSET clauses, if they exist */ addrBreak = sqlite3VdbeMakeLabel(v); p->nSelectRow = 320; /* 4 billion rows */ computeLimitRegisters(pParse, p, addrBreak); pLimit = p->pLimit; pOffset = p->pOffset; regLimit = p->iLimit; regOffset = p->iOffset; p->pLimit = p->pOffset = 0; p->iLimit = p->iOffset = 0; |
︙ | |||
5166 5167 5168 5169 5170 5171 5172 | 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 | + - + + | if( pDest->eDest==SRT_EphemTab ){ sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr); } /* Set the limiter. */ iEnd = sqlite3VdbeMakeLabel(v); if( (p->selFlags & SF_FixedLimit)==0 ){ |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
3558 3559 3560 3561 3562 3563 3564 | 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 | - + | void sqlite3ExprListSetSortOrder(ExprList*,int); void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*); void sqlite3ExprListDelete(sqlite3*, ExprList*); u32 sqlite3ExprListFlags(const ExprList*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); |
︙ | |||
3636 3637 3638 3639 3640 3641 3642 | 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 | - + | void sqlite3AutoincrementEnd(Parse *pParse); #else # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int); void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); |
︙ |
Changes to src/vdbe.c.
︙ | |||
4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 | 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if( rc ) goto abort_due_to_error; pC->nullRow = (u8)res; assert( pOp->p2>0 && pOp->p2<p->nOp ); VdbeBranchTaken(res!=0,2); if( res ) goto jump_to_p2; break; } /* ** Opcode: EstRowCnt P1 P2 P3 * * * ** ** Estimate the number of entries in btree for cursor P1 do a proportional ** seek to of P3. Store the result as a floating point value in P2. */ case OP_EstRowCnt: { /* out2 */ VdbeCursor *pC; BtCursor *pCrsr; int rc; sqlite3_uint64 n = 0; assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC->eCurType==CURTYPE_BTREE ); pCrsr = pC->uc.pCursor; assert( pCrsr ); rc = sqlite3BtreeMovetoProportional(pCrsr, pOp->p3, &n); if( rc ) goto abort_due_to_error; pOut = out2Prerelease(p, pOp); pOut->flags = MEM_Real; pOut->u.r = n; pC->nullRow = 0; pC->deferredMoveto = 0; pC->cacheStatus = CACHE_STALE; break; } /* Opcode: Next P1 P2 P3 P4 P5 ** ** Advance cursor P1 so that it points to the next key/data pair in its ** table or index. If there are no more key/value pairs then fall through ** to the following instruction. But if the cursor advance was successful, ** jump immediately to P2. |
︙ |
Changes to test/with3.test.
︙ | |||
56 57 58 59 60 61 62 63 64 | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | CREATE TABLE t1(x); WITH x1(a) AS (values(100)) INSERT INTO t1(x) SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2); SELECT * FROM t1; } {200} #------------------------------------------------------------------------- # Test that the planner notices LIMIT clauses on recursive WITH queries. # ifcapable analyze { do_execsql_test 3.1.1 { CREATE TABLE y1(a, b); CREATE INDEX y1a ON y1(a); WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000) INSERT INTO y1 SELECT i%10, i FROM cnt; ANALYZE; } do_eqp_test 3.1.2 { WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1) SELECT * FROM cnt, y1 WHERE i=a } { 3 0 0 {SCAN TABLE cnt} 1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)} 0 0 0 {SCAN SUBQUERY 1} 0 1 1 {SEARCH TABLE y1 USING INDEX y1a (a=?)} } do_eqp_test 3.1.3 { WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000000) SELECT * FROM cnt, y1 WHERE i=a } { 3 0 0 {SCAN TABLE cnt} 1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)} 0 0 1 {SCAN TABLE y1} 0 1 0 {SEARCH SUBQUERY 1 USING AUTOMATIC COVERING INDEX (i=?)} } } do_execsql_test 3.2.1 { CREATE TABLE w1(pk INTEGER PRIMARY KEY, x INTEGER); CREATE TABLE w2(pk INTEGER PRIMARY KEY); } do_eqp_test 3.2.2 { WITH RECURSIVE c(w,id) AS (SELECT 0, (SELECT pk FROM w2 LIMIT 1) UNION ALL SELECT c.w + 1, x FROM w1, c LIMIT 1) SELECT * FROM c, w2, w1 WHERE c.id=w2.pk AND c.id=w1.pk; } { 2 0 0 {EXECUTE SCALAR SUBQUERY 3} 3 0 0 {SCAN TABLE w2} 4 0 0 {SCAN TABLE w1} 4 1 1 {SCAN TABLE c} 1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)} 0 0 0 {SCAN SUBQUERY 1} 0 1 1 {SEARCH TABLE w2 USING INTEGER PRIMARY KEY (rowid=?)} 0 2 2 {SEARCH TABLE w1 USING INTEGER PRIMARY KEY (rowid=?)} } finish_test |
Changes to test/without_rowid1.test.
︙ | |||
323 324 325 326 327 328 329 330 331 332 | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | + + + + + + + + + + + + + + + + + + + | } {1 {CHECK constraint failed: t70a}} do_catchsql_test 7.3 { CREATE TABLE t70b( a INT CHECK( rowid!=33 ), b TEXT PRIMARY KEY ) WITHOUT ROWID; } {1 {no such column: rowid}} # The PRAGMA index_info and index_xinfo pragmas work on # WITHOUT ROWID tables too, but not on rowid tables. # do_execsql_test 8.1 { CREATE TABLE t80a(a TEXT, b INT, c BLOB, PRIMARY KEY(c,b)); PRAGMA index_info(t80a); } {} do_execsql_test 8.2 { PRAGMA index_xinfo(t80a); } {} do_execsql_test 8.3 { CREATE TABLE t80b(a TEXT, b INT, c BLOB, PRIMARY KEY(c,b)) WITHOUT ROWID; PRAGMA index_info(t80b); } {0 2 c 1 1 b} do_execsql_test 8.4 { PRAGMA index_xinfo(t80b); } {0 2 c 0 BINARY 1 1 1 b 0 BINARY 1 2 0 a 0 BINARY 0} finish_test |
Added tool/faststat1.c.