Skip to content

PG19: make partition foreign key checks deterministic - #8675

Open
ihalatci wants to merge 2 commits into
pg19-supportfrom
ihalatci-pg19-fk-expected-output
Open

PG19: make partition foreign key checks deterministic#8675
ihalatci wants to merge 2 commits into
pg19-supportfrom
ihalatci-pg19-fk-expected-output

Conversation

@ihalatci

@ihalatci ihalatci commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make the partition-to-partition fkey and partition-to-reference-table fkey_to_ref checks mutually exclusive
  • use one cross-version expected output for PostgreSQL 17, 18, and 19
  • remove the now-redundant numbered alternative expected output
  • leave normalize.sed and production code unchanged

Coverage fix

The test previously used (id, value_1) = (0, 5) while both foreign keys were unsatisfied. PostgreSQL 17/18 reported fkey first, while PostgreSQL 19beta2 reported fkey_to_ref first, so the row did not independently prove either check.

The revised sequence makes each failure unambiguous:

  1. Seed reference key 5, then insert (0, 5) before partition referencing_table_0 contains id = 0. Only fkey is unsatisfied:

    foreign key constraint "fkey_xxxxxxx"
    Key (id)=(X) is not present in table "referencing_table_0_xxxxxxx".
    
  2. Insert (0, 1) into partition referencing_table_0, satisfying fkey for id = 0. Then insert (0, 4), where reference key 4 is absent. Only fkey_to_ref is unsatisfied:

    foreign key constraint "fkey_to_ref_xxxxxxx"
    Key (value_1)=(4) is not present in table "referenced_table_xxxxxxx".
    
  3. Insert (0, 5) successfully once both constraints are satisfied.

Validation

PostgreSQL Focused test Expected output
17.10 Passed Primary, byte-for-byte
18.4 Passed Primary, byte-for-byte
19beta2 Passed Primary, byte-for-byte

Each leg used a fresh Citus build with absolute PostgreSQL installation paths. The focused schedule included its required helper tests and all 5 tests passed. All three normalized results were identical (sha256 8b6ab879b0581fed4fd1efbe023d896c00513c42f1d0b95ad8edddf523ae3527). The primary output is normalization-idempotent, and git diff --check passes.

Closes #8669

Note

This draft targets the non-default pg19-support branch. GitHub's closing keyword takes effect only when the change reaches the repository's default branch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2a53d4d7-c12a-41cc-96ea-46be67eff49d
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.79%. Comparing base (cfb4063) to head (cc1b4ae).

Additional details and impacted files
@@              Coverage Diff              @@
##           pg19-support    #8675   +/-   ##
=============================================
  Coverage         88.79%   88.79%           
=============================================
  Files               288      288           
  Lines             64416    64416           
  Branches           8101     8102    +1     
=============================================
  Hits              57201    57201           
  Misses             4877     4877           
  Partials           2338     2338           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Seed the reference key before checking the partition-to-partition foreign key, then use a distinct missing reference key for the reference-table check. This makes both constraints independently covered on PostgreSQL 17, 18, and 19 and removes the redundant alternative output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2a53d4d7-c12a-41cc-96ea-46be67eff49d
@ihalatci ihalatci changed the title PG19: add alternative foreign key expected output PG19: make partition foreign key checks deterministic Jul 17, 2026
@ihalatci
ihalatci marked this pull request as ready for review July 17, 2026 11:53
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.

2 participants