-
Notifications
You must be signed in to change notification settings - Fork 695
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
Fix crash caused by some form of ALTER TABLE ADD COLUMN statements. #7522
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a test would be nice, at least the one noted in linked issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just going to note that I did not think this deserved a test :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally try to add all crashes that we fix as a test, for two reasons:
- Make sure that we don't regress in the future
- Generally these crashes happen because of using uncommon SQL features. And increasing our coverage for such uncommon features is quite useful for catching other issues too (e.g. we've caught issues introduced in new PG beta versions because our test suite tests some stuff better than Postgres).
Sometimes we don't of course, for instance if it's hard to reproduce the test reliably. But in this case I think adding the test should be very simple.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7522 +/- ##
==========================================
- Coverage 89.69% 89.65% -0.04%
==========================================
Files 283 283
Lines 60427 60428 +1
Branches 7524 7525 +1
==========================================
- Hits 54197 54178 -19
- Misses 4078 4097 +19
- Partials 2152 2153 +1 |
|
||
if (list_length(constraint->pk_attrs) > 0) | ||
{ | ||
char *referencedColumn = strVal(lfirst(list_head(constraint->pk_attrs))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only considering head of the list feels a bit misleading because a pkey might cover more than one column too.
create table ref5(a int, b int, primary key(a, b));
@@ -44,6 +44,15 @@ ERROR: cannot execute ADD COLUMN command with PRIMARY KEY, UNIQUE, FOREIGN and | |||
DETAIL: Adding a column with a constraint in one command is not supported because all constraints in Citus must have explicit names | |||
HINT: You can issue each command separately such as ALTER TABLE referencing ADD COLUMN test_8 data_type; ALTER TABLE referencing ADD CONSTRAINT constraint_name CHECK (check_expression); | |||
ALTER TABLE referencing ADD COLUMN test_8 integer CONSTRAINT check_test_8 CHECK (test_8 > 0); | |||
-- error out properly even if the REFERENCES does not include the column list of the referenced table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the PR description include that this is specific the case we're fixing would be good.
@JelteF @onurctirtir, is this change good to go? |
e13d90c
to
4d0fb50
Compare
…7522) DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs. For instance, the following statement results in a crash: ``` ALTER TABLE lt ADD COLUMN new_col1 bool, ADD COLUMN new_col2 int references rt; ``` Fixes #7520. (cherry picked from commit fdd658a)
…7522) DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs. For instance, the following statement results in a crash: ``` ALTER TABLE lt ADD COLUMN new_col1 bool, ADD COLUMN new_col2 int references rt; ``` Fixes #7520. (cherry picked from commit fdd658a)
…7522) DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs. For instance, the following statement results in a crash: ``` ALTER TABLE lt ADD COLUMN new_col1 bool, ADD COLUMN new_col2 int references rt; ``` Fixes #7520. (cherry picked from commit fdd658a)
…7522) DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs. For instance, the following statement results in a crash: ``` ALTER TABLE lt ADD COLUMN new_col1 bool, ADD COLUMN new_col2 int references rt; ``` Fixes #7520. (cherry picked from commit fdd658a)
…7522) DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs. For instance, the following statement results in a crash: ``` ALTER TABLE lt ADD COLUMN new_col1 bool, ADD COLUMN new_col2 int references rt; ``` Fixes #7520. (cherry picked from commit fdd658a)
DESCRIPTION: Fixes a crash caused by some form of ALTER TABLE ADD COLUMN statements. When adding multiple columns, if one of the ADD COLUMN statements contains a FOREIGN constraint ommitting the referenced columns in the statement, a SEGFAULT occurs.
For instance, the following statement results in a crash:
Fixes #7520.