Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist
Date
Msg-id 2988492.1767033434@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] Fix escaping for '\' and '"' in pageinspect for gist  (Roman Khapov <rkhapov@yandex-team.ru>)
Responses Re: [PATCH] Fix escaping for '\' and '"' in pageinspect for gist
List pgsql-hackers
Roman Khapov <rkhapov@yandex-team.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



pgsql-hackers by date:

Previous
From: Matthias van de Meent
Date:
Subject: Re: lsyscache: free IndexAmRoutine objects returned by GetIndexAmRoutineByAmId()
Next
From: Masahiko Sawada
Date:
Subject: Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE