Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGgR5-00FuO8-DX for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:55:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sGgR4-00D62v-0q for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:55:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGgNm-00CycH-1X for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 14:52:26 +0000 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGgNk-000ww9-8y for pgsql-general@postgresql.org; Mon, 10 Jun 2024 14:52:26 +0000 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-254c22faf4cso535366fac.2 for ; Mon, 10 Jun 2024 07:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718031142; x=1718635942; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Uv2HgpK95taQ9ZnMlKBX0zCpX2WSBEX0kZ3BZEf2zLo=; b=frAeEL7YaiRcX82MOsxMqnLGJg+c05Svb4QGxwLgWhSt2Hb9Gjo/OjwbRtYI/WQurm Kx/8ki8OVy9Lj8Pi8y+YqU8cCxH4dvlJOB0U4GzdNKUBZuNeP0T7XgRqwVWWQxGtrLDy UjcFbFO0HDp++zgmfmrkk/lOeA5NSf7tzZSSJ/gWI9fQRaEP/jBS6YhXPzIZ0x1R/+Zv HjXPStFUigb1g6dnhcYfnYoNMeMqx1YJIJNC459547d1zflTYm0aV3PeUhA9yC6vE8Oq +7ojXupYL8j74eLS/O9OzUtOByUUrJwF9EH0eoyN9BNfJje7USbkBegFtjUPdzX5Q7Zr cFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718031142; x=1718635942; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Uv2HgpK95taQ9ZnMlKBX0zCpX2WSBEX0kZ3BZEf2zLo=; b=Dqgfck/htId5r0WoDO7ncbNmnF91+RhCla2wzpS09/b7+5ZDjpwwvXpuYQmux+DnoW IM1JW7N6j2W5UM5nLbJ+N6JkKWIy07IOCO7wnYphoClaPMkDQbOeGY/AbZqY4AHLBEVI /nV9ZJMj0aFzQjNJXHo8IjE0hbvMQV8X0ZtT22c7ocDavF5t66zKh6CmLld8QY8ip26N I7vo+g1/WggQXjwNrjhBIA1w8Vp7FbD07r5bQHM2InBVLihuD2XxuCkqknhup7DBrECU aRSHhcfHlLWEkwiacS3Z91JV7W69o3tQ3sWfb4BCjMD/5UWRjtj9y8xOf0vgBde8MvUw xwfQ== X-Gm-Message-State: AOJu0Yz7qGkuVbPme8sOd/5yMUdP1a47rfUfmYgGsfdMPNYKJjwAGCXd BxqQNU16BNQ6zfLtSxfaPsuWEaihxRJgM2ZIkwV5GTTZdeQkEkgm5fHakboA7Xsl254Zmozuaf2 hAb/mCaAhcvhjdkptwmnDJI0o+omurg== X-Google-Smtp-Source: AGHT+IHzF/RZ1tt4hRdWSP5svjKmULb1kaY88wib3CWm6elxElMrrQJm/xk6olaqijHKuPc+XWg4FK2DWjK4DjR7TYU= X-Received: by 2002:a05:6870:595:b0:250:58b8:bbe2 with SMTP id 586e51a60fabf-254644ebed1mr11118371fac.4.1718031142269; Mon, 10 Jun 2024 07:52:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Mon, 10 Jun 2024 10:52:10 -0400 Message-ID: Subject: Re: Escaping single quotes with backslash seems not to work To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000f2b7b1061a8a4b2a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f2b7b1061a8a4b2a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 10, 2024 at 10:08=E2=80=AFAM David G. Johnston < david.g.johnston@gmail.com> wrote: > On Mon, Jun 10, 2024 at 7:02=E2=80=AFAM Ron Johnson > wrote: > >> PG 9.6 and PG 14 >> >> >> https://www.postgresql.org/docs/14/sql-syntax-lexical.html#SQL-SYNTAX-CO= NSTANTS >> >> [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. --000000000000f2b7b1061a8a4b2a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jun 10, 2024 at 10:08=E2=80=AFAM = David G. Johnston <david.g= .johnston@gmail.com> wrote:
On Mon, Jun 10, 2024 at 7:02=E2=80= =AFAM Ron Johnson <ronljohnson= jr@gmail.com>= wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
PG 9.6 an= d PG 14

<= /div>

[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 st= ring by writing=C2=A0\', in addition to the= normal way of=C2=A0''.
[/quote]


= The link you provided goes to the wrong subsection.=C2=A0 The following sub= section, which discusses,=C2=A0String Constants With C-Style Escapes, requi= res 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.
=C2=A0
This hasn't changed from 9.6= , has it?

A Java app that uses backslash escapes b= roke this morning on fields with single quotes,=C2=A0after=C2=A0the weekend= migration from PG 9.6.24 to 14.12, and I don't know why.=C2=A0 I'm= not a Java programmer, though.

--000000000000f2b7b1061a8a4b2a--