You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ALTER COLUMN ignores SET DEFAULT and DROP DEFAULT #553
CREATETABLEt (id INT, n INTNOT NULL DEFAULT 1, v VARCHAR(10) DEFAULT 'x');
ALTERTABLE t ALTER COLUMN n SET DEFAULT 5;
ALTERTABLE t ALTER COLUMN v DROP DEFAULT;
INSERT INTO t (id) VALUES (1);
SELECT n, v FROM t;
-- 1, 'x' (MySQL: 5, NULL)
Both ALTER TABLE statements succeed without an error, but nothing changes. SHOW CREATE TABLE and INFORMATION_SCHEMA.COLUMNS still report DEFAULT '1' and DEFAULT 'x'.
Reproduced on trunk at 09963132adefd68dde404959d393aa2200066d44, with PHP 8.5 and SQLite 3.54.1.
Cause
record_alter_table() handles ADD, CHANGE, MODIFY, and DROP actions, but not ALTER [COLUMN] ... SET DEFAULT and DROP DEFAULT. The information schema stays unchanged, and execute_alter_table_statement() then rebuilds the table from it. So the statement copies the whole table, but the table keeps its old defaults.
A possible fix is to record the new default in record_alter_table(), using the same default handling as column definitions, and NULL for DROP DEFAULT.
changed the title [-]ALTER TABLE ... ALTER COLUMN SET DEFAULT and DROP DEFAULT are ignored[/-][+]`ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT` are ignored[/+]on Oct 22, 2026
changed the title [-]`ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT` are ignored[/-][+]`ALTER COLUMN` ignores `SET DEFAULT` and `DROP DEFAULT`[/+]on Oct 23, 2026
Activity
Apply ALTER COLUMN default changes
Apply ALTER COLUMN default changes
[-]ALTER TABLE ... ALTER COLUMN SET DEFAULT and DROP DEFAULT are ignored[/-][+]`ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT` are ignored[/+]Apply ALTER COLUMN default changes
Apply ALTER COLUMN default changes
[-]`ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT` are ignored[/-][+]`ALTER COLUMN` ignores `SET DEFAULT` and `DROP DEFAULT`[/+]Add support for `ALTER COLUMN` with `SET DEFAULT` and `DROP DEFAULT` (W…