Re: CREATE DOMAIN create two not null constraints

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE DOMAIN create two not null constraints
Date: 2025-07-03 09:52:56
Message-ID: 202507030952.px3iibtpl7rf@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Jun-02, jian he wrote:

> On Mon, Jun 2, 2025 at 12:13 AM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
> >
> > Hmm, I think it would be more consistent to reject the case of duplicate
> > constraints, instead of silently ignoring it. So you'd do it in the
> > loop that checks for constraints before creating anything, like

> I don't have a preference.
> error out would be fine, since it's a corner case.

Yeah, if you were to specify that they have different properties, it'd
be messy to allow two to be given because you somehow have to merge
them. Also, if something creates a constraint with a certain name, then
the jonstraint name should exist. If we allow two names to be given,
one of them is lost which is undesirable.

Pushed that way.

I noticed that for the "conflicting NULL/NOT NULL constraints" error we
use the SYNTAX_ERROR errcode but for redundant ones we use
INVALID_OBJECT_DEFINITION. Apparently this was changed in commit
33d4c828fde8 in 2003, in whose commit message Peter wrote

Some "feature not supported" errors are better syntax errors, because the
feature they complain about isn't a feature or cannot be implemented without
definitional changes.

... not sure what to think about this.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2025-07-03 10:06:47 Re: Pathify RHS unique-ification for semijoin planning
Previous Message Tender Wang 2025-07-03 09:48:38 Re: MergeJoin beats HashJoin in the case of multiple hash clauses