mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
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
This commit is contained in:
@ -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
|
||||
|
@ -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<nName; i++){
|
||||
if( zName[i]=='"' ) *p++ = '"';
|
||||
if( zName[i]=='`' ) *p++ = '`';
|
||||
*p++ = zName[i];
|
||||
}
|
||||
*p++ = '"';
|
||||
*p++ = '`';
|
||||
*p++ = '\0';
|
||||
}
|
||||
return zRet;
|
||||
|
Reference in New Issue
Block a user