From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Tender Wang <tndrwang(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: not null constraints, again |
Date: | 2024-10-01 08:17:00 |
Message-ID: | CACJufxFdxmPjhHeBLHZwFGWVp-qzqziUbuFbzO0GrxF_uFFxzA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
create table t2 (a int primary key constraint foo not null no inherit);
primary key cannot coexist with not-null no inherit?
here t2, pg_dump/restore will fail.
create table t7 (a int generated by default as identity, constraint
foo not null a no inherit, b int);
create table t7 (a int generated by default as identity not null no
inherit, b int);
first fail, second not fail. pg_dump output is:
CREATE TABLE public.t7 (a integer NOT NULL NO INHERIT,b integer);
ALTER TABLE public.t7 ALTER COLUMN a ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.t7_a_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
seems there is a consistency between column_constraint, table_constraint.
but in this case, the public.t7 dump is fine.
-------------------------------------------------------------------------------
+ By contrast, a <literal>NOT NULL</literal> constraint that was created
+ as <literal>NO INHERIT</literal> will be changed to a normal inheriting
+ one during attach.
Does this sentence don't have corresponding tests?
i think you mean something like:
drop table if exists idxpart,idxpart0,idxpart1 cascade;
create table idxpart (a int not null) partition by list (a);
create table idxpart0 (a int constraint foo not null no inherit);
alter table idxpart attach partition idxpart0 for values in (0,1,NULL);
---------------------------------------------------------------------------------
the pg_dump of
-------------
drop table if exists idxpart, idxpart0 cascade;
create table idxpart (a int) partition by range (a);
create table idxpart0 (a int not null);
alter table idxpart attach partition idxpart0 for values from (0) to (100);
alter table idxpart alter column a set not null;
-------------
is
CREATE TABLE public.idxpart (a integer NOT NULL)PARTITION BY RANGE (a);
CREATE TABLE public.idxpart0 (a integer NOT NULL);
ALTER TABLE ONLY public.idxpart ATTACH PARTITION public.idxpart0 FOR
VALUES FROM (0) TO (100);
After pu_dump, the attribute conislocal of constraint
idxpart0_a_not_null changes from true to false,
is this OK for attribute change after pg_dump in this case?
From | Date | Subject | |
---|---|---|---|
Next Message | wenhui qiu | 2024-10-01 08:44:57 | Re: Patch: Show queries of processes holding a lock |
Previous Message | jian he | 2024-10-01 08:14:18 | Re: not null constraints, again |