{{ message }}
Repository navigation
[v1.5] Quickfix ALTER TABLE ADD COLUMN IF NOT EXISTS ... DEFAULT regression - #23507
Merged
lnkuiper merged 2 commits intoJul 3, 2026
Merged
Conversation
yan-alex
force-pushed
the
avoid-rewrite-regression
branch
from
June 29, 2026 11:23
4d550ae to
4c67acf
Compare
lnkuiper
marked this pull request as draft
June 30, 2026 11:46
lnkuiper
marked this pull request as ready for review
June 30, 2026 11:46
lnkuiper
requested changes
Jun 30, 2026
lnkuiper
left a comment
Member
There was a problem hiding this comment.
The materializing multi-statement rewrite is now skipped, which fixes the linked issue, but regresses a WAL replay consistency. Repro:
# name: test/temp.test
# group: [temp]
statement ok
ATTACH '__TEST_DIR__/wal_replay_if_not_exists.db';
statement ok
USE wal_replay_if_not_exists;
statement ok
PRAGMA disable_checkpoint_on_shutdown;
statement ok
SET wal_autocheckpoint='1TB'
statement ok
CREATE TABLE t AS SELECT range::INT AS id FROM range(10);
statement ok
ALTER TABLE t ADD COLUMN IF NOT EXISTS r DOUBLE DEFAULT RANDOM();
statement ok
CREATE TABLE original AS SELECT id, r FROM t;
statement ok
USE memory;
statement ok
DETACH wal_replay_if_not_exists;
statement ok
ATTACH '__TEST_DIR__/wal_replay_if_not_exists.db';
statement ok
USE wal_replay_if_not_exists;
query I
SELECT COUNT(r) != 0 FROM t;
----
true
query I sort r1
SELECT r FROM t;
----
query I sort r1
SELECT r FROM original;
----
Member
Contributor
Author
Yes it addresses the same problem. That one targets main though, which we want to tackle differently I believe. |
Contributor
Author
lnkuiper
approved these changes
Jul 3, 2026
lnkuiper
left a comment
Member
There was a problem hiding this comment.
I think the issue that this fixes is more important than the issue it creates so we should merge it as-is, and come up with a proper solution for v2.0.0
2 tasks done
kaka11chen
pushed a commit
to kaka11chen/astrovela_vane
that referenced
this pull request
Aug 14, 2026
…gression (duckdb/duckdb#23507) https://github.com/duckdblabs/duckdb-internal/issues/9721 ## The problem When ADD COLUMN IF NOT EXISTS targets a column that already exists and the clause carries a DEFAULT, DuckDB 1.5.x does not treat the statement as a no-op: it re-applies the default expression to every existing row, silently destroying the column's current data. ## The fix Don't do the 3 multi-statement rewrite workaround from duckdb/duckdb#20224 when there is a `IF NOT EXISTS` This is just a v1.5-variegata quickfix. We can tackle this properly later on for v2.0. Upstream-Commit: duckdb/duckdb@2707468
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

https://github.com/duckdblabs/duckdb-internal/issues/9721
The problem
When ADD COLUMN IF NOT EXISTS targets a column that already exists and the clause carries a DEFAULT, DuckDB 1.5.x does not treat the statement as a no-op: it re-applies the default expression to every existing row, silently destroying the column's current data.
The fix
Don't do the 3 multi-statement rewrite workaround from #20224 when there is a
IF NOT EXISTSThis is just a v1.5-variegata quickfix. We can tackle this properly later on for v2.0.