Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TF6KF-0007Ad-2a for pgsql-jdbc@postgresql.org; Fri, 21 Sep 2012 16:43:35 +0000 Received: from smtp106.prem.mail.ac4.yahoo.com ([76.13.13.45]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TF6KA-0007d1-Iv for pgsql-jdbc@postgresql.org; Fri, 21 Sep 2012 16:43:34 +0000 Received: (qmail 75693 invoked from network); 21 Sep 2012 16:43:28 -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:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=ba0RrWaKF5ciTPAF7vr1MuneeJJ3Zebap7VD7Yo034/8CwZ91l59PfW9OglGgMbpRQrv1REtwip7agO0ijV93en500SWntxbEUNNCWLyTTP3MjuEGAUuoDT1C01B60LxGXlOy416NZBrAuidkB/XKhAgQ01wsSTfRZWsplNWEvo= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1348245808; bh=1dUE/dPa4ttRurdWekiHQ4ncDUOnRnLnS9vSZsnTeqE=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=lRnUkGJnzbQ+sx8IfJbnkoHIUfIC2wsyzq5rAgvbzAI8NXFbgBWo00vGjqICPrlayt9bzamJ8mgFPp5+NszSUINQzudMhY6Wwr2IEWaUX5kNSIxW037o4pFEIiDQorYkhSS3KJXlMXqp6M8BehBmdvF/oVRVVCAGDKb3fyp1GWE= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 4fQzWoYVM1kl6WHdUM0.dmeTm_7C7Lez0GPQxXhVpxr70iv OpI6tyWkZdBeFF_zKmdZrebCu_VlXs0.oTzR0r3oakTf54CL5JArayL2O3LL 7dFYViiktvYO6KT0vgoWd1U23DnSChI_o7DmnFdA6sByqZjTZWXKgeJeS5Mu 0l4wj415q7m3h6QlRPHhwOV.KG4_cPZ9NR4mcGENXA6QUxStL3tqO3beD2IO PoZVI1PD2yYfiV2xpV.9.nn84REwx4hk5YrtrIlFRBKino5En0eYg2DRqaPV GZzcjHJW0wnkjIYcWH4LMkwlTfUI_zxQz6cuE1Ebmoaqi_HHHlUCfeP1md.Z C.lqZ2gMb19FM93GjdwEywmBjrKyQMGhT2xc2E83tqN2lMJo99Ola5O6qpKQ 54BG.zGyFs.mCUZXAD_RDxuhdsXwdH1qAsiQp X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.23.188 with login) by smtp106.prem.mail.ac4.yahoo.com with SMTP; 21 Sep 2012 09:43:28 -0700 PDT From: "David Johnston" To: "'GEISINGER Marc - Contractor'" , "'Dave Cramer'" Cc: References: <31630_1348140231_505AFCC7_31630_19463_1_E4DFA2E3210FA443B032684B39D16BB4092FB05DA1@THSNCOA06MXS02P.ONE-06.GRP> <20900_1348212583_505C1767_20900_6851_1_E4DFA2E3210FA443B032684B39D16BB4092FB06168@THSNCOA06MXS02P.ONE-06.GRP> <012501cd9815$42b55e50$c8201af0$@yahoo.com> In-Reply-To: <012501cd9815$42b55e50$c8201af0$@yahoo.com> Subject: Re: Bug in AbstracJdbc2Statement.replaceProcessing when using dollar quoting? Date: Fri, 21 Sep 2012 12:42:38 -0400 Message-ID: <012c01cd9818$1ca45060$55ecf120$@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+ZV0iQ92YvBLV3Nq2AMHb27DsQQD4mz0iAjnGRI0BptNbhJaMmoMQ Content-Language: en-us X-Pg-Spam-Score: -2.5 (--) X-Archive-Number: 201209/49 X-Sequence-Number: 23285 All the following said would it be within the realm of acceptability to test the query for dollar-quoting and, if found, to automatically disable JDBC escape mode? The presence of dollar-quoting in a PostgreSQL driver is something that is likely to occur and when it does the user should hopefully understand that any JDBC escaping isn't going to guarantee the portability that is implied by its presence. It would seem to be a newbie friendly way of making things work given the escaping is on by default and for someone not as familiar with JDBC features as they are PostgreSQL features the risk posed by the combination, while minimal, would be mostly invisible (since it would not generate syntax errors directly but would rather simply store invalid data). David J. > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc- > owner@postgresql.org] On Behalf Of David Johnston > Sent: Friday, September 21, 2012 12:22 PM > To: 'GEISINGER Marc - Contractor'; 'Dave Cramer' > Cc: pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] Bug in AbstracJdbc2Statement.replaceProcessing when > using dollar quoting? > > > -----Original Message----- > > > > Hi Dave, > > in the potsgresql documentation it says: > > > > > > And that is excactly what i am trying to do. An easy and safe way to > escape > > strings that are coming from "outside". And since I tried it and it > > worked > with > > PgAdmin, i expect it to be a way that can be used. > > > > > > To Victor: > > And I cannot just setEnableProcessing to false. The code I've posted > > here > is > > just an example code. The code where I came to this problem is not > > that simple. And I would have to either disable it completely or not > > at all (we > are > > using an ORM framework for db access). Since reading the above I think > this > > is a thing that should be fixed in the driver I don't want to > > completely > block > > SQL escape clauses in my code (even though i never used them myself :) > > ) > > > > > > Can you show me where in the spec it says you can use dollar sign > > quoting like that ? > > > > So: > > Dollar-quoting is PostgreSQL specific and if used with any other database the > query will likely fail. > > The JDBC escape mechanism is defined to allow for cross-vendor query > writing. > > In order for the JDBC escape mechanism to serve its purpose it would have > to recognize dollar-quoting generally and convert it into whatever string > delimiting mechanism its server is familiar with (i.e., back to single-quote and > quote escaping) in order to serve its function. > > If it simply accepts dollar-quoting but does not convert it when necessary > then queries using the escapes will fail anyway when put to a database not > supporting dollar-quoting. While the PostgreSQL driver could indeed do this > properly it does not mean that the, for example, Oracle and SQLServer > drivers out there are going to perform the conversion since it is not required > of them in the JDBC specification. > > The decision of whether to allow escaping by default is project specific but > regardless of the default decision the driver and whatever interface your > ORM provides should allow you to make the decision on a per-query basis. > > The main risk I can see with using dollar-quoting and having escaping enabled > is if the strings in question use the obscure escape syntax for some reason > (unlikely) then the string valued stored is going to be messed up but > otherwise PostgreSQL will still treat it as a string. I have in fact been living > with this for quite a while (when I store and execute CREATE > FUNCTION) and haven't had any clobbering. The question to ask yourself is > whether that risk window is large enough to warrant modifying your > execution environment. > > You need to decide whether all of your code is supposedly vendor-neutral > and so you can leave escaping on and ignore dollar-quoting OR you can code > in a strictly literal syntax and disable escaping. If you want to live in both > worlds then you need to be able to tell your execution environment which > world you are living in for each query you write. > > David J. > > > > > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes > to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc