Re: Escaping single quotes with backslash seems not to work - Mailing list pgsql-general

From David G. Johnston
Subject Re: Escaping single quotes with backslash seems not to work
Date
Msg-id CAKFQuwbdAm7=RziKxF+jQki0KXb-quan5fA3sfq8JKoDR3Jumw@mail.gmail.com
Whole thread Raw
In response to Escaping single quotes with backslash seems not to work  (Ron Johnson <ronljohnsonjr@gmail.com>)
Responses Re: Escaping single quotes with backslash seems not to work
Re: Escaping single quotes with backslash seems not to work
List pgsql-general
On Mon, Jun 10, 2024 at 7:02 AM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
PG 9.6 and PG 14

[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.

David J.

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Escaping single quotes with backslash seems not to work
Next
From: "David G. Johnston"
Date:
Subject: Re: Escaping single quotes with backslash seems not to work