]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix psql describe commands' handling of ACL columns for old servers.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 24 Sep 2024 21:21:38 +0000 (17:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 24 Sep 2024 21:21:38 +0000 (17:21 -0400)
Commit d1379ebf4 carelessly broke printACLColumn for pre-9.4 servers,
by using the cardinality() function which we introduced in 9.4.
We expect psql's describe-related commands to work back to 9.2, so
this is bad.  Use the longstanding array_length() function instead.

Per report from Christoph Berg.  Back-patch to v17.

Discussion: https://postgr.es/m/ZvLXYglRS6hMMhtr@msg.df7cb.de

src/bin/psql/describe.c

index f67bf0b8925312242540597e6fc72c142bf4a08d..770f52bc4552be76aa9a3643a816fe71f4f20796 100644 (file)
@@ -6660,7 +6660,7 @@ printACLColumn(PQExpBuffer buf, const char *colname)
 {
        appendPQExpBuffer(buf,
                                          "CASE"
-                                         " WHEN pg_catalog.cardinality(%s) = 0 THEN '%s'"
+                                         " WHEN pg_catalog.array_length(%s, 1) = 0 THEN '%s'"
                                          " ELSE pg_catalog.array_to_string(%s, E'\\n')"
                                          " END AS \"%s\"",
                                          colname, gettext_noop("(none)"),