Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9xps-0005FL-0y for pgsql-odbc@arkaria.postgresql.org; Thu, 15 Aug 2013 13:43:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V9xpr-0005wM-Fz for pgsql-odbc@arkaria.postgresql.org; Thu, 15 Aug 2013 13:43:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9xpq-0005ty-1E for pgsql-odbc@postgresql.org; Thu, 15 Aug 2013 13:43:30 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9xph-0004gp-Bp for pgsql-odbc@postgresql.org; Thu, 15 Aug 2013 13:43:28 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id A08CD29930 for ; Thu, 15 Aug 2013 06:43:17 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 9491AB02BC for ; Thu, 15 Aug 2013 06:43:17 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 4EEDC120030 for ; Thu, 15 Aug 2013 06:49:59 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA for ; Thu, 15 Aug 2013 06:49:58 -0700 (PDT) Message-ID: <520CDAF2.5010005@vmware.com> Date: Thu, 15 Aug 2013 16:43:14 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: "pgsql-odbc@postgresql.org" Subject: UseServerSidePrepare and data-at-execution Content-Type: multipart/mixed; boundary="------------040906030007010901050104" X-Pg-Spam-Score: -9.7 (---------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multi-part message in MIME format. --------------040906030007010901050104 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, In preparation of changing UseServerSidePrepare=1 as the default, I tried running the regression tests in UseServerSidePrepare=1 mode, and got two failures. The first seems to be harmless: --- /home/heikki/git-sandbox-pgsql/psqlodbc/test/expected/insertreturning.out 2013-06-12 13:58:32.535982856 +0300 +++ /home/heikki/git-sandbox-pgsql/psqlodbc/test/results/insertreturning.out 2013-08-15 16:28:09.892155293 +0300 @@ -1,303 +1,303 @@ \! ./src/insertreturning-test connected -# of result cols before SQLExecute: 0, after: 1 +# of result cols before SQLExecute: 1, after: 1 Result set: foobar 0 -# of result cols before SQLExecute: 0, after: 1 +# of result cols before SQLExecute: 1, after: 1 Result set: foobar 1 ... That basically means that with UseServerSidePrepare=0, if you call SQLNumResultCols() on an "INSERT ... RETURNING" statement, after SQLPrepare but before SQLExecute, it returns 0. With UseServerSidePrepare=1, it returns 1. That seems logical - the driver doesn't know how many cols the statement will return before at least preparing it. In any case, the behavior with UseServerSidePrepare=1 is better. The second failure, however, looks like a bug: *** /home/heikki/git-sandbox-pgsql/psqlodbc/test/expected/dataatexecution.out 2013-06-12 13:58:32.535982856 +0300 --- /home/heikki/git-sandbox-pgsql/psqlodbc/test/results/dataatexecution.out 2013-08-15 16:35:04.108136825 +0300 *************** *** 7,12 **** Fetching result sets for array bound (2 results expected) 1: Result set: 4 - 2: Result set: - 5 disconnecting --- 7,10 ---- The test case executes a SELECT statement twice, using data-at-execution parameters (ie. SQLParamData and SQLPutData) and array binding together. In that combination, the server logs confirm that the query is executed twice with different parameters, but only the first result is returned to the client. After some debugging, I came up with the attached patch. It clears the curr_param_result flag from the statement object, in SQLParamData, after executing the statement with the current set of parameters. To be honest, I don't understand how this works; I just mimicked how SQLExecute clears that flag. So I may have broken something. Any better insights into this? - Heikki --------------040906030007010901050104 Content-Type: text/x-diff; name="fix-data-at-execution-with-array-bind-and-useserversideprepare.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="fix-data-at-execution-with-array-bind-and-useserversideprepa"; filename*1="re.patch" diff --git a/execute.c b/execute.c index da4f77e..5909f2f 100644 --- a/execute.c +++ b/execute.c @@ -1490,6 +1490,11 @@ inolog("ipdopts=%p\n", ipdopts); retval = dequeueNeedDataCallback(retval, stmt); goto cleanup; } + else + { + stmt->curr_param_result = 0; + } + if (retval = PGAPI_Execute(estmt, flag), SQL_NEED_DATA != retval) { goto cleanup; --------------040906030007010901050104 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc --------------040906030007010901050104--