/ Check-in [cda79028]
Login

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

Overview
Comment:Do not raise an error if an unknown SQL function is found in a CHECK constraint while parsing the schema of an existing database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cda790280a52d65f98a45bacb9123367b159ac7c
User & Date: drh 2013-01-08 12:48:10
Context
2013-01-09
11:25
Add a test case that demonstrates ticket [c997b11c4d53a2ee9983]. check-in: 598f5f75 user: drh tags: trunk
2013-01-08
17:24
Merge updates from trunk. Closed-Leaf check-in: f29680c4 user: mistachkin tags: configReadOnly
12:48
Do not raise an error if an unknown SQL function is found in a CHECK constraint while parsing the schema of an existing database. check-in: cda79028 user: drh tags: trunk
2013-01-05
17:17
More bug fixes to the test_regexp.c module. Bring test_regexp.c into alignment with the regexp.c file in the Fossil sources. check-in: 7695b88f user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
        }
      }
#endif
      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
        pNC->nErr++;
        is_agg = 0;
      }else if( no_such_func ){
        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
        pNC->nErr++;
      }else if( wrong_num_args ){
        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
             nId, zId);
        pNC->nErr++;
      }







|







643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
        }
      }
#endif
      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
        pNC->nErr++;
        is_agg = 0;
      }else if( no_such_func && pParse->db->init.busy==0 ){
        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
        pNC->nErr++;
      }else if( wrong_num_args ){
        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
             nId, zId);
        pNC->nErr++;
      }

Changes to test/check.test.

11
12
13
14
15
16
17

18
19
20
21
22
23
24
...
408
409
410
411
412
413
414
415






































416
# This file implements regression tests for SQLite library.  The
# focus of this file is testing CHECK constraints
#
# $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl


# Only run these tests if the build includes support for CHECK constraints
ifcapable !check {
  finish_test
  return
}

................................................................................
} {0 {}}
do_test check-6.15 {
  execsql {SELECT * FROM t1}
} {3 12.0 2 20.0}


}







































finish_test







>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# This file implements regression tests for SQLite library.  The
# focus of this file is testing CHECK constraints
#
# $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix check

# Only run these tests if the build includes support for CHECK constraints
ifcapable !check {
  finish_test
  return
}

................................................................................
} {0 {}}
do_test check-6.15 {
  execsql {SELECT * FROM t1}
} {3 12.0 2 20.0}


}

#--------------------------------------------------------------------------
# If a connection opens a database that contains a CHECK constraint that
# uses an unknown UDF, the schema should not be considered malformed.
# Attempting to modify the table should fail (since the CHECK constraint
# cannot be tested).
#
reset_db
proc myfunc {x} {expr $x < 10}
db func myfunc myfunc

do_execsql_test  7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) }
do_execsql_test  7.2 { INSERT INTO t6 VALUES(9)  }
do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } {1 {constraint failed}}

do_test 7.4 {
  sqlite3 db2 test.db
  execsql { SELECT * FROM t6 } db2 
} {9}

do_test 7.5 {
  catchsql { INSERT INTO t6 VALUES(8) } db2
} {1 {unknown function: myfunc()}}

do_test 7.6 {
  catchsql { CREATE TABLE t7(a CHECK (myfunc(a))) } db2
} {1 {no such function: myfunc}}

do_test 7.7 {
  db2 func myfunc myfunc
  execsql { INSERT INTO t6 VALUES(8) } db2
} {}

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


finish_test