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 1sGfhC-00FlO0-Pf for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:08:27 +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 1sGfhA-00CYRR-Vt for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 14:08:25 +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 1sGfhA-00CYOA-Ky for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 14:08:25 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGfh8-000diH-Se for pgsql-general@postgresql.org; Mon, 10 Jun 2024 14:08:24 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5ba1f60eb96so2405594eaf.3 for ; Mon, 10 Jun 2024 07:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718028502; x=1718633302; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Dr/7a+BeI7PBTbi0JJplB+iK0PEobHAGmZozZZYLLhU=; b=RnBJmtAFqxcYE7m+okuR9i6iLUdYAR4PcO384CCOkqlVo4LuEaipci+mPbL64j2Rho sxkPuOaMYnKifZLxIELLVmyZ5gtAS8/luenG72kMq6WB3/dARDtjjDB/9yxEY8eFDJBR JVocAGWm5M34IaZhYCbJqDG1CXfPczg/Nv73/oKM8RfuhTO2dGUBFLxYWtsqqfoSItxb 0UMJyeRZBQlSGZycI+bReAmpvQMBZzbJyQpqYdvW2siJ2U5aXcDYkiGYPVkQ+HMSB5fc +5I+f+xdh8yXqOdXRxypveBx+6yvvez4DmJKbcZ+AaGFNgBBsEia4etzLwKilGPOe55r VDXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718028502; x=1718633302; h=cc: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=Dr/7a+BeI7PBTbi0JJplB+iK0PEobHAGmZozZZYLLhU=; b=SojJDogGzSzZxA8oOBmoGe8oU0ZdJud7BSRDXUoH/WMVJRWXIJQDscY8aOdDq0nVZ6 WhUHZbGOTQ47gF3Oe1jv72KOV2PmE1xngvZAsE6Cu1svi3TN+MAaLV17HU218O+1X20E nwT/CSwQBfVLur+gDdWBuJqvDEUkFxMEYcaWY7g4Xpp6x0xuN/m4g9Buj0o1W2nMFBhy jBPAGoxi1HQPbNpxRLxa7pOfgmeyZfwyyDGw/w53tcT/kZOnLLJJ8Z7a2Yz8T+rg1/a+ mhPzgLSxWNSnsWyfIwsUpQobyfFkvbaLTxM1Dw9M2tRoobOrEa6rt57O/DqGqPWjzeAe bu1g== X-Gm-Message-State: AOJu0YzX1lc0HxjuXDU1/xxKXbUDtcGZQRauvwsSvKvK0Qr8+IOF5K2p YFc2MeKzhaiLN+mo4DL4tYb42eweaOgW4jIT5tMfTwIAmpZBxN09z3mMvRMzNO9u2JhmE/9fgA5 OTxBgN/YqXvBHC8gYPXszHaRqGza0RUcl X-Google-Smtp-Source: AGHT+IGo9qV7Jq+EicKLqowY4gAqWsXqR6HWV6qMW91FxvwW3YWLonTBG+tI3rWNgPXLNOpzNBGfR1jOcfAOAMJ/jpI= X-Received: by 2002:a05:6820:1aca:b0:5ba:7803:43ab with SMTP id 006d021491bc7-5baae55002cmr9538563eaf.3.1718028502016; Mon, 10 Jun 2024 07:08:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Mon, 10 Jun 2024 07:07:44 -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="00000000000093a986061a89aee3" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000093a986061a89aee3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-CON= STANTS > > [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. --00000000000093a986061a89aee3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jun 10, 2024 at 7:02=E2=80=AFAM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
=
Any other= character following a backslash is taken literally. Thus, to include a bac= kslash character, write two backslashes (\\). A= lso, a single quote can be included in an escape string by writing=C2=A0\&= #39;, in addition to the normal way of=C2=A0= 9;'.
= 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 con= sidering backslash as an escape.

David J.

=
--00000000000093a986061a89aee3--