From 64b74dfc55822502990f46984d76b7fca0973cdf Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 9 Jan 2026 09:28:41 +1100 Subject: [PATCH v1] Fix to make psql \d+ lists of inherits look same as other lists --- src/bin/psql/describe.c | 17 ++- src/test/regress/expected/alter_table.out | 30 +++-- src/test/regress/expected/constraints.out | 42 ++++--- src/test/regress/expected/create_table_like.out | 16 ++- src/test/regress/expected/foreign_data.out | 45 ++++--- src/test/regress/expected/generated_stored.out | 17 ++- src/test/regress/expected/generated_virtual.out | 17 ++- src/test/regress/expected/inherit.out | 151 +++++++++++++++--------- src/test/regress/expected/triggers.out | 3 +- src/test/regress/expected/without_overlaps.out | 9 +- 10 files changed, 218 insertions(+), 129 deletions(-) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index d3d9b84..2919618 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3482,21 +3482,18 @@ describeOneTableDetails(const char *schemaname, else { const char *s = _("Inherits"); - int sw = pg_wcswidth(s, strlen(s), pset.encoding); tuples = PQntuples(result); - for (i = 0; i < tuples; i++) + if (tuples > 0) { - if (i == 0) - printfPQExpBuffer(&buf, "%s: %s", - s, PQgetvalue(result, i, 0)); - else - printfPQExpBuffer(&buf, "%*s %s", - sw, "", PQgetvalue(result, i, 0)); - if (i < tuples - 1) - appendPQExpBufferChar(&buf, ','); + printfPQExpBuffer(&buf, "%s:", s); + printTableAddFooter(&cont, buf.data); + } + for (i = 0; i < tuples; i++) + { + printfPQExpBuffer(&buf, " %s", PQgetvalue(result, i, 0)); printTableAddFooter(&cont, buf.data); } diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index e98f1a9..900ff80 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -350,7 +350,8 @@ NOTICE: merging constraint "con1" with inherited definition d | integer | | | Check constraints: "con1" CHECK (a > 0) -Inherits: constraint_rename_test +Inherits: + constraint_rename_test ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo; -- fail ERROR: cannot rename inherited constraint "con1" @@ -378,7 +379,8 @@ Number of child tables: 1 (Use \d+ to list them.) d | integer | | | Check constraints: "con1foo" CHECK (a > 0) -Inherits: constraint_rename_test +Inherits: + constraint_rename_test ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT; ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo; -- ok @@ -405,7 +407,8 @@ Number of child tables: 1 (Use \d+ to list them.) d | integer | | | Check constraints: "con1foo" CHECK (a > 0) -Inherits: constraint_rename_test +Inherits: + constraint_rename_test ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a); ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo; -- ok @@ -433,7 +436,8 @@ Number of child tables: 1 (Use \d+ to list them.) d | integer | | | Check constraints: "con1foo" CHECK (a > 0) -Inherits: constraint_rename_test +Inherits: + constraint_rename_test DROP TABLE constraint_rename_test2; DROP TABLE constraint_rename_test; @@ -650,7 +654,8 @@ alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31':: Check constraints: "nv_child_2009_d_check" CHECK (d >= '01-01-2009'::date AND d <= '12-31-2009'::date) "nv_parent_d_check" CHECK (d >= '01-01-2001'::date AND d <= '12-31-2099'::date) NOT VALID -Inherits: nv_parent +Inherits: + nv_parent -- we leave nv_parent and children around to help test pg_dump logic -- Foreign key adding test with mixed types @@ -2408,7 +2413,8 @@ Number of child tables: 1 (Use \d+ to list them.) b | double precision | | | Check constraints: "test_inh_check_a_check" CHECK (a > 10.2::double precision) -Inherits: test_inh_check +Inherits: + test_inh_check select relname, conname, coninhcount, conislocal, connoinherit from pg_constraint c, pg_class r @@ -2439,7 +2445,8 @@ Number of child tables: 1 (Use \d+ to list them.) b | double precision | | | Check constraints: "test_inh_check_a_check" CHECK (a::double precision > 10.2::double precision) -Inherits: test_inh_check +Inherits: + test_inh_check select relname, conname, coninhcount, conislocal, connoinherit from pg_constraint c, pg_class r @@ -2479,7 +2486,8 @@ Check constraints: "blocal" CHECK (b < 1000::double precision) "bmerged" CHECK (b > 1::double precision) "test_inh_check_a_check" CHECK (a::double precision > 10.2::double precision) -Inherits: test_inh_check +Inherits: + test_inh_check select relname, conname, coninhcount, conislocal, connoinherit from pg_constraint c, pg_class r @@ -2519,7 +2527,8 @@ Check constraints: "blocal" CHECK (b::double precision < 1000::double precision) "bmerged" CHECK (b::double precision > 1::double precision) "test_inh_check_a_check" CHECK (a::double precision > 10.2::double precision) -Inherits: test_inh_check +Inherits: + test_inh_check select relname, conname, coninhcount, conislocal, connoinherit from pg_constraint c, pg_class r @@ -3308,7 +3317,8 @@ Typed table of type: test_type2 --------+---------+-----------+----------+--------- aa | integer | | | c | text | | | -Inherits: test_tbl2 +Inherits: + test_tbl2 DROP TABLE test_tbl2_subclass, test_tbl2; DROP TYPE test_type2; diff --git a/src/test/regress/expected/constraints.out b/src/test/regress/expected/constraints.out index 5ca4fba..bb66bc7 100644 --- a/src/test/regress/expected/constraints.out +++ b/src/test/regress/expected/constraints.out @@ -996,7 +996,8 @@ CREATE TABLE ATACC2 () INHERITS (ATACC1); Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | -Inherits: atacc1 +Inherits: + atacc1 DROP TABLE ATACC1, ATACC2; CREATE TABLE ATACC1 (a int); @@ -1007,7 +1008,8 @@ CREATE TABLE ATACC2 () INHERITS (ATACC1); Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | -Inherits: atacc1 +Inherits: + atacc1 DROP TABLE ATACC1, ATACC2; CREATE TABLE ATACC1 (a int); @@ -1018,7 +1020,8 @@ ALTER TABLE ATACC1 ADD NOT NULL a NO INHERIT; Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | -Inherits: atacc1 +Inherits: + atacc1 CREATE TABLE ATACC3 (PRIMARY KEY (a)) INHERITS (ATACC1); \d+ ATACC3 @@ -1030,7 +1033,8 @@ Indexes: "atacc3_pkey" PRIMARY KEY, btree (a) Not-null constraints: "atacc3_a_not_null" NOT NULL "a" -Inherits: atacc1 +Inherits: + atacc1 DROP TABLE ATACC1, ATACC2, ATACC3; -- NOT NULL NO INHERIT is not possible on partitioned tables @@ -1058,7 +1062,8 @@ ALTER TABLE ATACC1 ADD CONSTRAINT ditto NOT NULL a; a | integer | | not null | | plain | | Not-null constraints: "ditto" NOT NULL "a" (inherited) -Inherits: atacc2 +Inherits: + atacc2 DROP TABLE ATACC1, ATACC2, ATACC3; -- Can't have two constraints with the same name @@ -1117,7 +1122,8 @@ Child tables: b | integer | | not null | | plain | | Not-null constraints: "cnn_pk_b_not_null" NOT NULL "b" (inherited) -Inherits: cnn_pk +Inherits: + cnn_pk ALTER TABLE cnn_pk DROP CONSTRAINT cnn_primarykey; \d+ cnn_pk* @@ -1138,7 +1144,8 @@ Child tables: b | integer | | not null | | plain | | Not-null constraints: "cnn_pk_b_not_null" NOT NULL "b" (inherited) -Inherits: cnn_pk +Inherits: + cnn_pk DROP TABLE cnn_pk, cnn_pk_child; -- As above, but create the primary key ahead of time @@ -1164,7 +1171,8 @@ Child tables: b | integer | | not null | | plain | | Not-null constraints: "cnn_pk_b_not_null" NOT NULL "b" (inherited) -Inherits: cnn_pk +Inherits: + cnn_pk ALTER TABLE cnn_pk DROP CONSTRAINT cnn_primarykey; \d+ cnn_pk* @@ -1185,7 +1193,8 @@ Child tables: b | integer | | not null | | plain | | Not-null constraints: "cnn_pk_b_not_null" NOT NULL "b" (inherited) -Inherits: cnn_pk +Inherits: + cnn_pk DROP TABLE cnn_pk, cnn_pk_child; -- As above, but create the primary key using a UNIQUE index @@ -1214,7 +1223,8 @@ Child tables: b | integer | | not null | | plain | | Not-null constraints: "cnn_pk_b_not_null" NOT NULL "b" (inherited) -Inherits: cnn_pk +Inherits: + cnn_pk DROP TABLE cnn_pk, cnn_pk_child; -- Unique constraints don't give raise to not-null constraints, however. @@ -1313,7 +1323,8 @@ Not-null constraints: a | integer | | not null | | plain | | Not-null constraints: "notnull_tbl4_a_not_null" NOT NULL "a" (inherited) -Inherits: notnull_tbl4 +Inherits: + notnull_tbl4 \d+ notnull_tbl4_cld2 Table "public.notnull_tbl4_cld2" @@ -1324,7 +1335,8 @@ Indexes: "notnull_tbl4_cld2_pkey" PRIMARY KEY, btree (a) DEFERRABLE Not-null constraints: "notnull_tbl4_cld2_a_not_null" NOT NULL "a" (local, inherited) -Inherits: notnull_tbl4 +Inherits: + notnull_tbl4 \d+ notnull_tbl4_cld3 Table "public.notnull_tbl4_cld3" @@ -1335,7 +1347,8 @@ Indexes: "notnull_tbl4_cld3_pkey" PRIMARY KEY, btree (a) DEFERRABLE Not-null constraints: "a_nn" NOT NULL "a" (local, inherited) -Inherits: notnull_tbl4 +Inherits: + notnull_tbl4 -- leave these tables around for pg_upgrade testing -- It's possible to remove a constraint from parents without affecting children @@ -1353,7 +1366,8 @@ ALTER TABLE ONLY notnull_tbl5 ALTER b DROP NOT NULL; Not-null constraints: "ann" NOT NULL "a" "bnn" NOT NULL "b" -Inherits: notnull_tbl5 +Inherits: + notnull_tbl5 CREATE TABLE notnull_tbl6 (a int CONSTRAINT ann NOT NULL, b int CONSTRAINT bnn NOT NULL, check (a > 0)) PARTITION BY LIST (a); diff --git a/src/test/regress/expected/create_table_like.out b/src/test/regress/expected/create_table_like.out index d3c35c1..5720d16 100644 --- a/src/test/regress/expected/create_table_like.out +++ b/src/test/regress/expected/create_table_like.out @@ -261,8 +261,9 @@ CREATE TABLE test_like_5c (LIKE test_like_4 INCLUDING ALL) Check constraints: "test_like_4_a_check" CHECK (a > 0) "test_like_5x_p_check" CHECK (p > 0) -Inherits: test_like_5, - test_like_5x +Inherits: + test_like_5 + test_like_5x -- Test updating of column numbers in statistics expressions (bug #18468) CREATE TABLE test_like_6 (a int, c text, b text); @@ -394,7 +395,8 @@ Check constraints: "ctlt1_b_check" CHECK (length(b) > 100) NOT ENFORCED Not-null constraints: "ctlt1_a_not_null" NOT NULL "a" (local, inherited) -Inherits: ctlt1 +Inherits: + ctlt1 SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass; description @@ -419,8 +421,9 @@ Check constraints: "ctlt3_c_check" CHECK (length(c) < 7) Not-null constraints: "ctlt1_a_not_null" NOT NULL "a" (inherited) -Inherits: ctlt1, - ctlt3 +Inherits: + ctlt1 + ctlt3 CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1); NOTICE: merging column "a" with inherited definition @@ -441,7 +444,8 @@ Check constraints: "ctlt3_c_check" CHECK (length(c) < 7) Not-null constraints: "ctlt1_a_not_null" NOT NULL "a" (inherited) -Inherits: ctlt1 +Inherits: + ctlt1 SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass; description diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out index 06f3028..1c25a2f 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -1430,7 +1430,8 @@ Not-null constraints: "fd_pt1_c1_not_null" NOT NULL "c1" (inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 DROP FOREIGN TABLE ft2; \d+ fd_pt1 @@ -1484,7 +1485,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 CREATE TABLE ct3() INHERITS(ft2); CREATE FOREIGN TABLE ft3 ( @@ -1507,7 +1509,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 Child tables: ct3 ft3, FOREIGN @@ -1521,7 +1524,8 @@ Child tables: c3 | date | | | | plain | | Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (inherited) -Inherits: ft2 +Inherits: + ft2 \d+ ft3 Foreign table "public.ft3" @@ -1533,7 +1537,8 @@ Inherits: ft2 Not-null constraints: "ft3_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 -Inherits: ft2 +Inherits: + ft2 -- add attributes recursively ALTER TABLE fd_pt1 ADD COLUMN c4 integer; @@ -1576,7 +1581,8 @@ Not-null constraints: "fd_pt1_c7_not_null" NOT NULL "c7" (inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 Child tables: ct3 ft3, FOREIGN @@ -1596,7 +1602,8 @@ Child tables: Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (inherited) "fd_pt1_c7_not_null" NOT NULL "c7" (inherited) -Inherits: ft2 +Inherits: + ft2 \d+ ft3 Foreign table "public.ft3" @@ -1614,7 +1621,8 @@ Not-null constraints: "ft3_c1_not_null" NOT NULL "c1" (local, inherited) "fd_pt1_c7_not_null" NOT NULL "c7" (inherited) Server: s0 -Inherits: ft2 +Inherits: + ft2 -- alter attributes recursively ALTER TABLE fd_pt1 ALTER COLUMN c4 SET DEFAULT 0; @@ -1664,7 +1672,8 @@ Not-null constraints: "fd_pt1_c6_not_null" NOT NULL "c6" (inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 Child tables: ct3 ft3, FOREIGN @@ -1698,7 +1707,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 Child tables: ct3 ft3, FOREIGN @@ -1747,7 +1757,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 Child tables: ct3 ft3, FOREIGN @@ -1800,7 +1811,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 -- drop constraints recursively ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk1 CASCADE; @@ -1836,7 +1848,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 -- VALIDATE CONSTRAINT need do nothing on foreign tables ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3; @@ -1868,7 +1881,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "c1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 -- changes name of an attribute recursively ALTER TABLE fd_pt1 RENAME COLUMN c1 TO f1; @@ -1904,7 +1918,8 @@ Not-null constraints: "ft2_c1_not_null" NOT NULL "f1" (local, inherited) Server: s0 FDW options: (delimiter ',', quote '"', "be quoted" 'value') -Inherits: fd_pt1 +Inherits: + fd_pt1 DROP TABLE fd_pt1 CASCADE; NOTICE: drop cascades to foreign table ft2 diff --git a/src/test/regress/expected/generated_stored.out b/src/test/regress/expected/generated_stored.out index 8b7a71d..3461b6c 100644 --- a/src/test/regress/expected/generated_stored.out +++ b/src/test/regress/expected/generated_stored.out @@ -324,7 +324,8 @@ SELECT * FROM gtest1_1; --------+---------+-----------+----------+------------------------------------ a | integer | | not null | b | integer | | | generated always as (a * 2) stored -Inherits: gtest1 +Inherits: + gtest1 INSERT INTO gtest1_1 VALUES (4); SELECT * FROM gtest1_1; @@ -373,7 +374,8 @@ NOTICE: merging column "b" with inherited definition x | integer | | | | plain | | Not-null constraints: "gtest1_a_not_null" NOT NULL "a" (inherited) -Inherits: gtest1 +Inherits: + gtest1 INSERT INTO gtestx (a, x) VALUES (11, 22); SELECT * FROM gtest1; @@ -424,8 +426,9 @@ DETAIL: User-specified column moved to the position of the inherited column. a | integer | | not null | b | integer | | | generated always as (x + 1) stored x | integer | | | -Inherits: gtest1, - gtesty +Inherits: + gtest1 + gtesty -- test correct handling of GENERATED column that's only in child CREATE TABLE gtestp (f1 int); @@ -1300,7 +1303,8 @@ Number of child tables: 1 (Use \d+ to list them.) --------+---------+-----------+----------+--------- a | integer | | | b | integer | | | -Inherits: gtest30 +Inherits: + gtest30 DROP TABLE gtest30 CASCADE; NOTICE: drop cascades to table gtest30_1 @@ -1325,7 +1329,8 @@ Number of child tables: 1 (Use \d+ to list them.) --------+---------+-----------+----------+------------------------------------ a | integer | | | b | integer | | | generated always as (a * 2) stored -Inherits: gtest30 +Inherits: + gtest30 ALTER TABLE gtest30_1 ALTER COLUMN b DROP EXPRESSION; -- error ERROR: cannot drop generation expression from inherited column diff --git a/src/test/regress/expected/generated_virtual.out b/src/test/regress/expected/generated_virtual.out index 249e68b..e0af8de 100644 --- a/src/test/regress/expected/generated_virtual.out +++ b/src/test/regress/expected/generated_virtual.out @@ -318,7 +318,8 @@ SELECT * FROM gtest1_1; --------+---------+-----------+----------+----------------------------- a | integer | | not null | b | integer | | | generated always as (a * 2) -Inherits: gtest1 +Inherits: + gtest1 INSERT INTO gtest1_1 VALUES (4); SELECT * FROM gtest1_1; @@ -367,7 +368,8 @@ NOTICE: merging column "b" with inherited definition x | integer | | | | plain | | Not-null constraints: "gtest1_a_not_null" NOT NULL "a" (inherited) -Inherits: gtest1 +Inherits: + gtest1 INSERT INTO gtestx (a, x) VALUES (11, 22); SELECT * FROM gtest1; @@ -418,8 +420,9 @@ DETAIL: User-specified column moved to the position of the inherited column. a | integer | | not null | b | integer | | | generated always as (x + 1) x | integer | | | -Inherits: gtest1, - gtesty +Inherits: + gtest1 + gtesty -- test correct handling of GENERATED column that's only in child CREATE TABLE gtestp (f1 int); @@ -1270,7 +1273,8 @@ Number of child tables: 1 (Use \d+ to list them.) --------+---------+-----------+----------+----------------------------- a | integer | | | b | integer | | | generated always as (a * 2) -Inherits: gtest30 +Inherits: + gtest30 DROP TABLE gtest30 CASCADE; NOTICE: drop cascades to table gtest30_1 @@ -1295,7 +1299,8 @@ Number of child tables: 1 (Use \d+ to list them.) --------+---------+-----------+----------+----------------------------- a | integer | | | b | integer | | | generated always as (a * 2) -Inherits: gtest30 +Inherits: + gtest30 ALTER TABLE gtest30_1 ALTER COLUMN b DROP EXPRESSION; -- error ERROR: cannot drop generation expression from inherited column diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index 500c857..59c9a3f 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -795,7 +795,8 @@ Number of child tables: 1 (Use \d+ to list them.) ff1 | integer | | | Check constraints: "p2chk" CHECK (ff1 > 10) -Inherits: p1 +Inherits: + p1 -- Test that child does not override inheritable constraints of the parent create table c2 (constraint p2chk check (ff1 > 10) no inherit) inherits (p1); --fails @@ -990,8 +991,9 @@ create table c2(f3 int) inherits(p1,p2); f3 | integer | | | Check constraints: "p2_f2_check" CHECK (f2 > 0) -Inherits: p1, - p2 +Inherits: + p1 + p2 create table c3 (f4 int) inherits(c1,c2); NOTICE: merging multiple inherited definitions of column "f1" @@ -1007,8 +1009,9 @@ NOTICE: merging multiple inherited definitions of column "f3" f4 | integer | | | Check constraints: "p2_f2_check" CHECK (f2 > 0) -Inherits: c1, - c2 +Inherits: + c1 + c2 drop table p1 cascade; NOTICE: drop cascades to 3 other objects @@ -1029,7 +1032,8 @@ alter table pp1 add column a1 int check (a1 > 0); a1 | integer | | | Check constraints: "pp1_a1_check" CHECK (a1 > 0) -Inherits: pp1 +Inherits: + pp1 create table cc2(f4 float) inherits(pp1,cc1); NOTICE: merging multiple inherited definitions of column "f1" @@ -1045,8 +1049,9 @@ NOTICE: merging multiple inherited definitions of column "a1" f4 | double precision | | | Check constraints: "pp1_a1_check" CHECK (a1 > 0) -Inherits: pp1, - cc1 +Inherits: + pp1 + cc1 alter table pp1 add column a2 int check (a2 > 0); NOTICE: merging definition of column "a2" for child "cc2" @@ -1064,8 +1069,9 @@ NOTICE: merging constraint "pp1_a2_check" with inherited definition Check constraints: "pp1_a1_check" CHECK (a1 > 0) "pp1_a2_check" CHECK (a2 > 0) -Inherits: pp1, - cc1 +Inherits: + pp1 + cc1 drop table pp1 cascade; NOTICE: drop cascades to 2 other objects @@ -1090,8 +1096,9 @@ ALTER TABLE inhts RENAME d TO dd; b | integer | | | | plain | | c | integer | | | | plain | | dd | integer | | | | plain | | -Inherits: inht1, - inhs1 +Inherits: + inht1 + inhs1 DROP TABLE inhts; -- Test for adding a column to a parent table with complex inheritance @@ -1120,9 +1127,10 @@ Child tables: --------+---------+-----------+----------+---------+---------+--------------+------------- i | integer | | | | plain | | j | bigint | | | 1 | plain | | -Inherits: inhta, - inhtb, - inhtc +Inherits: + inhta + inhtb + inhtc DROP TABLE inhta, inhtb, inhtc, inhtd; -- Test for renaming in diamond inheritance @@ -1141,8 +1149,9 @@ ALTER TABLE inht1 RENAME aa TO aaa; x | integer | | | | plain | | y | integer | | | | plain | | z | integer | | | | plain | | -Inherits: inht2, - inht3 +Inherits: + inht2 + inht3 CREATE TABLE inhts (d int) INHERITS (inht2, inhs1); NOTICE: merging multiple inherited definitions of column "b" @@ -1158,8 +1167,9 @@ ERROR: cannot rename inherited column "b" x | integer | | | | plain | | c | integer | | | | plain | | d | integer | | | | plain | | -Inherits: inht2, - inhs1 +Inherits: + inht2 + inhs1 WITH RECURSIVE r AS ( SELECT 'inht1'::regclass AS inhrelid @@ -1226,7 +1236,8 @@ Child tables: id | integer | | | | plain | | val1 | character varying | | | | extended | | val2 | integer | | | | plain | | -Inherits: test_constraints +Inherits: + test_constraints DROP TABLE test_constraints_inh; DROP TABLE test_constraints; @@ -1259,7 +1270,8 @@ Child tables: Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+--------+-----------+----------+---------+---------+--------------+------------- c | circle | | | | plain | | -Inherits: test_ex_constraints +Inherits: + test_ex_constraints DROP TABLE test_ex_constraints_inh; DROP TABLE test_ex_constraints; @@ -1303,7 +1315,8 @@ Child tables: Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- id1 | integer | | | | plain | | -Inherits: test_foreign_constraints +Inherits: + test_foreign_constraints DROP TABLE test_foreign_constraints_inh; DROP TABLE test_foreign_constraints; @@ -1465,7 +1478,8 @@ alter table p1 drop constraint f1_pos; f1 | integer | | | Check constraints: "f1_pos" CHECK (f1 > 0) -Inherits: p1 +Inherits: + p1 drop table p1 cascade; NOTICE: drop cascades to table p1_c1 @@ -1485,8 +1499,9 @@ alter table p1 drop constraint f1_pos; Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- f1 | integer | | | -Inherits: p1, - p2 +Inherits: + p1 + p2 Table "public.p1p2_c2" Column | Type | Collation | Nullable | Default @@ -1494,8 +1509,9 @@ Inherits: p1, f1 | integer | | | Check constraints: "f1_pos" CHECK (f1 > 0) -Inherits: p1, - p2 +Inherits: + p1 + p2 drop table p1, p2 cascade; NOTICE: drop cascades to 2 other objects @@ -1513,8 +1529,9 @@ NOTICE: merging multiple inherited definitions of column "f1" f1 | integer | | | Check constraints: "f1_pos" CHECK (f1 > 0) -Inherits: p1_c1, - p1_c2 +Inherits: + p1_c1 + p1_c2 alter table p1 drop constraint f1_pos; \d p1_c1c2 @@ -1522,8 +1539,9 @@ alter table p1 drop constraint f1_pos; Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- f1 | integer | | | -Inherits: p1_c1, - p1_c2 +Inherits: + p1_c1 + p1_c2 drop table p1 cascade; NOTICE: drop cascades to 3 other objects @@ -1548,9 +1566,10 @@ alter table p1_c2 drop constraint f1_pos; Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- f1 | integer | | | -Inherits: p1_c1, - p1_c2, - p1 +Inherits: + p1_c1 + p1_c2 + p1 drop table p1 cascade; NOTICE: drop cascades to 3 other objects @@ -2202,9 +2221,10 @@ alter table pp1 alter f1 set not null; f4 | double precision | | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) -Inherits: pp1, - cc1, - cc2 +Inherits: + pp1 + cc1 + cc2 alter table cc3 no inherit pp1; alter table cc3 no inherit cc1; @@ -2234,7 +2254,8 @@ alter table cc1 add column a2 int constraint nn not null; Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" -Inherits: pp1 +Inherits: + pp1 Child tables: cc2 @@ -2250,8 +2271,9 @@ Child tables: Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" (inherited) -Inherits: pp1, - cc1 +Inherits: + pp1 + cc1 alter table pp1 alter column f1 set not null; \d+ pp1 @@ -2276,7 +2298,8 @@ Child tables: Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" -Inherits: pp1 +Inherits: + pp1 Child tables: cc2 @@ -2292,8 +2315,9 @@ Child tables: Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) "nn" NOT NULL "a2" (inherited) -Inherits: pp1, - cc1 +Inherits: + pp1 + cc1 -- cannot create table with inconsistent NO INHERIT constraint create table cc3 (a2 int not null no inherit) inherits (cc1); @@ -2320,7 +2344,8 @@ alter table cc1 alter column a2 drop not null; a2 | integer | | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) -Inherits: pp1 +Inherits: + pp1 Child tables: cc2 @@ -2338,8 +2363,9 @@ ERROR: cannot drop inherited constraint "pp1_f1_not_null" of relation "cc2" a2 | integer | | | | plain | | Not-null constraints: "pp1_f1_not_null" NOT NULL "f1" (inherited) -Inherits: pp1, - cc1 +Inherits: + pp1 + cc1 -- remove from cc1, should fail again alter table cc1 alter column f1 drop not null; @@ -2405,8 +2431,9 @@ alter table inh_pp1 alter column f1 drop not null; f2 | text | | | | extended | | f3 | integer | | | | plain | | f4 | double precision | | | | plain | | -Inherits: inh_pp1, - inh_cc1 +Inherits: + inh_pp1 + inh_cc1 drop table inh_pp1, inh_cc1, inh_cc2; -- Test a not-null addition that must walk down the hierarchy @@ -2430,8 +2457,9 @@ create table inh_child1 () inherits (inh_parent1, inh_parent2); Not-null constraints: "nn" NOT NULL "a" (inherited) "inh_child1_b_not_null" NOT NULL "b" (inherited) -Inherits: inh_parent1, - inh_parent2 +Inherits: + inh_parent1 + inh_parent2 create table inh_child2 (constraint foo not null a) inherits (inh_parent1, inh_parent2); alter table inh_child2 no inherit inh_parent2; @@ -2444,7 +2472,8 @@ alter table inh_child2 no inherit inh_parent2; Not-null constraints: "foo" NOT NULL "a" (local, inherited) "nn" NOT NULL "b" -Inherits: inh_parent1 +Inherits: + inh_parent1 drop table inh_parent1, inh_parent2, inh_child1, inh_child2; -- Test multiple parents with overlapping primary keys @@ -2483,8 +2512,9 @@ Not-null constraints: "inh_parent1_a_not_null" NOT NULL "a" (inherited) "inh_parent1_b_not_null" NOT NULL "b" (inherited) "inh_parent2_d_not_null" NOT NULL "d" (inherited) -Inherits: inh_parent1, - inh_parent2 +Inherits: + inh_parent1 + inh_parent2 drop table inh_parent1, inh_parent2, inh_child; -- NOT NULL NO INHERIT @@ -2508,13 +2538,15 @@ select conrelid::regclass, conname, contype, conkey, Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | -Inherits: inh_nn_parent +Inherits: + inh_nn_parent Table "public.inh_nn_child2" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+---------+--------------+------------- a | integer | | | | plain | | -Inherits: inh_nn_parent +Inherits: + inh_nn_parent Table "public.inh_nn_parent" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description @@ -2593,7 +2625,8 @@ Child tables: f1 | integer | | not null | | plain | | Not-null constraints: "inh_child1_f1_not_null" NOT NULL "f1" (local, inherited) -Inherits: inh_parent +Inherits: + inh_parent Child tables: inh_child2 @@ -2604,7 +2637,8 @@ Child tables: f1 | integer | | not null | | plain | | Not-null constraints: "inh_child2_f1_not_null" NOT NULL "f1" (local, inherited) -Inherits: inh_child1 +Inherits: + inh_child1 select conrelid::regclass, conname, contype, coninhcount, conislocal from pg_constraint where contype = 'n' and @@ -2649,7 +2683,8 @@ Child tables: f1 | integer | | not null | | plain | | Not-null constraints: "inh_child2_f1_not_null" NOT NULL "f1" (local, inherited) -Inherits: inh_child1 +Inherits: + inh_child1 select conrelid::regclass, conname, contype, coninhcount, conislocal from pg_constraint where contype = 'n' and diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out index 1eb8fba..296f414 100644 --- a/src/test/regress/expected/triggers.out +++ b/src/test/regress/expected/triggers.out @@ -3558,7 +3558,8 @@ alter trigger parenttrig on parent rename to anothertrig; a | integer | | | | plain | | Triggers: parenttrig AFTER INSERT ON child FOR EACH ROW EXECUTE FUNCTION f() -Inherits: parent +Inherits: + parent drop table parent, child; drop function f(); diff --git a/src/test/regress/expected/without_overlaps.out b/src/test/regress/expected/without_overlaps.out index f3144bd..717e379 100644 --- a/src/test/regress/expected/without_overlaps.out +++ b/src/test/regress/expected/without_overlaps.out @@ -80,7 +80,8 @@ CREATE TABLE temporal_rng2 () INHERITS (temporal_rng); ----------+-----------+-----------+----------+--------- id | int4range | | not null | valid_at | daterange | | not null | -Inherits: temporal_rng +Inherits: + temporal_rng DROP TABLE temporal_rng2; DROP TABLE temporal_rng; @@ -100,7 +101,8 @@ CREATE TABLE temporal_rng2 ( valid_at | daterange | | not null | Indexes: "temporal_rng_pk" PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) -Inherits: temporal_rng +Inherits: + temporal_rng DROP TABLE temporal_rng CASCADE; NOTICE: drop cascades to table temporal_rng2 @@ -120,7 +122,8 @@ ALTER TABLE temporal_rng2 valid_at | daterange | | not null | Indexes: "temporal_rng_pk" PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) -Inherits: temporal_rng +Inherits: + temporal_rng DROP TABLE temporal_rng2; DROP TABLE temporal_rng; -- 1.8.3.1