Re: Function pg_get_constraintdef

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Erki Eessaar <erki(dot)eessaar(at)taltech(dot)ee>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Function pg_get_constraintdef
Date: 2024-11-21 12:30:52
Message-ID: 202411211230.ocnd65fqmdk2@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2024-Nov-21, Magnus Hagander wrote:

> On Thu, Nov 21, 2024 at 1:01 PM Erki Eessaar <erki(dot)eessaar(at)taltech(dot)ee>
> wrote:
>
> > SELECT pg_get_constraintdef(c.oid)
> > FROM pg_catalog.pg_constraint c;
> >
> > If I execute the query in two different servers with PostgreSQL 17.1 and
> > in different databases in these servers, then I get the answer
> >
> > ERROR: invalid constraint type "n"

> Looks like this is an omission in the catalog-not-null-constraints patch.
> It happens when you've got a domain that has a not null constraint on it.
> Easily reproducible with
>
> create domain test as int int not null;
> SELECT pg_get_constraintdef(c.oid) FROM pg_catalog.pg_constraint c;

Ah, yeah. The overall catalog-not-null-constraints patch was reverted
in 17 (and recently reintroduced in 18). But we kept not-null
constraints for domains. However, the ruleutils.c code to support
domain ones wasn't kept. So we need something based on the attached
patch, which just copies what the code in 18 does for the domain case.

I wonder if there are other places that need to handle these constraint
entries, though.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/

Attachment Content-Type Size
getconstraintdef-domains.patch text/x-diff 487 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2024-11-21 12:32:44 Re: BUG #18718: Incorrect Twitter/X Logo Displayed on PostgreSQL Documentation Page
Previous Message radagast42 2024-11-21 12:28:29 AW: Wrong german error message encoding