Fossil SCM

Update the built-in SQLite to a newer version that fixes the btree overflow page cache bug.

drh 2024-04-12 15:24 trunk
Commit 6a571f88ccf5ef58391bea508a6a0617dc1b30d36843245b7dd256fe6e7484ba
+20 -6
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15882,10 +15882,19 @@
1588215882
}
1588315883
}
1588415884
}
1588515885
}
1588615886
15887
+/* This macro is a copy of the MX_CELL() macro in the SQLite core. Given
15888
+** a page-size, it returns the maximum number of cells that may be present
15889
+** on the page. */
15890
+#define DBDATA_MX_CELL(pgsz) ((pgsz-8)/6)
15891
+
15892
+/* Maximum number of fields that may appear in a single record. This is
15893
+** the "hard-limit", according to comments in sqliteLimit.h. */
15894
+#define DBDATA_MX_FIELD 32676
15895
+
1588715896
/*
1588815897
** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
1588915898
*/
1589015899
static int dbdataNext(sqlite3_vtab_cursor *pCursor){
1589115900
DbdataCursor *pCsr = (DbdataCursor*)pCursor;
@@ -15910,10 +15919,13 @@
1591015919
}
1591115920
1591215921
assert( iOff+3+2<=pCsr->nPage );
1591315922
pCsr->iCell = pTab->bPtr ? -2 : 0;
1591415923
pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
15924
+ if( pCsr->nCell>DBDATA_MX_CELL(pCsr->nPage) ){
15925
+ pCsr->nCell = DBDATA_MX_CELL(pCsr->nPage);
15926
+ }
1591515927
}
1591615928
1591715929
if( pTab->bPtr ){
1591815930
if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){
1591915931
pCsr->iCell = pCsr->nCell;
@@ -15954,23 +15966,23 @@
1595415966
}
1595515967
1595615968
if( pCsr->iCell>=pCsr->nCell ){
1595715969
bNextPage = 1;
1595815970
}else{
15971
+ int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2;
1595915972
15960
- iOff += 8 + nPointer + pCsr->iCell*2;
15961
- if( iOff>pCsr->nPage ){
15973
+ if( iCellPtr>pCsr->nPage ){
1596215974
bNextPage = 1;
1596315975
}else{
15964
- iOff = get_uint16(&pCsr->aPage[iOff]);
15976
+ iOff = get_uint16(&pCsr->aPage[iCellPtr]);
1596515977
}
1596615978
1596715979
/* For an interior node cell, skip past the child-page number */
1596815980
iOff += nPointer;
1596915981
1597015982
/* Load the "byte of payload including overflow" field */
15971
- if( bNextPage || iOff>pCsr->nPage ){
15983
+ if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){
1597215984
bNextPage = 1;
1597315985
}else{
1597415986
iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload);
1597515987
if( nPayload>0x7fffff00 ) nPayload &= 0x3fff;
1597615988
}
@@ -16049,11 +16061,13 @@
1604916061
}
1605016062
}else{
1605116063
pCsr->iField++;
1605216064
if( pCsr->iField>0 ){
1605316065
sqlite3_int64 iType;
16054
- if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){
16066
+ if( pCsr->pHdrPtr>=&pCsr->pRec[pCsr->nRec]
16067
+ || pCsr->iField>=DBDATA_MX_FIELD
16068
+ ){
1605516069
bNextPage = 1;
1605616070
}else{
1605716071
int szField = 0;
1605816072
pCsr->pHdrPtr += dbdataGetVarintU32(pCsr->pHdrPtr, &iType);
1605916073
szField = dbdataValueBytes(iType);
@@ -17537,11 +17551,11 @@
1753717551
if( rc==SQLITE_OK ){
1753817552
recoverSqlCallback(p, zSql);
1753917553
if( bTable && !bVirtual ){
1754017554
if( SQLITE_ROW==sqlite3_step(pTblname) ){
1754117555
const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0);
17542
- recoverAddTable(p, zTbl, iRoot);
17556
+ if( zTbl ) recoverAddTable(p, zTbl, iRoot);
1754317557
}
1754417558
recoverReset(p, pTblname);
1754517559
}
1754617560
}else if( rc!=SQLITE_ERROR ){
1754717561
recoverDbError(p, p->dbOut);
1754817562
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15882,10 +15882,19 @@
15882 }
15883 }
15884 }
15885 }
15886
 
 
 
 
 
 
 
 
 
