Silently ignore database name qualifiers in CHECK constraints and in

partial index WHERE clauses.

FossilOrigin-Name: 2e8c845eb5011a2743dace333aa38383588f2080
This commit is contained in:
drh 2013-08-02 14:18:18 +00:00
parent 3bf0ac1709
commit 1e7d43c977
5 changed files with 39 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C Fix\sbug\sin\sthe\slogic\sthat\sdetermines\sthe\send\sof\sa\sCREATE\sINDEX\sstatement.\nAdded\sa\sVACUUM\stest\scase\sthat\sexposed\sthe\sbug.
D 2013-08-01T16:02:40.113
C Silently\signore\sdatabase\sname\squalifiers\sin\sCHECK\sconstraints\sand\sin\npartial\sindex\sWHERE\sclauses.
D 2013-08-02T14:18:18.252
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -214,7 +214,7 @@ F src/pragma.c 590c75750d93ec5a1f903e4bb0dc6d2a0845bf8b
F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
F src/printf.c 41c49dac366a3a411190001a8ab495fa8887974e
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 8b3c7a439cc6ba242e45566284adb72fa770b7c8
F src/resolve.c 17e670996729ac41aadf6a31f57b4e6f29b3d819
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 20369c82dc38eb4a77b458c8f6e353ef550580c9
F src/shell.c 52f975eae87c8338c4dfbf4c2842d2a0971f01fd
@ -362,7 +362,7 @@ F test/capi3c.test 93d24621c9ff84da9da060f30431e0453db1cdb0
F test/capi3d.test 6d0fc0a86d73f42dd19a7d8b7761ab9bc02277d0
F test/capi3e.test ad90088b18b0367125ff2d4b5400153fd2f99aab
F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3
F test/check.test 2eb93611139a7dfaed3be80067c7dc5ceb5fb287
F test/check.test 1e9be446eb0bbd47a5f65955802e9632425096ab
F test/close.test 340bd24cc58b16c6bc01967402755027c37eb815
F test/closure01.test dbb28f1ea9eeaf0a53ec5bc0fed352e479def8c7
F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
@ -589,7 +589,7 @@ F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7
F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026
F test/index5.test fc07c14193c0430814e7a08b5da46888ee795c33
F test/index6.test 3967161678dd5268e6ad1e263cc82e2b8050d055
F test/index6.test 0005b3093012c6d0f20cc54d9057210221216143
F test/indexedby.test 0e959308707c808515c3a51363f7a9835027108c
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
@ -1104,7 +1104,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 0c8cfdfae215c95cf167f404a1d346690b28e972
R 7829f40a29ab8d32821ed080da801961
P 2e3df0bc900c01286d3ce32c2bbf9e5293973f9b
R b5d4ae8fe01e42e4e171b69c990dde10
U drh
Z d181891086829543aa75dfb2ba9cf461
Z 4a98808a1193d1ac659ec78aea29a043

View File

@ -1 +1 @@
2e3df0bc900c01286d3ce32c2bbf9e5293973f9b
2e8c845eb5011a2743dace333aa38383588f2080

View File

@ -240,11 +240,20 @@ static int lookupName(
** resulting in an appropriate error message toward the end of this routine
*/
if( zDb ){
for(i=0; i<db->nDb; i++){
assert( db->aDb[i].zName );
if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
pSchema = db->aDb[i].pSchema;
break;
testcase( pNC->ncFlags & NC_PartIdx );
testcase( pNC->ncFlags & NC_IsCheck );
if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
/* Silently ignore database qualifiers inside CHECK constraints and partial
** indices. Do not raise errors because that might break legacy and
** because it does not hurt anything to just ignore the database name. */
zDb = 0;
}else{
for(i=0; i<db->nDb; i++){
assert( db->aDb[i].zName );
if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
pSchema = db->aDb[i].pSchema;
break;
}
}
}
}

View File

@ -451,5 +451,11 @@ do_test 7.8 {
catchsql { INSERT INTO t6 VALUES(12) } db2
} {1 {constraint failed}}
# 2013-08-02: Silently ignore database name qualifiers in CHECK constraints.
#
do_execsql_test 8.1 {
CREATE TABLE t810(a, CHECK( main.t810.a>0 ));
CREATE TABLE t811(b, CHECK( xyzzy.t811.b BETWEEN 5 AND 10 ));
} {}
finish_test

View File

@ -217,4 +217,14 @@ do_execsql_test index6-4.0 {
PRAGMA integrity_check;
} {ok}
# Silently ignore database name qualifiers in partial indices.
#
do_execsql_test index6-5.0 {
CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;
/* ^^^^^-- ignored */
ANALYZE;
SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;
SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';
} {6 6}
finish_test