From: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Escaping single quotes with backslash seems not to work |
Date: | 2024-06-10 14:59:22 |
Message-ID: | CANzqJaDTY0AEB2zxumCbDtZu_pVxcjWpf5FdSeGwShLM3SfVzg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Jun 10, 2024 at 10:56 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Monday, June 10, 2024, Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:
>
>> On Mon, Jun 10, 2024 at 10:08 AM David G. Johnston <
>> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>>
>>> On Mon, Jun 10, 2024 at 7:02 AM Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
>>> wrote:
>>>
>>>> PG 9.6 and PG 14
>>>>
>>>>
>>>> https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
>>>>
>>>> [quote]
>>>> Any other character following a backslash is taken literally. Thus, to
>>>> include a backslash character, write two backslashes (\\). Also, a
>>>> single quote can be included in an escape string by writing \', in
>>>> addition to the normal way of ''.
>>>> [/quote]
>>>>
>>>>
>>> The link you provided goes to the wrong subsection. The following
>>> subsection, which discusses, String Constants With C-Style Escapes,
>>> requires that you write the literal as E'abc\'def'
>>>
>>> Note the E prefix on the literal, which is the thing that enables
>>> considering backslash as an escape.
>>>
>>
>> This hasn't changed from 9.6, has it?
>>
>> A Java app that uses backslash escapes broke this morning on fields with
>> single quotes, after the weekend migration from PG 9.6.24 to 14.12, and I
>> don't know why. I'm not a Java programmer, though.
>>
>>
> As the caution on that page says the default for standard conforming
> strings changed in 9.1. But maybe your 9.6 had the old value configured but
> when you upgraded to 14 you decided to go with the new default.
>
That was the first thing I checked... It's the same on both the 9.6 and 14
systems:.
TAP=# show standard_conforming_strings;
standard_conforming_strings
-----------------------------
on
(1 row)
TAP=#
TAP=# show backslash_quote;
backslash_quote
-----------------
safe_encoding
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-06-10 15:08:31 | Re: Escaping single quotes with backslash seems not to work |
Previous Message | David G. Johnston | 2024-06-10 14:56:21 | Re: Escaping single quotes with backslash seems not to work |