X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4213E9DC9C7 for ; Wed, 11 Jan 2006 12:54:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18378-05 for ; Wed, 11 Jan 2006 12:54:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by postgresql.org (Postfix) with SMTP id DB2079DC9B6 for ; Wed, 11 Jan 2006 12:54:00 -0400 (AST) Received: (qmail 13908 invoked by uid 1112); 11 Jan 2006 16:58:55 -0000 Date: Wed, 11 Jan 2006 11:58:55 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Marc Herbert cc: pgsql-jdbc@postgresql.org Subject: Re: cannot dollar-quote $$?$$ in PreparedStatements In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.042 required=5 tests=[AWL=0.042] X-Spam-Score: 0.042 X-Spam-Level: X-Archive-Number: 200601/51 X-Sequence-Number: 14502 On Wed, 11 Jan 2006, Marc Herbert wrote: > > With 8.0 postgresql and driver, this works fine: > ps = con.prepareStatement("insert into product values(?, '?' , ?)"); > > But this fails: > ps = con.prepareStatement("insert into product values(?, $$?$$ , ?)"); > > It looks like "someone" (driver or engine?) is counting 3 parameters > instead of 3: > This is a known issue. The driver has no knowledge of dollar quotes in its query parser. This is not just a problem for parameters, but also an issue when people want to issue a create function command with Statement.execute("CREATE FUNCTION f() RETURNS int AS $$ [a number of statements separated by semicolons] $$ language plpgsql"); The driver will detect the semicolons and try to execute each fragment separately. So this is a know issue with the only workaround being to not use dollar quotes. Kris Jurka