/ Check-in [2e8c845e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Silently ignore database name qualifiers in CHECK constraints and in partial index WHERE clauses.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | partial-indices
Files: files | file ages | folders
SHA1: 2e8c845eb5011a2743dace333aa38383588f2080
User & Date: drh 2013-08-02 14:18:18
Context
2013-08-02
16:41
Add support for partial indices. check-in: 478113f1 user: drh tags: trunk
14:18
Silently ignore database name qualifiers in CHECK constraints and in partial index WHERE clauses. Closed-Leaf check-in: 2e8c845e user: drh tags: partial-indices
2013-08-01
16:02
Fix bug in the logic that determines the end of a CREATE INDEX statement. Added a VACUUM test case that exposed the bug. check-in: 2e3df0bc user: drh tags: partial-indices
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

   236    236     ExprSetIrreducible(pExpr);
   237    237   
   238    238     /* Translate the schema name in zDb into a pointer to the corresponding
   239    239     ** schema.  If not found, pSchema will remain NULL and nothing will match
   240    240     ** resulting in an appropriate error message toward the end of this routine
   241    241     */
   242    242     if( zDb ){
   243         -    for(i=0; i<db->nDb; i++){
   244         -      assert( db->aDb[i].zName );
   245         -      if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
   246         -        pSchema = db->aDb[i].pSchema;
   247         -        break;
          243  +    testcase( pNC->ncFlags & NC_PartIdx );
          244  +    testcase( pNC->ncFlags & NC_IsCheck );
          245  +    if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
          246  +      /* Silently ignore database qualifiers inside CHECK constraints and partial
          247  +      ** indices.  Do not raise errors because that might break legacy and
          248  +      ** because it does not hurt anything to just ignore the database name. */
          249  +      zDb = 0;
          250  +    }else{
          251  +      for(i=0; i<db->nDb; i++){
          252  +        assert( db->aDb[i].zName );
          253  +        if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){
          254  +          pSchema = db->aDb[i].pSchema;
          255  +          break;
          256  +        }
   248    257         }
   249    258       }
   250    259     }
   251    260   
   252    261     /* Start at the inner-most context and move outward until a match is found */
   253    262     while( pNC && cnt==0 ){
   254    263       ExprList *pEList;

Changes to test/check.test.

   447    447   } {}
   448    448   
   449    449   do_test 7.8 {
   450    450     db2 func myfunc myfunc
   451    451     catchsql { INSERT INTO t6 VALUES(12) } db2
   452    452   } {1 {constraint failed}}
   453    453   
          454  +# 2013-08-02:  Silently ignore database name qualifiers in CHECK constraints.
          455  +#
          456  +do_execsql_test 8.1 {
          457  +  CREATE TABLE t810(a, CHECK( main.t810.a>0 ));
          458  +  CREATE TABLE t811(b, CHECK( xyzzy.t811.b BETWEEN 5 AND 10 ));
          459  +} {}
   454    460   
   455    461   finish_test

Changes to test/index6.test.

   212    212   } {162}
   213    213   integrity_check index6-3.5
   214    214   
   215    215   do_execsql_test index6-4.0 {
   216    216     VACUUM;
   217    217     PRAGMA integrity_check;
   218    218   } {ok}
          219  +
          220  +# Silently ignore database name qualifiers in partial indices.
          221  +#
          222  +do_execsql_test index6-5.0 {
          223  +  CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;
          224  +                               /* ^^^^^-- ignored */
          225  +  ANALYZE;
          226  +  SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;
          227  +  SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';
          228  +} {6 6}
   219    229   
   220    230   finish_test