sqlite crashes when alter add check is used with internal sqlite_ tables.
(1) By Pavan Nambi (Pavan-Nambi) on 2026-05-10 01:11:28 [source]
> fossil info
project-name: SQLite
repository: /Users/pavan/sqlite/src.fossil
local-root: /Users/pavan/sqlite/
config-db: /Users/pavan/.config/fossil.db
project-code: 2ab58778c2967968b94284e989e43dc11791f548
checkout: 5a8497dbec80b55a2dedc8a6f9ee823243e01a08 2026-05-07 20:45:57 UTC
parent: 7e6fd838a15f08bf15d57f1887ed1019b58aa6be 2026-05-07 15:04:30 UTC
tags: trunk
comment: Remove unnecessary and incorrect assert() statements in the new %J code. (user: drh)
check-ins: 35983
CREATE TABLE t(a);
INSERT INTO t VALUES(1);
ALTER TABLE t ADD CONSTRAINT c CHECK(
sqlite_drop_column(999, 'CREATE TABLE x(a,b)', 0)
);
outputs
[1] 2350 segmentation fault ./sqlite3
few more repros i think comes under same category
empty table and crashes later when the CHECK is evaluated:
CREATE TABLE t(a);
ALTER TABLE t ADD CONSTRAINT c CHECK(
sqlite_drop_column(999, 'CREATE TABLE x(a,b)', 0)
);
INSERT INTO t VALUES(1);
CREATE TABLE t(a);
ALTER TABLE t ADD CONSTRAINT c CHECK(
sqlite_drop_column(-1, 'CREATE TABLE x(a,b)', 0)
);
INSERT INTO t VALUES(1);
(2) By Bo Lindbergh (_blgl_) on 2026-05-12 02:56:33 in reply to 1 [link] [source]
Note that the current fix is not sufficient, because ALTER TABLE ADD CONSTRAINT is not the only way to sneak expressions into table definitions. ALTER TABLE ADD COLUMN can be used to create CHECK and GENERATED ALWAYS AS column constraints using internal functions too.