15887 /*
15888 ** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
15889 */
15890 static int dbdataNext(sqlite3_vtab_cursor *pCursor){
15891 DbdataCursor *pCsr = (DbdataCursor*)pCursor;
@@ -15910,10 +15919,13 @@
15910 }
15911
15912 assert( iOff+3+2<=pCsr->nPage );
15913 pCsr->iCell = pTab->bPtr ? -2 : 0;
15914 pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
 
 
 
15915 }
15916
15917 if( pTab->bPtr ){
15918 if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){
15919 pCsr->iCell = pCsr->nCell;
@@ -15954,23 +15966,23 @@
15954 }
15955
15956 if( pCsr->iCell>=pCsr->nCell ){
15957 bNextPage = 1;
15958 }else{
 
15959
15960 iOff += 8 + nPointer + pCsr->iCell*2;
15961 if( iOff>pCsr->nPage ){
15962 bNextPage = 1;
15963 }else{
15964 iOff = get_uint16(&pCsr->aPage[iOff]);
15965 }
15966
15967 /* For an interior node cell, skip past the child-page number */
15968 iOff += nPointer;
15969
15970 /* Load the "byte of payload including overflow" field */
15971 if( bNextPage || iOff>pCsr->nPage ){
15972 bNextPage = 1;
15973 }else{
15974 iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload);
15975 if( nPayload>0x7fffff00 ) nPayload &= 0x3fff;
15976 }
@@ -16049,11 +16061,13 @@
16049 }
16050 }else{
16051 pCsr->iField++;
16052 if( pCsr->iField>0 ){
16053 sqlite3_int64 iType;
16054 if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){
 
 
16055 bNextPage = 1;
16056 }else{
16057 int szField = 0;
16058 pCsr->pHdrPtr += dbdataGetVarintU32(pCsr->pHdrPtr, &iType);
16059 szField = dbdataValueBytes(iType);
@@ -17537,11 +17551,11 @@
17537 if( rc==SQLITE_OK ){
17538 recoverSqlCallback(p, zSql);
17539 if( bTable && !bVirtual ){
17540 if( SQLITE_ROW==sqlite3_step(pTblname) ){
17541 const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0);
17542 recoverAddTable(p, zTbl, iRoot);
17543 }
17544 recoverReset(p, pTblname);
17545 }
17546 }else if( rc!=SQLITE_ERROR ){
17547 recoverDbError(p, p->dbOut);
17548
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15882,10 +15882,19 @@
15882 }
15883 }
15884 }
15885 }
15886
15887 /* This macro is a copy of the MX_CELL() macro in the SQLite core. Given
15888 ** a page-size, it returns the maximum number of cells that may be present
15889 ** on the page. */
15890 #define DBDATA_MX_CELL(pgsz) ((pgsz-8)/6)
15891
15892 /* Maximum number of fields that may appear in a single record. This is
15893 ** the "hard-limit", according to comments in sqliteLimit.h. */
15894 #define DBDATA_MX_FIELD 32676
15895
15896 /*
15897 ** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
15898 */
15899 static int dbdataNext(sqlite3_vtab_cursor *pCursor){
15900 DbdataCursor *pCsr = (DbdataCursor*)pCursor;
@@ -15910,10 +15919,13 @@
15919 }
15920
15921 assert( iOff+3+2<=pCsr->nPage );
15922 pCsr->iCell = pTab->bPtr ? -2 : 0;
15923 pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
15924 if( pCsr->nCell>DBDATA_MX_CELL(pCsr->nPage) ){
15925 pCsr->nCell = DBDATA_MX_CELL(pCsr->nPage);
15926 }
15927 }
15928
15929 if( pTab->bPtr ){
15930 if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){
15931 pCsr->iCell = pCsr->nCell;
@@ -15954,23 +15966,23 @@
15966 }
15967
15968 if( pCsr->iCell>=pCsr->nCell ){
15969 bNextPage = 1;
15970 }else{
15971 int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2;
15972
15973 if( iCellPtr>pCsr->nPage ){
 
15974 bNextPage = 1;
15975 }else{
15976 iOff = get_uint16(&pCsr->aPage[iCellPtr]);
15977 }
15978
15979 /* For an interior node cell, skip past the child-page number */
15980 iOff += nPointer;
15981
15982 /* Load the "byte of payload including overflow" field */
15983 if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){
15984 bNextPage = 1;
15985 }else{
15986 iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload);
15987 if( nPayload>0x7fffff00 ) nPayload &= 0x3fff;
15988 }
@@ -16049,11 +16061,13 @@
16061 }
16062 }else{
16063 pCsr->iField++;
16064 if( pCsr->iField>0 ){
16065 sqlite3_int64 iType;
16066 if( pCsr->pHdrPtr>=&pCsr->pRec[pCsr->nRec]
16067 || pCsr->iField>=DBDATA_MX_FIELD
16068 ){
16069 bNextPage = 1;
16070 }else{
16071 int szField = 0;
16072 pCsr->pHdrPtr += dbdataGetVarintU32(pCsr->pHdrPtr, &iType);
16073 szField = dbdataValueBytes(iType);
@@ -17537,11 +17551,11 @@
17551 if( rc==SQLITE_OK ){
17552 recoverSqlCallback(p, zSql);
17553 if( bTable && !bVirtual ){
17554 if( SQLITE_ROW==sqlite3_step(pTblname) ){
17555 const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0);
17556 if( zTbl ) recoverAddTable(p, zTbl, iRoot);
17557 }
17558 recoverReset(p, pTblname);
17559 }
17560 }else if( rc!=SQLITE_ERROR ){
17561 recoverDbError(p, p->dbOut);
17562
+34 -20
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** 69ec714b2d698acf9e37635256c01b233ce3.
21
+** 5dede50d9e7b6942df9f7b00fbfeaa2103c3.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459459
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460460
** [sqlite_version()] and [sqlite_source_id()].
461461
*/
462462
#define SQLITE_VERSION "3.46.0"
463463
#define SQLITE_VERSION_NUMBER 3046000
464
-#define SQLITE_SOURCE_ID "2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940"
464
+#define SQLITE_SOURCE_ID "2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d"
465465
466466
/*
467467
** CAPI3REF: Run-Time Library Version Numbers
468468
** KEYWORDS: sqlite3_version sqlite3_sourceid
469469
**
@@ -64141,11 +64141,11 @@
6414164141
/*
6414264142
** Return the file handle for the journal file (if it exists).
6414364143
** This will be either the rollback journal or the WAL file.
6414464144
*/
6414564145
SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
64146
-#if SQLITE_OMIT_WAL
64146
+#ifdef SQLITE_OMIT_WAL
6414764147
return pPager->jfd;
6414864148
#else
6414964149
return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;
6415064150
#endif
6415164151
}
@@ -75632,10 +75632,14 @@
7563275632
}
7563375633
}
7563475634
memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
7563575635
pCur->curFlags |= BTCF_ValidOvfl;
7563675636
}else{
75637
+ /* Sanity check the validity of the overflow page cache */
75638
+ assert( pCur->aOverflow[0]==nextPage || pCur->aOverflow[0]==0 );
75639
+ assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 );
75640
+
7563775641
/* If the overflow page-list cache has been allocated and the
7563875642
** entry for the first required overflow page is valid, skip
7563975643
** directly to it.
7564075644
*/
7564175645
if( pCur->aOverflow[offset/ovflSize] ){
@@ -76112,10 +76116,27 @@
7611276116
*pRes = 1;
7611376117
rc = SQLITE_OK;
7611476118
}
7611576119
return rc;
7611676120
}
76121
+
76122
+#ifdef SQLITE_DEBUG
76123
+/* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
76124
+** this flags are true for a consistent database.
76125
+**
76126
+** This routine is is called from within assert() statements only.
76127
+** It is an internal verification routine and does not appear in production
76128
+** builds.
76129
+*/
76130
+static int cursorIsAtLastEntry(BtCursor *pCur){
76131
+ int ii;
76132
+ for(ii=0; ii<pCur->iPage; ii++){
76133
+ if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0;
76134
+ }
76135
+ return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0;
76136
+}
76137
+#endif
7611776138
7611876139
/* Move the cursor to the last entry in the table. Return SQLITE_OK
7611976140
** on success. Set *pRes to 0 if the cursor actually points to something
7612076141
** or set *pRes to 1 if the table is empty.
7612176142
*/
@@ -76141,22 +76162,11 @@
7614176162
assert( cursorOwnsBtShared(pCur) );
7614276163
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
7614376164
7614476165
/* If the cursor already points to the last entry, this is a no-op. */
7614576166
if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){
76146
-#ifdef SQLITE_DEBUG
76147
- /* This block serves to assert() that the cursor really does point
76148
- ** to the last entry in the b-tree. */
76149
- int ii;
76150
- for(ii=0; ii<pCur->iPage; ii++){
76151
- assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );
76152
- }
76153
- assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB );
76154
- testcase( pCur->ix!=pCur->pPage->nCell-1 );
76155
- /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */
76156
- assert( pCur->pPage->leaf );
76157
-#endif
76167
+ assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
7615876168
*pRes = 0;
7615976169
return SQLITE_OK;
7616076170
}
7616176171
return btreeLast(pCur, pRes);
7616276172
}
@@ -76205,10 +76215,11 @@
7620576215
*pRes = 0;
7620676216
return SQLITE_OK;
7620776217
}
7620876218
if( pCur->info.nKey<intKey ){
7620976219
if( (pCur->curFlags & BTCF_AtLast)!=0 ){
76220
+ assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
7621076221
*pRes = -1;
7621176222
return SQLITE_OK;
7621276223
}
7621376224
/* If the requested key is one more than the previous key, then
7621476225
** try to get there using sqlite3BtreeNext() rather than a full
@@ -80010,11 +80021,11 @@
8001080021
dropCell(pPage, idx, info.nSize, &rc);
8001180022
if( rc ) goto end_insert;
8001280023
}else if( loc<0 && pPage->nCell>0 ){
8001380024
assert( pPage->leaf );
8001480025
idx = ++pCur->ix;
80015
- pCur->curFlags &= ~BTCF_ValidNKey;
80026
+ pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
8001680027
}else{
8001780028
assert( pPage->leaf );
8001880029
}
8001980030
rc = insertCellFast(pPage, idx, newCell, szNew);
8002080031
assert( pPage->nOverflow==0 || rc==SQLITE_OK );
@@ -80040,11 +80051,11 @@
8004080051
** larger than the largest existing key, it is possible to insert the
8004180052
** row without seeking the cursor. This can be a big performance boost.
8004280053
*/
8004380054
if( pPage->nOverflow ){
8004480055
assert( rc==SQLITE_OK );
80045
- pCur->curFlags &= ~(BTCF_ValidNKey);
80056
+ pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
8004680057
rc = balance(pCur);
8004780058
8004880059
/* Must make sure nOverflow is reset to zero even if the balance()
8004980060
** fails. Internal data structure corruption will result otherwise.
8005080061
** Also, set the cursor state to invalid. This stops saveCursorPosition()
@@ -135985,11 +135996,14 @@
135985135996
** further downstream. */
135986135997
return 0; /* Corrupt schema - two indexes on the same btree */
135987135998
}
135988135999
}
135989136000
#ifndef SQLITE_OMIT_CHECK
135990
- if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
136001
+ if( pDest->pCheck
136002
+ && (db->mDbFlags & DBFLAG_Vacuum)==0
136003
+ && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1)
136004
+ ){
135991136005
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
135992136006
}
135993136007
#endif
135994136008
#ifndef SQLITE_OMIT_FOREIGN_KEY
135995136009
/* Disallow the transfer optimization if the destination table contains
@@ -202436,11 +202450,11 @@
202436202450
}else{
202437202451
iScore += 1000;
202438202452
}
202439202453
mCover |= mPhrase;
202440202454
202441
- for(j=0; j<pPhrase->nToken; j++){
202455
+ for(j=0; j<pPhrase->nToken && j<pIter->nSnippet; j++){
202442202456
mHighlight |= (mPos>>j);
202443202457
}
202444202458
202445202459
if( 0==(*pCsr & 0x0FE) ) break;
202446202460
fts3GetDeltaPosition(&pCsr, &iCsr);
@@ -252156,11 +252170,11 @@
252156252170
int nArg, /* Number of args */
252157252171
sqlite3_value **apUnused /* Function arguments */
252158252172
){
252159252173
assert( nArg==0 );
252160252174
UNUSED_PARAM2(nArg, apUnused);
252161
- sqlite3_result_text(pCtx, "fts5: 2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940", -1, SQLITE_TRANSIENT);
252175
+ sqlite3_result_text(pCtx, "fts5: 2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d", -1, SQLITE_TRANSIENT);
252162252176
}
252163252177
252164252178
/*
252165252179
** Return true if zName is the extension on one of the shadow tables used
252166252180
** by this module.
252167252181
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 69ec714b2d698acf9e37635256c01b233ce3.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.46.0"
463 #define SQLITE_VERSION_NUMBER 3046000
464 #define SQLITE_SOURCE_ID "2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -64141,11 +64141,11 @@
64141 /*
64142 ** Return the file handle for the journal file (if it exists).
64143 ** This will be either the rollback journal or the WAL file.
64144 */
64145 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
64146 #if SQLITE_OMIT_WAL
64147 return pPager->jfd;
64148 #else
64149 return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;
64150 #endif
64151 }
@@ -75632,10 +75632,14 @@
75632 }
75633 }
75634 memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
75635 pCur->curFlags |= BTCF_ValidOvfl;
75636 }else{
 
 
 
 
75637 /* If the overflow page-list cache has been allocated and the
75638 ** entry for the first required overflow page is valid, skip
75639 ** directly to it.
75640 */
75641 if( pCur->aOverflow[offset/ovflSize] ){
@@ -76112,10 +76116,27 @@
76112 *pRes = 1;
76113 rc = SQLITE_OK;
76114 }
76115 return rc;
76116 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76117
76118 /* Move the cursor to the last entry in the table. Return SQLITE_OK
76119 ** on success. Set *pRes to 0 if the cursor actually points to something
76120 ** or set *pRes to 1 if the table is empty.
76121 */
@@ -76141,22 +76162,11 @@
76141 assert( cursorOwnsBtShared(pCur) );
76142 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
76143
76144 /* If the cursor already points to the last entry, this is a no-op. */
76145 if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){
76146 #ifdef SQLITE_DEBUG
76147 /* This block serves to assert() that the cursor really does point
76148 ** to the last entry in the b-tree. */
76149 int ii;
76150 for(ii=0; ii<pCur->iPage; ii++){
76151 assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );
76152 }
76153 assert( pCur->ix==pCur->pPage->nCell-1 || CORRUPT_DB );
76154 testcase( pCur->ix!=pCur->pPage->nCell-1 );
76155 /* ^-- dbsqlfuzz b92b72e4de80b5140c30ab71372ca719b8feb618 */
76156 assert( pCur->pPage->leaf );
76157 #endif
76158 *pRes = 0;
76159 return SQLITE_OK;
76160 }
76161 return btreeLast(pCur, pRes);
76162 }
@@ -76205,10 +76215,11 @@
76205 *pRes = 0;
76206 return SQLITE_OK;
76207 }
76208 if( pCur->info.nKey<intKey ){
76209 if( (pCur->curFlags & BTCF_AtLast)!=0 ){
 
76210 *pRes = -1;
76211 return SQLITE_OK;
76212 }
76213 /* If the requested key is one more than the previous key, then
76214 ** try to get there using sqlite3BtreeNext() rather than a full
@@ -80010,11 +80021,11 @@
80010 dropCell(pPage, idx, info.nSize, &rc);
80011 if( rc ) goto end_insert;
80012 }else if( loc<0 && pPage->nCell>0 ){
80013 assert( pPage->leaf );
80014 idx = ++pCur->ix;
80015 pCur->curFlags &= ~BTCF_ValidNKey;
80016 }else{
80017 assert( pPage->leaf );
80018 }
80019 rc = insertCellFast(pPage, idx, newCell, szNew);
80020 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
@@ -80040,11 +80051,11 @@
80040 ** larger than the largest existing key, it is possible to insert the
80041 ** row without seeking the cursor. This can be a big performance boost.
80042 */
80043 if( pPage->nOverflow ){
80044 assert( rc==SQLITE_OK );
80045 pCur->curFlags &= ~(BTCF_ValidNKey);
80046 rc = balance(pCur);
80047
80048 /* Must make sure nOverflow is reset to zero even if the balance()
80049 ** fails. Internal data structure corruption will result otherwise.
80050 ** Also, set the cursor state to invalid. This stops saveCursorPosition()
@@ -135985,11 +135996,14 @@
135985 ** further downstream. */
135986 return 0; /* Corrupt schema - two indexes on the same btree */
135987 }
135988 }
135989 #ifndef SQLITE_OMIT_CHECK
135990 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
 
 
 
