-C Add\s"PRAGMA\sforeign_keys=OFF;"\sto\sthe\sstart\sof\sthe\sscript\soutput\sby\s".recover",\sjust\sas\sis\sdone\sfor\s".dump".
-D 2019-08-06T18:40:36.681
+C Enhance\sthe\s".recover"\soutput\sin\sthe\sshell\sto\suse\sdouble-quotes\saround\stable\nand\scolumn\sidentifiers.
+D 2019-08-06T20:26:17.504
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/resolve.c 3ed5a3de18b455366771a89241283fef16508a7f681af546296e95e81458efeb
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c db06006136ec50868ce6f6fe17e8dfad21b58c089f9372d29c1a79283445907f
-F src/shell.c.in 486dbf00639caefff49157ff0fb495ece63b5d3446226530a4d12da4523a85d7
+F src/shell.c.in 97714cd5e177b6d53fac83c74becf4b19fe0aa8f1a4ed6a4fa1eede4bafb96f7
F src/sqlite.h.in dfe86c132b5085e00cf0539c78510b75e60d740191804c9848e8bb7aa850fff5
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 9ecc93b8493bd20c0c07d52e2ac0ed8bab9b549c7f7955b59869597b650dd8b5
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 9c8c1092a8ce80e114fcfe8ce780332a6f269b8c87df226242b582d2d825c393
-R 57f54a483ad45f70950f478d347477c2
-U dan
-Z 611328cc84a1359679c9e0fa05abc352
+P bfc29e62eff0ed00c153e18a27815f7e3ba316f46871e9645b84ab1e6709a392
+R 10086bf66980a741a6f6a6c27d24c72b
+U drh
+Z 2822779ed58d184aa4feb3102735adde
}
}
+/*
+** Scalar function "shell_idquote(X)" returns string X quoted as an identifier,
+** using "..." with internal double-quote characters doubled.
+*/
+static void shellIdQuote(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ const char *zName = (const char*)sqlite3_value_text(argv[0]);
+ if( zName ){
+ char *z = sqlite3_mprintf("\"%w\"", zName);
+ sqlite3_result_text(context, z, -1, sqlite3_free);
+ }
+}
+
/*
** Scalar function "shell_escape_crnl" used by the .recover command.
** The argument passed to this function is the output of built-in
shellEscapeCrnl, 0, 0);
sqlite3_create_function(p->db, "shell_int32", 2, SQLITE_UTF8, 0,
shellInt32, 0, 0);
+ sqlite3_create_function(p->db, "shell_idquote", 1, SQLITE_UTF8, 0,
+ shellIdQuote, 0, 0);
#ifndef SQLITE_NOHAVE_SYSTEM
sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
editFunc, 0, 0);
sqlite3_stmt *pStmt = 0;
rc = sqlite3_open("", &dbtmp);
+ if( rc==SQLITE_OK ){
+ sqlite3_create_function(dbtmp, "shell_idquote", 1, SQLITE_UTF8, 0,
+ shellIdQuote, 0, 0);
+ }
if( rc==SQLITE_OK ){
rc = sqlite3_exec(dbtmp, "PRAGMA writable_schema = on", 0, 0, 0);
}
}
}
- pTab->zQuoted = shellMPrintf(&rc, "%Q", zName);
+ pTab->zQuoted = shellMPrintf(&rc, "\"%w\"", zName);
pTab->azlCol = (char**)shellMalloc(&rc, sizeof(char*) * (nSqlCol+1));
pTab->nCol = nSqlCol;
if( bIntkey ){
- pTab->azlCol[0] = shellMPrintf(&rc, "%Q", zPk);
+ pTab->azlCol[0] = shellMPrintf(&rc, "\"%w\"", zPk);
}else{
pTab->azlCol[0] = shellMPrintf(&rc, "");
}
i = 1;
shellPreparePrintf(dbtmp, &rc, &pStmt,
- "SELECT %Q || group_concat(quote(name), ', ') "
+ "SELECT %Q || group_concat(shell_idquote(name), ', ') "
" FILTER (WHERE cid!=%d) OVER (ORDER BY %s cid) "
"FROM pragma_table_info(%Q)",
bIntkey ? ", " : "", pTab->iPk,
pTab = (RecoverTable*)shellMalloc(pRc, sizeof(RecoverTable));
if( pTab ){
- pTab->zQuoted = shellMPrintf(pRc, "%Q", zTab);
+ pTab->zQuoted = shellMPrintf(pRc, "\"%w\"", zTab);
pTab->nCol = nCol;
pTab->iPk = -2;
if( nCol>0 ){
if( pTab==0 ) break;
}
- if( 0==sqlite3_stricmp(pTab->zQuoted, "'sqlite_sequence'") ){
+ if( 0==sqlite3_stricmp(pTab->zQuoted, "\"sqlite_sequence\"") ){
raw_printf(pState->out, "DELETE FROM sqlite_sequence;\n");
}
sqlite3_bind_int(pPages, 1, iRoot);