Subject: Fix how some lists are displayed by psql \d+

From: Peter Smith <[email-masked]>
Date: Fri, 9 Jan 2026 09:47:19 +1100

Hi.

I recently saw that the psql \d+ lists for "Partitions:" are not
aligned in quite the same way as other lists ("Publications:" etc)
because they use indents and line breaks differently. e.g. See below:

test_pub=# \d+ part1
                                    Partitioned table "public.part1"
 Column |  Type   | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 a      | integer |           |          |         | plain   |
    |              |
Partition of: t1 FOR VALUES FROM (0) TO (50)
Partition constraint: ((a IS NOT NULL) AND (a >= 0) AND (a < 50))
Partition key: RANGE (a)
Publications:
    "pub1"
    "pub2"
    "pub_only"
Partitions: part1_1 FOR VALUES FROM (0) TO (25), PARTITIONED,
            part1_2 FOR VALUES FROM (25) TO (50)

~~~

PSA v1
0001 - Fix (common code) lists for "Partitions:" and "Child tables:"
0002 - Fix list for "Inherits:" in the same way

~~~

The *patched* result for the same example now looks like below. Notice
that in passing I also removed the comma separators, which are not
present in the other footer lists.

test_pub=# \d+ part1
                                    Partitioned table "public.part1"
 Column |  Type   | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 a      | integer |           |          |         | plain   |
    |              |
Partition of: t1 FOR VALUES FROM (0) TO (50)
Partition constraint: ((a IS NOT NULL) AND (a >= 0) AND (a < 50))
Partition key: RANGE (a)
Publications:
    "pub1"
    "pub2"
    "pub_only"
Partitions:
    part1_1 FOR VALUES FROM (0) TO (25), PARTITIONED
    part1_2 FOR VALUES FROM (25) TO (50)

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

---

From: Chao Li <[email-masked]>
Date: Fri, 9 Jan 2026 08:45:36 +0800

> On Jan 9, 2026, at 06:47, Peter Smith <[email-masked]> wrote:
> 
> Hi.
> 
> <v1-0002-Fix-to-make-psql-d-lists-of-inherits-look-same-as.patch><v1-0001-Fix-to-make-psql-d-lists-of-partitions-look-same-.patch>

This is a simple change, but makes sense to me, making the display looking better.

The code change is straightforward and LGTM.

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

---

From: Peter Smith <[email-masked]>
Date: Wed, 21 Jan 2026 09:24:57 +1100

Ping. This small patch had received a couple of LGTM, but then the
thread went silent for nearly 2 weeks.

I've created a new CF entry [1] marked "ready for committer". Is there
anything else I can do to help get this one over the line?

======
[1] https://commitfest.postgresql.org/patch/6413/

Kind Regards,
Peter Smith.
Fujitsu Australia

---

From: Peter Smith <[email-masked]>
Date: Wed, 21 Jan 2026 13:58:08 +1100

A rebase was needed for some more test expected output changes.

PSA v2.

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

---

From: Chao Li <[email-masked]>
Date: Wed, 21 Jan 2026 16:04:34 +0800

> On Jan 21, 2026, at 10:58, Peter Smith <[email-masked]> wrote:
> 
> <v2-0002-Fix-to-make-psql-d-lists-of-inherits-look-same-as.patch><v2-0001-Fix-to-make-psql-d-lists-of-partitions-look-same-.patch>

I still see some difference:
```
evantest=# \d+ p_test;
                                     Partitioned table "public.p_test"
  Column  |  Type   | Collation | Nullable | Default | Storage  | Compression | Stats target | Description
----------+---------+-----------+----------+---------+----------+-------------+--------------+-------------
 id       | integer |           |          |         | plain    |             |              |
 username | text    |           |          |         | extended |             |              |
 category | text    |           |          |         | extended |             |              |
Partition key: LIST (category)
Indexes:
    "idx_p_test_id" btree (id)
Partitions:
    p_test_v1 FOR VALUES IN ('A')
    p_test_v2 FOR VALUES IN ('B')
```

The index name is quoted, but the partition names are not.

Best regards,

---

From: Peter Smith <[email-masked]>
Date: Wed, 21 Jan 2026 19:22:44 +1100

>   Column  |  Type   | Collation | Nullable | Default | Storage  | Compression | Stats target | Description

AFAICT
Indexes are quoted
Constraints are quoted
Publications are also quoted

Partitions are NOT quoted
Inherits are NOT quoted

~

Please confirm --- So, you are expecting that Partitions and Child
tables should also be quoted, so that everything looks the same?

This is scope creep from the original intent of this thread, so I will
look at doing this in a separate patch 0003.

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

---

From: Chao Li <[email-masked]>
Date: Wed, 21 Jan 2026 16:30:12 +0800

> On Jan 21, 2026, at 16:22, Peter Smith <[email-masked]> wrote:
> 

Actually I don’t know the rule, which should be quoted and which should not. Is the inconstancy a blocker?

So, I was just pointing out the inconsistency, and I want to hear a clarification from someone.

Best regards,

---

From: Peter Smith <[email-masked]>
Date: Thu, 22 Jan 2026 08:08:31 +1100

> So, I was just pointing out the inconsistency, and I want to hear a clarification from someone.

OK. I feel that the "Partitions" and "Child tables" + "Interits" might
be the odd ones out here, just as those were the odd ones out re the
list indentation logic.

But I will hold off on adding quotes for them until I hear some
committer advice that it would be a worthwhile change.

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

---

From: Soumya S Murali <[email-masked]>
Date: Wed, 4 Feb 2026 10:30:27 +0530

Hi all,

Thank you for updating the patches.

> committer advice that it would be a worthwhile change.

I went through the discussions and verified the unpatched psql display
and after tested the v2 patches on the current master. The patches
applied cleanly, make check and tests passed successfully and using
the patches confirms that "Partitions" and "Child tables" are now
displayed consistently as intended. LGTM from my side.

Regards,
Soumya

---

From: Peter Smith <[email-masked]>
Date: Fri, 20 Mar 2026 14:48:29 +1100

Ping, This thread has been idle for about 6 weeks but AFAIK the patch
is good to go.

Is there any else I can do to help move it forwards?

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

---

From: Fujii Masao <[email-masked]>
Date: Thu, 26 Mar 2026 12:18:25 +0900

> Is there any else I can do to help move it forwards?

I like the updated \d+ display. The patch looks good to me.
So, barring objections, I'm thinking to commit it.

BTW, with these changes there appear to be no remaining callers of
pg_wcswidth() in the core. I'm not sure if we should remove it,
or keep it for reference or potential external use, though.

Regards,

-- 
Fujii Masao

---

From: Fujii Masao <[email-masked]>
Date: Mon, 30 Mar 2026 11:23:02 +0900

> So, barring objections, I'm thinking to commit it.

I've pushed the patches. Thanks!

Regards,

-- 
Fujii Masao

---

From: Peter Smith <[email-masked]>
Date: Tue, 31 Mar 2026 08:55:56 +1100

> I've pushed the patches. Thanks!

Thanks for pushing!

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