Re: Fix array-element quoting in postgres_fdw import statistics

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>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, efujita(at)postgresql(dot)org
Subject: Re: Fix array-element quoting in postgres_fdw import statistics
Date: 2026-05-14 08:57:41
Message-ID: CAPmGK16Xbwf7QSP_N0w6e2pG5KG9cBPXnnx=rWE2=Nw=5nrWBA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 21, 2026 at 7:55 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> On Sun, Apr 12, 2026 at 3:46 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> > On Sun, Apr 12, 2026 at 12:13 PM SATYANARAYANA NARLAPURAM
> > <satyanarlapuram(at)gmail(dot)com> wrote:
> > > build_remattrmap() used quote_identifier() to format column names
> > > for a text[] array literal passed to the remote pg_stats query.
> > > quote_identifier() applies SQL identifier quoting, which doubles
> > > double-quote characters but does not escape backslashes. However,
> > > inside a PostgreSQL array literal, backslash is an escape character.
> > >
> > > Column names containing backslashes (e.g. "a\b") were silently
> > > mangled by the array parser—"a\b" became "ab"—causing the
> > > WHERE attname = ANY('{...}') filter to miss those columns. The
> > > statistics import would then fail with a WARNING about missing
> > > attribute statistics. This is a very corner cases because usually
> > > backslash is not included in the column names. Anyways attached
> > > a draft patch. Please take a look and let me know what you think.

> I think your analysis is correct, but a simpler solution for this
> issue is to use deparseStringLiteral() for column names, instead of
> quote_identifier(), as proposed in [1].

For the record: this has been addressed using the patch in that thread
(see commit 5107398e6d5e).

Best regards,
Etsuro Fujita

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message vignesh C 2026-05-14 08:53:14 Re: Proposal: Conflict log history table for Logical Replication