Re: cataloguing NOT NULL constraints

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Andrew Bille <andrewbille(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: cataloguing NOT NULL constraints
Date: 2024-05-03 04:00:00
Message-ID: 7d0f1fea-0f1a-2c9f-9b02-867b73abee78@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

02.05.2024 19:21, Alvaro Herrera wrote:

> Now, you could claim that the standard doesn't mention
> INCLUDING/EXCLUDING CONSTRAINTS, therefore since we have come up with
> its definition then we should make it affect not-null constraints.
> However, there's also this note:
>
> NOTE 520 — <column constraint>s, except for NOT NULL, are not included in
> CDi; <column constraint definition>s are effectively transformed to <table
> constraint definition>s and are thereby also excluded.
>
> which is explicitly saying that not-null constraints are treated
> differently; in essence, with INCLUDING CONSTRAINTS we choose to affect
> the constraints that the standard says to ignore.

Thank you for very detailed and convincing explanation!

Now I see what the last sentence here (from [1]) means:
INCLUDING CONSTRAINTS

    CHECK constraints will be copied. No distinction is made between
    column constraints and table constraints. _Not-null constraints are
    always copied to the new table._

(I hadn't paid enough attention to it, because this exact paragraph is
also presented in previous versions...)

[1] https://www.postgresql.org/docs/devel/sql-createtable.html

Best regards,
Alexander

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-05-03 04:03:45 Incorrect Assert in BufFileSize()?
Previous Message Andrei Lepikhov 2024-05-03 03:19:58 Re: Removing unneeded self joins