Inconsistency in psql output with \d+x PATTERN
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
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
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.
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
Import Notes
Reply to msg id not found: CB042250-ED18-45AE-947D-2287623A658E@databricks.com
+1, I think a doc fix is good enough for this case.
Hi Fujii,
Missed your patch email, I think this patch is LGTM.
Thanks,
Shihao