X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4D2C2329E8B for ; Wed, 15 Sep 2004 23:20:21 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30125-07 for ; Wed, 15 Sep 2004 22:20:14 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 207F3329E0E for ; Wed, 15 Sep 2004 23:20:17 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1C7i7p-0002tf-00; Thu, 16 Sep 2004 10:19:41 +1200 Message-ID: <4148BFF9.5060705@opencloud.com> Date: Thu, 16 Sep 2004 10:19:37 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Jurka Cc: Tim Penhey , pgsql-jdbc@postgresql.org Subject: Re: Problem with dollar-quoted CREATE OR REPLACE FUNCTION References: <41470089.8010207@penhey.net> <41477610.8070202@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/74 X-Sequence-Number: 10964 Kris Jurka wrote: > > On Wed, 15 Sep 2004, Oliver Jowett wrote: > > >>Kris Jurka wrote: >> >> >>>Your options seem to be: >>> - don't use dollar quoting >>> - use the 7.4 driver which doesn't try to split queries >>> - teach the driver about dollar quoting >> >>It's a pity the grammar doesn't let you specify the function body as a >>parameter, then you could just use a PreparedStatement and avoid the >>quoting problems altogether.. > > > Yes and no. The problem with that approach is that you have to know what > you're doing ahead of time instead of just blindly passing a query string > into Statement.execute(). Well, yes. But it'd still be useful. COMMENT ON is another example where the grammar doesn't let you pass data (not needed at parse/plan time) as a parameter. Our app has to do its own escaping of comment text and glue it into the COMMENT ON query. Yuck. > Consider an admin interface (or say psql) > written in java, it should be able to take an arbitrary sql string and run > it without problem. Depending on the exact interface, the client code may need exactly the same parsing logic as the driver, e.g. to determine the end of a multiline query. Part of the problem is that JDBC is not really set up for multiple-statement queries; they're a driver-specific extension that doesn't interact wonderfully with the standard API. > This is just another case of the driver not correctly > lexing/parsing a query. Also note that the current code does not > correctly handle single quotes that are escaped with backslashes. Sure. It looks like double quotes also aren't handled correctly. I think that parsing code got inherited from the pre-v3 version. -O