I've thought about this a bit more, and concluded this is probably a bug.

If you define your own function, and reference it in a check constraint, and 
then try to select from sqlite_master when that function is not currently 
defined, the select fails with Error: malformed database schema.  I've noticed 
this since 3.7.2 and it still happens at 3.7.15.1.  It will occur even if there 
is a where clause that would avoid selecting the table with the check constaint.

Example (hopefully this will format properly):

/rococo3/peter > sqlite3 -header -column b.sqlite
sqlite3 -header -column b.sqlite
SQLite version 3.7.15.1 2012-12-19 20:39:10 Enter ".help" for instructions 
Enter 

SQL statements terminated with a ";"
sqlite> .read add_check.sql
select load_extension ('libspatialite.so'); 
load_extension ('libspatialite.so')
-----------------------------------

create table if not exists boom (c1 float check(c1 <> PI())); 
select * from sqlite_master;
type       name       tbl_name   rootpage   sql 
---------- ---------- ---------- ---------- 
----------------------------------------------
table      boom       boom       2          CREATE TABLE boom (c1 float 
check(c1 
<> PI()))
.quit
sqlite> .q
.q

/rococo3/peter > sqlite3 -header -column b.sqlite SQLite version 3.7.15.1 
2012-12-19 20:39:10 Enter ".help" for instructions Enter SQL statements 
terminated with a ";"
sqlite> select * from sqlite_master;
Error: malformed database schema (boom) - no such function: PI
sqlite> .q
/rococo3/peter > 

Oddly enough, this doesn't appear to happen with triggers -- you only get an 
error message when actually firing the trigger.
 
Peter
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to