Skip to content

PgExclusion: exclusion constraints end to end #25

Open
13 of 14 issues completed
Open

Description

@CaffeinatedCoder

2026-11-12, name claims are #96 (PR #97): the planner asks every contributor and the dialect what names the target takes, and a name taken twice is one SchemaDiagnostic.NameCollision (SK1001) in a SchemaValidationException that holds all of them. PostgreSQL's namespaces are held against the server on 16 and 18. Still open here: Sql.Raw<T> in an element (#26) and a factory for PgExclusion.SpGist, the compile probes against the shipped assemblies, the exact kernel pin (#35).


2026-11-12, the 5.x reader is #92 (PR #94): the PostgreSQL package reads CustomExclusion:Constraints through a new seam of the kernel (LegacyDeclarationReader<T>). A snapshot scaffolded by the published 5.6.0 diffs to nothing against the same model declared with SchemaKit, and the database its migration builds has the catalog EnsureCreated() builds, on PostgreSQL 16 and 18. That is the last "done when" below. Refused, not dropped: equality-only constraints, access methods other than GiST and one-element SP-GiST, a constraint on a TPC root (#43). The stored form of Pg.Exclusion needed no change for it. Still open after #92: name claims (#44), Sql.Raw<T> in an element (#26) and a factory for SpGist, the compile probes, the exact kernel pin (#35). Found on the way: #93.


Decided 2026-11-12 by the maintainer, on the decisions PRs #77 and #79 listed as unconfirmed:

The other decisions of the two PRs are still unconfirmed. The stored form of Pg.Exclusion is deliberately left open until the 5.x reader (#18) has been written against it.

2026-11-12, later: the second slice is #78 (PR #79, stacked on #77): btree_gist is injected where an element needs it, once per migration and first; SuppressBtreeGistInjection() and a model's own HasPostgresExtension switch it off. Green on PostgreSQL 16 and 18 locally.

2026-11-12: cut into slices. The first is #76 (PR #77): the PostgreSQL package, UseSchemaKit() on Npgsql's builder, the dialect that counts bytes, PgExclusion with the staged chain and DeclarePostgres, and the contributor with its rename in place and its measured ImpactOf. Green on PostgreSQL 16 and 18 locally: every runtime path sees the constraint, overlapping rows are refused, rows outside the filter are not.

Still open here after #76:


Decided 2026-11-12 by the maintainer: the lambda translator (#26) comes before the PostgreSQL package (#25), so that an exclusion constraint in preview.1 takes a lambda filter. The plan had the translator in preview.2. A 5.x consumer that passes its exclusion filters as lambdas could otherwise not try preview.1 without rewriting them as SQL.


From #42, 2026-11-11: the PostgreSQL dialect is this issue's to add. The kernel's SchemaDialect counts an identifier's length in characters. PostgreSQL keeps 63 bytes and shortens a longer name without an error, so a name of 40 two-byte characters passes the generic check and is truncated by the server. The PostgreSQL package registers a dialect that overrides Measure to count UTF-8 bytes, before the kernel's TryAdd. Its statements are written through SchemaSql, and the index or constraint contributor's live test has to hold the qualified drop, as PostgresStatementTests does for the builder.


The feature of preview.1 (#2). Design, sections 5 (P2, P3, P6) and 14.

Change

pg.Equal(…).Overlaps(…) stages, pg.Exclusion(…, where:, deferral:, name:), PgExclusion.Gist | SpGist, the contributor (plain ADD CONSTRAINT, qualified names, Plan with rename in place), btree_gist injection, name claims across kinds, the read model and Redeclare, the 5.x reader for CustomExclusion:Constraints.

Done when

On PostgreSQL 16 and 18: every runtime path sees the constraint; overlapping rows are refused and rows outside the filter are not; a 5.x model with exclusion constraints moves with no operations (#18).

Sub-issues

Sub-issues

13 of 14 Issues completed
Loading 14 sub-issues

Activity

  1. added this to the 11.0.0 milestone on Nov 11, 2026
  2. added
    enhancement
    package/postgresql
    area/constraints
    on Nov 11, 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/constraintsenhancementpackage/postgresql

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions