public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: jian he <[email protected]>
Cc: Tender Wang <[email protected]>
Cc: Pg Hackers <[email protected]>
Subject: Re: not null constraints, again
Date: Tue, 24 Sep 2024 18:59:46 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACJufxHNQs3PyUNz9h6tThFyrXBuNzxb2G=2n4DMZNPmKVKB_Q@mail.gmail.com>
On 2024-Sep-24, jian he wrote:
> sql-createtable.html
> SECTION: LIKE source_table [ like_option ... ]
> 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.
>
> drop table if exists t, t_1,ssa;
> create table t(a int, b int, not null a no inherit);
> create table ssa (like t INCLUDING all);
>
> Here create table like won't include no inherit not-null constraint,
> seems to conflict with the doc?
Hmm, actually I think this is a bug, because if you have CHECK
constraint with NO INHERIT, it will be copied:
create table t (a int check (a > 0) no inherit);
create table ssa (like t including constraints);
55490 18devel 141626=# \d+ ssa
Tabla «public.ssa»
Columna │ Tipo │ Ordenamiento │ Nulable │ Por omisión │ Almacenamiento>
─────────┼─────────┼──────────────┼─────────┼─────────────┼───────────────>
a │ integer │ │ │ │ plain >
Restricciones CHECK:
"t_a_check" CHECK (a > 0) NO INHERIT
Método de acceso: heap
It seems that NOT NULL constraint should behave the same as CHECK
constraints in this regard, i.e., we should not heed NO INHERIT in this
case.
I have made these changes and added some tests, and will be posting a v5
shortly.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
<inflex> really, I see PHP as like a strange amalgamation of C, Perl, Shell
<crab> inflex: you know that "amalgam" means "mixture with mercury",
more or less, right?
<crab> i.e., "deadly poison"
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: not null constraints, again
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox