1
0
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:
dan
2014-09-15 15:22:32 +00:00
parent 02cf6e1681
commit ee8d0b4111
4 changed files with 36 additions and 12 deletions

View File

@ -75,5 +75,29 @@ do_execsql_test 2.2 {
PRAGMA integrity_check; PRAGMA integrity_check;
} {ok} } {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 finish_test

View File

@ -299,7 +299,7 @@ static int otaObjIterFirst(sqlite3ota *p, OtaObjIter *pIter){
** string in the argument buffer, suitable for use as an SQL identifier. ** string in the argument buffer, suitable for use as an SQL identifier.
** For example: ** 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 ** Assuming the allocation is successful, a pointer to the new buffer is
** returned. It is the responsibility of the caller to free it using ** returned. It is the responsibility of the caller to free it using
@ -312,12 +312,12 @@ static char *otaQuoteName(const char *zName){
if( zRet ){ if( zRet ){
int i; int i;
char *p = zRet; char *p = zRet;
*p++ = '"'; *p++ = '`';
for(i=0; i<nName; i++){ for(i=0; i<nName; i++){
if( zName[i]=='"' ) *p++ = '"'; if( zName[i]=='`' ) *p++ = '`';
*p++ = zName[i]; *p++ = zName[i];
} }
*p++ = '"'; *p++ = '`';
*p++ = '\0'; *p++ = '\0';
} }
return zRet; return zRet;

View File

@ -1,5 +1,5 @@
C Ensure\sthe\scorrect\scollation\ssequences\sare\sused\swhen\ssorting\sdata\sin\ssqlite3ota.c. C Have\ssqlite3ota.c\suse\sgrave\saccents\sinstead\sof\sdouble-quotes\sto\senclose\sidentifiers\sin\sgenerated\sSQL.\sTo\savoid\shaving\sthe\sSQL\sengine\ssubstitute\sa\sliteral\sstring\sif\sa\scolumn\sreference\scannot\sbe\sresolved.
D 2014-09-15T14:54:07.328 D 2014-09-15T15:22:32.496
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -124,8 +124,8 @@ F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841 F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841
F ext/ota/ota1.test fe0bb8acf0caef6c19937b84c6547b788342610d F ext/ota/ota1.test fe0bb8acf0caef6c19937b84c6547b788342610d
F ext/ota/ota2.test 13f76922446c62ed96192e938b8e625ebf0142fa F ext/ota/ota2.test 13f76922446c62ed96192e938b8e625ebf0142fa
F ext/ota/ota3.test 7179a90eb64cf8135a6885568653f158fb130872 F ext/ota/ota3.test 1c48b7476af1c5920db9a43e7b1476d421a463b5
F ext/ota/sqlite3ota.c c29b3eb617f37d0e51744508b8f609014244727d F ext/ota/sqlite3ota.c 668ed08dd81ff8ae1e8524b2d4bf0f2609cbf907
F ext/ota/sqlite3ota.h 39ce4dffbfcf4ade9e4526369fe2243709345c8e F ext/ota/sqlite3ota.h 39ce4dffbfcf4ade9e4526369fe2243709345c8e
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b
@ -1199,7 +1199,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P cca376bff3510dc5e99fc5824862c3471ceced16 P 473a72d7009a22ea514a98ee8869e7e7bca14cf5
R 286b5daf6c561394d2eea11438cdac48 R 6e8944bfcc8da0bf6b98d50ae7beb161
U dan U dan
Z e26ad3cda7162cfc9e1d6f5aeb5cd971 Z 793743aae527be1bb170d7639993b8ad

View File

@ -1 +1 @@
473a72d7009a22ea514a98ee8869e7e7bca14cf5 79f2418429aa05c56069c56d51b4d72f662a6970