| | @@ -16,11 +16,11 @@ |
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | | -** db82b4281a0e0d5e365553df11e0347f60c. |
| 21 | +** 4be9af4469d7e31ee852f67e5aa32996557. |
| 22 | 22 | */ |
| 23 | 23 | #define SQLITE_CORE 1 |
| 24 | 24 | #define SQLITE_AMALGAMATION 1 |
| 25 | 25 | #ifndef SQLITE_PRIVATE |
| 26 | 26 | # define SQLITE_PRIVATE static |
| | @@ -459,11 +459,11 @@ |
| 459 | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | 461 | */ |
| 462 | 462 | #define SQLITE_VERSION "3.44.0" |
| 463 | 463 | #define SQLITE_VERSION_NUMBER 3044000 |
| 464 | | -#define SQLITE_SOURCE_ID "2023-10-23 02:01:14 0db82b4281a0e0d5e365553df11e0347f60c00c861c0fb96227059edff3a0ef6" |
| 464 | +#define SQLITE_SOURCE_ID "2023-10-24 11:06:44 54be9af4469d7e31ee852f67e5aa32996557c10de654a60103fd165d2fedf311" |
| 465 | 465 | |
| 466 | 466 | /* |
| 467 | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| 468 | 468 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 469 | 469 | ** |
| | @@ -80195,18 +80195,20 @@ |
| 80195 | 80195 | /* |
| 80196 | 80196 | ** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that |
| 80197 | 80197 | ** corresponds to page iPg is already set. |
| 80198 | 80198 | */ |
| 80199 | 80199 | static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80200 | + assert( pCheck->aPgRef!=0 ); |
| 80200 | 80201 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 80201 | 80202 | return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); |
| 80202 | 80203 | } |
| 80203 | 80204 | |
| 80204 | 80205 | /* |
| 80205 | 80206 | ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. |
| 80206 | 80207 | */ |
| 80207 | 80208 | static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ |
| 80209 | + assert( pCheck->aPgRef!=0 ); |
| 80208 | 80210 | assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); |
| 80209 | 80211 | pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); |
| 80210 | 80212 | } |
| 80211 | 80213 | |
| 80212 | 80214 | |
| | @@ -109460,14 +109462,14 @@ |
| 109460 | 109462 | int nAlloc; |
| 109461 | 109463 | if( dupFlags ){ |
| 109462 | 109464 | nAlloc = dupedExprSize(p); |
| 109463 | 109465 | }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 109464 | 109466 | nToken = sqlite3Strlen30NN(p->u.zToken)+1; |
| 109465 | | - nAlloc = EXPR_FULLSIZE + ROUND8(nToken); |
| 109467 | + nAlloc = ROUND8(EXPR_FULLSIZE + nToken); |
| 109466 | 109468 | }else{ |
| 109467 | 109469 | nToken = 0; |
| 109468 | | - nAlloc = EXPR_FULLSIZE; |
| 109470 | + nAlloc = ROUND8(EXPR_FULLSIZE); |
| 109469 | 109471 | } |
| 109470 | 109472 | assert( nAlloc==ROUND8(nAlloc) ); |
| 109471 | 109473 | sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc); |
| 109472 | 109474 | #ifdef SQLITE_DEBUG |
| 109473 | 109475 | sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0; |
| | @@ -138956,10 +138958,11 @@ |
| 138956 | 138958 | int r2; /* Previous key for WITHOUT ROWID tables */ |
| 138957 | 138959 | int mxCol; /* Maximum non-virtual column number */ |
| 138958 | 138960 | |
| 138959 | 138961 | if( pObjTab && pObjTab!=pTab ) continue; |
| 138960 | 138962 | if( !IsOrdinaryTable(pTab) ){ |
| 138963 | +#ifndef SQLITE_OMIT_VIRTUALTABLE |
| 138961 | 138964 | sqlite3_vtab *pVTab; |
| 138962 | 138965 | int a1; |
| 138963 | 138966 | if( !IsVirtual(pTab) ) continue; |
| 138964 | 138967 | if( pTab->nCol<=0 ){ |
| 138965 | 138968 | const char *zMod = pTab->u.vtab.azArg[0]; |
| | @@ -138975,10 +138978,11 @@ |
| 138975 | 138978 | sqlite3VdbeAddOp2(v, OP_VCheck, 0, 3); |
| 138976 | 138979 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); |
| 138977 | 138980 | a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); |
| 138978 | 138981 | integrityCheckResultRow(v); |
| 138979 | 138982 | sqlite3VdbeJumpHere(v, a1); |
| 138983 | +#endif |
| 138980 | 138984 | continue; |
| 138981 | 138985 | } |
| 138982 | 138986 | if( isQuick || HasRowid(pTab) ){ |
| 138983 | 138987 | pPk = 0; |
| 138984 | 138988 | r2 = 0; |
| | @@ -179837,11 +179841,11 @@ |
| 179837 | 179841 | void *pArg /* First callback argument */ |
| 179838 | 179842 | ){ |
| 179839 | 179843 | void *pRet; |
| 179840 | 179844 | |
| 179841 | 179845 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 179842 | | - if( db==0 || xCallback==0 ){ |
| 179846 | + if( db==0 ){ |
| 179843 | 179847 | return 0; |
| 179844 | 179848 | } |
| 179845 | 179849 | #endif |
| 179846 | 179850 | sqlite3_mutex_enter(db->mutex); |
| 179847 | 179851 | pRet = db->pPreUpdateArg; |
| | @@ -187833,22 +187837,30 @@ |
| 187833 | 187837 | */ |
| 187834 | 187838 | static int fts3Integrity(sqlite3_vtab *pVtab, char **pzErr){ |
| 187835 | 187839 | Fts3Table *p = (Fts3Table*)pVtab; |
| 187836 | 187840 | char *zSql; |
| 187837 | 187841 | int rc; |
| 187842 | + char *zErr = 0; |
| 187838 | 187843 | |
| 187839 | 187844 | zSql = sqlite3_mprintf( |
| 187840 | 187845 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", |
| 187841 | 187846 | p->zDb, p->zName, p->zName); |
| 187842 | | - rc = sqlite3_exec(p->db, zSql, 0, 0, 0); |
| 187847 | + if( zSql==0 ){ |
| 187848 | + return SQLITE_NOMEM; |
| 187849 | + } |
| 187850 | + rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr); |
| 187843 | 187851 | sqlite3_free(zSql); |
| 187844 | 187852 | if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 187845 | 187853 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", |
| 187846 | 187854 | p->bFts4 ? 4 : 3, p->zDb, p->zName); |
| 187847 | | - rc = SQLITE_OK; |
| 187855 | + }else if( rc!=SQLITE_OK ){ |
| 187856 | + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" |
| 187857 | + " FTS%d table %s.%s: %s", |
| 187858 | + p->bFts4 ? 4 : 3, p->zDb, p->zName, zErr); |
| 187848 | 187859 | } |
| 187849 | | - return rc; |
| 187860 | + sqlite3_free(zErr); |
| 187861 | + return SQLITE_OK; |
| 187850 | 187862 | } |
| 187851 | 187863 | |
| 187852 | 187864 | |
| 187853 | 187865 | |
| 187854 | 187866 | static const sqlite3_module fts3Module = { |
| | @@ -198115,10 +198127,12 @@ |
| 198115 | 198127 | assert( pNode->n>0 ); |
| 198116 | 198128 | assert_fts3_nc( (pNode->a[0]=='\0')==(aDoclist!=0) ); |
| 198117 | 198129 | |
| 198118 | 198130 | blobGrowBuffer(pPrev, nTerm, &rc); |
| 198119 | 198131 | if( rc!=SQLITE_OK ) return rc; |
| 198132 | + assert( pPrev!=0 ); |
| 198133 | + assert( pPrev->a!=0 ); |
| 198120 | 198134 | |
| 198121 | 198135 | nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); |
| 198122 | 198136 | nSuffix = nTerm - nPrefix; |
| 198123 | 198137 | if( nSuffix<=0 ) return FTS_CORRUPT_VTAB; |
| 198124 | 198138 | memcpy(pPrev->a, zTerm, nTerm); |
| | @@ -221489,12 +221503,14 @@ |
| 221489 | 221503 | ** The buffer that the argument points to contains a serialized SQL value. |
| 221490 | 221504 | ** Return the number of bytes of space occupied by the value (including |
| 221491 | 221505 | ** the type byte). |
| 221492 | 221506 | */ |
| 221493 | 221507 | static int sessionSerialLen(const u8 *a){ |
| 221494 | | - int e = *a; |
| 221508 | + int e; |
| 221495 | 221509 | int n; |
| 221510 | + assert( a!=0 ); |
| 221511 | + e = *a; |
| 221496 | 221512 | if( e==0 || e==0xFF ) return 1; |
| 221497 | 221513 | if( e==SQLITE_NULL ) return 1; |
| 221498 | 221514 | if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; |
| 221499 | 221515 | return sessionVarintGet(&a[1], &n) + 1 + n; |
| 221500 | 221516 | } |
| | @@ -226336,10 +226352,11 @@ |
| 226336 | 226352 | int nRec, /* Number of bytes in aRec */ |
| 226337 | 226353 | SessionChange **ppNew /* OUT: Merged change */ |
| 226338 | 226354 | ){ |
| 226339 | 226355 | SessionChange *pNew = 0; |
| 226340 | 226356 | int rc = SQLITE_OK; |
| 226357 | + assert( aRec!=0 ); |
| 226341 | 226358 | |
| 226342 | 226359 | if( !pExist ){ |
| 226343 | 226360 | pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec); |
| 226344 | 226361 | if( !pNew ){ |
| 226345 | 226362 | return SQLITE_NOMEM; |
| | @@ -247420,11 +247437,11 @@ |
| 247420 | 247437 | int nArg, /* Number of args */ |
| 247421 | 247438 | sqlite3_value **apUnused /* Function arguments */ |
| 247422 | 247439 | ){ |
| 247423 | 247440 | assert( nArg==0 ); |
| 247424 | 247441 | UNUSED_PARAM2(nArg, apUnused); |
| 247425 | | - sqlite3_result_text(pCtx, "fts5: 2023-10-22 23:44:32 678a9728dc6b88d8ef924c86603056df18204bc9a9c4776b9baffd7c5b10c5f2", -1, SQLITE_TRANSIENT); |
| 247442 | + sqlite3_result_text(pCtx, "fts5: 2023-10-23 23:34:53 9d388267e4e6724e2df333fe09d509e87defcfe984c5c2ebe031152d320812d0", -1, SQLITE_TRANSIENT); |
| 247426 | 247443 | } |
| 247427 | 247444 | |
| 247428 | 247445 | /* |
| 247429 | 247446 | ** Return true if zName is the extension on one of the shadow tables used |
| 247430 | 247447 | ** by this module. |
| | @@ -247447,23 +247464,28 @@ |
| 247447 | 247464 | */ |
| 247448 | 247465 | static int fts5Integrity(sqlite3_vtab *pVtab, char **pzErr){ |
| 247449 | 247466 | Fts5FullTable *pTab = (Fts5FullTable*)pVtab; |
| 247450 | 247467 | Fts5Config *pConfig = pTab->p.pConfig; |
| 247451 | 247468 | char *zSql; |
| 247469 | + char *zErr = 0; |
| 247452 | 247470 | int rc; |
| 247453 | 247471 | zSql = sqlite3_mprintf( |
| 247454 | 247472 | "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", |
| 247455 | 247473 | pConfig->zDb, pConfig->zName, pConfig->zName); |
| 247456 | | - rc = sqlite3_exec(pConfig->db, zSql, 0, 0, 0); |
| 247474 | + if( zSql==0 ) return SQLITE_NOMEM; |
| 247475 | + rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr); |
| 247457 | 247476 | sqlite3_free(zSql); |
| 247458 | 247477 | if( (rc&0xff)==SQLITE_CORRUPT ){ |
| 247459 | 247478 | *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", |
| 247460 | 247479 | pConfig->zDb, pConfig->zName); |
| 247461 | | - rc = SQLITE_OK; |
| 247480 | + }else if( rc!=SQLITE_OK ){ |
| 247481 | + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" |
| 247482 | + " FTS5 table %s.%s: %s", |
| 247483 | + pConfig->zDb, pConfig->zName, zErr); |
| 247462 | 247484 | } |
| 247463 | | - return rc; |
| 247464 | | - |
| 247485 | + sqlite3_free(zErr); |
| 247486 | + return SQLITE_OK; |
| 247465 | 247487 | } |
| 247466 | 247488 | |
| 247467 | 247489 | static int fts5Init(sqlite3 *db){ |
| 247468 | 247490 | static const sqlite3_module fts5Mod = { |
| 247469 | 247491 | /* iVersion */ 4, |
| 247470 | 247492 | |