DOCS - "\d mytable" also shows any publications that publish mytable

Started by Peter Smith20 days ago8 messages
#1Peter Smith
smithpb2250@gmail.com
1 attachment(s)

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachments:

v1-0001-DOCS-psql-describe-table-can-list-publications.patchapplication/octet-stream; name=v1-0001-DOCS-psql-describe-table-can-list-publications.patchDownload
From 36abb89c50ffaf449a4d0bb328e799eb4fd9560e Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Tue, 23 Dec 2025 07:54:06 +1100
Subject: [PATCH v1] DOCS - psql describe table can list publications

---
 doc/src/sgml/ref/psql-ref.sgml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index f56c702..c0ff203 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1299,7 +1299,7 @@ SELECT $1 \parse stmt1
         <replaceable class="parameter">pattern</replaceable>, show all
         columns, their types, the tablespace (if not the default) and any
         special attributes such as <literal>NOT NULL</literal> or defaults.
-        Associated indexes, constraints, rules, and triggers are
+        Associated indexes, constraints, rules, publications, and triggers are
         also shown.  For foreign tables, the associated foreign
         server is shown as well.
         (<quote>Matching the pattern</quote> is defined in
-- 
1.8.3.1

#2Peter Smith
smithpb2250@gmail.com
In reply to: Peter Smith (#1)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

See here [1]https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-META-COMMAND-D

======
[1]: https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-META-COMMAND-D

Show quoted text

On Tue, Dec 23, 2025 at 8:07 AM Peter Smith <smithpb2250@gmail.com> wrote:

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

#3Andreas Karlsson
andreas@proxel.se
In reply to: Peter Smith (#1)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On 12/22/25 10:07 PM, Peter Smith wrote:

Here is a trivial patch to fix that omission.

The patch looks good to me as this seems like useful information and I
do not think it needs to be added in more places since e.g. \d+ does not
have its own entry.

Andreas

#4Chao Li
li.evan.chao@gmail.com
In reply to: Peter Smith (#1)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On Dec 23, 2025, at 05:07, Peter Smith <smithpb2250@gmail.com> wrote:

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v1-0001-DOCS-psql-describe-table-can-list-publications.patch>

Not only publication, “\d table_name” also shows partition information:

```
evantest=# \d t_part;
Partitioned table "public.t_part"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition key: RANGE (id)
Publications:
"mypub"
Number of partitions: 3 (Use \d+ to list them.)

evantest=# \d t_part_p1;
Table "public.t_part_p1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition of: t_part FOR VALUES FROM (0) TO (100)
```

As you updating this section, you may add “partition info” as well.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#5Peter Smith
smithpb2250@gmail.com
In reply to: Chao Li (#4)
1 attachment(s)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On Tue, Dec 23, 2025 at 7:28 PM Chao Li <li.evan.chao@gmail.com> wrote:

On Dec 23, 2025, at 05:07, Peter Smith <smithpb2250@gmail.com> wrote:

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v1-0001-DOCS-psql-describe-table-can-list-publications.patch>

Not only publication, “\d table_name” also shows partition information:

```
evantest=# \d t_part;
Partitioned table "public.t_part"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition key: RANGE (id)
Publications:
"mypub"
Number of partitions: 3 (Use \d+ to list them.)

evantest=# \d t_part_p1;
Table "public.t_part_p1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition of: t_part FOR VALUES FROM (0) TO (100)
```

As you updating this section, you may add “partition info” as well.

OK, I've added some text about partitions. See patch v2.

~~~

TBH, the \d and \d+ partition output looked strange to me.

test_pub=# \d+ tp
Partitioned table "public.tp"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain |
| |
Partition key: RANGE (a)
Publications:
"pub1"
"pub3"
Partitions: tp1 FOR VALUES FROM (1) TO (10),
tp2 FOR VALUES FROM (10) TO (20)

For example:
a) Why isn't the "Partition key:" and "Partitions:" info kept together?
b) Why does the "Partitions:" list indentation look different?

Anyway, those are questions for another thread and another year.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachments:

v2-0001-DOCS-psql-describe-table-can-list-publications-an.patchapplication/octet-stream; name=v2-0001-DOCS-psql-describe-table-can-list-publications-an.patchDownload
From 6604255e1d56855ab0b265a3609b324748a255e2 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Wed, 24 Dec 2025 09:14:31 +1100
Subject: [PATCH v2] DOCS - psql describe table can list publications and
 partitions

---
 doc/src/sgml/ref/psql-ref.sgml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index f56c702..afae293 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1299,9 +1299,9 @@ SELECT $1 \parse stmt1
         <replaceable class="parameter">pattern</replaceable>, show all
         columns, their types, the tablespace (if not the default) and any
         special attributes such as <literal>NOT NULL</literal> or defaults.
-        Associated indexes, constraints, rules, and triggers are
-        also shown.  For foreign tables, the associated foreign
-        server is shown as well.
+        Associated indexes, constraints, rules, partition information,
+        publications, and triggers are also shown. For foreign tables, the
+        associated foreign server is shown as well.
         (<quote>Matching the pattern</quote> is defined in
         <xref linkend="app-psql-patterns"/> below.)
         </para>
@@ -1316,9 +1316,9 @@ SELECT $1 \parse stmt1
         The command form <literal>\d+</literal> is identical, except that
         more information is displayed: any comments associated with the
         columns of the table are shown, as is the presence of OIDs in the
-        table, the view definition if the relation is a view, a non-default
-        <link linkend="sql-altertable-replica-identity">replica
-         identity</link> setting and the
+        table, any partition tables, the view definition if the relation is a
+        view, a non-default <link linkend="sql-altertable-replica-identity">
+        replica identity</link> setting and the
         <link linkend="sql-create-access-method">access method</link> name
         if the relation has an access method.
         </para>
-- 
1.8.3.1

#6Chao Li
li.evan.chao@gmail.com
In reply to: Peter Smith (#5)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On Dec 24, 2025, at 06:20, Peter Smith <smithpb2250@gmail.com> wrote:

On Tue, Dec 23, 2025 at 7:28 PM Chao Li <li.evan.chao@gmail.com> wrote:

On Dec 23, 2025, at 05:07, Peter Smith <smithpb2250@gmail.com> wrote:

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v1-0001-DOCS-psql-describe-table-can-list-publications.patch>

Not only publication, “\d table_name” also shows partition information:

```
evantest=# \d t_part;
Partitioned table "public.t_part"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition key: RANGE (id)
Publications:
"mypub"
Number of partitions: 3 (Use \d+ to list them.)

evantest=# \d t_part_p1;
Table "public.t_part_p1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition of: t_part FOR VALUES FROM (0) TO (100)
```

As you updating this section, you may add “partition info” as well.

OK, I've added some text about partitions. See patch v2.

~~~

TBH, the \d and \d+ partition output looked strange to me.

test_pub=# \d+ tp
Partitioned table "public.tp"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain |
| |
Partition key: RANGE (a)
Publications:
"pub1"
"pub3"
Partitions: tp1 FOR VALUES FROM (1) TO (10),
tp2 FOR VALUES FROM (10) TO (20)

For example:
a) Why isn't the "Partition key:" and "Partitions:" info kept together?

I guess it shows the plus stuff after the regular stuff.

b) Why does the "Partitions:" list indentation look different?

Yeah, the list indentation should be identical.

Anyway, those are questions for another thread and another year.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v2-0001-DOCS-psql-describe-table-can-list-publications-an.patch>

V2 looks good to me.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#7Fujii Masao
masao.fujii@gmail.com
In reply to: Chao Li (#6)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On Wed, Dec 24, 2025 at 8:41 AM Chao Li <li.evan.chao@gmail.com> wrote:

On Dec 24, 2025, at 06:20, Peter Smith <smithpb2250@gmail.com> wrote:

On Tue, Dec 23, 2025 at 7:28 PM Chao Li <li.evan.chao@gmail.com> wrote:

On Dec 23, 2025, at 05:07, Peter Smith <smithpb2250@gmail.com> wrote:

I was looking at "\d" documentation yesterday.

The psql table describe (e.g. "\d mytable") will display a list of any
"Publications:" that are publishing the specified table. Somehow, this
ability had escaped being mentioned in the psql reference
documentation.

Here is a trivial patch to fix that omission.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v1-0001-DOCS-psql-describe-table-can-list-publications.patch>

Not only publication, “\d table_name” also shows partition information:

```
evantest=# \d t_part;
Partitioned table "public.t_part"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition key: RANGE (id)
Publications:
"mypub"
Number of partitions: 3 (Use \d+ to list them.)

evantest=# \d t_part_p1;
Table "public.t_part_p1"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
val | integer | | |
Partition of: t_part FOR VALUES FROM (0) TO (100)
```

As you updating this section, you may add “partition info” as well.

OK, I've added some text about partitions. See patch v2.

~~~

TBH, the \d and \d+ partition output looked strange to me.

test_pub=# \d+ tp
Partitioned table "public.tp"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
a | integer | | | | plain |
| |
Partition key: RANGE (a)
Publications:
"pub1"
"pub3"
Partitions: tp1 FOR VALUES FROM (1) TO (10),
tp2 FOR VALUES FROM (10) TO (20)

For example:
a) Why isn't the "Partition key:" and "Partitions:" info kept together?

I guess it shows the plus stuff after the regular stuff.

b) Why does the "Partitions:" list indentation look different?

Yeah, the list indentation should be identical.

Anyway, those are questions for another thread and another year.

======
Kind Regards,
Peter Smith.
Fujitsu Australia
<v2-0001-DOCS-psql-describe-table-can-list-publications-an.patch>

V2 looks good to me.

\d table also seems to display tablespaces, policies, and other objects.
Should the documentation try to list all possible objects that can be shown?

If maintaining a complete list is difficult, would a more general description
like "Associated objects, including indexes, constraints, rules, publications,
and so on, are also shown." be sufficient instead of enumerating everything?

Regards,

--
Fujii Masao

#8Peter Smith
smithpb2250@gmail.com
In reply to: Fujii Masao (#7)
1 attachment(s)
Re: DOCS - "\d mytable" also shows any publications that publish mytable

On Thu, Dec 25, 2025 at 11:45 AM Fujii Masao <masao.fujii@gmail.com> wrote:

...

\d table also seems to display tablespaces, policies, and other objects.
Should the documentation try to list all possible objects that can be shown?

If maintaining a complete list is difficult, would a more general description
like "Associated objects, including indexes, constraints, rules, publications,
and so on, are also shown." be sufficient instead of enumerating everything?

Hi Fujii-San.

Thanks for the review, and I agree with your point.

I prefer the suggestion for this description to be "correct" and
future-proof (albeit slightly generic). Listing too many details
doesn't add much value IMO and will be forever in need of
documentation maintenance.

PSA v3.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachments:

v3-0001-DOCS-psql-describe-table-can-list-publications-an.patchapplication/octet-stream; name=v3-0001-DOCS-psql-describe-table-can-list-publications-an.patchDownload
From 831822000762270ddc540072a216c0a37b323e79 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Mon, 5 Jan 2026 11:06:26 +1100
Subject: [PATCH v3] DOCS - psql describe table can list publications and
 partitions

---
 doc/src/sgml/ref/psql-ref.sgml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index f56c702..bb35f75 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1299,9 +1299,9 @@ SELECT $1 \parse stmt1
         <replaceable class="parameter">pattern</replaceable>, show all
         columns, their types, the tablespace (if not the default) and any
         special attributes such as <literal>NOT NULL</literal> or defaults.
-        Associated indexes, constraints, rules, and triggers are
-        also shown.  For foreign tables, the associated foreign
-        server is shown as well.
+        Associated objects, such as indexes, constraints, rules, publications,
+        triggers, and so on, are also shown. For foreign tables, the
+        associated foreign server is shown as well.
         (<quote>Matching the pattern</quote> is defined in
         <xref linkend="app-psql-patterns"/> below.)
         </para>
@@ -1316,9 +1316,9 @@ SELECT $1 \parse stmt1
         The command form <literal>\d+</literal> is identical, except that
         more information is displayed: any comments associated with the
         columns of the table are shown, as is the presence of OIDs in the
-        table, the view definition if the relation is a view, a non-default
-        <link linkend="sql-altertable-replica-identity">replica
-         identity</link> setting and the
+        table, any partition tables, the view definition if the relation is a
+        view, a non-default <link linkend="sql-altertable-replica-identity">
+        replica identity</link> setting and the
         <link linkend="sql-create-access-method">access method</link> name
         if the relation has an access method.
         </para>
-- 
1.8.3.1