From: Adam Rauch <adam@labkey.com>
To: Andreas Joseph Krogh <andreas@visena.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Simple queries with JDBC escaped scalar functions result in exceptions
Date: Sun, 28 Aug 2016 07:20:56 -0700
Message-ID: <c575b722-df04-91a6-8d17-e88071ca11c0@labkey.com> (raw)
In-Reply-To: <VisenaEmail.7.6d85467e04092837.156d161b73e@tc7-visena>
References: <VisenaEmail.7.6d85467e04092837.156d161b73e@tc7-visena>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
In our development and test environments (but not production), our SQL
generation engine inserts comments at strategic places in the queries it
constructs, e.g., tagging a GUID with the real-world name of the object
it represents or providing details about the requests from higher layers
in the system that caused the query to be produced. When a query results
in an exception, incorrect results, or poor performance, those comments
help us better understand the query so we can fix or optimize it. Of
course, this is legal and has been supported by the driver for many years.
The dollar sign ($) is the only case we came across in our test
environments, but it looks like a single quote (') or double quote (")
in a comment also trips up the parser. As do the two-character
combinations {D, {E, {F, {O, and {T... and their lowercase equivalents.
A full set of test queries that fail when executed via
postgresql-9.4.1209.jar:
SELECT /* " */ {fn curdate()};
SELECT /* $ */ {fn curdate()};
SELECT /* ' */ {fn curdate()};
SELECT /* {D */ {fn curdate()};
SELECT /* {E */ {fn curdate()};
SELECT /* {F */ {fn curdate()};
SELECT /* {O */ {fn curdate()};
SELECT /* {T */ {fn curdate()};
SELECT /* {d */ {fn curdate()};
SELECT /* {e */ {fn curdate()};
SELECT /* {f */ {fn curdate()};
SELECT /* {o */ {fn curdate()};
SELECT /* {t */ {fn curdate()};
Thanks,
Adam
On 8/28/2016 6:43 AM, Andreas Joseph Krogh wrote:
> På søndag 28. august 2016 kl. 03:18:42, skrev Dave Cramer
> <pg@fastcrypt.com <mailto:pg@fastcrypt.com>>:
>
> Looks like the JDBC mini parser is having troubles with that. Why
> do you have comments in your sql ?
>
> I think the universial answer here is "Because you can". Many use
> comments in SQL as a way to both understand what's going on better
> (ie. when the SQL is generated by code) and to make logging easier.
> There's no reason why a driver should not cope with valid comments.
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: adam@labkey.com, andreas@visena.com, pg@fastcrypt.com
Subject: Re: Simple queries with JDBC escaped scalar functions result in exceptions
In-Reply-To: <c575b722-df04-91a6-8d17-e88071ca11c0@labkey.com>
References: <VisenaEmail.7.6d85467e04092837.156d161b73e@tc7-visena> <c575b722-df04-91a6-8d17-e88071ca11c0@labkey.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox