Ben
15 years ago
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
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