-
Notifications
You must be signed in to change notification settings - Fork 670
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
PG17 compatibility: Fix Test Failure in multi_name_lengths multi_create_table_constraints #7726
base: release-13.0
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-13.0 #7726 +/- ##
===============================================
Coverage ? 89.64%
===============================================
Files ? 274
Lines ? 59583
Branches ? 7436
===============================================
Hits ? 53412
Misses ? 4040
Partials ? 2131 |
s/\|[[:space:]]*CHECK[[:space:]]*\((date_col_[a-zA-Z0-9_]+[[:space:]]*[>=<]+[[:space:]].*)\)/| CHECK \1/g | ||
|
||
# Specifically remove outer parentheses from CHECK constraints for int_col_* columns, ensuring proper formatting. | ||
s/\|[[:space:]]*CHECK[[:space:]]*\((int_col_[a-zA-Z0-9_]+[[:space:]]*[>=<]+[[:space:]].*)\)/| CHECK \1/g |
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.
It seems that these two normalization lines are specific to the column name, hence they don't take care of the following failure in multi_create_table_constraints
:
https://github.com/citusdata/citus/actions/runs/11775359161/attempts/1#summary-32795798881
SELECT "Constraint", "Definition" FROM table_checks WHERE relid='public.check_example_365068'::regclass;
Constraint | Definition
-------------------------------------+-----------------------------------
- check_example_other_col_check | CHECK (other_col >= 100)
- check_example_other_other_col_check | CHECK (abs(other_other_col) >= 100)
+ check_example_other_col_check | CHECK other_col >= 100
+ check_example_other_other_col_check | CHECK abs(other_other_col) >= 100
(2 rows)
So we have date_col
, int_col
, other_col
and abs(other_other_col)
I think we can rename these columns to make the normalization rules apply to them?
Example:
date_col_
to column_date
int_col_
to column_int
other_col
to column_other
And then have two normalization lines: one for CHECK column_...
and one for CHECK abs(...
?
There might be a better way, just thoughts from the top of my head. But definitely in this PR we should fix both multi_create_table_constraints
and multi_name_lengths
tests
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 tried to combine the rules into a single, more comprehensive one, but it didn't work out. A more general rule could potentially work, but it carries the risk of affecting other tests as well.
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 understand.
In that case, instead of 4 normalization rules, how about we look at this the other way around: add the parantheses where they are missing. In this case, .out
files won't change at all, instead just a single normalization line will take care of it.
Something like the following should work:
# PG 17 Removes outer parentheses from CHECK constraints
# we add them back for pg15,pg16 compatibility
# e.g. change CHECK other_col >= 100 to CHECK (other_col >= 100)
s/\| CHECK ([a-zA-Z])(.*)/| CHECK \(\1\2\)/g
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.
Thanks for the suggestion, @naisila. Adding parentheses for PostgreSQL 15 and 16 compatibility does seem like a straightforward solution that would reduce the number of normalization rules and keep the .out files consistent.
However, I'm wondering if we should align with PostgreSQL 17's standards instead, since it's the latest version and likely reflects the future direction. Adapting the tests to follow PostgreSQL 17's format might help reduce the need for version-specific handling as we move forward.
Let me know your thoughts. In the meantime, I'll try out the suggested normalization and update the PR.
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.
You are right, it would be ideal to go with PG17's output. But normalization lines slow down the tests so in this case it would be more performant to switch 4 normalization lines for 1, especially since the difference between versions doesn't reflect a feature or improvement in PG17 (the difference between versions only reflects a "style" change let's say). Other than performance, 1 normalization line is also cleaner than 4.
When we drop PG16 support, whichever way we choose, we would have to drop the normalization lines anyway. So, in conclusion, I think we can align with pg16/pg15 standards in this case.
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.
Hey @m3hm3t is there something else blocking the update of this PR?
1b3cfdc
to
34e3e90
Compare
remove citus-tools normalization added normlize update update update update update . update . revert some files update update
34e3e90
to
8b4a0e2
Compare
s/\|[[:space:]]*CHECK[[:space:]]*\((date_col_[a-zA-Z0-9_]+[[:space:]]*[>=<]+[[:space:]].*)\)/| CHECK \1/g | ||
|
||
# Specifically remove outer parentheses from CHECK constraints for int_col_* columns, ensuring proper formatting. | ||
s/\|[[:space:]]*CHECK[[:space:]]*\((int_col_[a-zA-Z0-9_]+[[:space:]]*[>=<]+[[:space:]].*)\)/| CHECK \1/g |
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 understand.
In that case, instead of 4 normalization rules, how about we look at this the other way around: add the parantheses where they are missing. In this case, .out
files won't change at all, instead just a single normalization line will take care of it.
Something like the following should work:
# PG 17 Removes outer parentheses from CHECK constraints
# we add them back for pg15,pg16 compatibility
# e.g. change CHECK other_col >= 100 to CHECK (other_col >= 100)
s/\| CHECK ([a-zA-Z])(.*)/| CHECK \(\1\2\)/g
Relevant PG commit:
e59fcbd712c777eb2987d7c9ad542a7e817954ec
CI link https://github.com/citusdata/citus/actions/runs/11844794788