Thread: pg_constraint catalog changes in v18 beta1???

pg_constraint catalog changes in v18 beta1???

From
Dominique Devienne
Date:
Hi. I decided to test our stuff against the v18 beta1.

And right off the bat, I'm getting differences when introspecting a
schema via the catalogs, which now return NOT NULL constraints for
regular columns, which was not the case before, and when the doc seems
to say pg_constraint.contype = n is for domains only, while on our
test, the schema contains only the table as below, and no DOMAIN
types.

CREATE TABLE test_table (id numeric NOT NULL, name varchar(256))

Is this change of behavior normal?

This breaks our code, which is of course fixable, but this is old code
that hasn't changed since at least v14, thus I'm surprised. Was this
intentional?

Thanks, --DD

PS: Interestingly, our code also has this comment, which seems related:

    // We used information_schema.table_constraints in the past ,
    // but that view also presents system-generated not null constraints.
    // Using pg_catalog.pg_constraint gets rid of the problem



Re: pg_constraint catalog changes in v18 beta1???

From
Dominique Devienne
Date:
On Wed, Jun 4, 2025 at 3:07 PM Dominique Devienne <ddevienne@gmail.com> wrote:
> Is this change of behavior normal?
> ... Was this intentional?

Well, apparently it is intentional, I found an entry in the release notes.
Case closed I guess. I adapted our introspection. Thanks, --DD

From https://www.postgresql.org/docs/18/release-18.html#RELEASE-18-CONSTRAINTS:
Store column NOT NULL specifications in pg_constraint (Álvaro Herrera,
Bernd Helmle) §
This allows names to be specified for NOT NULL constraint. This also
adds NOT NULL constraints to foreign tables and NOT NULL inheritance
control to local tables.