/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/resolve.c.

236
237
238
239
240
241
242








243
244
245
246
247
248
249
250

251
252
253
254
255
256
257
  ExprSetIrreducible(pExpr);

  /* Translate the schema name in zDb into a pointer to the corresponding
  ** schema.  If not found, pSchema will remain NULL and nothing will match
  ** 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;
      }
    }
  }


  /* Start at the inner-most context and move outward until a match is found */
  while( pNC && cnt==0 ){
    ExprList *pEList;
    SrcList *pSrcList = pNC->pSrcList;

    if( pSrcList ){







>
>
>
>
>
>
>
>








>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
  ExprSetIrreducible(pExpr);

  /* Translate the schema name in zDb into a pointer to the corresponding
  ** schema.  If not found, pSchema will remain NULL and nothing will match
  ** resulting in an appropriate error message toward the end of this routine
  */
  if( zDb ){
    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;
        }
      }
    }
  }

  /* Start at the inner-most context and move outward until a match is found */
  while( pNC && cnt==0 ){
    ExprList *pEList;
    SrcList *pSrcList = pNC->pSrcList;

    if( pSrcList ){

Changes to test/check.test.

447
448
449
450
451
452
453

454





455
} {}

do_test 7.8 {
  db2 func myfunc myfunc
  catchsql { INSERT INTO t6 VALUES(12) } db2
} {1 {constraint failed}}








finish_test







>
|
>
>
>
>
>

447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
} {}

do_test 7.8 {
  db2 func myfunc myfunc
  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

Changes to test/index6.test.

212
213
214
215
216
217
218
219










220
} {162}
integrity_check index6-3.5

do_execsql_test index6-4.0 {
  VACUUM;
  PRAGMA integrity_check;
} {ok}











finish_test








>
>
>
>
>
>
>
>
>
>

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
} {162}
integrity_check index6-3.5

do_execsql_test index6-4.0 {
  VACUUM;
  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