Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Roman Khapov <rkhapov(at)yandex-team(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org, michael(at)paquier(dot)xyz
Subject: Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist
Date: 2025-12-29 19:17:47
Message-ID: CALdSSPg_c6NaSRP3vwGyp7zaajY5YCmHwkze5ZehWAqE3Y4v2g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 29 Dec 2025 at 23:37, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Roman Khapov <rkhapov(at)yandex-team(dot)ru> writes:
> > I noticed, that there is bug in escaping values that contains '\' or '"' in text representation
> > inside pageinspect for gist: the string 'foo"bar' are printed like "foo""bar" and not "foo\"bar".
>
> I do not think this is a bug. The comment at line 295 says
> "Most of this is copied from record_out().", and this logic
> matches what record_out() does, and the output is legal
> according to the manual's specifications [1]:
>
> To put a double quote or backslash in a quoted composite field
> value, precede it with a backslash. (Also, a pair of double quotes
> within a double-quoted field value is taken to represent a double
> quote character, analogously to the rules for single quotes in SQL
> literal strings.)
>
> Now, your alternative coding would also produce legal output, but
> I do not think unnecessary change here is a good thing.
>
> regards, tom lane
>
> [1] https://www.postgresql.org/docs/devel/rowtypes.html#ROWTYPES-IO-SYNTAX
>
>

Should we then refactor code to avoid copying? I copied this code in
[0] for the third time, so if this has a chance to be committed, there
will be 3 times copied code...

[0] https://www.postgresql.org/message-id/CALdSSPgpD5RfPn5qMbozU4_SQpZAbG3V_%3DKdxV9YaEG9gX%3DqEA%40mail.gmail.com

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-12-29 19:24:49 Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist
Previous Message Tom Lane 2025-12-29 19:17:25 Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()