| From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | PSQL schema "describe" \dn is not escaping quotes |
| Date: | 2026-07-28 07:07:23 |
| Message-ID: | CAHut+Pu+xz1S+iqzUZE5bL_JOSK8KKecMMu+Z0KZs1k1iTA-5A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
The psql schema "describe" command (\dn) is not correctly escaping the
schema pattern arg given to it.
This results in an internal SQL error like below:
test_pub=# \dn "it's a bug"
2026-07-28 15:44:55.498 AEST [28319] ERROR: syntax error at or near
"s" at character 251
2026-07-28 15:44:55.498 AEST [28319] STATEMENT: /* Get publications
that publish this schema */
SELECT pubname
FROM pg_catalog.pg_publication p
JOIN pg_catalog.pg_publication_namespace pn ON p.oid = pn.pnpubid
JOIN pg_catalog.pg_namespace n ON n.oid = pn.pnnspid
WHERE n.nspname = '"it's a bug"'
ORDER BY 1
ERROR: syntax error at or near "s"
LINE 6: WHERE n.nspname = '"it's a bug"'
^
~~~
PSA a v1 patch to address this.
~~~
After applying my patch, now you can do stuff like the following:
test_pub=# CREATE SCHEMA "it's working";
CREATE SCHEMA
test_pub=# CREATE PUBLICATION pub1 FOR TABLES IN SCHEMA "it's working";
CREATE PUBLICATION
test_pub=# \dn "it's working"
List of schemas
Name | Owner
--------------+----------
it's working | postgres
Included in publications:
"pub1"
======
Kind Regards,
Peter Smith.
Fujitsu Australia
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-escapes-for-psql-describe-schema-patterns.patch | application/octet-stream | 1.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-07-28 07:27:08 | Re: Prove a NOT IN's left-hand expressions non-nullable from quals |
| Previous Message | Jakub Wartak | 2026-07-28 07:04:16 | Re: aio tests failing on newer Linux kernels |