Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bd95816

Browse files
committed
psql: Add information in \d+ about foreign partitions and child tables
\d+ is already able to show if a partition or a child table is "PARTITIONED" via its relkind, hence the addition of a keyword for "FOREIGN" in the relation description is basically free. Author: Ian Lawrence Barwick Reviewed-by: Tom Lane, Michael Paquier Discussion: https://postgr.es/m/CAB8KJ=iwzbEz2HR9EhNxQLVhMk2G_OYtQPJ9V=jWLadseggrOA@mail.gmail.com
1 parent 28cc297 commit bd95816

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/bin/psql/describe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,6 +3445,8 @@ describeOneTableDetails(const char *schemaname,
34453445
if (child_relkind == RELKIND_PARTITIONED_TABLE ||
34463446
child_relkind == RELKIND_PARTITIONED_INDEX)
34473447
appendPQExpBufferStr(&buf, ", PARTITIONED");
3448+
else if (child_relkind == RELKIND_FOREIGN_TABLE)
3449+
appendPQExpBufferStr(&buf, ", FOREIGN");
34483450
if (strcmp(PQgetvalue(result, i, 2), "t") == 0)
34493451
appendPQExpBufferStr(&buf, " (DETACH PENDING)");
34503452
if (i < tuples - 1)

src/test/regress/expected/foreign_data.out

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1)
14041404
c1 | integer | | not null | | plain | |
14051405
c2 | text | | | | extended | |
14061406
c3 | date | | | | plain | |
1407-
Child tables: ft2
1407+
Child tables: ft2, FOREIGN
14081408

14091409
\d+ ft2
14101410
Foreign table "public.ft2"
@@ -1449,7 +1449,7 @@ ALTER FOREIGN TABLE ft2 INHERIT fd_pt1;
14491449
c1 | integer | | not null | | plain | |
14501450
c2 | text | | | | extended | |
14511451
c3 | date | | | | plain | |
1452-
Child tables: ft2
1452+
Child tables: ft2, FOREIGN
14531453

14541454
\d+ ft2
14551455
Foreign table "public.ft2"
@@ -1483,7 +1483,7 @@ Server: s0
14831483
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
14841484
Inherits: fd_pt1
14851485
Child tables: ct3,
1486-
ft3
1486+
ft3, FOREIGN
14871487

14881488
\d+ ct3
14891489
Table "public.ct3"
@@ -1522,7 +1522,7 @@ ALTER TABLE fd_pt1 ADD COLUMN c8 integer;
15221522
c6 | integer | | | | plain | |
15231523
c7 | integer | | not null | | plain | |
15241524
c8 | integer | | | | plain | |
1525-
Child tables: ft2
1525+
Child tables: ft2, FOREIGN
15261526

15271527
\d+ ft2
15281528
Foreign table "public.ft2"
@@ -1540,7 +1540,7 @@ Server: s0
15401540
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
15411541
Inherits: fd_pt1
15421542
Child tables: ct3,
1543-
ft3
1543+
ft3, FOREIGN
15441544

15451545
\d+ ct3
15461546
Table "public.ct3"
@@ -1596,7 +1596,7 @@ ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL;
15961596
c6 | integer | | not null | | plain | |
15971597
c7 | integer | | | | plain | |
15981598
c8 | text | | | | external | |
1599-
Child tables: ft2
1599+
Child tables: ft2, FOREIGN
16001600

16011601
\d+ ft2
16021602
Foreign table "public.ft2"
@@ -1614,7 +1614,7 @@ Server: s0
16141614
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
16151615
Inherits: fd_pt1
16161616
Child tables: ct3,
1617-
ft3
1617+
ft3, FOREIGN
16181618

16191619
-- drop attributes recursively
16201620
ALTER TABLE fd_pt1 DROP COLUMN c4;
@@ -1629,7 +1629,7 @@ ALTER TABLE fd_pt1 DROP COLUMN c8;
16291629
c1 | integer | | not null | | plain | 10000 |
16301630
c2 | text | | | | extended | |
16311631
c3 | date | | | | plain | |
1632-
Child tables: ft2
1632+
Child tables: ft2, FOREIGN
16331633

