Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLr9t-0007HN-J9 for pgsql-jdbc@postgresql.org; Wed, 10 Oct 2012 07:56:49 +0000 Received: from news.hub.org ([200.46.204.72]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLr9q-0001KI-Ht for pgsql-jdbc@postgresql.org; Wed, 10 Oct 2012 07:56:48 +0000 Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.5/8.14.5) with ESMTP id q9A7ui9c045336 for ; Wed, 10 Oct 2012 04:56:44 -0300 (ADT) (envelope-from news@news.hub.org) Received: from news.hub.org (news@localhost) by news.hub.org (8.14.5/8.14.5/Submit) with NNTP id q9A7tE4X044596 for pgsql-jdbc@postgresql.org; Wed, 10 Oct 2012 04:55:14 -0300 (ADT) (envelope-from news) Received: by 10.224.183.13 with SMTP id ce13mr16549380qab.4.1349855714418; Wed, 10 Oct 2012 00:55:14 -0700 (PDT) Received: by 10.52.34.201 with SMTP id b9mr1211405vdj.1.1349855714365; Wed, 10 Oct 2012 00:55:14 -0700 (PDT) X-Newsgroups: pgsql.interfaces.jdbc Date: Wed, 10 Oct 2012 00:55:14 -0700 (PDT) In-Reply-To: <019b01cda646$492d00a0$db8701e0$@yahoo.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=62.225.145.235; posting-account=_tU_vwoAAACwUUJQArOUoVkbTF2SYToU References: <31630_1348140231_505AFCC7_31630_19463_1_E4DFA2E3210FA443B032684B39D16BB4092FB05DA1@THSNCOA06MXS02P.ONE-06.GRP> <00f501cd9bf7$57195dc0$054c1940$@yahoo.com> <5077_1348672047_50631A2F_5077_14708_1_E4DFA2E3210FA443B032684B39D16BB4092FB673D5@THSNCOA06MXS02P.ONE-06.GRP> <9945522a-bc49-44e4-906b-cfdacc801b41@googlegroups.com> <019b01cda646$492d00a0$db8701e0$@yahoo.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com> Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting? From: Marc Geisinger Injection-Date: Wed, 10 Oct 2012 07:55:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable To: pgsql-jdbc@postgresql.org X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201210/35 X-Sequence-Number: 23359 Am Dienstag, 9. Oktober 2012 19:49:17 UTC+2 schrieb "David Johnston": > Hi, >=20 >=20 >=20 > See below for my thoughts on how this is limited and inefficient. >=20 ... >=20 > This patch appears to throw the exception when an unquoted identifier >=20 > includes a dollar-sign. I cannot speak to the standard but it would seem >=20 > that presence of the dollar-sign should only be evaluated if we are >=20 > "IN_SQLCODE" and the preceding character is NOT (alphanumeric or undersco= re) >=20 > {specifically whatever characters are allowed to begin an unquoted >=20 > identifier}. >=20 >=20 >=20 > Also, with the logic provided the addition of an exception and a try/catc= h >=20 > block appears to add unnecessary overhead. At the point the exception is >=20 > thrown I would suggest that we instead: >=20 >=20 >=20 > "return p_sql;" >=20 >=20 >=20 > and let the replaceProcessing method remain ignorant of whether the SQL i= t >=20 > is getting back is the original SQL or a modified version. >=20 >=20 >=20 > The fact is the presence of dollar-quoting with enabled escaping is going= to >=20 > be the common situation. Combine that with the fact we are not prompting >=20 > the user to "fix" anything means that using the exception mechanism a poo= r >=20 > choice - it is not Exceptional but rather ordinary. Everything that need= s >=20 > to be checked and confirmed can be done in the parseSQL method and since = it >=20 > has access to the original statement it can return the original when >=20 > necessary. >=20 >=20 >=20 > David J. Hi, I know that throwing that exception is a bit... uncommon. But I did that be= cause of the while loop in replaceProcessing. The code there does call pars= eSql several times, at least it can. And therefor I don't know if it is th= e first call when i found a dollar quote. If i just return the sql unchange= d it might have had changes before so the result would be replaced sql code= together with original sql code. What I wanted to achieve was that replaceProcessing get's to know that ther= e is a dollar quote and stop the replaceProcessing and return the original = sql string (just like replaceProcessingEnabled would have been set to false= ). I wanted to have a kind of stateful exit of the parseSql method. But sin= ce it only returns an int value, and might have been called before, throwin= g an exception was the only thing I found to be able to do that.