From ee8d0b4111b47bd91e9d3280e8540d3a560b0cc7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 15 Sep 2014 15:22:32 +0000 Subject: [PATCH] Have sqlite3ota.c use grave accents instead of double-quotes to enclose identifiers in generated SQL. To avoid having the SQL engine substitute a literal string if a column reference cannot be resolved. FossilOrigin-Name: 79f2418429aa05c56069c56d51b4d72f662a6970 --- ext/ota/ota3.test | 24 ++++++++++++++++++++++++ ext/ota/sqlite3ota.c | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ext/ota/ota3.test b/ext/ota/ota3.test index a4eee32271..dcf8f817aa 100644 --- a/ext/ota/ota3.test +++ b/ext/ota/ota3.test @@ -75,5 +75,29 @@ do_execsql_test 2.2 { PRAGMA integrity_check; } {ok} +#-------------------------------------------------------------------- +# Test that missing columns are detected. +# +forcedelete ota.db +reset_db + +do_execsql_test 2.0 { + CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c); + CREATE INDEX i1 ON x1(b, c); +} {} + +do_test 2.1 { + sqlite3 db2 ota.db + db2 eval { + CREATE TABLE data_x1(a, b, ota_control); + INSERT INTO data_x1 VALUES(1, 'a', 0); + } + db2 close + list [catch { run_ota test.db ota.db } msg] $msg +} {1 {SQLITE_ERROR - no such column: c}} + +do_execsql_test 2.2 { + PRAGMA integrity_check; +} {ok} finish_test diff --git a/ext/ota/sqlite3ota.c b/ext/ota/sqlite3ota.c index aca28e2e3b..999bc00cf7 100644 --- a/ext/ota/sqlite3ota.c +++ b/ext/ota/sqlite3ota.c @@ -299,7 +299,7 @@ static int otaObjIterFirst(sqlite3ota *p, OtaObjIter *pIter){ ** string in the argument buffer, suitable for use as an SQL identifier. ** For example: ** -** [quick "brown" fox] -> ["quick ""brown"" fox"] +** [quick `brown` fox] -> [`quick ``brown`` fox`] ** ** Assuming the allocation is successful, a pointer to the new buffer is ** returned. It is the responsibility of the caller to free it using @@ -312,12 +312,12 @@ static char *otaQuoteName(const char *zName){ if( zRet ){ int i; char *p = zRet; - *p++ = '"'; + *p++ = '`'; for(i=0; i