-
Notifications
You must be signed in to change notification settings - Fork 684
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: account for identity columns in partitioned tables. #7785
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-13.0 #7785 +/- ##
===============================================
Coverage ? 89.64%
===============================================
Files ? 274
Lines ? 59595
Branches ? 7436
===============================================
Hits ? 53425
Misses ? 4037
Partials ? 2133 |
29c660e
to
4cb15c5
Compare
4cb15c5
to
1f10b06
Compare
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.
This looks like a great fix. I don't see any immediate issues with previous PG version behavior. However, to be sure on PG17 behavior, we need to test on Citus all the cases in the PG commit:
- A newly created partition inherits identity property (this is currently done in
pg17.sql
for a distributed table, Citus local table not yet) - Attached partition inherits identity column
- Drop identity property when detaching partition
- Partitions with their own identity columns are not allowed.
- The usual ALTER operations (add identity column, add identity
property to existing column, alter properties of an indentity
column, drop identity property) are supported for partitioned
tables. Changing a column only in a partitioned table or a
partition is not allowed; the change needs to be applied to the
whole partition hierarchy.
Also, we need to test both distributed and Citus local partitioned tables, as they follow some different code paths for specific behaviors.
Note: I didn't test these locally myself, though I hope they all work. If there is any of these that doesn't work, we need to error out properly.
1f10b06
to
5698bf1
Compare
The PR has been updated with tests for inheriting identity (create and attach partition) and drop identity (detach) for distributed table and local tables - thanks for the comprehensive list! Independently of partitioned tables, it looks like adding an identity column to a citus table is unsupported (there is a test for this in generated_identity, via #6738) as also is adding identity to or altering the identity of an existing column, and dropping identity property from an existing column; alter table preprocessing currently rejects Alter Table - Set Identity and Alter Table - Drop Identity commands. The PR has been updated with tests for ALTER operations, with the corresponding errors in the goldfile, to show the current status, and perhaps they can be amended if and when support is added in Citus ? |
Thanks for addressing all of these cases, I had forgotten some of the Citus limitations. What you are saying makes total sense, and the current test suite is comprehensive for what we currently support. |
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.
LGTM, thanks!
Reminder to rebase to release-13.0
and drop the enable configure ...
commit before merging.
1c39f95
to
e8352a8
Compare
PG17 added support for identity columns in partitioned tables: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=699586315 A table with an identity column cannot be attached as a partition. In Citus on Postgres 17+, when propagating the CREATE TABLE ddl for a partition of a table with an identity column, the coordinator does not need to include identity definitions in the ddl. The identity will be inherited on attaching the partition to the parent table. With Postgres 16 (or less) partitions do not inherit identity.
5698bf1
to
37c9253
Compare
This is the final commit that adds PG17 compatibility with Citus's current capabilities. You can use Citus community, release-13.0 branch, with PG17.1. --------- Specifically, this commit: - Enables PG17 in the configure script. - Adds PG17 tests to CI using test images that have 17.1 - Fixes an upgrade test: see below for details In `citus_prepare_upgrade()`, don't drop any_value when upgrading from PG16+, because PG16+ has its own any_value function. Attempting to do so results in the error seen in [pg16-pg17 upgrade](https://github.com/citusdata/citus/actions/runs/11768444117/job/32778340003?pr=7661): ``` ERROR: cannot drop function any_value(anyelement) because it is required by the database system CONTEXT: SQL statement "DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement)" ``` When 16 becomes the minimum supported Postgres version, the drop statements can be removed. --------- Several PG17 Compatibility commits have been merged before this final one. All these subtasks are done #7653 See the list below: Compilation PR: #7699 Ruleutils PR: #7725 Sister PR for tests: citusdata/the-process#159 Helpful smaller PRs: - #7714 - #7726 - #7731 - #7732 - #7733 - #7738 - #7745 - #7747 - #7748 - #7749 - #7752 - #7755 - #7757 - #7759 - #7760 - #7761 - #7762 - #7765 - #7766 - #7768 - #7769 - #7771 - #7774 - #7776 - #7780 - #7781 - #7785 - #7788 - #7793 - #7796 --------- Co-authored-by: Colm <[email protected]>
PG17 added support for identity columns in partitioned tables: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=699586315 A consequence is that a table with an identity column cannot be attached as a partition. But Citus on Postgres 17 will generate identity column for the partitions if the parent table has one (or more) identity columns when propagating distributed table DDL to worker nodes, as happens in the
generated_identity
regress test in #7768:It is the Citus-generated ATTACH PARTITION statement that errors out, because the Citus-generated CREATE TABLE for the partitions included identity column definitions. The fix is straightforward - when propagating the CREATE TABLE ddl for a partition of a table with an identity column, don't include the identity column(s), they will be inherited on attaching the partition. In Citus on Postgres 16 (or less) partitions do not inherit identity; the partitions in the example would not have any identity columns so it was not an issue previously.