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 4DAF83A4B2B for ; Fri, 19 Nov 2004 14:22:48 +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 15271-09 for ; Fri, 19 Nov 2004 14:22:35 +0000 (GMT) Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 36BBC3A4B15 for ; Fri, 19 Nov 2004 14:22:36 +0000 (GMT) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CV9em-00008x-00 for ; Fri, 19 Nov 2004 15:22:36 +0100 Received: from secure.openpricer.com ([80.65.224.34]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Nov 2004 15:22:36 +0100 Received: from xpoinsard by secure.openpricer.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Nov 2004 15:22:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Xavier Poinsard Subject: Patch for jdbc escaped functions Date: Fri, 19 Nov 2004 15:02:33 +0100 Lines: 214 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030105040506080509080807" X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: secure.openpricer.com User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en X-Archive: Encrypt X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HOT_NASTY X-Spam-Level: X-Archive-Number: 200411/158 X-Sequence-Number: 11580 This is a multi-part message in MIME format. --------------030105040506080509080807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------030105040506080509080807 Content-Type: text/x-patch; name="escapedfunctions.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="escapedfunctions.diff" Index: jdbc2/AbstractJdbc2DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v retrieving revision 1.16 diff -u -r1.16 AbstractJdbc2DatabaseMetaData.java --- jdbc2/AbstractJdbc2DatabaseMetaData.java 9 Nov 2004 08:48:31 -0000 1.16 +++ jdbc2/AbstractJdbc2DatabaseMetaData.java 19 Nov 2004 10:17:47 -0000 @@ -475,7 +475,7 @@ { if (Driver.logDebug) Driver.debug("getStringFunctions"); - return ""; + return EscapedFunctions.CONCAT; } public String getSystemFunctions() throws SQLException Index: jdbc2/AbstractJdbc2Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v retrieving revision 1.50 diff -u -r1.50 AbstractJdbc2Statement.java --- jdbc2/AbstractJdbc2Statement.java 17 Nov 2004 02:43:49 -0000 1.50 +++ jdbc2/AbstractJdbc2Statement.java 19 Nov 2004 10:17:53 -0000 @@ -655,8 +655,9 @@ * * Currently implemented Escape clauses are those mentioned in 11.3 * in the specification. Basically we look through the sql string for - * {d xxx}, {t xxx} or {ts xxx} in non-string sql code. When we find - * them, we just strip the escape part leaving only the xxx part. + * {d xxx}, {t xxx}, {ts xxx}, {oj xxx} or {fn xxx} in non-string sql + * code. When we find them, we just strip the escape part leaving only + * the xxx part. * So, something like "select * from x where d={d '2001-10-09'}" would * return "select * from x where d= '2001-10-09'". */ @@ -728,8 +729,33 @@ newsql.append(c); break; - case ESC_TIMEDATE: case ESC_FUNCTION: + // extract function name + String functionName; + int posArgs = p_sql.indexOf('(',i); + if (posArgs!=-1){ + functionName=p_sql.substring(i,posArgs).trim(); + // extract arguments + i= posArgs+1;// we start the scan after the first ( + int nestedCount=0; + while (i