Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?

From: David Johnston <polobo(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, Dave Cramer <pg(at)fastcrypt(dot)com>, GEISINGER Marc - Contractor <Marc(dot)GEISINGER(at)external(dot)thalesgroup(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?
Date: 2012-09-24 18:43:59
Message-ID: 8F5F935B-AA2A-4973-9C5E-CB6CD6038854@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Sep 24, 2012, at 14:33, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com> writes:
>> On Mon, Sep 24, 2012 at 6:54 AM, David Johnston <polobo(at)yahoo(dot)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 unquoted identifier it must not begin the character sequence. Since we know whether our current position qualifies for start-of-sequence upon encountering a valid dollar sign we should know whether we are continuing an identifier or starting a string literal.

David J.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2012-09-24 18:45:55 Re: When will your JDBC 4.0 driver implement DatabaseMetadata.getFunctions?
Previous Message Dave Cramer 2012-09-24 18:43:40 Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?