@@ -14753,6 +14753,15 @@ static void dbdataValue(
1475314753 }
1475414754}
1475514755
14756+ /* This macro is a copy of the MX_CELL() macro in the SQLite core. Given
14757+ ** a page-size, it returns the maximum number of cells that may be present
14758+ ** on the page. */
14759+ #define DBDATA_MX_CELL(pgsz) ((pgsz-8)/6)
14760+
14761+ /* Maximum number of fields that may appear in a single record. This is
14762+ ** the "hard-limit", according to comments in sqliteLimit.h. */
14763+ #define DBDATA_MX_FIELD 32676
14764+
1475614765/*
1475714766** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
1475814767*/
@@ -14781,6 +14790,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
1478114790 assert( iOff+3+2<=pCsr->nPage );
1478214791 pCsr->iCell = pTab->bPtr ? -2 : 0;
1478314792 pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
14793+ if( pCsr->nCell>DBDATA_MX_CELL(pCsr->nPage) ){
14794+ pCsr->nCell = DBDATA_MX_CELL(pCsr->nPage);
14795+ }
1478414796 }
1478514797
1478614798 if( pTab->bPtr ){
@@ -14825,19 +14837,19 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
1482514837 if( pCsr->iCell>=pCsr->nCell ){
1482614838 bNextPage = 1;
1482714839 }else{
14840+ int iCellPtr = iOff + 8 + nPointer + pCsr->iCell*2;
1482814841
14829- iOff += 8 + nPointer + pCsr->iCell*2;
14830- if( iOff>pCsr->nPage ){
14842+ if( iCellPtr>pCsr->nPage ){
1483114843 bNextPage = 1;
1483214844 }else{
14833- iOff = get_uint16(&pCsr->aPage[iOff ]);
14845+ iOff = get_uint16(&pCsr->aPage[iCellPtr ]);
1483414846 }
1483514847
1483614848 /* For an interior node cell, skip past the child-page number */
1483714849 iOff += nPointer;
1483814850
1483914851 /* Load the "byte of payload including overflow" field */
14840- if( bNextPage || iOff>pCsr->nPage ){
14852+ if( bNextPage || iOff>pCsr->nPage || iOff<=iCellPtr ){
1484114853 bNextPage = 1;
1484214854 }else{
1484314855 iOff += dbdataGetVarintU32(&pCsr->aPage[iOff], &nPayload);
@@ -14920,7 +14932,9 @@ static int dbdataNext(sqlite3_vtab_cursor *pCursor){
1492014932 pCsr->iField++;
1492114933 if( pCsr->iField>0 ){
1492214934 sqlite3_int64 iType;
14923- if( pCsr->pHdrPtr>&pCsr->pRec[pCsr->nRec] ){
14935+ if( pCsr->pHdrPtr>=&pCsr->pRec[pCsr->nRec]
14936+ || pCsr->iField>=DBDATA_MX_FIELD
14937+ ){
1492414938 bNextPage = 1;
1492514939 }else{
1492614940 int szField = 0;
@@ -16408,7 +16422,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
1640816422 if( bTable && !bVirtual ){
1640916423 if( SQLITE_ROW==sqlite3_step(pTblname) ){
1641016424 const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0);
16411- recoverAddTable(p, zTbl, iRoot);
16425+ if( zTbl ) recoverAddTable(p, zTbl, iRoot);
1641216426 }
1641316427 recoverReset(p, pTblname);
1641416428 }
@@ -28771,6 +28785,7 @@ static const char zOptions[] =
2877128785 " -newline SEP set output row separator. Default: '\\n'\n"
2877228786 " -nofollow refuse to open symbolic links to database files\n"
2877328787 " -nonce STRING set the safe-mode escape nonce\n"
28788+ " -no-rowid-in-view Disable rowid-in-view using sqlite3_config()\n"
2877428789 " -nullvalue TEXT set text string for NULL values. Default ''\n"
2877528790 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
2877628791 " -pcachetrace trace all page cache operations\n"
@@ -29061,6 +29076,10 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
2906129076 stdin_is_interactive = 0;
2906229077 }else if( cli_strcmp(z,"-utf8")==0 ){
2906329078 }else if( cli_strcmp(z,"-no-utf8")==0 ){
29079+ }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){
29080+ int val = 0;
29081+ sqlite3_config(SQLITE_CONFIG_ROWID_IN_VIEW, &val);
29082+ assert( val==0 );
2906429083 }else if( cli_strcmp(z,"-heap")==0 ){
2906529084#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
2906629085 const char *zSize;
@@ -29336,6 +29355,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
2933629355 /* already handled */
2933729356 }else if( cli_strcmp(z,"-no-utf8")==0 ){
2933829357 /* already handled */
29358+ }else if( cli_strcmp(z,"-no-rowid-in-view")==0 ){
29359+ /* already handled */
2933929360 }else if( cli_strcmp(z,"-heap")==0 ){
2934029361 i++;
2934129362 }else if( cli_strcmp(z,"-pagecache")==0 ){
0 commit comments