Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY7CY-0001H1-IR for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 11:01:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hY7CX-0005Ba-AT for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 11:01:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY7CX-0005BT-0Q for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 11:01:57 +0000 Received: from box.beccati.com ([176.9.123.236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY7CU-0006eg-7h for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 11:01:56 +0000 Received: from authenticated-user (box.beccati.com [176.9.123.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by box.beccati.com (Postfix) with ESMTPSA id 4BAE520024E; Tue, 4 Jun 2019 13:01:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=beccati.com; s=mail; t=1559646113; bh=r5b2RK0PyCzZiLNyu2vfr1u4Beil5181u76NkHGTraE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=hM6F126YTUQoU4Ozn09GfmLdwbsBF2/Yy57MD8/3KjqxEtHHOgXLvCmMmkwPzpWVq foYORsxHHlTFshcaXv81Ghq7+ODwuPy8pX86rn30mrvXPV61dZRFDykKZASGBmHAiR CLzMWb/Sd6vPUR4N+SMDXsXgF8A280SuD7oW8HE+NdWX4gUCd44IbbPDK55EzRUAsJ SFHF5tu7w0fQ78Aj9CqWMmlSpVCaPzPP977mNA/Fv/Qf5pbHV5xPYhSKNsw23NSWda /NBUcXxK/TmzSBZ1pQ84CLNFLax1jEJQkmBxfArzYw1QAv75xB36B64gVdEiq9nHN4 nRabixjI6Ut3A== Subject: Re: Research on ?? operators To: Steve Atkins , PG mailing List References: <4b588eb1-a3af-3e25-c1f1-16fb93e602e3@beccati.com> From: Matteo Beccati Message-ID: <9e74ec66-8fbf-a2b1-dbde-c6808ded6a94@beccati.com> Date: Tue, 4 Jun 2019 13:01:49 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Steve, On 04/06/2019 12:49, Steve Atkins wrote: > Doubling "?" to "??" isn't an obvious, intuitive way to do that, at least > to me. Maybe it would be to people coming from Java. Funny enough, when I proposed \? on the pg mailing lists a few years ago I was suggested ?? to match SQL escaping and Hibernate (going from memory). > Perl's DBD::Pg deals with it in two ways. One is to allow escaping > the ? with a backslash - so "?" is a placeholder, while "\?" is passed as > "?" to the database. That's more consistent with other languages, and > I think you're far less likely to ever see a backslash in a custom operator > than "??". That is true as well, but '\' being also the escape character for strings would also lead to some WTF moments if one tried to escape the backslash itself, e.g. '\\? === '\?'. > The other is that it supports the postgresql standard placeholders - $1, > $2 etc. - which avoid the issue and are more flexible. It also has a configuration > option to completely ignore "?" in queries, so "$1" is a placeholder and "?" > is passed through to the database. > > (Though I like the ":foo" or "@foo" style named placeholders best) PDO does support both positional "?" and ":foo" named placeholders. Adding an option to disable one would probably break much more code and libraries than just a simple escape character. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/