From: Nathan Bossart <nathandbossart@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: phb.emaj@free.fr
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18923: pg_dump 18beta1 fails to process complex table names
Date: Thu, 15 May 2025 14:12:41 -0400
Message-ID: <aCYumTym-wLvDFp8@nathan> (raw)
In-Reply-To: <CACJufxFLUsXw2tsTLLvWSeO0cX=Wp+fnL-vKK7eiVu0=GSSnRA@mail.gmail.com>
References: <18923-e79273f87c6bed69@postgresql.org>
<37115.1747057899@sss.pgh.pa.us>
<CACJufxFLUsXw2tsTLLvWSeO0cX=Wp+fnL-vKK7eiVu0=GSSnRA@mail.gmail.com>
On Tue, May 13, 2025 at 07:34:51PM +0800, jian he wrote:
> On Mon, May 12, 2025 at 9:51 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> PG Bug reporting form <noreply@postgresql.org> writes:
>> > I have just run the E-Maj project regression test suite with PG18 beta1 and
>> > found a pg_dump abort when trying to dump a schema prefixed table having a
>> > complex name including single quote, double quote and space.
>>
>> Thanks for the report! Looks like fetchAttributeStats() is completely
>> misguided about the appropriate quoting rules for array elements.
D'oh, my bad.
> re-read ReadArrayToken.
> In this context, we need to care about single-quote, double-quotes.
> for backslash, we skip it.
>
> appendPGArray can help us handle double quotes,
> now we just need to make it also handle single quotes.
I don't think we want to teach appendPGArray() to handle single quotes.
That's meant for building a text representation of a 1-dimensional Postgres
array, which IIUC doesn't need to escape single quotes. Take the following
example:
postgres=# select array['nathan''s element'];
array
----------------------
{"nathan's element"}
(1 row)
My first instinct is that we need to build the array with appendPGArray()
and then append it to the query using appendStringLiteralAH(), as done in
the attached patch.
--
nathan
Attachments:
[text/plain] v2-0001-pg_dump-fix-quoting-in-fetchAttributeStats.patch (0B, ../aCYumTym-wLvDFp8@nathan/2-v2-0001-pg_dump-fix-quoting-in-fetchAttributeStats.patch)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: nathandbossart@gmail.com, jian.universality@gmail.com, tgl@sss.pgh.pa.us, phb.emaj@free.fr, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18923: pg_dump 18beta1 fails to process complex table names
In-Reply-To: <aCYumTym-wLvDFp8@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox