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

From: GEISINGER Marc - Contractor <Marc(dot)GEISINGER(at)external(dot)thalesgroup(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>, 'Dave Cramer' <pg(at)fastcrypt(dot)com>
Cc: "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-26 14:38:23
Message-ID: 32597_1348670307_50631363_32597_9347_1_E4DFA2E3210FA443B032684B39D16BB4092FB673AE@THSNCOA06MXS02P.ONE-06.GRP
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

-----Ursprüngliche Nachricht-----
Von: David Johnston [mailto:polobo(at)yahoo(dot)com]
Gesendet: Montag, 24. September 2012 17:49
An: GEISINGER Marc - Contractor; 'Dave Cramer'
Cc: pgsql-jdbc(at)postgresql(dot)org
Betreff: RE: [JDBC] Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?

> At worse even if you cannot code it yourself you can propose pseudo-code/algorithm that people could review and then someone could just code > and deploy.

Looking at
http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html

4.1.1. Identifiers and Key Words
...
SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable.

it seems to me, that $ are not allowed as identifiers by the SQL standard. But they are allowed in postgresql. But also in postgresql they are not allowed at the beginning of an identifier.
As far as I understand the parseSql method (line 864) in AbstractJdbc2Statement class, the looking for a dollar quoted string could be done similar to the looking for escape codes (line 894).
If we are IN_SQLCODE and we find a '$' as character, look through the following chars until the next '$' is found. Anything between the two '$' is the tag. Then we would have a state IN_DOLLARQOUTE, until we find this '$tag$' again.
The only problem I see with this idea might come from nested dollar quotes.

Marc

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Johnston 2012-09-26 14:58:07 Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?
Previous Message Kris Jurka 2012-09-25 03:31:20 Re: data type of projected item in a union not correct