Skip to content

Make foreign_key_to_reference_table constraint checks deterministic on PG19 #8669

Description

@ihalatci

Part of #8597.

The foreign_key_to_reference_table partition test creates both a partition-to-partition fkey and a partition-to-reference-table fkey_to_ref on the same partition. Its original negative row violated both constraints simultaneously, so PostgreSQL 17/18 and PostgreSQL 19 could report different valid constraints first without independently proving both enforcement paths.

Make the checks deterministic and mutually exclusive:

  • seed reference key 5 before inserting (0, 5), leaving only the partition-to-partition fkey unsatisfied;
  • insert id = 0 into the referenced partition, then use missing reference key 4 for the separate fkey_to_ref failure;
  • retain the final successful (0, 5) insert after both constraints are satisfied;
  • use one primary expected output on PostgreSQL 17, 18, and 19, with no numbered alternative and no broader normalization.

Verify the focused regression test on PostgreSQL 17.10, 18.4, and 19beta2, and confirm each version reports fkey for the first negative insert and fkey_to_ref for the second.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions