I tested your code with the latest fossil checkout
 
It now gets this:
sqlite> INSERT INTO "stuff" DEFAULT VALUES;
Error: stuff.name may not be NULL

Which makes sense as you didn't specify a default value for it.
 
So adding this:
name TEXT NOT NULL DEFAULT 'unk';
 
produces this:
sqlite> INSERT INTO "stuff" DEFAULT VALUES;
sqlite> select * from stuff;
1|unk|||||1

 
Michael D. Black
Senior Scientist
Northrop Grumman Mission Systems
 

________________________________

From: sqlite-users-boun...@sqlite.org on behalf of Ben
Sent: Sat 5/15/2010 7:27 AM
To: General Discussion of SQLite Database
Subject: [sqlite] Bus error crash in SQLite



Hi list,

I've encountered some SQL which causes both my app and the sqlite3 command line 
tool to crash. Given the following table and trigger:

CREATE TABLE stuff (
        id INTEGER PRIMARY KEY,
        name TEXT NOT NULL,
        type TEXT,
        price REAL CHECK(price > 0),
        parent INTEGER,
        annotations TEXT,
        quantity INTEGER NOT NULL DEFAULT 1 CHECK(quantity > 0)
);


CREATE TRIGGER stuff_insert_trg
BEFORE INSERT ON stuff
BEGIN
        SELECT CASE
                WHEN NEW.parent IS NOT NULL AND (SELECT id FROM stuff WHERE 
id=NEW.parent) IS NULL
                THEN RAISE(ABORT, 'Foreign Key Violation: stuff.parent does not 
exist')
        END;
END;



Trying to execute 'INSERT INTO "stuff" DEFAULT VALUES' using the command-line 
program causes it to output 'Bus error' and quit. When doing the same thing in 
my Mac app, it reports EXC_BAD_ACCESS in sqlite3Insert() at the line:
sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);

Is this something I'm doing wrong?

If more information is needed, just let me know what to get.

- Ben

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to