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 D57FA3A4B68 for ; Sat, 20 Nov 2004 04:47:09 +0000 (GMT) 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 19978-08 for ; Sat, 20 Nov 2004 04:47:05 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 6AF3A3A49DA for ; Sat, 20 Nov 2004 04:47:02 +0000 (GMT) Received: (qmail 7894 invoked by uid 1112); 20 Nov 2004 04:47:41 -0000 Date: Fri, 19 Nov 2004 23:47:41 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Xavier Poinsard Cc: pgsql-jdbc@postgresql.org Subject: Re: Patch for jdbc escaped functions In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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: 200411/159 X-Sequence-Number: 11581 On Fri, 19 Nov 2004, Xavier Poinsard wrote: > Hi, > I saw that escaped functions were on the TODO list. > Here is a patch that prepare for adding escaped functions. > It supports nested escapes. > As example I have coded the concat function. > Tests and metadata updates are included. > If the patch is accepted, I will add more functions. > Any comments are welcome. > This code is not quite right in its determination of function arguments because it stops checking for literal and identifier markers. Consider that {fn concat('(', a."(")} should work. I also don't like the prospect of a giant if/else block that has every function that must do some kind of mapping/translation. What about a more pluggable architecture perhaps along the lines of the following: public interface StandardFunction { public void toSQL(StringBuffer sb, ArrayList args); } Then a static HashMap of say lowercase function name -> StandardFunction implementation can move all of the mapping/translation into a separate place. Maybe that's overkill in the opposite direction. Thoughts? Kris Jurka