135991 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
135992 }
135993 #endif
135994 #ifndef SQLITE_OMIT_FOREIGN_KEY
135995 /* Disallow the transfer optimization if the destination table contains
@@ -202436,11 +202450,11 @@
202436 }else{
202437 iScore += 1000;
202438 }
202439 mCover |= mPhrase;
202440
202441 for(j=0; j<pPhrase->nToken; j++){
202442 mHighlight |= (mPos>>j);
202443 }
202444
202445 if( 0==(*pCsr & 0x0FE) ) break;
202446 fts3GetDeltaPosition(&pCsr, &iCsr);
@@ -252156,11 +252170,11 @@
252156 int nArg, /* Number of args */
252157 sqlite3_value **apUnused /* Function arguments */
252158 ){
252159 assert( nArg==0 );
252160 UNUSED_PARAM2(nArg, apUnused);
252161 sqlite3_result_text(pCtx, "fts5: 2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940", -1, SQLITE_TRANSIENT);
252162 }
252163
252164 /*
252165 ** Return true if zName is the extension on one of the shadow tables used
252166 ** by this module.
252167
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 5dede50d9e7b6942df9f7b00fbfeaa2103c3.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.46.0"
463 #define SQLITE_VERSION_NUMBER 3046000
464 #define SQLITE_SOURCE_ID "2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -64141,11 +64141,11 @@
64141 /*
64142 ** Return the file handle for the journal file (if it exists).
64143 ** This will be either the rollback journal or the WAL file.
64144 */
64145 SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){
64146 #ifdef SQLITE_OMIT_WAL
64147 return pPager->jfd;
64148 #else
64149 return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;
64150 #endif
64151 }
@@ -75632,10 +75632,14 @@
75632 }
75633 }
75634 memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
75635 pCur->curFlags |= BTCF_ValidOvfl;
75636 }else{
75637 /* Sanity check the validity of the overflow page cache */
75638 assert( pCur->aOverflow[0]==nextPage || pCur->aOverflow[0]==0 );
75639 assert( pCur->aOverflow[0]!=0 || pCur->aOverflow[offset/ovflSize]==0 );
75640
75641 /* If the overflow page-list cache has been allocated and the
75642 ** entry for the first required overflow page is valid, skip
75643 ** directly to it.
75644 */
75645 if( pCur->aOverflow[offset/ovflSize] ){
@@ -76112,10 +76116,27 @@
76116 *pRes = 1;
76117 rc = SQLITE_OK;
76118 }
76119 return rc;
76120 }
76121
76122 #ifdef SQLITE_DEBUG
76123 /* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that
76124 ** this flags are true for a consistent database.
76125 **
76126 ** This routine is is called from within assert() statements only.
76127 ** It is an internal verification routine and does not appear in production
76128 ** builds.
76129 */
76130 static int cursorIsAtLastEntry(BtCursor *pCur){
76131 int ii;
76132 for(ii=0; ii<pCur->iPage; ii++){
76133 if( pCur->aiIdx[ii]!=pCur->apPage[ii]->nCell ) return 0;
76134 }
76135 return pCur->ix==pCur->pPage->nCell-1 && pCur->pPage->leaf!=0;
76136 }
76137 #endif
76138
76139 /* Move the cursor to the last entry in the table. Return SQLITE_OK
76140 ** on success. Set *pRes to 0 if the cursor actually points to something
76141 ** or set *pRes to 1 if the table is empty.
76142 */
@@ -76141,22 +76162,11 @@
76162 assert( cursorOwnsBtShared(pCur) );
76163 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
76164
76165 /* If the cursor already points to the last entry, this is a no-op. */
76166 if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){
76167 assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
 
 
 
 
 
 
 
 
 
 
 
76168 *pRes = 0;
76169 return SQLITE_OK;
76170 }
76171 return btreeLast(pCur, pRes);
76172 }
@@ -76205,10 +76215,11 @@
76215 *pRes = 0;
76216 return SQLITE_OK;
76217 }
76218 if( pCur->info.nKey<intKey ){
76219 if( (pCur->curFlags & BTCF_AtLast)!=0 ){
76220 assert( cursorIsAtLastEntry(pCur) || CORRUPT_DB );
76221 *pRes = -1;
76222 return SQLITE_OK;
76223 }
76224 /* If the requested key is one more than the previous key, then
76225 ** try to get there using sqlite3BtreeNext() rather than a full
@@ -80010,11 +80021,11 @@
80021 dropCell(pPage, idx, info.nSize, &rc);
80022 if( rc ) goto end_insert;
80023 }else if( loc<0 && pPage->nCell>0 ){
80024 assert( pPage->leaf );
80025 idx = ++pCur->ix;
80026 pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
80027 }else{
80028 assert( pPage->leaf );
80029 }
80030 rc = insertCellFast(pPage, idx, newCell, szNew);
80031 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
@@ -80040,11 +80051,11 @@
80051 ** larger than the largest existing key, it is possible to insert the
80052 ** row without seeking the cursor. This can be a big performance boost.
80053 */
80054 if( pPage->nOverflow ){
80055 assert( rc==SQLITE_OK );
80056 pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
80057 rc = balance(pCur);
80058
80059 /* Must make sure nOverflow is reset to zero even if the balance()
80060 ** fails. Internal data structure corruption will result otherwise.
80061 ** Also, set the cursor state to invalid. This stops saveCursorPosition()
@@ -135985,11 +135996,14 @@
135996 ** further downstream. */
135997 return 0; /* Corrupt schema - two indexes on the same btree */
135998 }
135999 }
136000 #ifndef SQLITE_OMIT_CHECK
136001 if( pDest->pCheck
136002 && (db->mDbFlags & DBFLAG_Vacuum)==0
136003 && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1)
136004 ){
136005 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
136006 }
136007 #endif
136008 #ifndef SQLITE_OMIT_FOREIGN_KEY
136009 /* Disallow the transfer optimization if the destination table contains
@@ -202436,11 +202450,11 @@
202450 }else{
202451 iScore += 1000;
202452 }
202453 mCover |= mPhrase;
202454
202455 for(j=0; j<pPhrase->nToken && j<pIter->nSnippet; j++){
202456 mHighlight |= (mPos>>j);
202457 }
202458
202459 if( 0==(*pCsr & 0x0FE) ) break;
202460 fts3GetDeltaPosition(&pCsr, &iCsr);
@@ -252156,11 +252170,11 @@
252170 int nArg, /* Number of args */
252171 sqlite3_value **apUnused /* Function arguments */
252172 ){
252173 assert( nArg==0 );
252174 UNUSED_PARAM2(nArg, apUnused);
252175 sqlite3_result_text(pCtx, "fts5: 2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d", -1, SQLITE_TRANSIENT);
252176 }
252177
252178 /*
252179 ** Return true if zName is the extension on one of the shadow tables used
252180 ** by this module.
252181
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.46.0"
150150
#define SQLITE_VERSION_NUMBER 3046000
151
-#define SQLITE_SOURCE_ID "2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940"
151
+#define SQLITE_SOURCE_ID "2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.46.0"
150 #define SQLITE_VERSION_NUMBER 3046000
151 #define SQLITE_SOURCE_ID "2024-04-08 11:50:07 69ec714b2d698acf9e37635256c01b233ce32f22e8323e226441d5ddd948a940"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.46.0"
150 #define SQLITE_VERSION_NUMBER 3046000
151 #define SQLITE_SOURCE_ID "2024-04-12 15:02:16 5dede50d9e7b6942df9f7b00fbfeaa2103c36c5da01d63d88136fb0ef4b7d26d"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button