Postgres uses ? as an operator; may its JDBC driver allow escaping?
Mark Rotteveel
mark at lawinegevaar.nl
Mon Feb 11 11:58:35 PST 2013
On 11-2-2013 20:45, Lance Andersen - Oracle wrote:
> Forwarding while I get the moderator password sorted out
Might the problem be that Seamus is not subscribed to the list? (didn't
see him in the memberlist)
> Is there any language in the JDBC spec that disallows Postgres's JDBC driver from supporting
>
> SELECT * FROM foo WHERE bar ? 'baz'
>
> ... given that ? in this case is an operator and not a placeholder for a bind variable?
>
> The discussion on pgsql-hackers [1] led to a question on StackOverflow [2], where Mark Rotteveel suggested that I ask jdbc-spec-discuss (greetings!)
Hi! :)
>
> [1] http://www.postgresql.org/message-id/alpine.BSO.2.00.1302081134320.15260@leary.csoft.net
> [2] http://stackoverflow.com/questions/14779896/does-the-jdbc-spec-prevent-from-being-used-as-an-operator-outside-of-quotes
Just to be complete my answer as it is one stackoverflow:
I think it would be perfectly acceptable if the JDBC driver would allow
for the ? operator to be unescaped and used as it is, but it might 1)
complicate your parser to actually identify parameters from this
operator and 2) might confuse people (and maybe tools) who are used to ?
only meaning parameter placeholder.
So my suggestion would be to provide some sort of escape (or alternative
operator). However looking at the JDBC spec, drivers should only use the
JDBC escape syntax to implement the escapes defined in the JDBC spec
(13.4.2: "The escape syntax is not intended to be used to invoke
user-defined or vendor specific scalar functions."; although this is
specifically about the {fn ...} escape).
So either you need to use an alternative escape, or 'break' the rules (I
don't think anyone would mind). If you want a more authorative answer,
you could send your question to the jdbc-spec-discuss mailinglist. I am
sure Lance Andersen (JDBC spec lead) will provide an answer.
Mark
--
Mark Rotteveel
More information about the jdbc-spec-discuss
mailing list