summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera2018-11-19 19:54:26 +0000
committerAlvaro Herrera2018-11-19 20:30:06 +0000
commitd56e0fde828b95497ce9acfb4ce18bab64803c82 (patch)
tree79ed787b19dddd1b601501b3a868f889dcce691f /src
parentdf303aff6601a893cf83c26ffd6c7eb5fb6b067e (diff)
psql: Describe partitioned tables/indexes as such
In \d and \z, instead of conflating partitioned tables and indexes with plain ones, set the "type" column and table title differently to make the distinction obvious. A simple ease-of-use improvement. Author: Pavel Stehule, Michaël Paquier, Álvaro Herrera Reviewed-by: Amit Langote Discussion: https://postgr.es/m/CAFj8pRDMWPgijpt_vPj1t702PgLG4Ls2NCf+rEcb+qGPpossmg@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/describe.c19
-rw-r--r--src/test/regress/expected/create_table.out14
-rw-r--r--src/test/regress/expected/foreign_data.out12
-rw-r--r--src/test/regress/expected/foreign_key.out4
-rw-r--r--src/test/regress/expected/indexing.out16
-rw-r--r--src/test/regress/expected/insert.out4
-rw-r--r--src/test/regress/expected/rowsecurity.out2
7 files changed, 39 insertions, 32 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 4ca0db1d0ca..bd7a97bd6f4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -955,7 +955,7 @@ permissionsList(const char *pattern)
gettext_noop("materialized view"),
gettext_noop("sequence"),
gettext_noop("foreign table"),
- gettext_noop("table"), /* partitioned table */
+ gettext_noop("partitioned table"),
gettext_noop("Type"));
printACLColumn(&buf, "c.relacl");
@@ -1896,7 +1896,6 @@ describeOneTableDetails(const char *schemaname,
schemaname, relationname);
break;
case RELKIND_INDEX:
- case RELKIND_PARTITIONED_INDEX:
if (tableinfo.relpersistence == 'u')
printfPQExpBuffer(&title, _("Unlogged index \"%s.%s\""),
schemaname, relationname);
@@ -1904,6 +1903,14 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&title, _("Index \"%s.%s\""),
schemaname, relationname);
break;
+ case RELKIND_PARTITIONED_INDEX:
+ if (tableinfo.relpersistence == 'u')
+ printfPQExpBuffer(&title, _("Unlogged partitioned index \"%s.%s\""),
+ schemaname, relationname);
+ else
+ printfPQExpBuffer(&title, _("Partitioned index \"%s.%s\""),
+ schemaname, relationname);
+ break;
case 's':
/* not used as of 8.2, but keep it for backwards compatibility */
printfPQExpBuffer(&title, _("Special relation \"%s.%s\""),
@@ -1923,10 +1930,10 @@ describeOneTableDetails(const char *schemaname,
break;
case RELKIND_PARTITIONED_TABLE:
if (tableinfo.relpersistence == 'u')
- printfPQExpBuffer(&title, _("Unlogged table \"%s.%s\""),
+ printfPQExpBuffer(&title, _("Unlogged partitioned table \"%s.%s\""),
schemaname, relationname);
else
- printfPQExpBuffer(&title, _("Table \"%s.%s\""),
+ printfPQExpBuffer(&title, _("Partitioned table \"%s.%s\""),
schemaname, relationname);
break;
default:
@@ -3524,8 +3531,8 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
gettext_noop("sequence"),
gettext_noop("special"),
gettext_noop("foreign table"),
- gettext_noop("table"), /* partitioned table */
- gettext_noop("index"), /* partitioned index */
+ gettext_noop("partitioned table"),
+ gettext_noop("partitioned index"),
gettext_noop("Type"),
gettext_noop("Owner"));
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 7b184330ed5..f474f0d73e1 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -403,7 +403,7 @@ CREATE TABLE fail () INHERITS (partitioned2);
ERROR: cannot inherit from partitioned table "partitioned2"
-- Partition key in describe output
\d partitioned
- Table "public.partitioned"
+ Partitioned table "public.partitioned"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -414,7 +414,7 @@ Partition key: RANGE (a oid_ops, plusone(b), c, d COLLATE "C")
Number of partitions: 0
\d+ partitioned2
- Table "public.partitioned2"
+ Partitioned table "public.partitioned2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
a | integer | | | | plain | |
@@ -769,7 +769,7 @@ Check constraints:
-- Both partition bound and partition key in describe output
\d+ part_c
- Table "public.part_c"
+ Partitioned table "public.part_c"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
a | text | | | | extended | |
@@ -798,7 +798,7 @@ Check constraints:
-- output could vary depending on the order in which partition oids are
-- returned.
\d parted
- Table "public.parted"
+ Partitioned table "public.parted"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | text | | |
@@ -809,7 +809,7 @@ Check constraints:
Number of partitions: 3 (Use \d+ to list them.)
\d hash_parted
- Table "public.hash_parted"
+ Partitioned table "public.hash_parted"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -891,7 +891,7 @@ SELECT obj_description('parted_col_comment'::regclass);
(1 row)
\d+ parted_col_comment
- Table "public.parted_col_comment"
+ Partitioned table "public.parted_col_comment"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+---------------
a | integer | | | | plain | | Partition key
@@ -917,7 +917,7 @@ create table boolspart (a bool) partition by list (a);
create table boolspart_t partition of boolspart for values in (true);
create table boolspart_f partition of boolspart for values in (false);
\d+ boolspart
- Table "public.boolspart"
+ Partitioned table "public.boolspart"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | boolean | | | | plain | |
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index 75365501d4a..b16c8e2c247 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -1853,7 +1853,7 @@ CREATE TABLE fd_pt2 (
CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1)
SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value');
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
@@ -1898,7 +1898,7 @@ ERROR: table "fd_pt2_1" contains column "c4" not found in parent "fd_pt2"
DETAIL: The new partition may contain only the columns present in parent.
DROP FOREIGN TABLE fd_pt2_1;
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
@@ -1925,7 +1925,7 @@ FDW options: (delimiter ',', quote '"', "be quoted" 'value')
-- no attach partition validation occurs for foreign tables
ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
@@ -1953,7 +1953,7 @@ ERROR: cannot add column to a partition
ALTER TABLE fd_pt2_1 ALTER c3 SET NOT NULL;
ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '');
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
@@ -1983,7 +1983,7 @@ ERROR: column "c1" is marked NOT NULL in parent table
ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1;
ALTER TABLE fd_pt2 ALTER c2 SET NOT NULL;
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
@@ -2011,7 +2011,7 @@ ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1);
ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1;
ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0);
\d+ fd_pt2
- Table "public.fd_pt2"
+ Partitioned table "public.fd_pt2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
c1 | integer | | not null | | plain | |
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index fee594531d6..085c9aba115 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -1692,7 +1692,7 @@ ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_4;
ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500,3502);
-- should only have one constraint
\d fk_partitioned_fk_4
- Table "public.fk_partitioned_fk_4"
+ Partitioned table "public.fk_partitioned_fk_4"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -1737,7 +1737,7 @@ ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN
-- this one has two constraints, similar but not quite the one in the parent,
-- so it gets a new one
\d fk_partitioned_fk_5
- Table "public.fk_partitioned_fk_5"
+ Partitioned table "public.fk_partitioned_fk_5"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out
index ca27346f182..3e61f50e7ce 100644
--- a/src/test/regress/expected/indexing.out
+++ b/src/test/regress/expected/indexing.out
@@ -260,7 +260,7 @@ Indexes:
"idxpart1_a_idx" btree (a)
\d idxpart2
- Table "public.idxpart2"
+ Partitioned table "public.idxpart2"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -305,7 +305,7 @@ where indexrelid::regclass::text like 'idxpart%'
-- attaching idxpart22 is not enough to set idxpart22_a_idx valid ...
alter index idxpart2_a_idx attach partition idxpart22_a_idx;
\d idxpart2
- Table "public.idxpart2"
+ Partitioned table "public.idxpart2"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -319,7 +319,7 @@ Number of partitions: 2 (Use \d+ to list them.)
create index on idxpart21 (a);
alter index idxpart2_a_idx attach partition idxpart21_a_idx;
\d idxpart2
- Table "public.idxpart2"
+ Partitioned table "public.idxpart2"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
@@ -728,7 +728,7 @@ create table idxpart (col_keep int) partition by range (col_keep);
create index on idxpart (col_keep);
alter table idxpart attach partition idxpart1 for values from (0) to (1000);
\d idxpart
- Table "public.idxpart"
+ Partitioned table "public.idxpart"
Column | Type | Collation | Nullable | Default
----------+---------+-----------+----------+---------
col_keep | integer | | |
@@ -771,7 +771,7 @@ create index on idxpart1 (col_keep);
create index on idxpart (col_keep);
alter table idxpart attach partition idxpart1 for values from (0) to (1000);
\d idxpart
- Table "public.idxpart"
+ Partitioned table "public.idxpart"
Column | Type | Collation | Nullable | Default
----------+---------+-----------+----------+---------
col_keep | integer | | |
@@ -810,7 +810,7 @@ drop table idxpart;
-- Verify that it works to add primary key / unique to partitioned tables
create table idxpart (a int primary key, b int) partition by range (a);
\d idxpart
- Table "public.idxpart"
+ Partitioned table "public.idxpart"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
@@ -872,7 +872,7 @@ ERROR: insufficient columns in PRIMARY KEY constraint definition
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
alter table idxpart add primary key (a, b); -- this works
\d idxpart
- Table "public.idxpart"
+ Partitioned table "public.idxpart"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | not null |
@@ -903,7 +903,7 @@ ERROR: insufficient columns in UNIQUE constraint definition
DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
alter table idxpart add unique (b, a); -- this works
\d idxpart
- Table "public.idxpart"
+ Partitioned table "public.idxpart"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
a | integer | | |
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index 5edf2693679..1cf6531c019 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -448,7 +448,7 @@ from hash_parted order by part;
-- test \d+ output on a table which has both partitioned and unpartitioned
-- partitions
\d+ list_parted
- Table "public.list_parted"
+ Partitioned table "public.list_parted"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
a | text | | | | extended | |
@@ -799,7 +799,7 @@ create table mcrparted6_common_ge_10 partition of mcrparted for values from ('co
create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue);
create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue);
\d+ mcrparted
- Table "public.mcrparted"
+ Partitioned table "public.mcrparted"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
a | text | | | | extended | |
diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out
index bc16ca4c43f..6f77f5c8a46 100644
--- a/src/test/regress/expected/rowsecurity.out
+++ b/src/test/regress/expected/rowsecurity.out
@@ -938,7 +938,7 @@ CREATE POLICY pp1 ON part_document AS PERMISSIVE
CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave
USING (cid < 55);
\d+ part_document
- Table "regress_rls_schema.part_document"
+ Partitioned table "regress_rls_schema.part_document"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------+---------+-----------+----------+---------+----------+--------------+-------------
did | integer | | | | plain | |