pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_dump: Fix array literals in fetchAttributeStats().
Date: Tue, 20 May 2025 21:31:31 +0000
Message-ID: <E1uHUYd-0000m5-0C@gemulon.postgresql.org> (raw)

pg_dump: Fix array literals in fetchAttributeStats().

Presently, fetchAttributeStats() builds array literals by treating
the elements as SQL identifiers.  This is incorrect for a couple of
reasons:

* Array literal content must match the external text representation
  of the array, i.e., what array_out() would return.  One notable
  problem is that double quotes are escaped with "" in identifiers
  but with \" in array literals.  To fix, build the array content
  using the pre-existing appendPGArray() function.

* Array literals must be written as string constants.  A notable
  problem here is that single quotes are escaped via '' in strings
  but are not escaped in the text representation of an array.  To
  fix, append the aforementioned array literal content to the query
  with appendStringLiteralAH().

While at it, modify a test case to use an identifier that would
cause the test to fail without this change.

Oversight in commit 9c02e3a986.

Reported-by: Philippe Beaudoin <pbh.emaj@free.fr>
Author: Jian He <jian.universality@gmail.com>
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Co-authored-by: Stepan Neretin <slpmcf@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Bug: #18923
Discussion: https://postgr.es/m/18923-e79273f87c6bed69%40postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a6060f1cbec39575634043baeeaeb11e86042fa6

Modified Files
--------------
src/bin/pg_dump/pg_dump.c        | 21 +++++++++++++--------
src/bin/pg_dump/t/002_pg_dump.pl |  6 +++---
2 files changed, 16 insertions(+), 11 deletions(-)



Message-ID: <E1uHUYd-0000m5-0C@gemulon.postgresql.org>
Permalink:  ../E1uHUYd-0000m5-0C@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uHUYd-0000m5-0C@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_dump: Fix array literals in fetchAttributeStats().
  In-Reply-To: <E1uHUYd-0000m5-0C@gemulon.postgresql.org>

* 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