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 1sGgRf-00FuV2-BR for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:56:28 +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 1sGgRd-00D6BI-P7 for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:56:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGgRd-00D6B9-9X for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 14:56:26 +0000 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGgRb-000e20-E8 for pgsql-general@postgresql.org; Mon, 10 Jun 2024 14:56:24 +0000 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-6b0682d1b12so14573246d6.0 for ; Mon, 10 Jun 2024 07:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718031383; x=1718636183; darn=postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FPkUrRPwk90h7UqR5hH77Qpam5BX54bmrnQTdnCehrI=; b=F4jSp+NOUJX4qmVxJ54DOzg9JBrwNFQnZaGv2zk9q5GkCVP2u4GGkEno0qO2sIXNtm ImtpSYg2VgSEyL6MAEW/oUZpqJrKo5IGC45RoL2v26853V1OHuoOL/iVmicCpjrEKE4X HAdAG0yPQvVNBSe0yfrWzm5ETdjdgAKo6T/dMXmT0sCnoYJBR4/v/5UY+z5Ui4JgVkaP pPDdQcDc8oJei8UIDpksB7it3hpOha5srQ1lAenzKnBKQHQqb9iW0hvlfbhWhpEhyzKu gkx4hXTarPcqJIar1Utuz2a0CKOBLQH+HcGJ2IMvDqM+bZQ3pc/k/ybM8oMmPq1GrIy6 pdHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718031383; x=1718636183; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FPkUrRPwk90h7UqR5hH77Qpam5BX54bmrnQTdnCehrI=; b=i0EfTQDLTwJZ9Occ8N62EBKxFtqb3Qd88XR1A2/3/bMh0+eWH8gQtn9uWQLu4N6D4B P5nDHu6SKNgKJisYVMYFeVdqRMYR0N7o1GkTz/wl2qB3XY5S7au5Rj3iE0ei88AwryEU Rp+HMKLh0+BsNKDOZX6BUCiKG/L5IGidoh+Ku7jVrxrpg5Fnwg/NQXOJOjIBOvwEPI/C RDTnEb4bjPNjjkuC0enu/vmIpvJ9pxm+gqTOrA5qB3q/z89cP4zZMFuT7uwNxk0sNJ8w YOUH+p1QyTIzBGLGN7LFhj2ORhiGBJxefaae80UiRBf3LLYGsP0X4Ta2g8zt1n0qbA/x kGJw== X-Gm-Message-State: AOJu0YycsZ5spOGn/qA57sPhS8Kz154iC4VmTMGaQG55Js+v69zA6ECT e8urcIMJjX7Uf/eUbuB627270mFZ0kah19N+x0u/C7QL/0b27T7/zplxlBXfhf5/otdSlF1ldRd Lz1r8L6kuMYiEpN/BxQzoqtCB/1RlUQ== X-Google-Smtp-Source: AGHT+IGGOIORHm+CLthC4kAurM/vjJIUcEpPf9f1j0zqKm/IH7y7XcDc2vDteMoT1Qpmd3ByXeTrZqnQXtFpi/mOsIE= X-Received: by 2002:a05:6214:3d9b:b0:6b0:6788:c3f5 with SMTP id 6a1803df08f44-6b06788c58dmr76585646d6.37.1718031382596; Mon, 10 Jun 2024 07:56:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6214:4209:b0:6b0:822a:8583 with HTTP; Mon, 10 Jun 2024 07:56:21 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Mon, 10 Jun 2024 07:56:21 -0700 Message-ID: Subject: Re: Escaping single quotes with backslash seems not to work To: Ron Johnson Cc: pgsql-general Content-Type: multipart/alternative; boundary="00000000000045d771061a8a5a7d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000045d771061a8a5a7d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, June 10, 2024, Ron Johnson wrote: > 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-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. David J. --00000000000045d771061a8a5a7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, June 10, 2024, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Mon, Jun 10, 2024 at 10:08=E2= =80=AFAM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Mon, J= un 10, 2024 at 7:02=E2=80=AFAM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
<= div dir=3D"ltr">PG 9.6 and PG 14

[quote]
Any other character follo= wing 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=C2=A0\', in addition to the normal w= ay of=C2=A0''= .
[/quo= te]


The link you provided goes to t= he wrong subsection.=C2=A0 The following subsection, which discusses,=C2=A0= 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 consideri= ng backslash as an escape.
=C2=A0<= /div>
This hasn't changed from 9.6, has it?

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


As the caut= ion on that page says the default for standard conforming strings changed i= n 9.1. But maybe your 9.6 had the old value configured but when you upgrade= d to 14 you decided to go with the new default.

Da= vid J.
=C2=A0
--00000000000045d771061a8a5a7d--