Re: Research on ?? operators

From: Steve Atkins <steve(at)blighty(dot)com>
To: PG mailing List <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Research on ?? operators
Date: 2019-06-04 10:49:36
Message-ID: D5829AF7-2F39-44E2-81C0-D2AE19BD7D02@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Jun 4, 2019, at 10:00 AM, Matteo Beccati <php(at)beccati(dot)com> wrote:
>
> Hello generals,
>
> I'm trying to resurrect a change to the PHP PDO driver to allow using
> the "?" json operator (and other operators containing a question mark),
> without it being interpreted as a placeholder for a query argument. In
> order to do so, like Hibernate, I went for the double "??" escaping:
>
> https://wiki.php.net/rfc/pdo_escape_placeholders
>
> One question that I'm supposed to answer now is: is there any known
> usage in the wild of some custom "??" operator that would require funny
> escaping like "????"?

I don't know of one today, but that doesn't mean there isn't or won't
be tomorrow.

> I've tried to search pgxn but couldn't find any match, so I thought it
> was worth to try and ask here.

Doubling "?" to "??" isn't an obvious, intuitive way to do that, at least
to me. Maybe it would be to people coming from Java.

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 "??".

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)

Cheers,
Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matteo Beccati 2019-06-04 10:55:27 Re: Research on ?? operators
Previous Message Andrew Gierth 2019-06-04 10:38:45 Re: Research on ?? operators