From: Kyotaro Horiguchi Date: Mon, 28 Aug 2023 15:27:53 +0900 Subject: [PATCH 2/2] Add tests for \d+ not-null constraints Separated for improved readability. --- src/test/regress/expected/inherit.out | 35 ++++++++++++++++++++++++--- src/test/regress/sql/inherit.sql | 7 +++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index c80e398f71..99f260b1a5 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -2155,10 +2155,14 @@ Inherits: inh_parent1, drop table inh_parent1, inh_parent2, inh_child; -- NOT NULL NO INHERIT -create table inh_nn_parent(a int); +create table inh_nn_parent(a int, b int); create table inh_nn_child() inherits (inh_nn_parent); alter table inh_nn_parent add not null a no inherit; -create table inh_nn_child2() inherits (inh_nn_parent); +create table inh_nn_child2(c int not null) inherits (inh_nn_parent); +create table inh_nn_child3(a int not null, b int not null no inherit, c int not null no inherit) inherits (inh_nn_child2); +NOTICE: merging column "a" with inherited definition +NOTICE: merging column "b" with inherited definition +NOTICE: merging column "c" with inherited definition select conrelid::regclass, conname, contype, conkey, (select attname from pg_attribute where attrelid = conrelid and attnum = conkey[1]), coninhcount, conislocal, connoinherit @@ -2167,32 +2171,55 @@ select conrelid::regclass, conname, contype, conkey, order by 2, 1; conrelid | conname | contype | conkey | attname | coninhcount | conislocal | connoinherit ---------------+--------------------------+---------+--------+---------+-------------+------------+-------------- + inh_nn_child2 | inh_nn_child2_c_not_null | n | {3} | c | 0 | t | f + inh_nn_child3 | inh_nn_child3_a_not_null | n | {1} | a | 0 | t | f + inh_nn_child3 | inh_nn_child3_b_not_null | n | {2} | b | 0 | t | t + inh_nn_child3 | inh_nn_child3_c_not_null | n | {3} | c | 1 | t | t inh_nn_parent | inh_nn_parent_a_not_null | n | {1} | a | 0 | t | t -(1 row) +(5 rows) \d+ inh_nn* Table "public.inh_nn_child" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | + b | integer | | | | plain | | Inherits: inh_nn_parent Table "public.inh_nn_child2" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | + b | integer | | | | plain | | + c | integer | | not null | | plain | | +Not-null constraints: + "inh_nn_child2_c_not_null" NOT NULL "c" Inherits: inh_nn_parent +Child tables: inh_nn_child3 + + Table "public.inh_nn_child3" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+---------+---------+--------------+------------- + a | integer | | not null | | plain | | + b | integer | | not null | | plain | | + c | integer | | not null | | plain | | +Not-null constraints: + "inh_nn_child3_a_not_null" NOT NULL "a" + "inh_nn_child3_b_not_null" NOT NULL "b": uninheritable + "inh_nn_child3_c_not_null" NOT NULL "c": local inherited uninheritable +Inherits: inh_nn_child2 Table "public.inh_nn_parent" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | not null | | plain | | + b | integer | | | | plain | | Not-null constraints: "inh_nn_parent_a_not_null" NOT NULL "a": uninheritable Child tables: inh_nn_child, inh_nn_child2 -drop table inh_nn_parent, inh_nn_child, inh_nn_child2; +drop table inh_nn_parent, inh_nn_child, inh_nn_child2, inh_nn_child3; -- -- test inherit/deinherit -- diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql index d8fae92a53..82e9118745 100644 --- a/src/test/regress/sql/inherit.sql +++ b/src/test/regress/sql/inherit.sql @@ -777,10 +777,11 @@ select conrelid::regclass, conname, contype, conkey, drop table inh_parent1, inh_parent2, inh_child; -- NOT NULL NO INHERIT -create table inh_nn_parent(a int); +create table inh_nn_parent(a int, b int); create table inh_nn_child() inherits (inh_nn_parent); alter table inh_nn_parent add not null a no inherit; -create table inh_nn_child2() inherits (inh_nn_parent); +create table inh_nn_child2(c int not null) inherits (inh_nn_parent); +create table inh_nn_child3(a int not null, b int not null no inherit, c int not null no inherit) inherits (inh_nn_child2); select conrelid::regclass, conname, contype, conkey, (select attname from pg_attribute where attrelid = conrelid and attnum = conkey[1]), coninhcount, conislocal, connoinherit @@ -788,7 +789,7 @@ select conrelid::regclass, conname, contype, conkey, conrelid::regclass::text like 'inh\_nn\_%' order by 2, 1; \d+ inh_nn* -drop table inh_nn_parent, inh_nn_child, inh_nn_child2; +drop table inh_nn_parent, inh_nn_child, inh_nn_child2, inh_nn_child3; -- -- test inherit/deinherit -- 2.39.3 ----Next_Part(Mon_Aug_28_16_16_58_2023_869)----