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: v1-0001-Fix-escapes-for-psql-describe-schema-patterns.patch
Description: Binary data

Reply via email to