16341634
\d+ ft2
16351635
Foreign table "public.ft2"
@@ -1642,7 +1642,7 @@ Server: s0
16421642
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
16431643
Inherits: fd_pt1
16441644
Child tables: ct3,
1645-
ft3
1645+
ft3, FOREIGN
16461646

16471647
-- add constraints recursively
16481648
ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk1 CHECK (c1 > 0) NO INHERIT;
@@ -1669,7 +1669,7 @@ SELECT relname, conname, contype, conislocal, coninhcount, connoinherit
16691669
Check constraints:
16701670
"fd_pt1chk1" CHECK (c1 > 0) NO INHERIT
16711671
"fd_pt1chk2" CHECK (c2 <> ''::text)
1672-
Child tables: ft2
1672+
Child tables: ft2, FOREIGN
16731673

16741674
\d+ ft2
16751675
Foreign table "public.ft2"
@@ -1684,7 +1684,7 @@ Server: s0
16841684
FDW options: (delimiter ',', quote '"', "be quoted" 'value')
16851685
Inherits: fd_pt1
16861686
Child tables: ct3,
1687-
ft3
1687+
ft3, FOREIGN
16881688

16891689
DROP FOREIGN TABLE ft2; -- ERROR
16901690
ERROR: cannot drop foreign table ft2 because other objects depend on it
@@ -1716,7 +1716,7 @@ ALTER FOREIGN TABLE ft2 INHERIT fd_pt1;
17161716
Check constraints:
17171717
"fd_pt1chk1" CHECK (c1 > 0) NO INHERIT
17181718
"fd_pt1chk2" CHECK (c2 <> ''::text)
1719-
Child tables: ft2
1719+
Child tables: ft2, FOREIGN
17201720

17211721
\d+ ft2
17221722
Foreign table "public.ft2"
@@ -1746,7 +1746,7 @@ ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID;
17461746
c3 | date | | | | plain | |
17471747
Check constraints:
17481748
"fd_pt1chk3" CHECK (c2 <> ''::text) NOT VALID
1749-
Child tables: ft2
1749+
Child tables: ft2, FOREIGN
17501750

17511751
\d+ ft2
17521752
Foreign table "public.ft2"
@@ -1773,7 +1773,7 @@ ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3;
17731773
c3 | date | | | | plain | |
17741774
Check constraints:
17751775
"fd_pt1chk3" CHECK (c2 <> ''::text)
1776-
Child tables: ft2
1776+
Child tables: ft2, FOREIGN
17771777

17781778
\d+ ft2
17791779
Foreign table "public.ft2"
@@ -1804,7 +1804,7 @@ ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check;
18041804
f3 | date | | | | plain | |
18051805
Check constraints:
18061806
"f2_check" CHECK (f2 <> ''::text)
1807-
Child tables: ft2
1807+
Child tables: ft2, FOREIGN
18081808

18091809
\d+ ft2
18101810
Foreign table "public.ft2"
@@ -1862,7 +1862,7 @@ CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1)
18621862
c2 | text | | | | extended | |
18631863
c3 | date | | | | plain | |
18641864
Partition key: LIST (c1)
1865-
Partitions: fd_pt2_1 FOR VALUES IN (1)
1865+
Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
18661866

18671867
\d+ fd_pt2_1
18681868
Foreign table "public.fd_pt2_1"
@@ -1934,7 +1934,7 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
19341934
c2 | text | | | | extended | |
19351935
c3 | date | | | | plain | |
19361936
Partition key: LIST (c1)
1937-
Partitions: fd_pt2_1 FOR VALUES IN (1)
1937+
Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
19381938

19391939
\d+ fd_pt2_1
19401940
Foreign table "public.fd_pt2_1"
@@ -1962,7 +1962,7 @@ ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '');
19621962
c2 | text | | | | extended | |
19631963
c3 | date | | | | plain | |
19641964
Partition key: LIST (c1)
1965-
Partitions: fd_pt2_1 FOR VALUES IN (1)
1965+
Partitions: fd_pt2_1 FOR VALUES IN (1), FOREIGN
19661966

19671967
\d+ fd_pt2_1
19681968
Foreign table "public.fd_pt2_1"

0 commit comments

Comments
 (0)