Skip to content

Conversation

m3hm3t
Copy link
Contributor

@m3hm3t m3hm3t commented Aug 14, 2025

fixes #8126

PostgreSQL 18 introduced upstream changes to foreign key propagation and naming for partitioned tables (commit [53af9491a0](https://github.com/postgres/postgres/commit/53af9491a0439720094a11b72602952d79f59ac7)), causing foreign key names to change even when the underlying constraints are identical. Examples in our regression tests include:

sensors_8970000_measureid_eventdatetime_fkey
→ fkey_from_parent_to_parent_8970000_1

These name changes are purely cosmetic but cause false test failures because our current queries assert directly on fk."Constraint".

  • Updated table_fkeys view:

    • Replaces constraint_name with a dummy boolean column (t) to indicate existence.
    • Uses the canonical FOREIGN KEY (…) REFERENCES … text as the stable representation.
  • Adjusted regression test queries:

    • Sort by relname and Definition instead of the volatile constraint name column.
    • Where filtering was previously done via constraint name prefix, now filter by child table (relid::regclass) and referenced table in the Definition.

With these changes:

  • Row counts are preserved — each FK is still represented as a row.
  • Tests continue to verify the presence and correctness of FKs, but not their internal names.
  • PG15–PG18 regression runs now produce consistent results.

@m3hm3t m3hm3t self-assigned this Aug 14, 2025
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch 2 times, most recently from a2d6f26 to 3025c41 Compare August 14, 2025 13:35
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (ce7ddc0) to head (80e5421).

❌ Your project check has failed because the head coverage (0.00%) is below the target coverage (87.50%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (ce7ddc0) and HEAD (80e5421). Click for more details.

HEAD has 68 uploads less than BASE
Flag BASE (ce7ddc0) HEAD (80e5421)
15_regress_check-pytest 1 0
16_regress_check-pytest 1 0
17_regress_check-pytest 1 0
15_citus_upgrade 1 0
15_regress_check-follower-cluster 1 0
16_regress_check-follower-cluster 1 0
17_regress_check-follower-cluster 1 0
17_regress_check-columnar-isolation 1 0
16_regress_check-add-backup-node 1 0
16_regress_check-query-generator 1 0
15_regress_check-query-generator 1 0
16_regress_check-columnar-isolation 1 0
15_regress_check-add-backup-node 1 0
15_regress_check-columnar-isolation 1 0
17_regress_check-add-backup-node 1 0
16_regress_check-enterprise-isolation-logicalrep-3 1 0
15_regress_check-enterprise-isolation-logicalrep-2 1 0
15_regress_check-enterprise-isolation-logicalrep-3 1 0
17_regress_check-enterprise-isolation-logicalrep-3 1 0
16_regress_check-enterprise-isolation-logicalrep-2 1 0
17_regress_check-query-generator 1 0
17_regress_check-enterprise-isolation-logicalrep-2 1 0
16_regress_check-split 1 0
17_regress_check-enterprise-failure 1 0
17_regress_check-columnar 1 0
15_regress_check-enterprise-failure 1 0
17_regress_check-enterprise 1 0
15_regress_check-vanilla 1 0
15_regress_check-enterprise 1 0
16_regress_check-vanilla 1 0
17_regress_check-vanilla 1 0
16_regress_check-enterprise 1 0
15_arbitrary_configs_3 1 0
16_regress_check-multi-mx 1 0
16_arbitrary_configs_2 1 0
17_arbitrary_configs_2 1 0
15_regress_check-operations 1 0
16_regress_check-operations 1 0
17_regress_check-operations 1 0
17_regress_check-isolation 1 0
15_regress_check-multi-mx 1 0
16_regress_check-failure 1 0
17_regress_check-multi-mx 1 0
17_regress_check-enterprise-isolation 1 0
16_regress_check-isolation 1 0
15_regress_check-isolation 1 0
15_regress_check-enterprise-isolation 1 0
16_regress_check-enterprise-isolation-logicalrep-1 1 0
16_regress_check-enterprise-isolation 1 0
17_regress_check-enterprise-isolation-logicalrep-1 1 0
15_regress_check-enterprise-isolation-logicalrep-1 1 0
16_cdc_installcheck 1 0
15_cdc_installcheck 1 0
17_regress_check-failure 1 0
15_regress_check-failure 1 0
17_arbitrary_configs_3 1 0
15_arbitrary_configs_5 1 0
16_arbitrary_configs_5 1 0
17_arbitrary_configs_5 1 0
15_arbitrary_configs_4 1 0
16_regress_check-multi-1 1 0
15_arbitrary_configs_0 1 0
15_regress_check-multi-1 1 0
17_arbitrary_configs_0 1 0
17_regress_check-multi-1 1 0
16_arbitrary_configs_1 1 0
17_arbitrary_configs_1 1 0
15_arbitrary_configs_1 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #8127       +/-   ##
==========================================
- Coverage   86.82%   0.00%   -86.83%     
==========================================
  Files         287     287               
  Lines       63087   63110       +23     
  Branches     7929    7903       -26     
==========================================
- Hits        54775       0    -54775     
- Misses       5767   63110    +57343     
+ Partials     2545       0     -2545     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m3hm3t m3hm3t changed the title M3hm3t/pg18 fk const fix PG18 - FK tests resilient to PG18 constraint name changes Aug 14, 2025
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch from 3025c41 to e8cbae2 Compare August 14, 2025 13:51
@m3hm3t m3hm3t requested review from Copilot and naisila August 20, 2025 11:58
Copilot

This comment was marked as outdated.

@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch from e8cbae2 to 4ca7775 Compare August 20, 2025 14:20
@m3hm3t m3hm3t marked this pull request as ready for review August 21, 2025 07:18
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch 10 times, most recently from af019ba to fbd0800 Compare August 25, 2025 12:52
Pg18 beta conf file updated

(cherry picked from commit c36410c)

Update image suffix in build and test workflow

Update image suffix in build configuration

Update image suffix in build configuration

Update image suffix in build configuration

(cherry picked from commit 7dbb946)

Update image suffix in build_and_test.yml to reflect latest development version

Update PostgreSQL version to 18beta3 in Dockerfile and CI workflow

Pg18 beta conf file updated

Pg18 beta conf file updated

(cherry picked from commit c36410c)

Update image suffix in build and test workflow

Update image suffix in build configuration

Update image suffix in build configuration

Update image suffix in build configuration

(cherry picked from commit 7dbb946)

Update image suffix in build_and_test.yml to reflect latest development version
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch from fbd0800 to 7d59914 Compare August 25, 2025 13:06
@m3hm3t m3hm3t changed the title PG18 - FK tests resilient to PG18 constraint name changes PG18 - Make regression tests resilient to PG18 foreign key name changes Aug 25, 2025
@m3hm3t m3hm3t requested a review from Copilot August 25, 2025 13:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the regression tests to be resilient to PostgreSQL 18's foreign key name changes for partitioned tables. PostgreSQL 18 introduced upstream changes that cause foreign key names to change (e.g., sensors_8970000_measureid_eventdatetime_fkeyfkey_from_parent_to_parent_8970000_1) even when the underlying constraints are identical.

  • Updated table_fkeys view to replace the constraint name column with a dummy boolean column
  • Modified test queries to sort by relationship and definition instead of volatile constraint names
  • Added PostgreSQL 18 support to CI/CD configuration

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/regress/sql/multi_test_catalog_views.sql Updated table_fkeys view to use TRUE placeholder instead of constraint names
src/test/regress/sql/multi_colocated_shard_rebalance.sql Modified FK query to filter by table names and FK definitions
src/test/regress/sql/citus_split_shard_columnar_partitioned.sql Updated ORDER BY clauses to sort by column 3 instead of 2
src/test/regress/sql/citus_non_blocking_split_columnar.sql Updated ORDER BY clauses to sort by column 3 instead of 2
src/test/regress/expected/*.out Updated test expectations to show 't' for constraint column
configure.ac Added PostgreSQL 18 version compatibility check
configure Generated configure script with PG 18 support
.github/workflows/build_and_test.yml Added PostgreSQL 18 to CI matrix and updated versions
.github/workflows/packaging-test-pipelines.yml Fixed regex for extracting PG versions
.devcontainer/Dockerfile Added PostgreSQL 18beta3 build stage
citus-tools Added submodule reference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

53af9491a0439720094a11b72602952d79f59ac7
@m3hm3t m3hm3t force-pushed the m3hm3t/pg18_fk_const_fix branch from 7d59914 to 80e5421 Compare August 25, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PG18: FK constraint names changed in tests
1 participant