pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedInconsistency in psql output with \d+x PATTERN
7+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2026-10-21 54f38d8115 154052c354 4272618fbb doc: Correct psql's \d+x documentation for sequences
* Inconsistency in psql output with \d+x PATTERN
@ 2026-10-16 14:35 George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: George MacKerron @ 2026-10-16 14:35 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
Hello.
While working on https://github.com/neondatabase/psql-describe, I came across what I think is minor bug in the output of psql’s `\d` with a pattern or name.
Using psql 19rc1, this command is not listed by `\?` as accepting the expanded (x) option:
```
db=# \?
...
Informational
(options: S = show system objects, x = expanded mode, + = additional detail)
\d[Sx+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
```
And, in general, setting the x option -- either globally with `\x on` or temporarily with `\d+x PATTERN` -- is ignored.
However, it is not ignored when describing sequences. For example:
```
db=# create table example_table (col int);
CREATE TABLE
db=# create sequence example_sequence;
CREATE SEQUENCE
db=# create index example_idx on example_table(col);
CREATE INDEX
db=# \d+x example_*
Index "public.example_idx"
Column | Type | Key? | Definition | Storage | Stats target
--------+---------+------+------------+---------+--------------
col | integer | yes | col | plain |
btree, for table "public.example_table"
Sequence "public.example_sequence"
-[ RECORD 1 ]------------------
Type | bigint
Start | 1
Minimum | 1
Maximum | 9223372036854775807
Increment | 1
Cycles? | no
Cache | 1
Table "public.example_table"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
col | integer | | | | plain | | |
Indexes:
"example_idx" btree (col)
Access method: heap
```
This inconsistency seems like a bug to me.
Proximately, the bug appears to arise on line 1780 of src/bin/psql/describe.c (REL_19_RC1), where a new, shadowing `myopt` variable is created without setting `myopt.topt.expanded = false`.
History:
• In 2005, commit 3332e38189b2 disables expanded output for \d NAME.
• In 2017, commit 2a14b9609df1 redesigns sequence descriptions as a separate query and (presumably unintentionally) bypasses that disabling.
• In 2025, commit 00f4c2959d6 adds the temporary x modifier. Its regression test explicitly verifies that \d+x table remains non-expanded, but does not test a sequence.
All the best,
George
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
@ 2026-10-19 10:09 ` Fujii Masao <masao.fujii@gmail.com>
2026-10-19 11:34 ` Re: Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 16:09 ` Re: Inconsistency in psql output with \d+x PATTERN shihao zhong <zhong950419@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Fujii Masao @ 2026-10-19 10:09 UTC (permalink / raw)
To: George MacKerron <george.mackerron@databricks.com>; +Cc: pgsql-bugs@lists.postgresql.org
On Sat, Oct 17, 2026 at 1:16 AM George MacKerron
<george.mackerron@databricks.com> wrote:
> This inconsistency seems like a bug to me.
Sequence descriptions have honored expanded mode since v10, so disabling it
would change longstanding behavior. Also the vertical layout seems useful
for sequence descriptions, so I'd prefer to keep the current behavior and
update the documentation instead. Thought?
We could clarify that, when a name or pattern is specified, only sequence
descriptions honor expanded mode, whether enabled globally with \x on or
\x auto, or temporarily with \d+x.
Regards,
--
Fujii Masao
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
@ 2026-10-19 11:34 ` George MacKerron <george.mackerron@databricks.com>
2026-10-19 16:07 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: George MacKerron @ 2026-10-19 11:34 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org
On 19 Oct 2026, at 11:09, Fujii Masao <masao.fujii@gmail.com> wrote:
> I'd prefer to keep the current behavior and update the documentation instead. Thought?
>
> We could clarify that, when a name or pattern is specified, only sequence descriptions honor expanded mode
Sure: I think documenting the inconsistency is a reasonable response here. Thanks.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
2026-10-19 11:34 ` Re: Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
@ 2026-10-19 16:07 ` Fujii Masao <masao.fujii@gmail.com>
2026-10-19 16:10 ` Re: Inconsistency in psql output with \d+x PATTERN shihao zhong <zhong950419@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Fujii Masao @ 2026-10-19 16:07 UTC (permalink / raw)
To: George MacKerron <george.mackerron@databricks.com>; +Cc: pgsql-bugs@lists.postgresql.org
On Mon, Oct 19, 2026 at 8:34 PM George MacKerron
<george.mackerron@databricks.com> wrote:
> Sure: I think documenting the inconsistency is a reasonable response here. Thanks.
The attached patch corrects the \d+x docs for sequences. Thoughts?
Regards,
--
Fujii Masao
Attachments:
v1-0001-doc-Correct-psql-s-d-x-documentation-for-sequence.patch (application/octet-stream, 3.2K) download
From 8f314ab957f411023e76764d971f0597bd7a052a Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Mon, 19 Oct 2026 16:58:40 +0900
Subject: [PATCH v1] doc: Correct psql's \d+x documentation for sequences
Commit 00f4c2959d6 added the x modifier to psql's list commands, making
\d+x display sequence descriptions in expanded mode. However, the
documentation and \? help indicate that x applies only without a pattern.
Clarify that \d+x also uses expanded mode when describing sequences
matched by a name or pattern, and update the command help accordingly.
Also clarify that the same restriction applies to \x on and \x auto.
Backpatch to v18, where the x modifier was introduced.
Reported-by: George MacKerron <george.mackerron@databricks.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/FEA91EA9-CF32-4920-9674-F2C3E01C3807@databricks.com
Backpatch-through: 18
---
doc/src/sgml/ref/psql-ref.sgml | 11 +++++++----
src/bin/psql/help.c | 3 ++-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index bb9e009e719..4058caf061b 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1340,10 +1340,13 @@ SELECT $1 \parse stmt1
</para>
<para>
As with many other commands, if <literal>x</literal> is appended to
- the command name, the results are displayed in expanded mode, but note
- that this only applies when <command>\d</command> is used without a
- <replaceable class="parameter">pattern</replaceable> argument, and
- the <literal>x</literal> modifier cannot appear immediately after the
+ the command name, the results are displayed in expanded mode for this
+ command only, but note that this only applies when <command>\d</command>
+ is used without a <replaceable class="parameter">pattern</replaceable>
+ argument or to describe a sequence.
+ The same limitation on expanded output applies to
+ <command>\x on</command> and <command>\x auto</command>.
+ The <literal>x</literal> modifier cannot appear immediately after the
<command>\d</command> (because <command>\dx</command> is a different
command); the <literal>x</literal> modifier may only appear after an
<literal>S</literal> or <literal>+</literal> modifier. For example,
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 6b599c4705a..0def23418d5 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -220,7 +220,8 @@ slashUsage(unsigned short int pager)
HELP0("Informational\n");
HELP0(" (options: S = show system objects, x = expanded mode, + = additional detail)\n");
HELP0(" \\d[Sx+] list tables, views, and sequences\n");
- HELP0(" \\d[S+] NAME describe table, view, sequence, or index\n");
+ HELP0(" \\d[Sx+] NAME describe table, view, sequence, or index\n");
+ HELP0(" (x applies only to sequences)\n");
HELP0(" \\da[Sx] [PATTERN] list aggregates\n");
HELP0(" \\dA[x+] [PATTERN] list access methods\n");
HELP0(" \\dAc[x+] [AMPTRN [TYPEPTRN]] list operator classes\n");
--
2.56.0
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
2026-10-19 11:34 ` Re: Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 16:07 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
@ 2026-10-19 16:10 ` shihao zhong <zhong950419@gmail.com>
2026-10-21 14:47 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: shihao zhong @ 2026-10-19 16:10 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: George MacKerron <george.mackerron@databricks.com>; pgsql-bugs@lists.postgresql.org
Hi Fujii,
Missed your patch email, I think this patch is LGTM.
Thanks,
Shihao
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
2026-10-19 11:34 ` Re: Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 16:07 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
2026-10-19 16:10 ` Re: Inconsistency in psql output with \d+x PATTERN shihao zhong <zhong950419@gmail.com>
@ 2026-10-21 14:47 ` Fujii Masao <masao.fujii@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Fujii Masao @ 2026-10-21 14:47 UTC (permalink / raw)
To: shihao zhong <zhong950419@gmail.com>; +Cc: George MacKerron <george.mackerron@databricks.com>; pgsql-bugs@lists.postgresql.org
On Tue, Oct 20, 2026 at 1:10 AM shihao zhong <zhong950419@gmail.com> wrote:
> Missed your patch email, I think this patch is LGTM.
Thanks for the review! I've pushed the patch.
Regards,
--
Fujii Masao
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Inconsistency in psql output with \d+x PATTERN
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Re: Inconsistency in psql output with \d+x PATTERN Fujii Masao <masao.fujii@gmail.com>
@ 2026-10-19 16:09 ` shihao zhong <zhong950419@gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: shihao zhong @ 2026-10-19 16:09 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: George MacKerron <george.mackerron@databricks.com>; pgsql-bugs@lists.postgresql.org
+1, I think a doc fix is good enough for this case.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-10-21 14:47 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 14:35 Inconsistency in psql output with \d+x PATTERN George MacKerron <george.mackerron@databricks.com>
2026-10-19 10:09 ` Fujii Masao <masao.fujii@gmail.com>
2026-10-19 11:34 ` George MacKerron <george.mackerron@databricks.com>
2026-10-19 16:07 ` Fujii Masao <masao.fujii@gmail.com>
2026-10-19 16:10 ` shihao zhong <zhong950419@gmail.com>
2026-10-21 14:47 ` Fujii Masao <masao.fujii@gmail.com>
2026-10-19 16:09 ` shihao zhong <zhong950419@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox