Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting? - Mailing list pgsql-jdbc

From David Johnston
Subject Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?
Date
Msg-id 8F5F935B-AA2A-4973-9C5E-CB6CD6038854@yahoo.com
Whole thread Raw
In response to Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-jdbc
On Sep 24, 2012, at 14:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Maciek Sakrejda <m.sakrejda@gmail.com> writes:
>> On Mon, Sep 24, 2012 at 6:54 AM, David Johnston <polobo@yahoo.com> wrote:
>>> Is there any SQL syntax that allows for a dollar-sign outside of a string
>>> literal?  If not then if we are not in a string and we encounter a
>>> dollar-sign we could assume that we are dealing with a PostgreSQL string and
>>> immediately return the original input unchanged.
>
>> Identifiers can also contain "$" when quoted:
>
> Identifiers can contain "$" even when not quoted ...
>
> regression=# create table foo$ (bar$ int);
> CREATE TABLE
>
> I don't think that's per SQL spec, but PG allows it, mainly because some
> other databases do.
>
>            regards, tom lane
>

This is true but I just realized that for dollar-quoting the dollar sign must start the character sequence while for an
unquotedidentifier it must not begin the character sequence.  Since we know whether our current position qualifies for
start-of-sequenceupon encountering a valid dollar sign we should know whether we are continuing an identifier or
startinga string literal. 

David J.

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: When will your JDBC 4.0 driver implement DatabaseMetadata.getFunctions?
Next
From: the6campbells
Date:
Subject: data type of projected item in a union not correct