Re: Alias hstore's ? to ~ so that it works with JDBC

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Kris Jurka <books(at)ejurka(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Seamus Abshere <seamus(at)abshere(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Alias hstore's ? to ~ so that it works with JDBC
Date: 2013-02-11 17:30:50
Message-ID: 23349.1360603850@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com> writes:
> The thing is PostgeSQL JDBC driver should be able to parse sql in order to
> tell if specific question mark is a bind variable or it is inside string
> literal, or it is inside of some comment.

What's your point? Those cases don't have anything to do with variables
versus operators, neither of which would be inside a literal or comment.

It would take extremely deep knowledge of SQL syntax for the driver to
reliably tell the difference between a variable and an operator --- and
even then, I'm not sure it'd be terribly user-friendly, because the
parsing would depend on details like where there is whitespace. For
instance, the backend parser would think that "?= 2" is a prefix
operator named "?=" followed by literal 2, whereas "? = 2" will be
parsed differently, and "? ? 2" yet differently (because "=" is
special-cased but an operator named "?" isn't). I'm not sure it'd be
any more usable to work like that than with an explicit escaping
convention.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Seamus Abshere 2013-02-11 17:42:18 Re: Alias hstore's ? to ~ so that it works with JDBC
Previous Message Vladimir Sitnikov 2013-02-11 17:05:53 Re: Alias hstore's ? to ~ so that it works with JDBC