X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A2989D1B18F for ; Fri, 21 May 2004 04:52:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32831-05 for ; Fri, 21 May 2004 04:52:11 -0300 (ADT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 09736D1B203 for ; Fri, 21 May 2004 04:52:09 -0300 (ADT) 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 1BR4p3-00085Z-00; Fri, 21 May 2004 19:52:05 +1200 Message-ID: <40ADB523.9010506@opencloud.com> Date: Fri, 21 May 2004 19:52:03 +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: Olivier Hubaut Cc: pgsql-jdbc@postgresql.org Subject: Re: Parsing problem when launching SQL files with Ant (through References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200405/143 X-Sequence-Number: 10153 Olivier Hubaut wrote: > Using > - Ant 1.6.1 > - PostgreSQL 7.4.2 > - PostgreSQL 7.4.2 JDBC Driver > > We detected that when launching SQL script files with Ant (using the > sql task), a parsing problem occurs when those files contain comments. > > We found a VERY ugly workaround: positionning the semi-colons at the > beginnig of the lines instead of the end. > > [snippet] > -- > -- This code does NOT work with this comment > -- > CREATE FUNCTION foo.bar (VARCHAR(256)) > RETURNS integer > LANGUAGE SQL > AS ' > DELETE FROM foo.bar_table WHERE field = $1; > SELECT 1 > ' > ; By default, Ant's sql task uses ';' as a query delimiter (see the Ant manual). Also, Ant doesn't appear to check for string constants when breaking up the input file -- all semicolons are treated as delimiters regardless of where they occur. So this is being given to the driver as two queries: query 1: CREATE FUNCTION foo.bar (VARCHAR(256)) RETURNS integer LANGUAGE SQL AS 'DELETE FROM foo.bar_table WHERE field = $1 query 2: SELECT 1' and things break horribly. If you specify a different delimiter via the delimiter attribute of the sql task, the above example works fine. > [snippet] > -- > -- This code works with this comment > -- > CREATE FUNCTION foo.bar (VARCHAR(256)) > RETURNS integer > LANGUAGE SQL > AS ' > ; DELETE FROM foo.bar_table WHERE field = $1 > ; SELECT 1' > ; I don't know why this works (it shouldn't!) -- but for some reason Ant submits this as a single query even with delimiter=";". You can see the exact queries being submitted to the server by setting "log_statement = true" in postgresql.conf. -O