Bug: trailing comma syntax error in postgres_fdw fetch_attstats()

From: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Bug: trailing comma syntax error in postgres_fdw fetch_attstats()
Date: 2026-04-12 01:45:35
Message-ID: CAHg+QDdEE7wp1S60Fn9Kmna8KfdMo5Tu6dROLpMn_-EOUBKmWQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v1-0001-postgres_fdw-fix-trailing-comma.patch application/octet-stream 494 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message SATYANARAYANA NARLAPURAM 2026-04-12 03:12:58 Fix array-element quoting in postgres_fdw import statistics
Previous Message Tom Lane 2026-04-12 01:12:08 Re: StringInfo fixes, v19 edition. Plus a few oddities