PSQL schema "describe" \dn is not escaping quotes - Mailing list pgsql-hackers

From Peter Smith
Subject PSQL schema "describe" \dn is not escaping quotes
Date
Msg-id CAHut+Pu+xz1S+iqzUZE5bL_JOSK8KKecMMu+Z0KZs1k1iTA-5A@mail.gmail.com
Whole thread
List 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

pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: aio tests failing on newer Linux kernels
Next
From: Ayush Tiwari
Date:
Subject: Re: Prove a NOT IN's left-hand expressions non-nullable from quals