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

Function recoverLostAndFoundInsert

modules/dasSQLITE/sqlite/shell.c:14904–14934  ·  view source on GitHub ↗

** Synthesize and prepare an INSERT statement to write to the lost_and_found ** table in the output database. The name of the table is zTab, and it has ** nField c* fields. */

Source from the content-addressed store, hash-verified

14902** nField c* fields.
14903*/
14904static sqlite3_stmt *recoverLostAndFoundInsert(
14905 sqlite3_recover *p,
14906 const char *zTab,
14907 int nField
14908){
14909 int nTotal = nField + 4;
14910 int ii;
14911 char *zBind = 0;
14912 sqlite3_stmt *pRet = 0;
14913
14914 if( p->xSql==0 ){
14915 for(ii=0; ii<nTotal; ii++){
14916 zBind = recoverMPrintf(p, "%z%s?", zBind, zBind?", ":"", ii);
14917 }
14918 pRet = recoverPreparePrintf(
14919 p, p->dbOut, "INSERT INTO %s VALUES(%s)", zTab, zBind
14920 );
14921 }else{
14922 const char *zSep = "";
14923 for(ii=0; ii<nTotal; ii++){
14924 zBind = recoverMPrintf(p, "%z%squote(?)", zBind, zSep);
14925 zSep = "|| ', ' ||";
14926 }
14927 pRet = recoverPreparePrintf(
14928 p, p->dbOut, "SELECT 'INSERT INTO %s VALUES(' || %s || ')'", zTab, zBind
14929 );
14930 }
14931
14932 sqlite3_free(zBind);
14933 return pRet;
14934}
14935
14936/*
14937** Input database page iPg contains data that will be written to the

Callers 1

recoverLostAndFound3InitFunction · 0.85

Calls 2

recoverMPrintfFunction · 0.85
recoverPreparePrintfFunction · 0.85

Tested by

no test coverage detected