From 73390f09c2e93c61e4da507d2b61e4cf03a98b59 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 15 Sep 2022 03:54:52 +0000 Subject: [PATCH] Fix windows builds of recover extension. FossilOrigin-Name: abcbb6abfe08fc590123f0aa1bd72cfdecc75908f078f1348dc0e957de98bf52 --- Makefile.msc | 6 ++++++ ext/recover/sqlite3recover.c | 18 +++++++----------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 9baa4ae937..4abf2d8e82 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1587,6 +1587,9 @@ TESTEXT = \ $(TOP)\ext\misc\unionvtab.c \ $(TOP)\ext\misc\wholenumber.c \ $(TOP)\ext\rtree\test_rtreedoc.c \ + $(TOP)\ext\recover\sqlite3recover.c \ + $(TOP)\ext\recover\test_recover.c \ + $(TOP)\ext\misc\dbdata.c \ fts5.c # If use of zlib is enabled, add the "zipfile.c" source file. @@ -2224,6 +2227,9 @@ SHELL_SRC = \ $(TOP)\ext\expert\sqlite3expert.c \ $(TOP)\ext\expert\sqlite3expert.h \ $(TOP)\ext\misc\memtrace.c \ + $(TOP)/ext/misc/dbdata.c \ + $(TOP)/ext/recover/sqlite3recover.c \ + $(TOP)/ext/recover/sqlite3recover.h \ $(TOP)\src\test_windirent.c # If use of zlib is enabled, add the "zipfile.c" source file. diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c index 6c52d99855..a370ca0c46 100644 --- a/ext/recover/sqlite3recover.c +++ b/ext/recover/sqlite3recover.c @@ -137,7 +137,7 @@ struct RecoverColumn { typedef struct RecoverBitmap RecoverBitmap; struct RecoverBitmap { i64 nPg; /* Size of bitmap */ - u32 aElem[0]; /* Array of 32-bit bitmasks */ + u32 aElem[1]; /* Array of 32-bit bitmasks */ }; /* @@ -999,8 +999,8 @@ static int recoverWriteSchema1(sqlite3_recover *p){ recoverSqlCallback(p, zSql); if( bTable && !bVirtual ){ if( SQLITE_ROW==sqlite3_step(pTblname) ){ - const char *zName = sqlite3_column_text(pTblname, 0); - recoverAddTable(p, zName, iRoot); + const char *zTbl = (const char*)sqlite3_column_text(pTblname, 0); + recoverAddTable(p, zTbl, iRoot); } recoverReset(p, pTblname); } @@ -1252,7 +1252,6 @@ static sqlite3_stmt *recoverLostAndFoundInsert( int nTotal = nField + 4; int ii; char *zBind = 0; - const char *zSep = ""; sqlite3_stmt *pRet = 0; if( p->xSql==0 ){ @@ -1328,7 +1327,7 @@ static void recoverLostAndFoundPopulate( recoverBindValue(p, pInsert, 5+ii, apVal[ii]); } if( sqlite3_step(pInsert)==SQLITE_ROW ){ - recoverSqlCallback(p, sqlite3_column_text(pInsert, 0)); + recoverSqlCallback(p, (const char*)sqlite3_column_text(pInsert, 0)); } recoverReset(p, pInsert); @@ -1376,7 +1375,7 @@ static void recoverLostAndFoundPopulate( ** db and writes all orphaned rows to it. Or, if the recover handle is ** in SQL callback mode, issues equivalent callbacks. */ -static int recoverLostAndFound(sqlite3_recover *p){ +static void recoverLostAndFound(sqlite3_recover *p){ i64 nPg = 0; RecoverBitmap *pMap = 0; @@ -1558,9 +1557,7 @@ static int recoverWriteData(sqlite3_recover *p){ if( bNewCell ){ if( nVal>=0 ){ - int ii; int iVal = 0; - int iBind = 1; if( pInsert==0 || nVal!=nInsert ){ recoverFinalize(p, pInsert); @@ -1570,9 +1567,8 @@ static int recoverWriteData(sqlite3_recover *p){ if( nVal>0 ){ for(ii=0; iinCol; ii++){ RecoverColumn *pCol = &pTab->aCol[ii]; - - if( pCol->iBind>0 ){ - int iBind = pCol->iBind; + int iBind = pCol->iBind; + if( iBind>0 ){ if( pCol->bIPK ){ sqlite3_bind_int64(pInsert, iBind, iRowid); }else if( pCol->iField