Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch branch-3.41 Excluding Merge-Ins
This is equivalent to a diff from 05941c2a04 to 4011b9d340
2023-04-25
| ||
15:12 | If an ON clause to the left of a RIGHT JOIN is false, that does not imply that the query returns no rows. (Leaf check-in: 4011b9d340 user: drh tags: branch-3.41) | |
14:54 | Remove unused variable ltoj accidentally added by [1783655e]. (check-in: faa1575ce0 user: dan tags: trunk) | |
14:37 | Avoid assuming that an expression in an ON() clause that evaluates to zero implies that the query will return zero rows when the query contains a RIGHT JOIN. Forum Post 95849acbe1. (check-in: 1783655ea4 user: dan tags: trunk) | |
11:52 | Fixes to SQL extension functions base64() and base85(). (check-in: ab3331f41e user: drh tags: branch-3.41) | |
2023-02-23
| ||
17:12 | Provide -DHAVE_LOG2=0 and -DHAVE_LOG10=0 compile-time options for use on systems that lack the log2() and log10() standard math library routines, to cause SQLite to substitute its own alternatives. (check-in: ff3362ab53 user: drh tags: branch-3.41) | |
2023-02-21
| ||
21:26 | Update the reuse-schema branch to version 3.41.0. (check-in: bbd35706b7 user: drh tags: reuse-schema) | |
21:19 | Update the wal2 branch to version 3.41.0. (check-in: 7bb1f6dca2 user: drh tags: wal2) | |
21:19 | Update the begin-concurrent branch to version 3.41.0 (check-in: 918aea50ed user: drh tags: begin-concurrent) | |
18:47 | Unconditionally disable -sSTRICT_JS flag in wasm build because it no longer works with emsdk 3.1.31+. (check-in: b5e0b69649 user: stephan tags: trunk) | |
18:09 | Version 3.41.0 (check-in: 05941c2a04 user: drh tags: trunk, release, version-3.41.0) | |
13:28 | Disable DQS by default in the MSVC makefile for the amalgamation tarball. (check-in: 409a19145e user: drh tags: trunk) | |
Changes to VERSION.
| 1 | - + |
|
Changes to autoconf/tea/configure.ac.
︙ | |||
15 16 17 18 19 20 21 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - + | # This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION # set as provided. These will also be added as -D defs in your Makefile # so you can encode the package version directly into the source files. # This will also define a special symbol for Windows (BUILD_<PACKAGE_NAME> # so that we create the export library with the dll. #----------------------------------------------------------------------- |
︙ |
Changes to configure.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | #! /bin/sh # Guess values for system-dependent variables and create Makefiles. |
︙ | |||
722 723 724 725 726 727 728 | 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | - - + + | subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' |
︙ | |||
1466 1467 1468 1469 1470 1471 1472 | 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 | - + | # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF |
︙ | |||
1531 1532 1533 1534 1535 1536 1537 | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | - + | --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in |
︙ | |||
1661 1662 1663 1664 1665 1666 1667 | 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 | - + | cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF |
︙ | |||
2080 2081 2082 2083 2084 2085 2086 | 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 | - + | eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. |
︙ | |||
12453 12454 12455 12456 12457 12458 12459 | 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 | - + | test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" |
︙ | |||
12519 12520 12521 12522 12523 12524 12525 | 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 | - + | Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ |
︙ |
Changes to ext/fts3/fts3_write.c.
︙ | |||
2663 2664 2665 2666 2667 2668 2669 | 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 | - + - - + + + + | ** trying to resize the buffer, return SQLITE_NOMEM. */ static int fts3MsrBufferData( Fts3MultiSegReader *pMsr, /* Multi-segment-reader handle */ char *pList, i64 nList ){ |
︙ |
Changes to ext/fts5/fts5_expr.c.
︙ | |||
403 404 405 406 407 408 409 | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | - + | } } int sqlite3Fts5ExprAnd(Fts5Expr **pp1, Fts5Expr *p2){ Fts5Parse sParse; memset(&sParse, 0, sizeof(sParse)); |
︙ | |||
428 429 430 431 432 433 434 | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | - + | } p1->nPhrase = nPhrase; p1->apExprPhrase = ap; } } sqlite3_free(p2->apExprPhrase); sqlite3_free(p2); |
︙ |
Changes to ext/fts5/test/fts5ak.test.
︙ | |||
149 150 151 152 153 154 155 156 157 | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | + + + + + + + + + + + + + + + + + + + + + + + + + + | } { {a b c x c d e} {a b c c d e} {a b c d e} } } # 2023-04-06 https://sqlite.org/forum/forumpost/cae4367d9b # # This is not a test of FTS5, but rather a test of the of what happens to # prepared statements that encounter SQLITE_SCHEMA while other prepared # statements are running. The original problem POC used FTS5, and so # is seems reasonable to put the test here. # # The vdbeaux24.test module in TH3 also tests this same behavior but # without requiring FTS5 or an other extension. # reset_db db null NULL do_execsql_test 4.0 { CREATE TABLE t5(a PRIMARY KEY); INSERT INTO t5 VALUES(0); CREATE VIRTUAL TABLE t6 USING fts5(0); DELETE FROM t6; CREATE TABLE t7(x); WITH cte(a) AS ( SELECT a FROM t5 WHERE ((0,0) IN (SELECT 0, LAG(0) OVER (PARTITION BY 0) FROM t6), 0) < (a,0) ) SELECT max(a) FROM cte; } NULL finish_test |
Changes to ext/fts5/test/fts5misc.test.
︙ | |||
438 439 440 441 442 443 444 445 446 447 | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + | do_execsql_test 16.5 { COMMIT } do_execsql_test -db db2 16.6 { SELECT * FROM x1 } {abc def} #------------------------------------------------------------------------- reset_db do_execsql_test 17.1 { CREATE VIRTUAL TABLE ft USING fts5(x, tokenize="unicode61 separators 'X'"); } do_execsql_test 17.2 { SELECT 0 FROM ft WHERE ft MATCH 'X' AND ft MATCH 'X' } do_execsql_test 17.3 { SELECT 0 FROM ft('X') } do_execsql_test 17.4 { CREATE VIRTUAL TABLE t0 USING fts5(c0, t="trigram"); INSERT INTO t0 VALUES('assertionfaultproblem'); } do_execsql_test 17.5 { SELECT 0 FROM t0(0) WHERE c0 GLOB 0; } {} do_execsql_test 17.5 { SELECT c0 FROM t0 WHERE c0 GLOB '*f*'; } {assertionfaultproblem} do_execsql_test 17.5 { SELECT c0 FROM t0 WHERE c0 GLOB '*faul*'; } {assertionfaultproblem} finish_test |
Changes to ext/misc/base64.c.
︙ | |||
143 144 145 146 147 148 149 | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | - + - + - + | *pOut++ = '\n'; } *pOut = 0; return pOut; } /* Skip over text which is not base64 numeral(s). */ |
︙ | |||
213 214 215 216 217 218 219 220 221 222 | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | + + + + + + + + - + + + + + + + + - | case SQLITE_BLOB: nb = nv; nc = 4*(nv+2/3); /* quads needed */ nc += (nc+(B64_DARK_MAX-1))/B64_DARK_MAX + 1; /* LFs and a 0-terminator */ if( nvMax < nc ){ sqlite3_result_error(context, "blob expanded to base64 too big", -1); return; } bBuf = (u8*)sqlite3_value_blob(av[0]); if( !bBuf ){ if( SQLITE_NOMEM==sqlite3_errcode(sqlite3_context_db_handle(context)) ){ goto memFail; } sqlite3_result_text(context,"",-1,SQLITE_STATIC); break; } cBuf = sqlite3_malloc(nc); if( !cBuf ) goto memFail; |
︙ |
Changes to ext/misc/base85.c.
︙ | |||
136 137 138 139 140 141 142 | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | - + - + | } #endif /* Width of base64 lines. Should be an integer multiple of 5. */ #define B85_DARK_MAX 80 |
︙ | |||
208 209 210 211 212 213 214 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | - + | } /* Decode base85 text into a byte buffer. */ static u8* fromBase85( char *pIn, int ncIn, u8 *pOut ){ if( ncIn>0 && pIn[ncIn-1]=='\n' ) --ncIn; while( ncIn>0 ){ static signed char nboi[] = { 0, 0, 1, 2, 3, 4 }; |
︙ | |||
292 293 294 295 296 297 298 299 300 301 | 292 293 294 295 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 | + + + + + + + + - + + + + + + + + - | case SQLITE_BLOB: nb = nv; /* ulongs tail newlines tailenc+nul*/ nc = 5*(nv/4) + nv%4 + nv/64+1 + 2; if( nvMax < nc ){ sqlite3_result_error(context, "blob expanded to base85 too big", -1); return; } bBuf = (u8*)sqlite3_value_blob(av[0]); if( !bBuf ){ if( SQLITE_NOMEM==sqlite3_errcode(sqlite3_context_db_handle(context)) ){ goto memFail; } sqlite3_result_text(context,"",-1,SQLITE_STATIC); break; } cBuf = sqlite3_malloc(nc); if( !cBuf ) goto memFail; |
︙ |
Changes to ext/misc/zipfile.c.
︙ | |||
1093 1094 1095 1096 1097 1098 1099 | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | - + + + + | } sqlite3_free(aFree); }else{ /* Figure out if this is a directory or a zero-sized file. Consider ** it to be a directory either if the mode suggests so, or if ** the final character in the name is '/'. */ u32 mode = pCDS->iExternalAttr >> 16; |
︙ |
Changes to ext/recover/dbdata.c.
︙ | |||
508 509 510 511 512 513 514 | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | - + + + + + | int bNextPage = 0; if( pCsr->aPage==0 ){ while( 1 ){ if( pCsr->bOnePage==0 && pCsr->iPgno>pCsr->szDb ) return SQLITE_OK; rc = dbdataLoadPage(pCsr, pCsr->iPgno, &pCsr->aPage, &pCsr->nPage); if( rc!=SQLITE_OK ) return rc; |
︙ | |||
746 747 748 749 750 751 752 | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | - - + | ** and return SQLITE_OK. Otherwise, return an SQLite error code. */ static int dbdataGetEncoding(DbdataCursor *pCsr){ int rc = SQLITE_OK; int nPg1 = 0; u8 *aPg1 = 0; rc = dbdataLoadPage(pCsr, 1, &aPg1, &nPg1); |
︙ |
Changes to src/alter.c.
︙ | |||
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 | 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 | + + + + + + + + + + + + + | }else{ rc = SQLITE_NOMEM; } sqlite3_free(zQuot); return rc; } /* ** Set all pEList->a[].fg.eEName fields in the expression-list to val. */ static void renameSetENames(ExprList *pEList, int val){ if( pEList ){ int i; for(i=0; i<pEList->nExpr; i++){ assert( val==ENAME_NAME || pEList->a[i].fg.eEName==ENAME_NAME ); pEList->a[i].fg.eEName = val; } } } /* ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming ** it was read from the schema of database zDb. Return SQLITE_OK if ** successful. Otherwise, return an SQLite error code and leave an error ** message in the Parse object. */ |
︙ | |||
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | 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 | + + + + + + + + + + | pParse, pStep->pExprList, pSrc, 0, 0, 0, 0, 0, 0 ); if( pSel==0 ){ pStep->pExprList = 0; pSrc = 0; rc = SQLITE_NOMEM; }else{ /* pStep->pExprList contains an expression-list used for an UPDATE ** statement. So the a[].zEName values are the RHS of the ** "<col> = <expr>" clauses of the UPDATE statement. So, before ** running SelectPrep(), change all the eEName values in ** pStep->pExprList to ENAME_SPAN (from their current value of ** ENAME_NAME). This is to prevent any ids in ON() clauses that are ** part of pSrc from being incorrectly resolved against the ** a[].zEName values as if they were column aliases. */ renameSetENames(pStep->pExprList, ENAME_SPAN); sqlite3SelectPrep(pParse, pSel, 0); renameSetENames(pStep->pExprList, ENAME_NAME); rc = pParse->nErr ? SQLITE_ERROR : SQLITE_OK; assert( pStep->pExprList==0 || pStep->pExprList==pSel->pEList ); assert( pSrc==pSel->pSrc ); if( pStep->pExprList ) pSel->pEList = 0; pSel->pSrc = 0; sqlite3SelectDelete(db, pSel); } |
︙ |
Changes to src/analyze.c.
︙ | |||
990 991 992 993 994 995 996 997 | 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | + + + - + - + + | int regRowid = iMem++; /* Rowid argument passed to stat_push() */ int regTemp = iMem++; /* Temporary use register */ int regTemp2 = iMem++; /* Second temporary use register */ int regTabname = iMem++; /* Register containing table name */ int regIdxname = iMem++; /* Register containing index name */ int regStat1 = iMem++; /* Value for the stat column of sqlite_stat1 */ int regPrev = iMem; /* MUST BE LAST (see below) */ #ifdef SQLITE_ENABLE_STAT4 int doOnce = 1; /* Flag for a one-time computation */ #endif #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
︙ | |||
1100 1101 1102 1103 1104 1105 1106 | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | - + | ** end_of_scan: */ /* Make sure there are enough memory cells allocated to accommodate ** the regPrev array and a trailing rowid (the rowid slot is required ** when building a record to insert into the sample column of ** the sqlite_stat4 table. */ |
︙ | |||
1272 1273 1274 1275 1276 1277 1278 | 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + | int regSample = regStat1+3; int regCol = regStat1+4; int regSampleRowid = regCol + nCol; int addrNext; int addrIsNull; u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound; if( doOnce ){ int mxCol = nCol; Index *pX; |
︙ | |||
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 | 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 | + | openStatTable(pParse, iDb, iStatCur, 0, 0); iMem = pParse->nMem+1; iTab = pParse->nTab; assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ Table *pTab = (Table*)sqliteHashData(k); analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab); iMem = sqlite3FirstAvailableRegister(pParse, iMem); } loadAnalysis(pParse, iDb); } /* ** Generate code that will do an analysis of a single table in ** a database. If pOnlyIdx is not NULL then it is a single index |
︙ | |||
1833 1834 1835 1836 1837 1838 1839 | 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 | - + | const Table *pStat4; assert( db->lookaside.bDisable ); if( (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0 && IsOrdinaryTable(pStat4) ){ rc = loadStatTbl(db, |
︙ |
Changes to src/backup.c.
︙ | |||
238 239 240 241 242 243 244 | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - - - - - + - - | i64 iOff; assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 ); assert( p->bDestLocked ); assert( !isFatalError(p->rc) ); assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ); assert( zSrcData ); |
︙ | |||
377 378 379 380 381 382 383 | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | - + + + + | } /* Do not allow backup if the destination database is in WAL mode ** and the page sizes are different between source and destination */ pgszSrc = sqlite3BtreeGetPageSize(p->pSrc); pgszDest = sqlite3BtreeGetPageSize(p->pDest); destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest)); |
︙ |
Changes to src/btree.c.
︙ | |||
1720 1721 1722 1723 1724 1725 1726 | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 | - + + | /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size ** and the reserved space is zero (the usual value for reserved space) ** then the cell content offset of an empty page wants to be 65536. ** However, that integer is too large to be stored in a 2-byte unsigned ** integer, so a value of 0 is used in its place. */ pTmp = &data[hdr+5]; top = get2byte(pTmp); |
︙ | |||
6080 6081 6082 6083 6084 6085 6086 | 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 | - + | pCur->eState = CURSOR_VALID; if( pCur->skipNext>0 ) return SQLITE_OK; } } pPage = pCur->pPage; idx = ++pCur->ix; |
︙ | |||
7298 7299 7300 7301 7302 7303 7304 | 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 | - + | u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager); u8 *pData; int k; /* Current slot in pCArray->apEnd[] */ u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ assert( i<iEnd ); j = get2byte(&aData[hdr+5]); |
︙ | |||
7532 7533 7534 7535 7536 7537 7538 | 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 | - + | int nTail = pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray); assert( nCell>=nTail ); nCell -= nTail; } pData = &aData[get2byteNotZero(&aData[hdr+5])]; if( pData<pBegin ) goto editpage_fail; |
︙ | |||
9167 9168 9169 9170 9171 9172 9173 | 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 | - + | x2.nData = pX->nKey; x2.nZero = 0; return btreeOverwriteCell(pCur, &x2); } } } assert( pCur->eState==CURSOR_VALID |
︙ | |||
9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 | 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 | + | }else{ rc = fillInCell(pPage, newCell, pX, &szNew); if( rc ) goto end_insert; } assert( szNew==pPage->xCellSize(pPage, newCell) ); assert( szNew <= MX_CELL_SIZE(p->pBt) ); idx = pCur->ix; pCur->info.nSize = 0; if( loc==0 ){ CellInfo info; assert( idx>=0 ); if( idx>=pPage->nCell ){ return SQLITE_CORRUPT_BKPT; } rc = sqlite3PagerWrite(pPage->pDbPage); |
︙ | |||
9281 9282 9283 9284 9285 9286 9287 | 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 | - | ** happen while processing an "INSERT INTO ... SELECT" statement), it ** is advantageous to leave the cursor pointing to the last entry in ** the b-tree if possible. If the cursor is left pointing to the last ** entry in the table, and the next row inserted has an integer key ** larger than the largest existing key, it is possible to insert the ** row without seeking the cursor. This can be a big performance boost. */ |
︙ | |||
9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 | 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 | + + + | pPage = pCur->pPage; if( pPage->nCell<=iCellIdx ){ return SQLITE_CORRUPT_BKPT; } pCell = findCell(pPage, iCellIdx); if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){ return SQLITE_CORRUPT_BKPT; } if( pCell<&pPage->aCellIdx[pPage->nCell] ){ return SQLITE_CORRUPT_BKPT; } /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must ** be preserved following this delete operation. If the current delete ** will cause a b-tree rebalance, then this is done by saving the cursor ** key and leaving the cursor in CURSOR_REQUIRESEEK state before ** returning. |
︙ |
Changes to src/build.c.
︙ | |||
1447 1448 1449 1450 1451 1452 1453 | 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 | - + | void sqlite3AddReturning(Parse *pParse, ExprList *pList){ Returning *pRet; Hash *pHash; sqlite3 *db = pParse->db; if( pParse->pNewTrigger ){ sqlite3ErrorMsg(pParse, "cannot use RETURNING in a trigger"); }else{ |
︙ | |||
1473 1474 1475 1476 1477 1478 1479 | 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 | - + + | pRet->retTrig.pSchema = db->aDb[1].pSchema; pRet->retTrig.pTabSchema = db->aDb[1].pSchema; pRet->retTrig.step_list = &pRet->retTStep; pRet->retTStep.op = TK_RETURNING; pRet->retTStep.pTrig = &pRet->retTrig; pRet->retTStep.pExprList = pList; pHash = &(db->aDb[1].pSchema->trigHash); |
︙ | |||
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 | 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 | + | if( ALWAYS(pExpr) && pExpr->op==TK_ID ){ /* The value of a generated column needs to be a real expression, not ** just a reference to another column, in order for covering index ** optimizations to work correctly. So if the value is not an expression, ** turn it into one by adding a unary "+" operator. */ pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0); } if( pExpr && pExpr->op!=TK_RAISE ) pExpr->affExpr = pCol->affinity; sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); pExpr = 0; goto generated_done; generated_error: sqlite3ErrorMsg(pParse, "error in generated column \"%s\"", pCol->zCnName); |
︙ |
Changes to src/delete.c.
︙ | |||
110 111 112 113 114 115 116 | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | - + - + + + | /* ** Check to make sure the given table is writable. ** ** If pTab is not writable -> generate an error message and return 1. ** If pTab is writable but other errors have occurred -> return 1. ** If pTab is writable and no prior errors -> return 0; */ |
︙ | |||
370 371 372 373 374 375 376 | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | - + | /* If pTab is really a view, make sure it has been initialized. */ if( sqlite3ViewGetColumnNames(pParse, pTab) ){ goto delete_from_cleanup; } |
︙ | |||
479 480 481 482 483 484 485 | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | - + | sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); } } }else #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ { u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK; |
︙ |
Changes to src/expr.c.
︙ | |||
274 275 276 277 278 279 280 | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | - - - + + - + | } if( p->flags & EP_Collate ){ if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){ p = p->pLeft; }else{ Expr *pNext = p->pRight; /* The Expr.x union is never used at the same time as Expr.pRight */ |
︙ | |||
2932 2933 2934 2935 2936 2937 2938 | 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 | - | colUsed = 0; /* Columns of index used so far */ for(i=0; i<nExpr; i++){ Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i); Expr *pRhs = pEList->a[i].pExpr; CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs); int j; |
︙ | |||
3835 3836 3837 3838 3839 3840 3841 3842 3843 | 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 | + - + + + | Parse *pParse, /* Parsing context */ Table *pTab, /* Table containing the generated column */ Column *pCol, /* The generated column */ int regOut /* Put the result in this register */ ){ int iAddr; Vdbe *v = pParse->pVdbe; int nErr = pParse->nErr; assert( v!=0 ); assert( pParse->iSelfTab!=0 ); |
︙ | |||
4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 | 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 | + + + + + + + + + + + | Parse *pParse, /* The parsing context */ Expr *pExpr, /* The expression to potentially bypass */ int target /* Where to store the result of the expression */ ){ IndexedExpr *p; Vdbe *v; for(p=pParse->pIdxEpr; p; p=p->pIENext){ u8 exprAff; int iDataCur = p->iDataCur; if( iDataCur<0 ) continue; if( pParse->iSelfTab ){ if( p->iDataCur!=pParse->iSelfTab-1 ) continue; iDataCur = -1; } if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue; assert( p->aff>=SQLITE_AFF_BLOB && p->aff<=SQLITE_AFF_NUMERIC ); exprAff = sqlite3ExprAffinity(pExpr); if( (exprAff<=SQLITE_AFF_BLOB && p->aff!=SQLITE_AFF_BLOB) || (exprAff==SQLITE_AFF_TEXT && p->aff!=SQLITE_AFF_TEXT) || (exprAff>=SQLITE_AFF_NUMERIC && p->aff!=SQLITE_AFF_NUMERIC) ){ /* Affinity mismatch on a generated column */ continue; } v = pParse->pVdbe; assert( v!=0 ); if( p->bMaybeNullRow ){ /* If the index is on a NULL row due to an outer join, then we ** cannot extract the value from the index. The value must be ** computed using the original expression. */ int addr = sqlite3VdbeCurrentAddr(v); |
︙ | |||
4204 4205 4206 4207 4208 4209 4210 | 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 | - + + + + + + + + + + + + + | op = pExpr->op; } switch( op ){ case TK_AGG_COLUMN: { AggInfo *pAggInfo = pExpr->pAggInfo; struct AggInfo_col *pCol; assert( pAggInfo!=0 ); |
︙ | |||
4379 4380 4381 4382 4383 4384 4385 | 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 | - - + + - - - | } case TK_REGISTER: { return pExpr->iTable; } #ifndef SQLITE_OMIT_CAST case TK_CAST: { /* Expressions of the form: CAST(pLeft AS token) */ |
︙ | |||
4715 4716 4717 4718 4719 4720 4721 | 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 | - - - + + + + + + + - - + - - - - - - + + | ** Z is stored in pExpr->pList->a[1].pExpr. */ case TK_BETWEEN: { exprCodeBetween(pParse, pExpr, target, 0, 0); return target; } case TK_COLLATE: { |
︙ | |||
4826 4827 4828 4829 4830 4831 4832 | 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 | - - + + + + + - - - - - + + + + + + - | sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab, pAggInfo->aCol[pExpr->iAgg].iSorterColumn, target); inReg = target; break; } } |
︙ | |||
5072 5073 5074 5075 5076 5077 5078 | 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 | - + + + | assert( pExpr==0 || !ExprHasVVAProperty(pExpr,EP_Immutable) ); assert( target>0 && target<=pParse->nMem ); assert( pParse->pVdbe!=0 || pParse->db->mallocFailed ); if( pParse->pVdbe==0 ) return; inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); if( inReg!=target ){ u8 op; |
︙ | |||
6257 6258 6259 6260 6261 6262 6263 6264 | 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 | + - - + + + - - + + + | if( ALWAYS(!ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced)) && pExpr->pAggInfo!=0 ){ AggInfo *pAggInfo = pExpr->pAggInfo; int iAgg = pExpr->iAgg; Parse *pParse = pWalker->pParse; sqlite3 *db = pParse->db; assert( iAgg>=0 ); if( pExpr->op!=TK_AGG_FUNCTION ){ |
︙ | |||
6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 | 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 | + + + + + - + + + + + | assert( pNC->ncFlags & NC_UAggInfo ); assert( pAggInfo->iFirstReg==0 ); switch( pExpr->op ){ default: { IndexedExpr *pIEpr; Expr tmp; int i; assert( pParse->iSelfTab==0 ); if( (pNC->ncFlags & NC_InAggFunc)==0 ) break; if( pParse->pIdxEpr==0 ) break; for(pIEpr=pParse->pIdxEpr; pIEpr; pIEpr=pIEpr->pIENext){ int iDataCur = pIEpr->iDataCur; if( iDataCur<0 ) continue; if( sqlite3ExprCompare(0, pExpr, pIEpr->pExpr, iDataCur)==0 ) break; } if( pIEpr==0 ) break; if( NEVER(!ExprUseYTab(pExpr)) ) break; for(i=0; i<pSrcList->nSrc; i++){ if( pSrcList->a[0].iCursor==pIEpr->iDataCur ) break; } if( i>=pSrcList->nSrc ) break; |
︙ | |||
6453 6454 6455 6456 6457 6458 6459 | 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 | - + | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); if( pExpr->iTable==pItem->iCursor ){ findOrCreateAggInfoColumn(pParse, pAggInfo, pExpr); break; } /* endif pExpr->iTable==pItem->iCursor */ } /* end loop over pSrcList */ } |
︙ | |||
6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 | 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** the sub/co-routine does not use registers in common with the code that ** invokes the sub/co-routine. */ void sqlite3ClearTempRegCache(Parse *pParse){ pParse->nTempReg = 0; pParse->nRangeReg = 0; } /* ** Make sure sufficient registers have been allocated so that ** iReg is a valid register number. */ void sqlite3TouchRegister(Parse *pParse, int iReg){ if( pParse->nMem<iReg ) pParse->nMem = iReg; } /* ** Return the latest reusable register in the set of all registers. ** The value returned is no less than iMin. If any register iMin or ** greater is in permanent use, then return one more than that last ** permanent register. */ int sqlite3FirstAvailableRegister(Parse *pParse, int iMin){ const ExprList *pList = pParse->pConstExpr; if( pList ){ int i; for(i=0; i<pList->nExpr; i++){ if( pList->a[i].u.iConstExprReg>=iMin ){ iMin = pList->a[i].u.iConstExprReg + 1; } } } pParse->nTempReg = 0; pParse->nRangeReg = 0; return iMin; } /* ** Validate that no temporary register falls within the range of ** iFirst..iLast, inclusive. This routine is only call from within assert() ** statements. */ #ifdef SQLITE_DEBUG int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){ int i; if( pParse->nRangeReg>0 && pParse->iRangeReg+pParse->nRangeReg > iFirst && pParse->iRangeReg <= iLast ){ return 0; } for(i=0; i<pParse->nTempReg; i++){ if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){ return 0; } } if( pParse->pConstExpr ){ ExprList *pList = pParse->pConstExpr; for(i=0; i<pList->nExpr; i++){ int iReg = pList->a[i].u.iConstExprReg; if( iReg==0 ) continue; if( iReg>=iFirst && iReg<=iLast ) return 0; } } return 1; } #endif /* SQLITE_DEBUG */ |
Changes to src/fkey.c.
︙ | |||
1313 1314 1315 1316 1317 1318 1319 | 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 | - + - - - - - - + + + + + + - + | sqlite3DbFree(db, aiCol); zFrom = pFKey->pFrom->zName; nFrom = sqlite3Strlen30(zFrom); if( action==OE_Restrict ){ int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
︙ |
Changes to src/func.c.
︙ | |||
2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 | 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 | + + + + + + + + + + + + | /* ** On some systems, ceil() and floor() are intrinsic function. You are ** unable to take a pointer to these functions. Hence, we here wrap them ** in our own actual functions. */ static double xCeil(double x){ return ceil(x); } static double xFloor(double x){ return floor(x); } /* ** Some systems do not have log2() and log10() in their standard math ** libraries. */ #if defined(HAVE_LOG10) && HAVE_LOG10==0 # define log10(X) (0.4342944819032517867*log(X)) #endif #if defined(HAVE_LOG2) && HAVE_LOG2==0 # define log2(X) (1.442695040888963456*log(X)) #endif /* ** Implementation of SQL functions: ** ** ln(X) - natural logarithm ** log(X) - log X base 10 ** log10(X) - log X base 10 |
︙ |
Changes to src/insert.c.
︙ | |||
790 791 792 793 794 795 796 | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | - + | */ if( sqlite3ViewGetColumnNames(pParse, pTab) ){ goto insert_cleanup; } /* Cannot insert into a read-only table. */ |
︙ | |||
1237 1238 1239 1240 1241 1242 1243 | 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 | - + | addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); sqlite3VdbeJumpHere(v, addr1); sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v); } /* Copy the new data already generated. */ |
︙ |
Changes to src/pager.c.
︙ | |||
5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 | 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 | + + + + | pPg->pPager = pPager; assert( !isOpen(pPager->fd) || !MEMDB ); if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){ if( pgno>pPager->mxPgno ){ rc = SQLITE_FULL; if( pgno<=pPager->dbSize ){ sqlite3PcacheRelease(pPg); pPg = 0; } goto pager_acquire_err; } if( noContent ){ /* Failure to set the bits in the InJournal bit-vectors is benign. ** It merely means that we might do some extra work to journal a ** page that does not need to be journaled. Nevertheless, be sure ** to test the case where a malloc error occurs while trying to set |
︙ |
Changes to src/parse.y.
︙ | |||
709 710 711 712 713 714 715 | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | - + | %ifndef SQLITE_OMIT_SUBQUERY seltablist(A) ::= stl_prefix(A) LP select(S) RP as(Z) on_using(N). { A = sqlite3SrcListAppendFromTerm(pParse,A,0,0,&Z,S,&N); } seltablist(A) ::= stl_prefix(A) LP seltablist(F) RP as(Z) on_using(N). { if( A==0 && Z.n==0 && N.pOn==0 && N.pUsing==0 ){ A = F; |
︙ |
Changes to src/pcache.c.
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | - + | ** clear PGHDR_NEED_SYNC flag or to a page that is older than this one ** (so that the right page to eject can be found by following pDirtyPrev ** pointers). */ struct PCache { PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */ PgHdr *pSynced; /* Last synced page in dirty page list */ |
︙ | |||
67 68 69 70 71 72 73 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | - + | int sqlite3PcacheMxDump = 9999; /* Max cache entries for pcacheDump() */ # define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;} static void pcachePageTrace(int i, sqlite3_pcache_page *pLower){ PgHdr *pPg; unsigned char *a; int j; pPg = (PgHdr*)pLower->pExtra; |
︙ | |||
811 812 813 814 815 816 817 | 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | - + - + | /* ** Return the total number of references to all pages held by the cache. ** ** This is not the total number of pages referenced, but the sum of the ** reference count for all pages. */ |
︙ |
Changes to src/pcache.h.
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | - + | u16 flags; /* PGHDR flags defined below */ /********************************************************************** ** Elements above, except pCache, are public. All that follow are ** private to pcache.c and should not be accessed by other modules. ** pCache is grouped with the public elements for efficiency. */ |
︙ | |||
117 118 119 120 121 122 123 | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | - + - + | /* Clear flags from pages of the page cache */ void sqlite3PcacheClearSyncFlags(PCache *); /* Discard the contents of the cache */ void sqlite3PcacheClear(PCache*); /* Return the total number of outstanding page references */ |
︙ |
Changes to src/pragma.c.
︙ | |||
1520 1521 1522 1523 1524 1525 1526 | 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 | - + | k = sqliteHashNext(k); } if( pTab==0 || !IsOrdinaryTable(pTab) || pTab->u.tab.pFKey==0 ) continue; iDb = sqlite3SchemaToIndex(db, pTab->pSchema); zDb = db->aDb[iDb].zDbSName; sqlite3CodeVerifySchema(pParse, iDb); sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
︙ | |||
1561 1562 1563 1564 1565 1566 1567 | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | - + | } addrOk = sqlite3VdbeMakeLabel(pParse); /* Generate code to read the child key values into registers ** regRow..regRow+n. If any of the child key values are NULL, this ** row cannot cause an FK violation. Jump directly to addrOk in ** this case. */ |
︙ | |||
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 | + | int cnt = 0; /* Number of entries in aRoot[] */ int mxIdx = 0; /* Maximum number of indexes for any table */ if( OMIT_TEMPDB && i==1 ) continue; if( iDb>=0 && i!=iDb ) continue; sqlite3CodeVerifySchema(pParse, i); pParse->okConstFactor = 0; /* tag-20230327-1 */ /* Do an integrity check of the B-Tree ** ** Begin by finding the root pages numbers ** for all tables and indices in the database. */ assert( sqlite3SchemaMutexHeld(db, i, 0) ); |
︙ | |||
1725 1726 1727 1728 1729 1730 1731 | 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 | - + | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ aRoot[++cnt] = pIdx->tnum; } } aRoot[0] = cnt; /* Make sure sufficient number of registers have been allocated */ |
︙ | |||
1875 1876 1877 1878 1879 1880 1881 1882 | 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 | + + + - - + + + + + + + + + + + + + | } } labelError = sqlite3VdbeMakeLabel(pParse); labelOk = sqlite3VdbeMakeLabel(pParse); if( pCol->notNull ){ /* (1) NOT NULL columns may not contain a NULL */ int jmp3; int jmp2 = sqlite3VdbeAddOp4Int(v, OP_IsType, p1, labelOk, p3, p4); VdbeCoverage(v); if( p1<0 ){ |
︙ | |||
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 | 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 | + + + + + + + + + + + + + + + + + | sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); sqlite3VdbeLoadString(v, 4, " missing from index "); sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); jmp4 = integrityCheckResultRow(v); sqlite3VdbeJumpHere(v, jmp2); /* The OP_IdxRowid opcode is an optimized version of OP_Column ** that extracts the rowid off the end of the index record. ** But it only works correctly if index record does not have ** any extra bytes at the end. Verify that this is the case. */ if( HasRowid(pTab) ){ int jmp7; sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3); jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1); VdbeCoverage(v); sqlite3VdbeLoadString(v, 3, "rowid not at end-of-record for row "); sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); sqlite3VdbeLoadString(v, 4, " of index "); sqlite3VdbeGoto(v, jmp5-1); sqlite3VdbeJumpHere(v, jmp7); } /* Any indexed columns with non-BINARY collations must still hold ** the exact same text value as the table. */ label6 = 0; for(kk=0; kk<pIdx->nKeyCol; kk++){ if( pIdx->azColl[kk]==sqlite3StrBINARY ) continue; if( label6==0 ) label6 = sqlite3VdbeMakeLabel(pParse); |
︙ |
Changes to src/prepare.c.
︙ | |||
302 303 304 305 306 307 308 | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | - + + + | #ifndef SQLITE_OMIT_UTF16 /* If opening the main database, set ENC(db). */ encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; if( encoding==0 ) encoding = SQLITE_UTF8; #else encoding = SQLITE_UTF8; #endif |
︙ | |||
696 697 698 699 700 701 702 | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | + - + + + + | memset(PARSE_HDR(&sParse), 0, PARSE_HDR_SZ); memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ); sParse.pOuterParse = db->pParse; db->pParse = &sParse; sParse.db = db; sParse.pReprepare = pReprepare; assert( ppStmt && *ppStmt==0 ); if( db->mallocFailed ){ |
︙ |
Changes to src/resolve.c.
︙ | |||
943 944 945 946 947 948 949 | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | - - + + - - - + - - + - | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ anRef[i] = p->nRef; } sqlite3WalkExpr(pWalker, pExpr->pLeft); if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ testcase( ExprHasProperty(pExpr, EP_OuterON) ); assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
︙ | |||
1252 1253 1254 1255 1256 1257 1258 | 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | - + | notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr); }else{ sqlite3WalkSelect(pWalker, pExpr->x.pSelect); } assert( pNC->nRef>=nRef ); if( nRef!=pNC->nRef ){ ExprSetProperty(pExpr, EP_VarSelect); |
︙ |
Changes to src/select.c.
︙ | |||
2314 2315 2316 2317 2318 2319 2320 | 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 | - + - - + + + - - - - - - - - - - - + + + + + + + + + + + + - | struct ExprList_item *a; NameContext sNC; assert( pSelect!=0 ); assert( (pSelect->selFlags & SF_Resolved)!=0 ); assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); |
︙ | |||
3857 3858 3859 3860 3861 3862 3863 | 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 | - + + + | Expr ifNullRow; assert( pSubst->pEList!=0 && iColumn<pSubst->pEList->nExpr ); assert( pExpr->pRight==0 ); if( sqlite3ExprIsVector(pCopy) ){ sqlite3VectorErrorMsg(pSubst->pParse, pCopy); }else{ sqlite3 *db = pSubst->pParse->db; |
︙ | |||
6373 6374 6375 6376 6377 6378 6379 6380 6381 | 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 | + + + + - + - - - - + + + | static void optimizeAggregateUseOfIndexedExpr( Parse *pParse, /* Parsing context */ Select *pSelect, /* The SELECT statement being processed */ AggInfo *pAggInfo, /* The aggregate info */ NameContext *pNC /* Name context used to resolve agg-func args */ ){ assert( pAggInfo->iFirstReg==0 ); assert( pSelect!=0 ); assert( pSelect->pGroupBy!=0 ); pAggInfo->nColumn = pAggInfo->nAccumulator; if( ALWAYS(pAggInfo->nSortingColumn>0) ){ int mx = pSelect->pGroupBy->nExpr - 1; int j, k; |
︙ | |||
6414 6415 6416 6417 6418 6419 6420 | 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 | + - + + | struct AggInfo_col *pCol; UNUSED_PARAMETER(pWalker); if( pExpr->pAggInfo==0 ) return WRC_Continue; if( pExpr->op==TK_AGG_COLUMN ) return WRC_Continue; if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue; if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue; pAggInfo = pExpr->pAggInfo; if( NEVER(pExpr->iAgg>=pAggInfo->nColumn) ) return WRC_Continue; |
︙ | |||
6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 | 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 | + + - + + + - + | Select *pSub, *pPrior; Expr *pExpr; Expr *pCount; sqlite3 *db; if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */ if( p->pEList->nExpr!=1 ) return 0; /* Single result column */ if( p->pWhere ) return 0; if( p->pHaving ) return 0; if( p->pGroupBy ) return 0; if( p->pOrderBy ) return 0; pExpr = p->pEList->a[0].pExpr; if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ assert( ExprUseUToken(pExpr) ); if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ assert( ExprUseXList(pExpr) ); if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */ pSub = p->pSrc->a[0].pSelect; if( pSub==0 ) return 0; /* The FROM is a subquery */ |
︙ | |||
7254 7255 7256 7257 7258 7259 7260 | 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 | - | } #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView) && countOfViewOptimization(pParse, p) ){ if( db->mallocFailed ) goto select_end; |
︙ |
Changes to src/shell.c.in.
︙ | |||
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 | 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 | + | } /* ** Output the given string as a quoted according to JSON quoting rules. */ static void output_json_string(FILE *out, const char *z, i64 n){ unsigned int c; if( z==0 ) z = ""; if( n<0 ) n = strlen(z); fputc('"', out); while( n-- ){ c = *(z++); if( c=='\\' || c=='"' ){ fputc('\\', out); fputc(c, out); |
︙ | |||
2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 | 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 | + | if( zTail==0 ) return; if( zTail[0]==';' && (strstr(z, "/*")!=0 || strstr(z,"--")!=0) ){ const char *zOrig = z; static const char *azTerm[] = { "", "*/", "\n" }; int i; for(i=0; i<ArraySize(azTerm); i++){ char *zNew = sqlite3_mprintf("%s%s;", zOrig, azTerm[i]); shell_check_oom(zNew); if( sqlite3_complete(zNew) ){ size_t n = strlen(zNew); zNew[n-1] = 0; zToFree = zNew; z = zNew; break; } |
︙ | |||
2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 | 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 | + - + | size_t len; char *zCode; char *zMsg; int i; if( db==0 || zSql==0 || (iOffset = sqlite3_error_offset(db))<0 || iOffset>=strlen(zSql) ){ return sqlite3_mprintf(""); } while( iOffset>50 ){ iOffset--; zSql++; while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; } } len = strlen(zSql); if( len>78 ){ len = 78; |
︙ | |||
3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 | 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 | + | const unsigned char *zNotUsed; int wx = p->colWidth[i]; if( wx==0 ){ wx = p->cmOpts.iWrap; } if( wx<0 ) wx = -wx; uz = (const unsigned char*)sqlite3_column_name(pStmt,i); if( uz==0 ) uz = (u8*)""; azData[i] = translateForDisplayAndDup(uz, &zNotUsed, wx, bw); } do{ int useNextLine = bNextLine; bNextLine = 0; if( (nRow+2)*nColumn >= nAlloc ){ nAlloc *= 2; |
︙ | |||
5086 5087 5088 5089 5090 5091 5092 | 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | } sqlite3_free(a); utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine); return 0; } #endif /* SQLITE_OMIT_DESERIALIZE */ |
︙ | |||
5362 5363 5364 5365 5366 5367 5368 | 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 | - - - - - - | sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, shellAddSchemaName, 0, 0); sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0, shellModuleSchema, 0, 0); sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, shellPutsFunc, 0, 0); |
︙ | |||
5637 5638 5639 5640 5641 5642 5643 | 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 | - + | const char *zSql; i64 nSql; if( p->traceOut==0 ) return 0; if( mType==SQLITE_TRACE_CLOSE ){ utf8_printf(p->traceOut, "-- closing database connection\n"); return 0; } |
︙ | |||
6197 6198 6199 6200 6201 6202 6203 | 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 | - + + + | sqlite3_finalize(pStmt); return 1; } sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC); if( sqlite3_step(pStmt)==SQLITE_ROW && sqlite3_column_bytes(pStmt,0)>100 ){ |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
3337 3338 3339 3340 3341 3342 3343 | 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 | - + | #define NC_AllowAgg 0x000001 /* Aggregate functions are allowed here */ #define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */ #define NC_IsCheck 0x000004 /* True if resolving a CHECK constraint */ #define NC_GenCol 0x000008 /* True for a GENERATED ALWAYS AS clause */ #define NC_HasAgg 0x000010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */ #define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */ |
︙ | |||
3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 | 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 | + | */ struct IndexedExpr { Expr *pExpr; /* The expression contained in the index */ int iDataCur; /* The data cursor associated with the index */ int iIdxCur; /* The index cursor */ int iIdxCol; /* The index column that contains value of pExpr */ u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */ u8 aff; /* Affinity of the pExpr expression */ IndexedExpr *pIENext; /* Next in a list of all indexed expressions */ #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS const char *zIdxName; /* Name of index, used only for bytecode comments */ #endif }; /* |
︙ | |||
3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 | 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 | + + + | u8 okConstFactor; /* OK to factor out constants */ u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ #endif #ifdef SQLITE_DEBUG u8 ifNotExists; /* Might be true if IF NOT EXISTS. Assert()s only */ #endif int nRangeReg; /* Size of the temporary register block */ int iRangeReg; /* First register in temporary register block */ int nErr; /* Number of errors seen */ int nTab; /* Number of previously allocated VDBE cursors */ int nMem; /* Number of memory cells used so far */ int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */ int iSelfTab; /* Table associated with an index on expr, or negative |
︙ | |||
4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 | 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 | + + | int sqlite3RunParser(Parse*, const char*); void sqlite3FinishCoding(Parse*); int sqlite3GetTempReg(Parse*); void sqlite3ReleaseTempReg(Parse*,int); int sqlite3GetTempRange(Parse*,int); void sqlite3ReleaseTempRange(Parse*,int,int); void sqlite3ClearTempRegCache(Parse*); void sqlite3TouchRegister(Parse*,int); int sqlite3FirstAvailableRegister(Parse*,int); #ifdef SQLITE_DEBUG int sqlite3NoTempsInRange(Parse*,int,int); #endif Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int); Expr *sqlite3Expr(sqlite3*,int,const char*); void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); |
︙ | |||
4789 4790 4791 4792 4793 4794 4795 | 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 | - + | Expr*, int, int, u8); void sqlite3DropIndex(Parse*, SrcList*, int); int sqlite3Select(Parse*, Select*, SelectDest*); Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, Expr*,ExprList*,u32,Expr*); void sqlite3SelectDelete(sqlite3*, Select*); Table *sqlite3SrcListLookup(Parse*, SrcList*); |
︙ |
Changes to src/trigger.c.
︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | + | if( !IN_RENAME_OBJECT ){ if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){ if( !noErr ){ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); }else{ assert( !db->init.busy ); sqlite3CodeVerifySchema(pParse, iDb); VVA_ONLY( pParse->ifNotExists = 1; ) } goto trigger_cleanup; } } /* Do not create a trigger on a system table */ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){ |
︙ | |||
979 980 981 982 983 984 985 | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | - + | sqlite3SelectPrep(pParse, &sSelect, 0); if( pParse->nErr==0 ){ assert( db->mallocFailed==0 ); sqlite3GenerateColumnNames(pParse, &sSelect); } sqlite3ExprListDelete(db, sSelect.pEList); pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); |
︙ | |||
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 | 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | + + + | int orconf /* Default ON CONFLICT policy for trigger steps */ ){ const int op = pChanges ? TK_UPDATE : TK_DELETE; u32 mask = 0; Trigger *p; assert( isNew==1 || isNew==0 ); if( IsView(pTab) ){ return 0xffffffff; } for(p=pTrigger; p; p=p->pNext){ if( p->op==op && (tr_tm&p->tr_tm) && checkColumnOverlap(p->pColumns,pChanges) ){ if( p->bReturning ){ mask = 0xffffffff; |
︙ |
Changes to src/update.c.
︙ | |||
404 405 406 407 408 409 410 | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | - + | pLimit = 0; } #endif if( sqlite3ViewGetColumnNames(pParse, pTab) ){ goto update_cleanup; } |
︙ | |||
723 724 725 726 727 728 729 | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | + + + - - + + + - - + + - + + + + + + + | eOnePass = ONEPASS_SINGLE; sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL); bFinishSeek = 0; }else{ /* Begin the database scan. ** ** Do not consider a single-pass strategy for a multi-row update if ** there is anything that might disrupt the cursor being used to do ** the UPDATE: ** (1) This is a nested UPDATE |
︙ |
Changes to src/vdbe.c.
︙ | |||
679 680 681 682 683 684 685 | 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | - + - | for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){ const Mem *p = &aMem[i]; if( p->flags & (MEM_Int|MEM_IntReal) ){ h += p->u.i; }else if( p->flags & MEM_Real ){ h += sqlite3VdbeIntValue(p); }else if( p->flags & (MEM_Str|MEM_Blob) ){ |
︙ | |||
2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 | 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 | + + + + + + | ** ** If P1 is -1, then P3 is a register number and the datatype is taken ** from the value in that register. ** ** P5 is a bitmask of data types. SQLITE_INTEGER is the least significant ** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04. ** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10. ** ** WARNING: This opcode does not reliably distinguish between NULL and REAL ** when P1>=0. If the database contains a NaN value, this opcode will think ** that the datatype is REAL when it should be NULL. When P1<0 and the value ** is already stored in register P3, then this opcode does reliably ** distinguish between NULL and REAL. The problem only arises then P1>=0. ** ** Take the jump to address P2 if and only if the datatype of the ** value determined by P1 and P3 corresponds to one of the bits in the ** P5 bitmask. ** */ case OP_IsType: { /* jump */ |
︙ | |||
4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 | 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 | + | printf("... fall through after %d steps\n", pOp->p1); } #endif VdbeBranchTaken(0,3); break; } nStep--; pC->cacheStatus = CACHE_STALE; rc = sqlite3BtreeNext(pC->uc.pCursor, 0); if( rc ){ if( rc==SQLITE_DONE ){ rc = SQLITE_OK; goto seekscan_search_fail; }else{ goto abort_due_to_error; |
︙ |
Changes to src/vdbeapi.c.
︙ | |||
267 268 269 270 271 272 273 | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | - + | SQLITE_NULL, /* 0x1b (not possible) */ SQLITE_INTEGER, /* 0x1c (not possible) */ SQLITE_NULL, /* 0x1d (not possible) */ SQLITE_INTEGER, /* 0x1e (not possible) */ SQLITE_NULL, /* 0x1f (not possible) */ SQLITE_FLOAT, /* 0x20 INTREAL */ SQLITE_NULL, /* 0x21 (not possible) */ |
︙ | |||
2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 | 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 | + + + + + + + + + - - + + | sqlite3_stmt *pStmt, /* Prepared statement being queried */ int iScan, /* Index of loop to report on */ int iScanStatusOp, /* Which metric to return */ int flags, void *pOut /* OUT: Write the answer here */ ){ Vdbe *p = (Vdbe*)pStmt; VdbeOp *aOp = p->aOp; int nOp = p->nOp; ScanStatus *pScan; int idx; if( p->pFrame ){ VdbeFrame *pFrame; for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); aOp = pFrame->aOp; nOp = pFrame->nOp; } if( iScan<0 ){ int ii; if( iScanStatusOp==SQLITE_SCANSTAT_NCYCLE ){ i64 res = 0; |
︙ | |||
2168 2169 2170 2171 2172 2173 2174 | 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 | - + - + | } } if( idx>=p->nScan ) return 1; switch( iScanStatusOp ){ case SQLITE_SCANSTAT_NLOOP: { if( pScan->addrLoop>0 ){ |
︙ | |||
2198 2199 2200 2201 2202 2203 2204 | 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 | - + - + - + - + - - + + - + | } case SQLITE_SCANSTAT_NAME: { *(const char**)pOut = pScan->zName; break; } case SQLITE_SCANSTAT_EXPLAIN: { if( pScan->addrExplain ){ |
︙ |
Changes to src/vdbeaux.c.
︙ | |||
3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 | 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 | + + | p->nChange = 0; }else{ db->nDeferredCons = 0; db->nDeferredImmCons = 0; db->flags &= ~(u64)SQLITE_DeferFKs; sqlite3CommitInternalChanges(db); } }else if( p->rc==SQLITE_SCHEMA && db->nVdbeActive>1 ){ p->nChange = 0; }else{ sqlite3RollbackAll(db, SQLITE_OK); p->nChange = 0; } db->nStatement = 0; }else if( eStatementOp==0 ){ if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){ |
︙ | |||
5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 | 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 | + + + + + + + + + + - - + + | int iBlobWrite ){ sqlite3 *db = v->db; i64 iKey2; PreUpdate preupdate; const char *zTbl = pTab->zName; static const u8 fakeSortOrder = 0; #ifdef SQLITE_DEBUG int nRealCol; if( pTab->tabFlags & TF_WithoutRowid ){ nRealCol = sqlite3PrimaryKeyIndex(pTab)->nColumn; }else if( pTab->tabFlags & TF_HasVirtual ){ nRealCol = pTab->nNVCol; }else{ nRealCol = pTab->nCol; } #endif assert( db->pPreUpdate==0 ); memset(&preupdate, 0, sizeof(PreUpdate)); if( HasRowid(pTab)==0 ){ iKey1 = iKey2 = 0; preupdate.pPk = sqlite3PrimaryKeyIndex(pTab); }else{ if( op==SQLITE_UPDATE ){ iKey2 = v->aMem[iReg].u.i; }else{ iKey2 = iKey1; } } assert( pCsr!=0 ); assert( pCsr->eCurType==CURTYPE_BTREE ); |
︙ |
Changes to src/vdbemem.c.
︙ | |||
1479 1480 1481 1482 1483 1484 1485 1486 | 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 | + + + - + | assert( pCtx!=0 ); assert( (p->flags & EP_TokenOnly)==0 ); assert( ExprUseXList(p) ); pList = p->x.pList; if( pList ) nVal = pList->nExpr; assert( !ExprHasProperty(p, EP_IntValue) ); pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0); #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION if( pFunc==0 ) return SQLITE_OK; #endif assert( pFunc ); |
︙ | |||
1515 1516 1517 1518 1519 1520 1521 | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 | - - - - - + - | pFunc->xSFunc(&ctx, nVal, apVal); if( ctx.isError ){ rc = ctx.isError; sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal)); }else{ sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8); assert( rc==SQLITE_OK ); |
︙ | |||
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 | 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 | + | if( op==TK_CAST ){ u8 aff; assert( !ExprHasProperty(pExpr, EP_IntValue) ); aff = sqlite3AffinityType(pExpr->u.zToken,0); rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx); testcase( rc!=SQLITE_OK ); if( *ppVal ){ rc = ExpandBlob(*ppVal); sqlite3VdbeMemCast(*ppVal, aff, enc); sqlite3ValueApplyAffinity(*ppVal, affinity, enc); } return rc; } /* Handle negative integers in a single step. This is needed in the |
︙ |
Changes to src/vtab.c.
︙ | |||
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | + + | assert( &db->pVtabCtx ); assert( xConstruct ); sCtx.pTab = pTab; sCtx.pVTable = pVTable; sCtx.pPrior = db->pVtabCtx; sCtx.bDeclared = 0; db->pVtabCtx = &sCtx; pTab->nTabRef++; rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr); sqlite3DeleteTable(db, pTab); db->pVtabCtx = sCtx.pPrior; if( rc==SQLITE_NOMEM ) sqlite3OomFault(db); assert( sCtx.pTab==pTab ); if( SQLITE_OK!=rc ){ if( zErr==0 ){ *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName); |
︙ |
Changes to src/where.c.
︙ | |||
958 959 960 961 962 963 964 | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 | + + + - + + | ** covering index. A "covering index" is an index that contains all ** columns that are needed by the query. With a covering index, the ** original table never needs to be accessed. Automatic indices must ** be a covering index because the index will not be updated if the ** original table changes and the index and table cannot both be used ** if they go out of sync. */ if( IsView(pTable) ){ extraCols = ALLBITS; }else{ |
︙ | |||
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | + + + + | int addrCont; /* Jump here to skip a row */ const WhereTerm *pTerm; /* For looping over WHERE clause terms */ const WhereTerm *pWCEnd; /* Last WHERE clause term */ Parse *pParse = pWInfo->pParse; /* Parsing context */ Vdbe *v = pParse->pVdbe; /* VDBE under construction */ WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ int iCur; /* Cursor for table getting the filter */ IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ saved_pIdxEpr = pParse->pIdxEpr; pParse->pIdxEpr = 0; assert( pLoop!=0 ); assert( v!=0 ); assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); do{ |
︙ | |||
1175 1176 1177 1178 1179 1180 1181 | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 | - - + | sqlite3ReleaseTempReg(pParse, r1); }else{ Index *pIdx = pLoop->u.btree.pIndex; int n = pLoop->u.btree.nEq; int r1 = sqlite3GetTempRange(pParse, n); int jj; for(jj=0; jj<n; jj++){ |
︙ | |||
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 | 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 | + | ** not able to do early evaluation of bloom filters that make use of ** the IN operator */ break; } } }while( iLevel < pWInfo->nLevel ); sqlite3VdbeJumpHere(v, addrOnce); pParse->pIdxEpr = saved_pIdxEpr; } #ifndef SQLITE_OMIT_VIRTUALTABLE /* ** Allocate and populate an sqlite3_index_info structure. It is the ** responsibility of the caller to eventually release the structure |
︙ | |||
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 | 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 | + | #ifndef SQLITE_DEBUG UNUSED_PARAMETER( pParse ); #endif assert( pRec!=0 ); assert( pIdx->nSample>0 ); assert( pRec->nField>0 ); /* Do a binary search to find the first sample greater than or equal ** to pRec. If pRec contains a single field, the set of samples to search ** is simply the aSample[] array. If the samples in aSample[] contain more ** than one fields, all fields following the first are ignored. ** ** If pRec contains N fields, where N is more than one, then as well as the |
︙ | |||
1551 1552 1553 1554 1555 1556 1557 | 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 | + + + + + - + | ** equal to the previous sample in the array. For example, in the above, ** sample 2 is the first sample of a block of N samples, so at first it ** appears that it should be 1 field in size. However, that would make it ** smaller than sample 1, so the binary search would not work. As a result, ** it is extended to two fields. The duplicates that this creates do not ** cause any problems. */ if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){ nField = pIdx->nKeyCol; }else{ nField = pIdx->nColumn; } |
︙ | |||
1987 1988 1989 1990 1991 1992 1993 | 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 | - + | } } #else UNUSED_PARAMETER(pParse); UNUSED_PARAMETER(pBuilder); assert( pLower || pUpper ); #endif |
︙ | |||
5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 | 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 | + + + + | pWInfo->bOrderedInnerLoop = 0; if( pWInfo->pOrderBy ){ pWInfo->nOBSat = pFrom->isOrdered; if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){ if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){ pWInfo->eDistinct = WHERE_DISTINCT_ORDERED; } if( pWInfo->pSelect->pOrderBy && pWInfo->nOBSat > pWInfo->pSelect->pOrderBy->nExpr ){ pWInfo->nOBSat = pWInfo->pSelect->pOrderBy->nExpr; } }else{ pWInfo->revMask = pFrom->revLoop; if( pWInfo->nOBSat<=0 ){ pWInfo->nOBSat = 0; if( nLoop>0 ){ u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags; if( (wsFlags & WHERE_ONEROW)==0 |
︙ | |||
5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 | 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 | + + + | } #endif p->pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); p->iDataCur = pTabItem->iCursor; p->iIdxCur = iIdxCur; p->iIdxCol = i; p->bMaybeNullRow = bMaybeNullRow; if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){ p->aff = pIdx->zColAff[i]; } #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS p->zIdxName = pIdx->zName; #endif pParse->pIdxEpr = p; if( p->pIENext==0 ){ sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); } |
︙ | |||
5947 5948 5949 5950 5951 5952 5953 | 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 | + + - - - + + + + + + + + + - - - + + + + - - + + + + + + + + - + + + + + + - - + + + + + | /* Analyze all of the subexpressions. */ sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC); if( pSelect && pSelect->pLimit ){ sqlite3WhereAddLimit(&pWInfo->sWC, pSelect); } if( pParse->nErr ) goto whereBeginError; /* The False-WHERE-Term-Bypass optimization: ** |
︙ | |||
6205 6206 6207 6208 6209 6210 6211 | 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 | - + | Bitmask b = pTabItem->colUsed; int n = 0; for(; b; b=b>>1, n++){} sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32); assert( n<=pTab->nCol ); } #ifdef SQLITE_ENABLE_CURSOR_HINTS |
︙ |
Changes to src/wherecode.c.
︙ | |||
1921 1922 1923 1924 1925 1926 1927 | 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 | - + | ** should we try before giving up and going with a seek. The cost ** of a seek is proportional to the logarithm of the of the number ** of entries in the tree, so basing the number of steps to try ** on the estimated number of rows in the btree seems like a good ** guess. */ addrSeekScan = sqlite3VdbeAddOp1(v, OP_SeekScan, (pIdx->aiRowLogEst[0]+9)/10); |
︙ | |||
1962 1963 1964 1965 1966 1967 1968 | 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 | - + - - - - - - - - - | /* Load the value for the inequality constraint at the end of the ** range (if any). */ nConstraint = nEq; assert( pLevel->p2==0 ); if( pRangeEnd ){ Expr *pRight = pRangeEnd->pExpr->pRight; |
︙ |
Changes to src/whereexpr.c.
︙ | |||
1852 1853 1854 1855 1856 1857 1858 | 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 | - + | pColRef->iColumn = k++; assert( ExprUseYTab(pColRef) ); pColRef->y.pTab = pTab; pItem->colUsed |= sqlite3ExprColUsed(pColRef); pRhs = sqlite3PExpr(pParse, TK_UPLUS, sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); |
︙ |
Changes to src/window.c.
︙ | |||
781 782 783 784 785 786 787 788 789 790 791 792 793 794 | 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | + | assert( pWin->pOwner==pExpr ); return WRC_Prune; } } } /* no break */ deliberate_fall_through case TK_IF_NULL_ROW: case TK_AGG_FUNCTION: case TK_COLUMN: { int iCol = -1; if( pParse->db->mallocFailed ) return WRC_Abort; if( p->pSub ){ int i; for(i=0; i<p->pSub->nExpr; i++){ |
︙ |
Added test/aggfault.test.
|
Changes to test/altertab.test.
︙ | |||
976 977 978 979 980 981 982 983 984 | 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | + + + + + + + + + + + + + + + + + + | do_catchsql_test 32.0 { CREATE TABLE t1(x); CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN UPDATE t1 SET x=x FROM (SELECT*); END; ALTER TABLE t1 RENAME TO x; } {1 {error in trigger r1: no tables specified}} # 2023-04-13 https://sqlite.org/forum/forumpost/ff3840145a # reset_db do_execsql_test 33.0 { CREATE TABLE t1(a TEXT); INSERT INTO t1(a) VALUES('abc'),('def'),(NULL); CREATE TABLE t2(b TEXT); CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN UPDATE t2 SET (b,a)=(SELECT 1) FROM t1 JOIN t2 ON (SELECT * FROM (SELECT a)); END; } do_catchsql_test 33.1 { ALTER TABLE t1 RENAME COLUMN a TO b; } {1 {error in trigger r3 after rename: no such column: a}} do_execsql_test 33.2 { SELECT quote(a) FROM t1 ORDER BY +a; } {NULL 'abc' 'def'} finish_test |
Changes to test/analyze3.test.
︙ | |||
731 732 733 734 735 736 737 738 739 | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | + + + + + + + + + + + + + | CREATE INDEX t1a ON t1(a); ANALYZE; SELECT * FROM sqlite_stat1; INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000'); INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000'); ANALYZE sqlite_master; } # 2023-04-22 https://sqlite.org/forum/info/6c118daad0f1f5ef # Case differences in the sqlite_stat4.idx field should not matter. # reset_db do_execsql_test 8.0 { CREATE TABLE t1(a PRIMARY KEY, v) WITHOUT ROWID; ANALYZE sqlite_schema; INSERT INTO sqlite_stat1 VALUES('t1','t1','1 1'); INSERT INTO sqlite_stat4 VALUES('t1','t1','1','0','0',X'021b76657273696f6e'); INSERT INTO sqlite_stat4 VALUES('T1','T1','1','0','0',X'021b76657273696f6e'); ANALYZE sqlite_schema; } {} finish_test |
Changes to test/analyzeE.test.
︙ | |||
234 235 236 237 238 239 240 241 242 | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a<1100 AND c=123 } {/SEARCH t1 USING INDEX t1ca/} do_execsql_test analyzeE-4.11 { EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a<1900 AND c=123 } {/SCAN t1/} # 2023-03-23 https://sqlite.org/forum/forumpost/dc4854437b # reset_db do_execsql_test analyzeE-5.0 { PRAGMA encoding = 'UTF-16'; CREATE TABLE t0 (c1 TEXT); INSERT INTO t0 VALUES (''); CREATE INDEX i0 ON t0(c1); ANALYZE; SELECT * FROM t0 WHERE t0.c1 BETWEEN '' AND (ABS('')); } {{}} # 2023-03-24 https://sqlite.org/forum/forumpost/bc39e531e5 # reset_db do_execsql_test analyzeE-6.0 { CREATE TABLE t1(x); CREATE INDEX i1 ON t1(x,x,x,x,x||2); CREATE INDEX i2 ON t1(1<2); WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000) INSERT INTO t1(x) SELECT x FROM c; ANALYZE; } {} do_execsql_test analyzeE-6.1 { SELECT count(*)>1 FROM sqlite_stat4 WHERE idx='i2' AND neq='1000 1'; } 1 do_execsql_test analyzeE-6.2 { SELECT count(*) FROM sqlite_stat4 WHERE idx='i2' AND neq<>'1000 1'; } 0 do_execsql_test analyzeE-6.3 { SELECT count(*)>1 FROM sqlite_stat4 WHERE idx='i1' AND neq='1 1 1 1 1 1'; } 1 do_execsql_test analyzeE-6.4 { SELECT count(*) FROM sqlite_stat4 WHERE idx='i1' AND neq<>'1 1 1 1 1 1'; } 0 # 2023-03-25 https://sqlite.org/forum/forumpost/5275207102 # Correctly expand zeroblobs while processing STAT4 information # during query planning. # reset_db do_execsql_test analyzeE-7.0 { CREATE TABLE t1(a TEXT COLLATE binary); CREATE INDEX t1x ON t1(a); INSERT INTO t1(a) VALUES(0),('apple'),(NULL),(''),('banana'); ANALYZE; SELECT format('(%s)',a) FROM t1 WHERE t1.a > CAST(zeroblob(5) AS TEXT); } {(0) (apple) (banana)} do_execsql_test analyzeE-7.1 { SELECT format('(%s)',a) FROM t1 WHERE t1.a <= CAST(zeroblob(5) AS TEXT); } {()} finish_test |
Changes to test/backup.test.
︙ | |||
973 974 975 976 977 978 979 980 981 | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | + + + + + + + + + + + + + + + + + + + + + + + | # do_test backup-11.1 { sqlite3 db1 :memory: sqlite3 db2 :memory: sqlite3_backup B db1 main db2 temp B finish } {SQLITE_OK} db1 close db2 close #------------------------------------------------------------------------- do_test backup-12.1 { sqlite3 db1 :memory: sqlite3 db2 :memory: db1 eval { PRAGMA page_size = 8192; CREATE TABLE t1(x); } db2 eval { PRAGMA page_size = 1024; CREATE TABLE t2(x); } sqlite3_backup B db1 main db2 temp B step 100 B finish } {SQLITE_READONLY} finish_test |
Changes to test/bloom1.test.
︙ | |||
95 96 97 98 99 100 101 | 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | |--CO-ROUTINE transit | |--SETUP | | `--SEARCH objs USING COVERING INDEX objs_cspo (o=? AND p=?) | `--RECURSIVE STEP | |--SCAN transit | `--SEARCH objs USING COVERING INDEX objs_cspo (o=? AND p=?) `--SCAN transit |
Changes to test/corruptI.test.
︙ | |||
119 120 121 122 123 124 125 | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - - - - - - + | INSERT INTO t1 VALUES(-1, 'abcdefghij'); INSERT INTO t1 VALUES(0, 'abcdefghij'); } set root [db one {SELECT rootpage FROM sqlite_master}] set offset [expr ($root-1) * 65536] |
︙ |
Changes to test/corruptL.test.
︙ | |||
1265 1266 1267 1268 1269 1270 1271 | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 | - + - + + + + | | 4048: 37 20 31 0b 03 04 11 11 13 63 31 63 31 37 20 31 7 1......c1c17 1 | 4064: 0e 02 04 11 13 07 63 31 63 31 64 37 20 31 20 31 ......c1c1d7 1 1 | 4080: 0e 01 04 11 13 17 63 31 63 31 63 37 20 31 00 00 ......c1c1c7 1.. | end crash-3afa1ca9e9c1bd.db }]} {} extra_schema_checks 0 |
︙ |
Changes to test/countofview.test.
︙ | |||
47 48 49 50 51 52 53 54 55 56 | 47 48 49 50 51 52 53 54 55 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | CREATE VIEW v1(x,y) AS SELECT x,1 FROM t1 UNION ALL SELECT x,2 FROM t1; SELECT count(*) FROM v1 WHERE x<>1; } {4} do_execsql_test 2.1 { SELECT count(*) FROM v1 GROUP BY y; } {3 3} # 2023-03-01 dbsqlfuzz ef8623915d843b150c159166ee4548c78cc6895a # count-of-view should not apply to CTEs. # ifcapable progress { proc progress_stop args {return 1} db progress 1000 progress_stop do_catchsql_test 3.1 { WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c) SELECT count(*) FROM c; } {1 interrupted} } # 2023-03-07 dbsqlfuzz 23d782160b71c3f8f535ccb2da313dfc8eb8c631 # do_execsql_test 4.1 { DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); INSERT INTO t1 VALUES(4,'four'); CREATE TABLE t2(c INTEGER PRIMARY KEY, d TEXT); CREATE VIEW t3 AS SELECT a, b FROM t1 UNION ALL SELECT c, d FROM t2; SELECT count(*) FROM t3 ORDER BY sum(a); } 1 # 2023-03-31 dbsqlfuzz 6a107e3055bd22afab31cfddabc2d9d54fcbaf69 # Having clauses should disqualify count-of-view # reset_db do_execsql_test 5.1 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); INSERT INTO t1 VALUES(1,'one'),(4,'four'); CREATE TABLE t2(c INTEGER PRIMARY KEY, d TEXT); INSERT INTO t2 VALUES(2,'two'),(5,'five'); CREATE VIEW t3 AS SELECT a, b FROM t1 UNION ALL SELECT c, d FROM t2; SELECT count(*) FROM t3 HAVING count(*)>0; } 4 do_execsql_test 5.2 { SELECT count(*) FROM t3 HAVING count(*)>5; } {} do_execsql_test 5.3 { SELECT count(*) FROM t3 HAVING max(b)>'mmm'; } 4 do_execsql_test 5.4 { SELECT count(*) FROM t3 HAVING min(b)>'mmm'; } {} do_execsql_test 5.5 { SELECT count(*) FROM ( SELECT a, max(b) FROM t1 HAVING a<100 UNION ALL SELECT c, d FROM t2 ) } 3 finish_test |
Changes to test/cursorhint.test.
︙ | |||
154 155 156 157 158 159 160 161 162 | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | + + + + + + + + + | } } {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))} do_test 4.6desc { p4_of_opcode db CursorHint { SELECT rowid FROM t1 WHERE b=22 AND c>=10 AND c<=20 ORDER BY b,c DESC; } } {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))} # 2023-03-24 https://sqlite.org/forum/forumpost/591006b1cc # reset_db do_execsql_test 5.0 { CREATE TABLE t1(x TEXT PRIMARY KEY) WITHOUT ROWID; CREATE VIEW t2 AS SELECT 0 FROM t1 WHERE x>='a' OR x='1'; SELECT * FROM t2 RIGHT JOIN t1 ON true; } finish_test |
Changes to test/delete.test.
︙ | |||
411 412 413 414 415 416 417 418 419 | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | + + + + + + + + + + + + + + + + + + + + + + + + | } {1 17 2 34 3 51 4 68 5 85 6 2 7 19 8 36 9 53 10 70 11 87 12 4 13 21 14 38 15 55 16 72 17 89 18 6 19 23 20 40} do_execsql_test delete-11.1 { DELETE FROM t11 AS xyz WHERE EXISTS(SELECT 1 FROM t11 WHERE t11.a>xyz.a AND t11.b<=xyz.b); SELECT * FROM t11; } {6 2 12 4 18 6 19 23 20 40} # 2023-03-15 # https://sqlite.org/forum/forumpost/e61252062c9d286d # # When the WHERE clause of a DELETE statement contains a subquery # which uses the table that is being deleted from and there is a # short-circuit operator of some kind in the WHERE clause such that # the subquery might not run right away, then the subquery might # run after one or more rows have been deleted, which can change # the result of the subquery, and result in the wrong answer. # # Similar problem for UPDATE tested by update-21.4 # https://sqlite.org/forum/forumpost/0007d1fdb1 # reset_db do_execsql_test delete-12.0 { CREATE TABLE t0(vkey INTEGER, pkey INTEGER,c1 INTEGER); INSERT INTO t0 VALUES(2,1,-20),(2,2,NULL),(2,3,0),(8,4,95); DELETE FROM t0 WHERE NOT ( (t0.vkey <= t0.c1) AND (t0.vkey <> (SELECT vkey FROM t0 ORDER BY vkey LIMIT 1 OFFSET 2)) ); SELECT * FROM t0; } {8 4 95} finish_test |
Changes to test/distinct.test.
︙ | |||
344 345 346 347 348 349 350 351 352 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ORDER BY a COLLATE nocase, b COLLATE nocase } { a a a b a c b a b b b c } } # 2023-03-16 # https://sqlite.org/forum/forumpost/16ce2bb7a639e29b # ticket c36cdb4afd504dc1 # ticket 4051a7f931d9ba24 # ticket d6fd512f50513ab7 # do_execsql_test 10.1 { SELECT DISTINCT 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ORDER BY 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x'; } {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} do_execsql_test 10.2 { EXPLAIN SELECT DISTINCT 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ORDER BY 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x','x','x','x','x','x','x', 'x','x','x','x'; } {/0 Init 0 /} do_execsql_test 10.3 { EXPLAIN CREATE TABLE t2 AS SELECT DISTINCT ':memory:', 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ORDER BY '%J%j%w%s', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', '%J%j%w%s', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 42e-300, 'unixepoch', 'unixepoch', 'unixepoch' LIMIT 0xda; } {/0 Init 0/} do_execsql_test 10.4 { DROP TABLE IF EXISTS t0; CREATE TABLE t0 AS SELECT DISTINCT 0xda, 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 0xda-0xda-42e-300, 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0', 'lit0' ORDER BY '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%Y-%m-%d', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', 'lit0', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', 'auto', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', ':memory:', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', '%%', ''; SELECT count(*) FROM t0; } {1} do_execsql_test 10.5 { DROP TABLE IF EXISTS t2; CREATE TABLE t2 AS SELECT DISTINCT ':memory:', 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0.0*7/0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ORDER BY '%J%j%w%s', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', '%J%j%w%s', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 'unixepoch', 42e-300, 'unixepoch', 'unixepoch', 'unixepoch' LIMIT 0xda; SELECT count(*) FROM t2; } {1} finish_test |
Changes to test/distinct2.test.
︙ | |||
296 297 298 299 300 301 302 303 304 | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | + + + + + + + + + + + + | do_execsql_test 3030 { SELECT DISTINCT * FROM t0 WHERE NULL IS c0; } { {} 1 {} {} 1 a } #------------------------------------------------------------------------- # reset_db do_execsql_test 4010 { CREATE TABLE t1(a, b COLLATE RTRIM); INSERT INTO t1 VALUES(1, ''), (2, ' '), (3, ' '); } do_execsql_test 4020 { SELECT b FROM t1 UNION SELECT 1; } {1 { }} finish_test |
Changes to test/fkey1.test.
︙ | |||
267 268 269 270 271 272 273 274 275 | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | + + + + + + + + + + + | CREATE TABLE sqlite_stat1(tbl INTEGER PRIMARY KEY DESC, idx UNIQUE DEFAULT NULL) WITHOUT ROWID; UPDATE sqlite_schema SET name='sqlite_autoindex_sqlite_stat1_1' WHERE name='sqlite_autoindex_sqlite_stat1_2'; PRAGMA writable_schema=RESET; } {} do_catchsql_test 8.3 { REINDEX; } {1 {database disk image is malformed}} # 2023-04-13 https://bugs.chromium.org/p/chromium/issues/detail?id=1405220 # Avoid double-de-quoting of table names when processing foreign keys. # reset_db do_execsql_test 9.1 { PRAGMA foreign_keys = ON; CREATE TABLE """1"("""2", """3" PRIMARY KEY); CREATE TABLE """4"("""5" REFERENCES """1" ON DELETE RESTRICT); DELETE FROM """1"; } finish_test |
Changes to test/gencol1.test.
︙ | |||
611 612 613 614 615 616 617 618 | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | CREATE TABLE t0(a PRIMARY KEY,b TEXT AS ('2') UNIQUE); INSERT INTO t0(a) VALUES(2); SELECT * FROM t0 AS x JOIN t0 AS y WHERE x.b='2' AND (y.a=2 OR (x.b LIKE '2*' AND y.a=x.b)); } {2 2 2 2} # 2023-03-02 dbsqlfuzz 65f5eb57f8859344d5f1f33e08c77ee12960ed83 # set typelist {ANY INT REAL BLOB TEXT {}} set cnt 0 foreach t1 $typelist { foreach t2 $typelist { incr cnt db eval " DROP TABLE IF EXISTS t1; CREATE TABLE t1( x $t1, a $t2 AS (x) VIRTUAL, b BLOB AS (x) VIRTUAL ); CREATE INDEX x2 ON t1(a); INSERT INTO t1(x) VALUES(NULL),('1'),(2),(3.5),('xyz'); " set x1 [lsort [db eval {SELECT typeof(b) FROM t1}]] do_test gencol1-23.1.$cnt { lsort [db eval {SELECT typeof(b) FROM t1 INDEXED BY x2}] } $x1 } } do_execsql_test gencol1-23.2 { DROP TABLE t1; CREATE TABLE t1( x, a INT AS (x) VIRTUAL, b BLOB AS (x) VIRTUAL ); CREATE INDEX x2 ON t1(a); INSERT INTO t1(x) VALUES(NULL),('1'),('xyz'),(2),(3.5); SELECT quote(a) FROM t1 INDEXED BY x2; } {NULL 1 2 3.5 'xyz'} do_execsql_test gencol1-23.3 { EXPLAIN SELECT a FROM t1 INDEXED BY x2; } {~/Column 0/} # ^^^^^^^^---- verfies that x2 acts like a covering index do_execsql_test gencol1-23.4 { EXPLAIN SELECT b FROM t1 INDEXED BY x2; } {/Column 0/} # ^^^^^^^^^^--- Must reference the original table in this case because # of the different datatype on column b. # 2023-03-07 https://sqlite.org/forum/forumpost/b312e075b5 # do_execsql_test gencol1-23.5 { CREATE TABLE v0(c1 INT, c2 AS (RAISE(IGNORE))); } do_catchsql_test gencol1-23.6 { SELECT * FROM v0; } {1 {RAISE() may only be used within a trigger-program}} finish_test |
Changes to test/in.test.
︙ | |||
825 826 827 828 829 830 831 | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + | do_execsql_test in-22.3 { SELECT * FROM t1 WHERE x IN (((SELECT a FROM t2))); } {2 200 4 400 6 600} do_execsql_test in-22.4 { SELECT * FROM t1 WHERE x IN ((((((SELECT a FROM t2)))))); } {2 200 4 400 6 600} # 2023-04-04 https://sqlite.org/forum/forumpost/dc16ec63d3 # Faulty assert() statement in the IN optimization. |
Changes to test/indexexpr1.test.
︙ | |||
587 588 589 590 591 592 593 | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | + + - + + + + + + + + + + + + + + + + + + + + + + | SELECT b FROM t1; } 300 do_execsql_test indexexpr1-2140 { UPDATE t1 SET b=400 WHERE (SELECT 'y') GLOB "y*"; SELECT b FROM t1; } 400 # 2023-04-18 Forum post https://sqlite.org/forum/forumpost/f34e32d120 from # Alexis King. |
Changes to test/indexexpr2.test.
︙ | |||
367 368 369 370 371 372 373 374 375 | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | SELECT * FROM t1 LEFT JOIN t2 WHERE $expr " {1 2 {} {} 3 4 {} {}} do_execsql_test 8.5.$tn.2 " SELECT ($expr) IS TRUE FROM t1 LEFT JOIN t2 " {1 1} } # 2023-03-24 https://sqlite.org/forum/forumpost/79cf371080 # reset_db do_execsql_test 9.0 { CREATE TABLE t1(a INT, b INT); CREATE INDEX t1x ON t1(a, abs(b)); CREATE TABLE t2(c INT, d INT); INSERT INTO t1(a,b) VALUES(4,4),(5,-5),(5,20),(6,6); INSERT INTO t2(c,d) VALUES(100,1),(200,1),(300,2); SELECT *, (SELECT max(c+abs(b)) FROM t2 GROUP BY d ORDER BY d LIMIT 1) AS subq FROM t1 WHERE a=5; } {5 -5 205 5 20 220} # 2023-04-03 https://sqlite.org/forum/forumpost/44270909bb # and https://sqlite.org/forum/forumpost/e45108732c which are the # same problem, namely the failure to omit the EP_Collate property # from an expression node when changing it from TK_COLLATE into # TK_AGG_COLUMN because it resolves to an indexed expression. # reset_db do_execsql_test 10.0 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); CREATE INDEX t1x ON t1 (b, +b COLLATE NOCASE); INSERT INTO t1(a,b) VALUES(1,'abcde'); SELECT * FROM t1 AS a0 WHERE (SELECT count(a0.b=+a0.b COLLATE NOCASE IN (b)) FROM t1 GROUP BY 2.5) ORDER BY a0.b; } {1 abcde} do_execsql_test 10.1 { CREATE TABLE t2(a TEXT); INSERT INTO t2 VALUES('alice'),('bob'),('cindy'),('david'); CREATE INDEX t2x ON t2 (+a COLLATE NOCASE); SELECT count(+a COLLATE NOCASE IN (SELECT 1)) AS x FROM t2 GROUP BY SUBSTR(0,0); } 4 # 2023-04-03 https://sqlite.org/forum/forumpost/409ebc7368 # When a generated column appears in both an outer and an inner loop # (that is to say, the same table is used in both loops) and the # generated column is indexed and it is used inside an aggregate function, # make sure that the terms resolve to the correct aggregate. # do_execsql_test 11.0 { CREATE TABLE t3 (a INT, b AS (-a)); CREATE INDEX t3x ON t3(b, a); INSERT INTO t3(a) VALUES(44); SELECT * FROM t3 AS a0 WHERE (SELECT sum(-a0.a=b) FROM t3 GROUP BY b) GROUP BY b; } {44 -44} finish_test |
Changes to test/join2.test.
︙ | |||
350 351 352 353 354 355 356 357 358 | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2; } {{} 1} optimization_control db query-flattener 0 do_execsql_test 9.11 { SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2; } {{} 1} # 2023-03-01 https://sqlite.org/forum/forumpost/26387ea7ef # When flattening a VIEW which is the RHS of a LEFT JOIN, always put # an TK_IF_NULL_ROW operator on all accesses, even TK_COLUMN nodes, since # the TK_COLUMN might reference an outer subquery. # reset_db db null NULL do_execsql_test 10.1 { CREATE TABLE t1 (x INTEGER); INSERT INTO t1 VALUES(1); -- Some true value CREATE TABLE t2 (z TEXT); INSERT INTO t2 VALUES('some value'); CREATE TABLE t3(w TEXT); INSERT INTO t3 VALUES('some other value'); } do_execsql_test 10.2 { SELECT ( SELECT 1 FROM t2 LEFT JOIN (SELECT x AS v FROM t3) ON 500=v WHERE (v OR FALSE) ) FROM t1; } NULL do_execsql_test 10.3 { SELECT ( SELECT 1 FROM t2 LEFT JOIN (SELECT x AS v FROM t3) ON 500=v WHERE (v) ) FROM t1; } NULL optimization_control db all 0 do_execsql_test 10.4 { SELECT ( SELECT 1 FROM t2 LEFT JOIN (SELECT x AS v FROM t3) ON 500=v WHERE (v OR FALSE) ) FROM t1; } NULL # 2023-03-02 https://sqlite.org/forum/forumpost/402f05296d # # The TK_IF_NULL_ROW expression node must ensure that it does not overwrite # the result register of an OP_Once subroutine. # optimization_control db all 1 do_execsql_test 11.1 { DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; CREATE TABLE t1(x TEXT, y INTEGER); INSERT INTO t1(x,y) VALUES(NULL,-2),(NULL,1),('0',2); CREATE TABLE t2(z INTEGER); INSERT INTO t2(z) VALUES(2),(-2); CREATE VIEW t3 AS SELECT z, (SELECT count(*) FROM t1) AS w FROM t2; SELECT * FROM t1 LEFT JOIN t3 ON y=z; } {NULL -2 -2 3 NULL 1 NULL NULL 0 2 2 3} # 2023-03-11 https://sqlite.org/forum/forumpost/b405033490fa56d9 # The fix that test 11.1 above checks also caused a performance regression. # This test case verifies that the performance regression has been resolved. # do_execsql_test 12.1 { DROP TABLE t1; DROP TABLE t2; DROP VIEW t3; CREATE TABLE t1(a INTEGER PRIMARY KEY); WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<100) INSERT INTO t1(a) SELECT n FROM c; CREATE VIEW t2(b) AS SELECT a FROM t1; } do_vmstep_test 12.2 { SELECT * FROM t1 LEFT JOIN t2 ON a=b LIMIT 10 OFFSET 98; } 2000 {99 99 100 100} do_eqp_test 12.3 { SELECT * FROM t1 LEFT JOIN t2 ON a=b LIMIT 10 OFFSET 98; } { QUERY PLAN |--SCAN t1 `--SEARCH t1 USING INTEGER PRIMARY KEY (rowid=?) LEFT-JOIN } finish_test |
Changes to test/joinH.test.
︙ | |||
85 86 87 88 89 90 91 92 93 | 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 121 122 123 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | CREATE INDEX i1 ON t1( (d IS NULL), d ); } do_execsql_test 4.4 { SELECT (d IS NULL) FROM t1 RIGHT JOIN t2 ON (j=33); } {1} #------------------------------------------------------------------------- # reset_db do_execsql_test 5.0 { CREATE TABLE t0(w); CREATE TABLE t1(x); CREATE TABLE t2(y); CREATE TABLE t3(z); INSERT INTO t3 VALUES('t3val'); } do_execsql_test 5.1 { SELECT * FROM t1 INNER JOIN t2 ON (0) RIGHT OUTER JOIN t3; } {{} {} t3val} do_execsql_test 5.2 { SELECT * FROM t1 INNER JOIN t2 ON (0) FULL OUTER JOIN t3; } {{} {} t3val} do_execsql_test 5.3 { SELECT * FROM t3 LEFT JOIN t2 ON (0); } {t3val {}} do_execsql_test 5.4 { SELECT * FROM t0 RIGHT JOIN t1 INNER JOIN t2 ON (0) RIGHT JOIN t3 } {{} {} {} t3val} do_execsql_test 5.5 { SELECT * FROM t0 RIGHT JOIN t1 INNER JOIN t2 ON (0) } {} finish_test |
Changes to test/notnull2.test.
︙ | |||
24 25 26 27 28 29 30 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | - - - - - - - - - - - - - - - - - - | WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 ) INSERT INTO t1 SELECT i, i FROM x; INSERT INTO t2 SELECT * FROM t1; } |
︙ |
Changes to test/pragma.test.
︙ | |||
2056 2057 2058 2059 2060 2061 2062 2063 | 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 | + + + + + + + + + + + + + | SELECT * FROM t1; } {1 {database disk image is malformed}} do_catchsql_test 24.2 { PRAGMA integrity_check; } {0 {{database disk image is malformed}}} } database_never_corrupt # 2023-03-27. Register allocation issue in integrity_check discovered # by new assert() statements added in [6f8b97f31a4c8552]. # dbsqlfuzz dc9ab26037cf5ef797d28cd1ae0855ade584216d # tag-20230327-1 # reset_db do_execsql_test 25.0 { CREATE TABLE t1(a INT, b AS (a*2) NOT NULL); CREATE TEMP TABLE t2(a PRIMARY KEY, b, c UNIQUE) WITHOUT ROWID; CREATE UNIQUE INDEX t2x ON t2(c,b); PRAGMA integrity_check; } ok finish_test |
Changes to test/returning1.test.
︙ | |||
208 209 210 211 212 213 214 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | - + - + - + - + | INSERT INTO log VALUES('insert', new.rowid, new.a, new.b); END; CREATE TRIGGER tr2 INSTEAD OF UPDATE ON t1 BEGIN INSERT INTO log VALUES('update', new.rowid, new.a, new.b); END; } |
︙ | |||
403 404 405 406 407 408 409 410 411 | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | # reset_db do_execsql_test 17.0 { CREATE TABLE bug(id INTEGER PRIMARY KEY NOT NULL, x); INSERT INTO bug(id,x) VALUES(20, NULL); UPDATE bug SET x=NULL WHERE id = 20 RETURNING quote(x), x IS NULL; } {NULL 1} # 2023-03-08 https://sqlite.org/forum/forumpost/f5a2b1db87 # NULL pointer dereference following an error. # do_execsql_test 18.0 { CREATE TABLE v0(c1 INT); CREATE VIEW view_2(c1) AS SELECT CASE WHEN c1 COLLATE TRUE THEN TRUE ELSE TRUE END FROM v0; CREATE TRIGGER x1 INSTEAD OF INSERT ON view_2 BEGIN SELECT true; END; } do_catchsql_test 18.1 { INSERT INTO view_2 DEFAULT VALUES RETURNING *; } {1 {no such collation sequence: TRUE}} # 2023-03-16 # https://sqlite.org/forum/forumpost/c99d6e0329 # ticket d15b3a4ea901ef0d # ticket 89d259d45b855a0d # # A RETURNING clause on an IF NOT EXISTS trigger does not generate # an error if the trigger already exists. # do_execsql_test 19.0 { DROP TABLE IF EXISTS t1;CREATE TABLE t1(a); CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN VALUES(0); END; } {} do_catchsql_test 19.1 { CREATE TRIGGER IF NOT EXISTS r1 AFTER DELETE ON t1 BEGIN INSERT INTO t1(a) VALUES (1) RETURNING FALSE; INSERT INTO t1(a) VALUES (2) RETURNING TRUE; END; } {0 {}} finish_test |
Changes to test/scanstatus2.test.
︙ | |||
227 228 229 230 231 232 233 234 235 236 237 | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + | --CO-ROUTINE v1 ----SCAN rt2 (nCycle=nnn) ----USE TEMP B-TREE FOR GROUP BY --SCAN rt1 (nCycle=nnn) --CREATE AUTOMATIC INDEX ON v1(x1, cnt) (nCycle=nnn) --SEARCH v1 USING AUTOMATIC COVERING INDEX (x1=?) (nCycle=nnn) } #------------------------------------------------------------------------- reset_db ifcapable trace { do_execsql_test 5.0 { CREATE TABLE t1(x, y); CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN SELECT 1; END; INSERT INTO t1 VALUES(1, 2); } proc trace {stmt sql} { array set A [sqlite3_stmt_scanstatus -flags complex [format %x $stmt] 0] lappend ::trace_explain $A(zExplain) } db trace_v2 trace set ::trace_explain [list] do_execsql_test 5.1 { DELETE FROM t1 WHERE x=1; } do_test 5.2 { set ::trace_explain } {{SCAN t1} {SCAN t1} {SCAN t1}} } finish_test |
Changes to test/seekscan1.test.
︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | + | CREATE TABLE t1(a TEXT, b INT, c INT NOT NULL, PRIMARY KEY(a,b,c)); WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<1997) INSERT INTO t1(a,b,c) SELECT printf('xyz%d',x/10),x/6,x FROM c; INSERT INTO t1 VALUES('abc',234,6); INSERT INTO t1 VALUES('abc',345,7); ANALYZE; } do_execsql_test 1.1 { SELECT a,b,c FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 6.5 AND a='abc' ORDER BY a, b; } { abc 234 6 |
︙ | |||
54 55 56 57 58 59 60 61 62 63 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | + + + + | SELECT a,b,c FROM t1 WHERE b IN (234, 345) AND c<=7 AND a='abc' ORDER BY a, b; } { abc 234 6 abc 345 7 } do_execsql_test 1.5 { SELECT a,b,c FROM t1 WHERE b IN (235, 345) AND c<=3 AND a='abc' ORDER BY a, b; } finish_test |
Changes to test/skipscan1.test.
︙ | |||
414 415 416 417 418 419 420 421 422 | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | + + + + + + + + + + | FROM t1 WHERE a = b AND a = 3 AND b IN (1,3,2,4) AND b >= 0 AND a <= 10; } {3} # 2023-03-24 https://sqlite.org/forum/forumpost/8cc1dc0fe9 # reset_db do_execsql_test skipscan1-5.0 { CREATE TABLE t1(a TEXT, UNIQUE(a,a,a)); INSERT INTO t1 VALUES (hex(zeroblob(241))),(1),(2),(3); ANALYZE; SELECT max(a) FROM t1 WHERE a IN t1; } {3} finish_test |
Changes to test/subtype1.test.
︙ | |||
49 50 51 52 53 54 55 | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | + + - + + + + + + + + + + + + + + + + + | do_execsql_test subtype1-230 { WITH t4(a) AS MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4; } {0} do_execsql_test subtype1-231 { WITH t4(a) AS NOT MATERIALIZED (SELECT json(1)) SELECT subtype(a) FROM t4; } {0} # 2023-03-01 # https://sqlite.org/forum/forumpost/37dd14a538 |
Changes to test/tester.tcl.
︙ | |||
944 945 946 947 948 949 950 951 952 953 954 955 956 957 | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | + + + + + + + + + + + + + + + + + + + + + + + | } proc normalize_list {L} { set L2 [list] foreach l $L {lappend L2 $l} set L2 } # Run SQL and verify that the number of "vmsteps" required is greater # than or less than some constant. # proc do_vmstep_test {tn sql nstep {res {}}} { uplevel [list do_execsql_test $tn.0 $sql $res] set vmstep [db status vmstep] if {[string range $nstep 0 0]=="+"} { set body "if {$vmstep<$nstep} { error \"got $vmstep, expected more than [string range $nstep 1 end]\" }" } else { set body "if {$vmstep>$nstep} { error \"got $vmstep, expected less than $nstep\" }" } # set name "$tn.vmstep=$vmstep,expect=$nstep" set name "$tn.1" uplevel [list do_test $name $body {}] } # Either: # # do_execsql_test TESTNAME SQL ?RES? # do_execsql_test -db DB TESTNAME SQL ?RES? # proc do_execsql_test {args} { |
︙ |
Changes to test/tkt-99378177930f87bd.test.
︙ | |||
171 172 173 174 175 176 177 178 179 | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | + + + + + + + + + + + + + + + + + | OR ( (SELECT avg( (SELECT sum((SELECT 1 FROM t1 NATURAL RIGHT JOIN t1 WHERE a=a)))) AS xyz ) AND a==2 ); } {1 2} # 2023-03-04 https://sqlite.org/forum/forumpost/a68313d054 # # See also indexexpr1-2200 added on 2023-03-18. # do_execsql_test tkt-99378-400 { DROP TABLE t1; CREATE TABLE t0(w); INSERT INTO t0(w) VALUES(1); CREATE TABLE t1(x); INSERT INTO t1(x) VALUES(1); CREATE INDEX t1x ON t1(x > 0); CREATE VIEW t2(y) AS SELECT avg(w) FROM t0 GROUP BY w>1; CREATE VIEW t3(z) AS SELECT count(*) FROM t2 WHERE y BETWEEN 0 and 0; SELECT count(*) FROM t1 NOT INDEXED WHERE (SELECT z FROM t3); SELECT count(*) FROM t1 INDEXED BY t1x WHERE (SELECT z FROM t3); } {0 0} finish_test |
Changes to test/update.test.
︙ | |||
727 728 729 730 731 732 733 734 735 | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } {ok} do_catchsql_test update-20.20 { UPDATE t1 SET a=0; } {1 {constraint failed}} do_execsql_test update-20.30 { PRAGMA integrity_check; } {ok} # 2023-03-16 https://sqlite.org/forum/forumpost/0007d1fdb1 # A subquery in the WHERE clause of an UPDATE and behind a # short-circuit evaluation caused problems because multi-row # single-pass was selected. # # Similar problem for DELETE tested by delete-12.0. # https://sqlite.org/src/info/73f0036f045bf371 # reset_db do_execsql_test update-21.1 { CREATE TABLE t1 (vkey INTEGER, c5 INTEGER); INSERT INTO t1 VALUES(3,NULL),(6,-54); } db null NULL do_execsql_test update-21.2 { BEGIN; UPDATE t1 SET vkey = 100 WHERE c5 is null; SELECT * FROM t1 ORDER BY vkey, c5; ROLLBACK; } {6 -54 100 NULL} do_execsql_test update-21.3 { BEGIN; UPDATE t1 SET vkey = 100 WHERE NOT (-10*(select min(vkey) from t1) >= c5); SELECT * FROM t1 ORDER BY vkey, c5; ROLLBACK; } {3 NULL 6 -54} do_execsql_test update-21.4 { BEGIN; UPDATE t1 SET vkey = 100 WHERE c5 is null OR NOT (-10*(select min(vkey) from t1) >= c5); SELECT * FROM t1 ORDER BY vkey, c5; ROLLBACK; } {6 -54 100 NULL} finish_test |
Changes to test/window1.test.
︙ | |||
2205 2206 2207 2208 2209 2210 2211 2212 2213 | 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } {/1 {.*}/} do_execsql_test 72.1 { CREATE TABLE dual(dummy); INSERT INTO dual VALUES('X'); CREATE VIEW v1(x,y) AS SELECT RANK() OVER (PARTITION BY 0), SUM(0) FROM dual; SELECT * FROM v1 WHERE true; } {1 0} #------------------------------------------------------------------------- reset_db do_execsql_test 72.0 { CREATE TABLE t0(c0); INSERT INTO t0(c0) VALUES (0); CREATE VIEW v0(c0) AS SELECT TOTAL(0) OVER (PARTITION BY t0.c0) FROM t0; } do_execsql_test 72.1 { SELECT COUNT(*) FROM ( SELECT TOTAL(0) OVER (PARTITION BY t0.c0) FROM t0 ) WHERE ('1' IS NOT ('abcde' NOTNULL)); } {1} # 2023-03-28 https://sqlite.org/forum/forumpost/dc3b92cfa0 (Song Liu) # reset_db do_execsql_test 73.0 { CREATE TABLE t1(a INT); INSERT INTO t1(a) VALUES(1),(2),(4); CREATE VIEW t2(b,c) AS SELECT * FROM t1 JOIN t1 A ORDER BY sum(0) OVER(PARTITION BY 0); CREATE TRIGGER x1 INSTEAD OF UPDATE ON t2 BEGIN SELECT true; END; } do_execsql_test 73.1 { SELECT * FROM t2; } {1 1 1 2 1 4 2 1 2 2 2 4 4 1 4 2 4 4} do_execsql_test 73.2 { UPDATE t2 SET c=99 WHERE b=4 RETURNING *; } {4 99 4 99 4 99} do_execsql_test 73.3 { SELECT *, nth_value(15,2) OVER() FROM t2, t1 WHERE b=4; } { 4 1 1 15 4 2 1 15 4 4 1 15 4 1 2 15 4 2 2 15 4 4 2 15 4 1 4 15 4 2 4 15 4 4 4 15 } do_execsql_test 73.4 { UPDATE t2 SET c=nth_value(15,2) OVER() FROM (SELECT * FROM t1) WHERE b=4 RETURNING *; } { 4 15 4 15 4 15 4 15 4 15 4 15 4 15 4 15 4 15 } do_execsql_test 73.5 { DROP TRIGGER x1; } do_catchsql_test 73.6 { UPDATE t2 SET c=99 WHERE b=4 RETURNING *; } {1 {cannot modify t2 because it is a view}} do_catchsql_test 73.7 { UPDATE t2 SET c=nth_value(15,2) OVER() FROM (SELECT * FROM t1) WHERE b=4 RETURNING *; } {1 {cannot modify t2 because it is a view}} # 2023-03-28 https://sqlite.org/forum/forumpost/bad532820c # reset_db do_execsql_test 74.0 { CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (c INT, d INT); CREATE INDEX idx ON t1(abs(a)); INSERT INTO t1 VALUES(1,2),(3,4); INSERT INTO t2 VALUES(5,6),(7,8); } do_execsql_test 74.1 { SELECT ( SELECT count( a ) FROM t2 LIMIT 1 ) FROM t1; } {2} ;# Verified using PG 14.2 do_execsql_test 74.2 { SELECT ( SELECT count( a+c ) FROM t2 LIMIT 1 ) FROM t1; } {2 2} ;# verified on PG 14.2. Crashes PG 9.6! do_execsql_test 74.3 { SELECT ( SELECT count( ( SELECT(sum(0) OVER(ORDER BY c, abs(a))) ) ) FROM t2 GROUP BY c LIMIT 1 ) FROM t1; } {1 1} ;# verified on PG 14.2 do_execsql_test 74.4 { /* Original test case reported in https://sqlite.org/forum/forumpost/bad532820c CREATE TABLE v0 (c1); CREATE INDEX i ON v0 (c1, c1=1); SELECT 0 FROM v0 AS a1 WHERE (SELECT count((SELECT(sum(0) OVER(PARTITION BY(c1), (a1.c1=1) )))) FROM v0 GROUP BY hex(0)) AND a1.c1=0; } {} # 2023-04-11 https://sqlite.org/forum/forumpost/6c5678e3da # An ALWAYS() turns out to be sometimes false. # do_execsql_test 75.0 { DROP TABLE t1; CREATE TABLE t1(a INT, b INT); CREATE INDEX t1x ON t1(a+b); } do_catchsql_test 75.1 { SELECT count((SELECT count(a0.a+a0.b) ORDER BY sum(0) OVER (PARTITION BY 0))) FROM t1 AS a0 JOIN t1 AS a1 GROUP BY a1.a; } {1 {misuse of aggregate: count()}} # 2023-04-11 https://sqlite.org/forum/forumpost/6c5678e3da # An ALWAYS() turns out to be sometimes false. # do_execsql_test 75.0 { DROP TABLE t1; CREATE TABLE t1(a INT, b INT); CREATE INDEX t1x ON t1(a+b); } do_catchsql_test 75.1 { SELECT count((SELECT count(a0.a+a0.b) ORDER BY sum(0) OVER (PARTITION BY 0))) FROM t1 AS a0 JOIN t1 AS a1 GROUP BY a1.a; } {1 {misuse of aggregate: count()}} # 2023-04-13 https://sqlite.org/forum/forumpost/0d48347967 reset_db do_execsql_test 76.0 { CREATE TABLE t1(a INT, b INT); INSERT INTO t1(a,b) VALUES (111,222),(111,223),(118,229); CREATE INDEX t1a ON t1(a); CREATE TABLE t2(x INT); INSERT INTO t2 VALUES (333),(444),(555); } do_execsql_test 76.1 { SELECT c, (SELECT c + sum(1) OVER ()) AS "res" FROM t2 LEFT JOIN (SELECT +a AS c FROM t1) AS v1 ON true GROUP BY c ORDER by c; } {111 112 118 119} # ^^^^^^^^^^^^^^^^^-- results verified against PG 14.2 finish_test |