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

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Roman Khapov <rkhapov(at)yandex-team(dot)ru>
Cc: 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 15:59:15
Message-ID: CALdSSPh4uMj3wVkeLcafk2hWJnK0Eu3t0p8LhjiaDEUz+cYktg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 29 Dec 2025 at 20:48, Roman Khapov <rkhapov(at)yandex-team(dot)ru> wrote:
>
> Hi hackers!
>
> 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".
>
> To fix that, we should do appendStringInfoCharMacro(&buf, '\\'); instead of
> appendStringInfoCharMacro(&buf, ch); in case ch is one of that symbols.
>
> Any thoughts?
>
> --
> Best regards,
> Roman Khapov
>

Hi!
Looks like we have two similar places in kernel [0] & [1], and at
least one of these three places is wrong.

[0] https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/rowtypes.c#L460

[1] https://github.com/postgres/postgres/blob/master/src/bin/pg_rewind/libpq_source.c#L621
--
Best regards,
Kirill Reshke

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-12-29 16:01:10 Re: Define DatumGetInt8 function.
Previous Message Tom Lane 2025-12-29 15:52:58 Re: Define DatumGetInt8 function.