Re: Catalog domain not-null constraints

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Catalog domain not-null constraints
Date: 2024-04-08 09:53:40
Message-ID: dd3bdf0e-a622-4111-9cba-1c458d70afb6@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 21.03.24 12:23, Peter Eisentraut wrote:
>> All the examples in the tests append "value" to this, presumably by
>> analogy with CHECK constraints, but it looks as though anything works,
>> and is simply ignored:
>>
>> ALTER DOMAIN d ADD CONSTRAINT nn NOT NULL xxx; -- works
>>
>> That doesn't seem particularly satisfactory. I think it should not
>> require (and reject) a column name after "NOT NULL".
>
> Hmm.  CREATE DOMAIN uses column constraint syntax, but ALTER DOMAIN uses
> table constraint syntax.  As long as you are only dealing with CHECK
> constraints, there is no difference, but it shows up when using NOT NULL
> constraint syntax.  I agree that this is unsatisfactory.  Attached is a
> patch to try to sort this out.

After studying this a bit more, I think moving forward in this direction
is the best way. Attached is a new patch version, mainly with a more
elaborate commit message. This patch makes the not-null constraint
syntax consistent between CREATE DOMAIN and ALTER DOMAIN, and also makes
the respective documentation correct.

(Note that, as I show in the commit message, commit e5da0fe3c22 had in
passing fixed a couple of bugs in CREATE and ALTER DOMAIN, so just
reverting that commit wouldn't be a complete solution.)

Attachment Content-Type Size
v2-0001-Fix-ALTER-DOMAIN-NOT-NULL-syntax.patch text/plain 8.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Borisov 2024-04-08 09:59:43 Re: Table AM Interface Enhancements
Previous Message Andrey M. Borodin 2024-04-08 09:40:17 Re: Should consider materializing the cheapest inner path in consider_parallel_nestloop()