Re: Bug: trailing comma syntax error in postgres_fdw fetch_attstats()

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug: trailing comma syntax error in postgres_fdw fetch_attstats()
Date: 2026-04-12 06:40:38
Message-ID: CAPmGK14BrhJvBnxCsz-eBy0Qh6kUUYLL+N6U2W5mRNwpHmGjGQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Apr 12, 2026 at 10:45 AM SATYANARAYANA NARLAPURAM
<satyanarlapuram(at)gmail(dot)com> wrote:
> 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.

My bad, I will take care of this. I added it to the open item.

Thanks for the report and patch!

Best regards,
Etsuro Fujita

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2026-04-12 06:46:12 Re: Fix array-element quoting in postgres_fdw import statistics
Previous Message Etsuro Fujita 2026-04-12 06:31:01 Re: Import Statistics in postgres_fdw before resorting to sampling.