SQLite Forum

Timeline
Login

3 forum posts by user sbinder

2022-01-16
13:52 Edit: Logic error when using CHECK constraints while adding a column (artifact: 3c1a00b66f user: sbinder)

I have compiled the 3.37.2 amalgamation with the recommended -DSQLITE_DQS=0 option.

Then, opening the shell and running the following two statements causes a logic error that is unexpected to me:

CREATE TABLE a (id INTEGER NOT NULL);
ALTER TABLE a ADD COLUMN enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1));

This error only happens when compiling without DQS which surprises me as neither statement is using a string literal. Further, no error is reported when the check is added in the CREATE TABLE statement (CREATE TABLE a (id INTEGER NOT NULL, enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)));) -- regardless of whether DQS is enabled or not.

Is this the expected behavior? Can anyone explain to me why?

Edit: The error message from the shell is simply Error: in prepare, SQL logic error (1).

12:39 Post: Logic error when using CHECK constraints while adding a column (artifact: 6224011cf2 user: sbinder)

I have compiled the 3.37.2 amalgamation with the recommended -DSQLITE_DQS=0 option.

Then, opening the shell and running the following two statements causes a logic error that is unexpected to me:

CREATE TABLE a (id INTEGER NOT NULL);
ALTER TABLE a ADD COLUMN enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1));

This error only happens when compiling without DQS which surprises me as neither statement is using a string literal. Further, no error is reported when the check is added in the CREATE TABLE statement (CREATE TABLE a (id INTEGER NOT NULL, enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)));) -- regardless of whether DQS is enabled or not.

Is this the expected behavior? Can anyone explain to me why?

2021-03-29
21:41 Post: Crash when a RETURNING clause refers to a table in UPDATE FROM (artifact: cdc28fec1a user: sbinder)

I'm using SQLite version 3.35.3. In an attempt to understand which columns a RETURNING clause can refer to, I tried to combine RETURNING with a FROM clause in an UPDATE statement:

CREATE TABLE a (id INTEGER NOT NULL PRIMARY KEY);
UPDATE a SET id = a.id + 1 FROM (SELECT * FROM a) AS old RETURNING old.*;

Running the update statement crashes sqlite.