-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YSQL] Table is in inconsistent state when adding column that is DEFAULT NOT NULL #9970
Comments
I looked at related code for the 'default 1 not null' case.
In the caller, ATExecAddColumn():
Since the default is non-volatile, missingMode field carries value of true. This logic is the same in PG (apart from Oid check being gone since Oid is not special column in upstream PG). Here is same commands executed on PG 13: We can see that, PG handles default value correctly but YB doesn't (for 'default 1 not null' case) |
If I temporarily drop the contain_volatile_functions() check, I see another error:
|
I was looking at the PG commit:
I added some debug logs in getmissingattr() and slot_getmissingattrs().
Still investigating ... |
Query on table created with column having default value returns the default value (correct behavior).
If 'default z not null' errors out for 'alter table x add y', 'default z' should error out as well. |
Yep, this behaviour is not fixed, and that is kinda a big problem being honest |
Fixed by commit 0aca19f |
Jira Link: DB-2570
I understand that adding columns with a new default doesn't work yet:
Producing:
Relevant issues are:
But when adding a
not null
constraint to the column, the statement should be rejected, alas it works:Producing:
I think this is a bug, independent of the above missing features. The following statement sequence where the
DEFAULT
clause and theNOT NULL
constraint are separated doesn't work:This produces an error:
I think that this statement should produce the same error:
The text was updated successfully, but these errors were encountered: