From: George MacKerron <george.mackerron@databricks.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Inconsistency in psql output with \d+x PATTERN
Date: Fri, 16 Oct 2026 15:35:33 +0100
Message-ID: <FEA91EA9-CF32-4920-9674-F2C3E01C3807@databricks.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: george.mackerron@databricks.com
Subject: Re: Inconsistency in psql output with \d+x PATTERN
In-Reply-To: <FEA91EA9-CF32-4920-9674-F2C3E01C3807@databricks.com>
References: <FEA91EA9-CF32-4920-9674-F2C3E01C3807@databricks.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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