pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Geisinger <marc.mg75@googlemail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?
Date: Wed, 10 Oct 2012 00:55:14 -0700 (PDT)
Message-ID: <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com> (raw)
In-Reply-To: <019b01cda646$492d00a0$db8701e0$@yahoo.com>
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>
	<CAF-4BpPaaiZuHX=6Rjtksuhf0PJYHDiroVRV3Yn4dFOEJqkhSw@mail.gmail.com>
	<9945522a-bc49-44e4-906b-cfdacc801b41@googlegroups.com>
	<019b01cda646$492d00a0$db8701e0$@yahoo.com>

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.






view thread (29+ messages)  latest in thread

Message-ID: <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com>
Permalink:  ../3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com/
Also on:    postgresql.org/message-id/3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: marc.mg75@googlemail.com
  Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting?
  In-Reply-To: <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com>
  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> <CAF-4BpPaaiZuHX=6Rjtksuhf0PJYHDiroVRV3Yn4dFOEJqkhSw@mail.gmail.com> <9945522a-bc49-44e4-906b-cfdacc801b41@googlegroups.com> <019b01cda646$492d00a0$db8701e0$@yahoo.com> <3468cb7c-5cf6-40ec-9025-ecc5f01e8479@googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox