Skip to content

An exclusion constraint declared on a derived type of a shared table covers its siblings' rows #82

Closed

Description

@CaffeinatedCoder

Decided 2026-11-12 by the maintainer: refuse it (option 1), on the target side of a diff only. PR #86. What it costs is #85.


Found by the analysis of #77 and #79, reproduced on PostgreSQL 16.15 and 18.6.

What happens

Stay and Hold derive from Reservation in one table. DeclarePostgres on Stay alone gives ALTER TABLE reservations ADD CONSTRAINT ex_stay EXCLUDE USING gist ("RoomId" WITH =, "Period" WITH &&): no discriminator in it. Two overlapping Hold rows are refused with 23P01.

The database refuses writes the model allows. Neither the design nor the plan says what a declaration on a derived type of a shared table means.

To decide

  1. Refuse a declaration on a derived type that shares its table, naming the base type to declare it on.
  2. Add the discriminator to the condition, so that the constraint covers the derived type's rows.

The same question will come for PgIndex (#27), and the answer should be one.

Activity

  1. added this to the 11.0.0 milestone on Nov 12, 2026
  2. added
    bug
    package/core
    package/postgresql
    area/constraints
    severity/medium
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/constraintsbugpackage/corepackage/postgresqlseverity/medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions