Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 26C879FBFA6 for ; Thu, 18 Oct 2007 12:43:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 35949-04 for ; Thu, 18 Oct 2007 12:43:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 6DE139FBD1D for ; Thu, 18 Oct 2007 12:43:18 -0300 (ADT) Received: (qmail invoked by alias); 18 Oct 2007 15:43:12 -0000 Received: from office01.emerion.com (EHLO [192.168.1.150]) [83.64.50.26] by mail.gmx.net (mp035) with SMTP; 18 Oct 2007 17:43:12 +0200 X-Authenticated: #1946847 X-Provags-ID: V01U2FsdGVkX1/AOoxBL77ANj7EFqBpkG9CTW8evT1fE72GpIwriE AcuXDbrA6LB3KH Message-ID: <47177F0E.6020601@gmx.at> Date: Thu, 18 Oct 2007 17:43:10 +0200 From: Michael Paesold User-Agent: Thunderbird 1.5.0.12 (X11/20070719) MIME-Version: 1.0 To: Michael Paesold CC: Kris Jurka , Tom Lane , Altaf Malik , pgsql-jdbc@postgresql.org Subject: Re: Unable to prepare a statement when the object names contain more than one $ symbol References: <540504.87872.qm@web39103.mail.mud.yahoo.com> <23286.1183999558@sss.pgh.pa.us> <46937FCD.7060409@gmx.at> <4714DDF1.9020403@gmx.at> In-Reply-To: <4714DDF1.9020403@gmx.at> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/92 X-Sequence-Number: 17664 Michael Paesold wrote: > Hi Kris, > > sorry for not coming back to this earlier. Yeah, this is no real > solution. I thought about checking the character directly before the > dollar quote. But I have not had the time to look at the grammer if that > is enough to fix all error cases... I will do so tomorrow. Well, I think we have several simple options (apart from implementing a real parser in the driver ;-)... 1) In parseDollarQuotes(), we look at the character directly before the $-char and compare it against all valid identifier characters. If it is, we don't have a possible dollar-quote start: From scan.l: ident_start [A-Za-z\200-\377_] ident_cont [A-Za-z\200-\377_0-9\$] 2) Same concept as 1), but instead create a new method parseIdentifier() in the Parser class that would be used to detect and "skip" all regular keywords and identifiers in the query string, and therefore avoid the current problem. Seems like a performance loss though, because we would do more checks on each character. 3) Again in parseDollarQuotes(), we look at the character directly before the $-char and see if it is an *allowed* character before a dollar-quote. But what is allowed? Operators, a comma, parenthesis, etc. ... this is much harder to get right. Looking at gram.y and scan.l (...but I'm no expert) I can't see another case of a dollar-character that I missed, except the one allowed in ident_cont... so option 1) seems like the easiest solution. I will send a patch implementing option 1 shortly. Regarding your patch: I'm not sure if we should apply it, too. You will probably get a different error messages in case of an unterminated dollar quote. I haven't looked at the possible results. My original reasoning was that if there is an unterminated quote, this should not cause us parsing what is inside the quotes. So I would leave it as-is. Another option would be to throw an "unterminated dollar-quote" exception directly in the driver, which would be more helpful in some cases. Best Regards Michael Paesold