pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedUseServerSidePrepare and data-at-execution
3+ messages / 2 participants
[nested] [flat]
* UseServerSidePrepare and data-at-execution
@ 2013-08-15 13:43 Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 1 reply; 3+ messages in thread
From: Heikki Linnakangas @ 2013-08-15 13:43 UTC (permalink / raw)
To: pgsql-odbc
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
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
fix-data-at-execution-with-array-bind-and-useserversideprepare.patch (text/x-diff, 372B) download
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;
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: UseServerSidePrepare and data-at-execution
@ 2013-08-21 23:50 Inoue, Hiroshi <inoue@tpf.co.jp>
parent: Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 1 reply; 3+ messages in thread
From: Inoue, Hiroshi @ 2013-08-21 23:50 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc
Sorry for thr late reply.
(2013/08/15 22:43), Heikki Linnakangas wrote:
> 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.
Oops I overlooked this case.
Yes the curr_param_result flag must be cleared before excecuting
the subsequent set of parameters.
regards,
Hirshi Inoue
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: UseServerSidePrepare and data-at-execution
@ 2013-08-22 06:50 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: Inoue, Hiroshi <inoue@tpf.co.jp>
0 siblings, 0 replies; 3+ messages in thread
From: Heikki Linnakangas @ 2013-08-22 06:50 UTC (permalink / raw)
To: Inoue, Hiroshi <inoue@tpf.co.jp>; +Cc: pgsql-odbc
On 22.08.2013 02:50, Inoue, Hiroshi wrote:
> (2013/08/15 22:43), Heikki Linnakangas wrote:
>> 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.
>
> Oops I overlooked this case.
> Yes the curr_param_result flag must be cleared before excecuting
> the subsequent set of parameters.
Ok then, I committed the patch. Thanks!
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2013-08-22 06:50 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-08-15 13:43 UseServerSidePrepare and data-at-execution Heikki Linnakangas <hlinnakangas@vmware.com>
2013-08-21 23:50 ` Inoue, Hiroshi <inoue@tpf.co.jp>
2013-08-22 06:50 ` Heikki Linnakangas <hlinnakangas@vmware.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox