From: Fujii Masao Date: Mon, 30 Mar 2026 02:21:22 +0000 (+0900) Subject: psql: Make \d+ inheritance tables list formatting consistent with other objects X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a11405a436038293f425f2ffc41b02235eda912;p=thirdparty%2Fpostgresql.git psql: Make \d+ inheritance tables list formatting consistent with other objects This followw up on the previous change (commit 7bff9f106a5) for partitions by applying the same formatting to inheritance tables lists. Previously, \d+ displayed inheritance tables differently from other object lists: the first inheritance table appeared on the same line as the "Inherits" header. For example: Inherits: test_like_5, test_like_5x This commit updates the output so that inheritance tables are listed consistently with other objects, with each entry on its own line starting below the header: Inherits: test_like_5 test_like_5x Author: Peter Smith Reviewed-by: Chao Li Reviewed-by: Neil Chen Reviewed-by: Greg Sabino Mullane Reviewed-by: Soumya S Murali Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/CAHut+Pu1puO00C-OhgLnAcECzww8MB3Q8DCsvx0cZWHRfs4gBQ@mail.gmail.com --- diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 44e6cb6d7ac..d755d25dcf0 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3676,21 +3676,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 9872899586a..dad9d36937e 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 75f61377143..728ef2fd17e 100644 --- a/src/test/regress/expected/constraints.out +++ b/src/test/regress/expected/constraints.out @@ -1084,7 +1084,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); @@ -1095,7 +1096,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); @@ -1106,7 +1108,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 @@ -1118,7 +1121,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 @@ -1146,7 +1150,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 @@ -1205,7 +1210,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* @@ -1226,7 +1232,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 @@ -1252,7 +1259,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* @@ -1273,7 +1281,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 @@ -1302,7 +1311,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. @@ -1401,7 +1411,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" @@ -1412,7 +1423,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" @@ -1423,7 +1435,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 @@ -1441,7 +1454,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 d3c35c14847..5720d160f05 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 8bf84f28df0..d8e4cb12c3d 100644 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@ -1459,7 +1459,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 @@ -1513,7 +1514,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 ( @@ -1536,7 +1538,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 @@ -1550,7 +1553,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" @@ -1562,7 +1566,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; @@ -1605,7 +1610,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 @@ -1625,7 +1631,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" @@ -1643,7 +1650,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; @@ -1693,7 +1701,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 @@ -1727,7 +1736,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 @@ -1776,7 +1786,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 @@ -1829,7 +1840,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; @@ -1865,7 +1877,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; @@ -1897,7 +1910,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; @@ -1933,7 +1947,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 2385573d913..43cddeac373 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); @@ -1366,7 +1369,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 @@ -1391,7 +1395,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 9365fd3c57b..234061fa1f7 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); @@ -1291,7 +1294,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 @@ -1316,7 +1320,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 7b646836ec9..3d8e8d8afd2 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; @@ -1527,7 +1540,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 @@ -1547,8 +1561,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 @@ -1556,8 +1571,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 @@ -1575,8 +1591,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 @@ -1584,8 +1601,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 @@ -1610,9 +1628,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 @@ -2264,9 +2283,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; @@ -2296,7 +2316,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 @@ -2312,8 +2333,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 @@ -2338,7 +2360,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 @@ -2354,8 +2377,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); @@ -2382,7 +2406,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 @@ -2400,8 +2425,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; @@ -2467,8 +2493,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 @@ -2492,8 +2519,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; @@ -2506,7 +2534,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 @@ -2545,8 +2574,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 @@ -2570,13 +2600,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 @@ -2655,7 +2687,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 @@ -2666,7 +2699,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 @@ -2711,7 +2745,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 98dee63b50a..511e7cfb6ce 100644 --- a/src/test/regress/expected/triggers.out +++ b/src/test/regress/expected/triggers.out @@ -3572,7 +3572,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 06f6fd2c8c5..36d2c18bdbe 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;