Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLzaP-0002pu-IQ for pgsql-jdbc@postgresql.org; Wed, 10 Oct 2012 16:56:45 +0000 Received: from smtp105.prem.mail.ac4.yahoo.com ([76.13.13.44]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TLzaN-0000h3-UY for pgsql-jdbc@postgresql.org; Wed, 10 Oct 2012 16:56:44 +0000 Received: (qmail 31216 invoked from network); 10 Oct 2012 16:56:42 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=nt30/ibjFDfWV2m1zJI9qK6DLQRRR9F9Wr0pOtkeQ0A7cSW1F+qiUskOybewBvBfVUoPyl7TykKJ9z7Nbl1NoCzbTxCOy47MdW1zhkvJv0AhsTlYWkENblIEJmxTD389ZDrgm31q3uYK7cEuG/2x5cihDXRSuf4S2xupzYbDCpY= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1349888202; bh=c996z2IgJhCckw7KSDBHp4YvDqq/x3ErEvS0QIQ8muM=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=uaV6O323a20QCt3CBPkuMaw97PP1oZhY+1KIPD6Y31MR/PWT5hm2x3m8NXGIQjcJmnSTC2NOPThd5QzfQ4DdravvwtxRnqJUl09rAj+nXJBs79lglFo1Qzw1RAeknDeLXG+4k/LmI4xMegEq+3SPTezM3tEsZ7A8ob1tMILB5L4= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: AwUwC3IVM1nra0Hi5qy03v.DZucuxzcZHyzDjva_rv4s3NW 9u6HpTUKGXFads0xJ69AvOH2kgMyPMZeN0PEr4.wtjYvwZKjAl_wSs6lCS1a 9HyhmJfyHYsgDG6id_hHSxOGbPydApLjPPC6yjD.Y1ns55QwyZcTkhVSXPa3 eSbJ_d61AP4EKZruswK4XKVS6VDsbiWVS9ZpzmxeQ9zQ969X.Rdcteyb24pT 59GL60SMoKGBeSs_UbL497SRUFEmqgRxd4EJ8_SD0YcNw16iX1yTV7yN_t7s 5SQ66sK8up1KFwDHkBx_ZGDJ_s354lhtzRS1drc13YOUwQtBMJZulv8HZV80 BzZRMzsWVd.MvuhJyRenv7GS1vr9OjNvKwUewZe_.s8ILp7nnJAkK9mOACYX KQm4qGaPAc_4fWxwpRtpE3hxr9MjO3UEpiEvRjyR3qFJ3eMUHLeXFZTJfFQX vZffd X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.23.188 with login) by smtp105.prem.mail.ac4.yahoo.com with SMTP; 10 Oct 2012 09:56:42 -0700 PDT From: "David Johnston" To: "'Marc Geisinger'" , 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> <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com> In-Reply-To: <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com> Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting? Date: Wed, 10 Oct 2012 12:56:36 -0400 Message-ID: <014101cda708$36382ac0$a2a88040$@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQI+ZV0iQ92YvBLV3Nq2AMHb27DsQQMFYdbSAmuKORMBYzWnRwEg5mnYAoFVFBwBtkLOG5Zv3dbw Content-Language: en-us X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201210/36 X-Sequence-Number: 23360 > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc- > owner@postgresql.org] On Behalf Of Marc Geisinger > Sent: Wednesday, October 10, 2012 3:55 AM > To: pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] Bug in AbstracJdbc2Statement.replaceProcessing when > using dollar quoting? > > Am Dienstag, 9. Oktober 2012 19:49:17 UTC+2 schrieb "David Johnston": > > Hi, > > > > > > > > See below for my thoughts on how this is limited and inefficient. > > > ... > > > > This patch appears to throw the exception when an unquoted identifier > > > > includes a dollar-sign. I cannot speak to the standard but it would > > seem > > > > that presence of the dollar-sign should only be evaluated if we are > > > > "IN_SQLCODE" and the preceding character is NOT (alphanumeric or > > underscore) > > > > {specifically whatever characters are allowed to begin an unquoted > > > > identifier}. > > > > > > > > Also, with the logic provided the addition of an exception and a > > try/catch > > > > block appears to add unnecessary overhead. At the point the exception > > is > > > > thrown I would suggest that we instead: > > > > > > > > "return p_sql;" > > > > > > > > and let the replaceProcessing method remain ignorant of whether the > > SQL it > > > > is getting back is the original SQL or a modified version. > > > > > > > > The fact is the presence of dollar-quoting with enabled escaping is > > going to > > > > be the common situation. Combine that with the fact we are not > > prompting > > > > the user to "fix" anything means that using the exception mechanism a > > poor > > > > choice - it is not Exceptional but rather ordinary. Everything that > > needs > > > > to be checked and confirmed can be done in the parseSQL method and > > since it > > > > has access to the original statement it can return the original when > > > > necessary. > > > > > > > > David J. > > Hi, > I know that throwing that exception is a bit... uncommon. But I did that > because of the while loop in replaceProcessing. The code there does call > parseSql several times, at least it can. And therefor I don't know if it is the > first call when i found a dollar quote. If i just return the sql unchanged 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 > there 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 since it > only returns an int value, and might have been called before, throwing an > exception was the only thing I found to be able to do that. > > This is probably a situation where returning "-1" would have merit. I dislike the fact this was implemented as a "protected static" method though - but changing the method signature is almost just as bad from that perspective. I'm also concerned that re-entry presumes that one is always in the "IN_SQLCODE" state; since the invalid character that is being protected against could theoretically appear anywhere. But I missed the implication of the re-entry on my first scan and need more time than I have now to ponder this further. I do at least like the fact that adding the checked exception will cause existing code to fail to compile since we are changing the mechanics of how the processing works. But as I said before the overhead is something to be concerned about given the fact this particular code path is one of the most heavily used ones in the driver. David J.