MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / recoverLostAndFoundOnePage

Function recoverLostAndFoundOnePage

modules/dasSQLITE/sqlite/shell.c:14979–15049  ·  view source on GitHub ↗

** Recover data from page iPage of the input database and write it to ** the lost-and-found table in the output database. */

Source from the content-addressed store, hash-verified

14977** the lost-and-found table in the output database.
14978*/
14979static void recoverLostAndFoundOnePage(sqlite3_recover *p, i64 iPage){
14980 RecoverStateLAF *pLaf = &p->laf;
14981 sqlite3_value **apVal = pLaf->apVal;
14982 sqlite3_stmt *pPageData = pLaf->pPageData;
14983 sqlite3_stmt *pInsert = pLaf->pInsert;
14984
14985 int nVal = -1;
14986 int iPrevCell = 0;
14987 i64 iRoot = 0;
14988 int bHaveRowid = 0;
14989 i64 iRowid = 0;
14990 int ii = 0;
14991
14992 if( recoverLostAndFoundFindRoot(p, iPage, &iRoot) ) return;
14993 sqlite3_bind_int64(pPageData, 1, iPage);
14994 while( p->errCode==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPageData) ){
14995 int iCell = sqlite3_column_int64(pPageData, 0);
14996 int iField = sqlite3_column_int64(pPageData, 1);
14997
14998 if( iPrevCell!=iCell && nVal>=0 ){
14999 /* Insert the new row */
15000 sqlite3_bind_int64(pInsert, 1, iRoot); /* rootpgno */
15001 sqlite3_bind_int64(pInsert, 2, iPage); /* pgno */
15002 sqlite3_bind_int(pInsert, 3, nVal); /* nfield */
15003 if( bHaveRowid ){
15004 sqlite3_bind_int64(pInsert, 4, iRowid); /* id */
15005 }
15006 for(ii=0; ii<nVal; ii++){
15007 recoverBindValue(p, pInsert, 5+ii, apVal[ii]);
15008 }
15009 if( sqlite3_step(pInsert)==SQLITE_ROW ){
15010 recoverSqlCallback(p, (const char*)sqlite3_column_text(pInsert, 0));
15011 }
15012 recoverReset(p, pInsert);
15013
15014 /* Discard the accumulated row data */
15015 for(ii=0; ii<nVal; ii++){
15016 sqlite3_value_free(apVal[ii]);
15017 apVal[ii] = 0;
15018 }
15019 sqlite3_clear_bindings(pInsert);
15020 bHaveRowid = 0;
15021 nVal = -1;
15022 }
15023
15024 if( iCell<0 ) break;
15025
15026 if( iField<0 ){
15027 assert( nVal==-1 );
15028 iRowid = sqlite3_column_int64(pPageData, 2);
15029 bHaveRowid = 1;
15030 nVal = 0;
15031 }else if( iField<pLaf->nMaxField ){
15032 sqlite3_value *pVal = sqlite3_column_value(pPageData, 2);
15033 apVal[iField] = sqlite3_value_dup(pVal);
15034 assert( iField==nVal || (nVal==-1 && iField==0) );
15035 nVal = iField+1;
15036 if( apVal[iField]==0 ){

Callers 1

recoverLostAndFound3StepFunction · 0.85

Calls 6

recoverBindValueFunction · 0.85
recoverSqlCallbackFunction · 0.85
recoverResetFunction · 0.85
assertFunction · 0.85
recoverErrorFunction · 0.85

Tested by

no test coverage detected