Bug: trailing comma syntax error in postgres_fdw fetch_attstats()

SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>

From: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-12T01:45:35Z
Lists: pgsql-hackers

Attachments

Hi Hackers,

When importing statistics from a remote server running PostgreSQL < 17,
fetch_attstats() emits three NULL placeholders for the range statistics
columns that don't exist on older servers.  The string literal included a
trailing
comma after the last NULL, producing invalid SQL:

    SELECT ... NULL, NULL, NULL, FROM pg_catalog.pg_stats ...

This fails ANALYZE or IMPORT STATISTICS on a foreign table backed
by a pre-v17 remote server with a syntax error.

Thanks,
Satya

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. postgres_fdw: Fix syntax error in fetch_attstats().