X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 24E409FB209 for ; Wed, 23 Aug 2006 09:55:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 15931-09 for ; Wed, 23 Aug 2006 12:55:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from samwel.tk (bsamwel.xs4all.nl [82.92.179.183]) by postgresql.org (Postfix) with ESMTP id F14A89FA6B1 for ; Wed, 23 Aug 2006 09:55:36 -0300 (ADT) Received: from localhost ([127.0.0.1]) by samwel.tk with esmtp (Exim 4.63) (envelope-from ) id 1GFsGa-00020x-Gf for pgsql-odbc@postgresql.org; Wed, 23 Aug 2006 14:55:32 +0200 Message-ID: <44EC504C.5060406@samwel.tk> Date: Wed, 23 Aug 2006 14:55:40 +0200 From: Bart Samwel User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Output parameters problem Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: bart@samwel.tk X-SA-Exim-Scanned: No (on samwel.tk); SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.951 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/82 X-Sequence-Number: 8046 Hi there, I've found a problem with psqlodbc and output parameters. The problem is as follows: if I execute {CALL foobar(?,x,y,z)} where the parameter is an output parameter, the psqlodbc will execute "SELECT foobar(,x,y,z)", instead of "SELECT foobar(x,y,z)". Output parameters in the second or later position are no problem, it's only the first parameter that's treated incorrectly. This is because even though the output parameter '?' is ignored, psqlodbc then tries to remove the comma _preceding_ the parameter from the output. If there is no comma (as is the case with the first parameter) this doesn't work, of course. I've fixed it as follows, by making the following changes in convert.c: 1. Pass an optional QueryParse *qp to ResolveOneParam(), i.e.: static int ResolveOneParam(QueryBuild *qb, QueryParse *qp); 2. In ResolveOneParam, there is the following segment of code: if (outputDiscard) { for (npos = qb->npos - 1; npos >= 0 && isspace(qb->query_statement[npos]) ; npos--) ; if (npos >= 0 && qb->query_statement[npos] == ',') { qb->npos = npos; qb->query_statement[npos] = '\0'; } return SQL_SUCCESS_WITH_INFO; } Immediately before the return statement, I added: else if (npos >= 0 && qb->query_statement[npos] == '(' && qp) { for (npos = qp->opos+1; isspace(qp->statement[npos]); npos++) ; if (qp->statement[npos] == ',') { qp->opos = npos; } } This made things work for me, but your solution may of course be different. This mail is just to let you know about the problem and about a possible solution. Cheers, Bart