]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
postgres_fdw: Fix syntax error in fetch_attstats().
authorEtsuro Fujita <efujita@postgresql.org>
Fri, 8 May 2026 04:15:00 +0000 (13:15 +0900)
committerEtsuro Fujita <efujita@postgresql.org>
Fri, 8 May 2026 04:15:00 +0000 (13:15 +0900)
When importing remote stats for a foreign table backed by a pre-v17
remote server, the query built/executed in this function has three NULL
placeholders for the range stats supported in v17 at the end of the
SELECT list.  Previously, it included a trailing comma after the last
NULL, like "SELECT ..., NULL, NULL, NULL, FROM pg_catalog.pg_stats ...",
causing a syntax error on the remote server.  Fix by removing the comma.

Oversight in commit 28972b6fc.

Author: Satya Narlapuram <satyanarlapuram@gmail.com>
Discussion: https://postgr.es/m/CAHg%2BQDdEE7wp1S60Fn9Kmna8KfdMo5Tu6dROLpMn_-EOUBKmWQ%40mail.gmail.com

contrib/postgres_fdw/postgres_fdw.c

index c42cb690c7bc9e976adbbd5755af29335d5b395c..0ff4ec23164b12b4c108aa08bb0dfe6ae50d3eb4 100644 (file)
@@ -5876,7 +5876,7 @@ fetch_attstats(PGconn *conn, int server_version_num,
                                                           " range_bounds_histogram");
        else
                appendStringInfoString(&sql,
-                                                          " NULL, NULL, NULL,");
+                                                          " NULL, NULL, NULL");
 
        appendStringInfoString(&sql,
                                                   " FROM pg_catalog.pg_stats"