pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedSQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
8+ messages / 4 participants
[nested] [flat]
* SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2013-11-26 08:13 Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
0 siblings, 1 reply; 8+ messages in thread
From: Przemyslaw Rzepecki @ 2013-11-26 08:13 UTC (permalink / raw)
To: pgsql-odbc
Hi,
I have encountered some problems with SQLFetchScroll when
SQL_ATTR_ROWS_FETCHED_PTR attribute is set. The statement is closed
after first call to SQLFetchScroll. This first call is successful the
numbers of fetched rows correct, but the statement handle, is after the
call, invalid and can not be used in any other SQLFetchScroll calls.
// table test with 'id' integer column and 20 rows.
The code looks like that:
alloc_stmt(hdbc, &hstmt);
SQLPrepare(hstmt, (SQLCHAR *)"select * from test", SQL_NTS);
SQLExecute(hstmt);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, 1, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, rowStatus, 0);
SQLBindCol(hstmt, 1, SQL_C_LONG, idout, sizeof(SQLINTEGER), indicator);
SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0);
// all above is success and rowStatus and idout arrays are correctly
// updated.
SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0);
// fails with error INVALID HANDLE
Is my usage of the fetch scroll function incorrect?
I am using unixODBC version: 2.3.1
with psqlodbc-09.02.0100 driver
and Postgresql 9.3.1 server.
Kind regards,
Przemyslaw
--
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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-04 14:21 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
0 siblings, 1 reply; 8+ messages in thread
From: Heikki Linnakangas @ 2014-03-04 14:21 UTC (permalink / raw)
To: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>; +Cc: pgsql-odbc
On 11/26/2013 10:13 AM, Przemyslaw Rzepecki wrote:
> Hi,
>
> I have encountered some problems with SQLFetchScroll when
> SQL_ATTR_ROWS_FETCHED_PTR attribute is set. The statement is closed
> after first call to SQLFetchScroll. This first call is successful the
> numbers of fetched rows correct, but the statement handle, is after the
> call, invalid and can not be used in any other SQLFetchScroll calls.
>
> // table test with 'id' integer column and 20 rows.
> The code looks like that:
> alloc_stmt(hdbc, &hstmt);
> SQLPrepare(hstmt, (SQLCHAR *)"select * from test", SQL_NTS);
> SQLExecute(hstmt);
> SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0);
> SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, 1, 0);
> SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, rowStatus, 0);
> SQLBindCol(hstmt, 1, SQL_C_LONG, idout, sizeof(SQLINTEGER), indicator);
> SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0);
> // all above is success and rowStatus and idout arrays are correctly
> // updated.
>
> SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0);
> // fails with error INVALID HANDLE
>
> Is my usage of the fetch scroll function incorrect?
Looks correct to me. I tried to reproduce this with the attached test
program (modified from the regression tests), and it worked fine.
- 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:
rows_fetched-test.c (text/x-csrc, 1.6K) download
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#define ARRAY_SIZE 100
int main(int argc, char **argv)
{
SQLRETURN rc;
HSTMT hstmt = SQL_NULL_HSTMT;
char *sql;
SQLINTEGER int_array[ARRAY_SIZE];
SQLLEN ind_array[ARRAY_SIZE];
SQLULEN rowsFetched[ARRAY_SIZE];
SQLUSMALLINT rowStatus[ARRAY_SIZE];
int i;
test_connect();
rc = SQLAllocStmt(conn, &hstmt);
if (!SQL_SUCCEEDED(rc))
{
print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
exit(1);
}
/* Prepare + Execute */
sql = "SELECT generate_series(1,20)";
rc = SQLPrepare(hstmt, (SQLCHAR *) sql, SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
rc = SQLExecute(hstmt);
CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
/* Set attributes */
rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &rowsFetched, 0);
CHECK_STMT_RESULT(rc, "SQLSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR) failed", hstmt);
rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) 1, 0);
CHECK_STMT_RESULT(rc, "SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE) failed", hstmt);
rc = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, &rowStatus, 0);
CHECK_STMT_RESULT(rc, "SQLSetStmtAttr(SQL_ATTR_ROW_STATUS_PTR) failed", hstmt);
/* Bind */
rc = SQLBindCol(hstmt, 1, SQL_INTEGER, int_array, sizeof(SQLLEN), ind_array);
CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt);
/* Fetch results with SQLFetchScroll */
i = 0;
while ((rc = SQLFetchScroll(hstmt, SQL_FETCH_NEXT, 0)) != SQL_NO_DATA)
{
i++;
CHECK_STMT_RESULT(rc, "SQLFetchScroll failed", hstmt);
printf("row %d: %d\n", i, int_array[0]);
}
/* Clean up */
test_disconnect();
return 0;
}
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-06 17:05 Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
parent: Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 2 replies; 8+ messages in thread
From: Przemyslaw Rzepecki @ 2014-03-06 17:05 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc
Hi,
Thanks for the answer! I have compare my program with Yours didn't
noticed any logical difference. Then tried rerun the tests on two
different systems, any my tests ware passing on one but the errors ware
still present on the other.
Tried to step by step eliminate all the differences and I believe its
the libodbcinst.so.2 vs libodbcinst.so.1 which cause the difference. It
works fine with unixodbc 1 but when I use a driver recompiled against
unixodbc 2 then the error happens.
Could You let me know which odbc libraries You use on your system? Is it
possible for someone else to retest with odbc2 libraries?
Best regards,
Przemek
On Tue, 2014-03-04 at 16:21 +0200, Heikki Linnakangas wrote:
> usage of the fetch scroll function incorrect?
>
> Looks correct to me. I tried to reproduce this with the attached test
> program (modified from the regression tests), and it worked fine.
>
> - 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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-06 19:10 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
1 sibling, 0 replies; 8+ messages in thread
From: Heikki Linnakangas @ 2014-03-06 19:10 UTC (permalink / raw)
To: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>; +Cc: pgsql-odbc
On 03/06/2014 07:05 PM, Przemyslaw Rzepecki wrote:
> Hi,
>
> Thanks for the answer! I have compare my program with Yours didn't
> noticed any logical difference. Then tried rerun the tests on two
> different systems, any my tests ware passing on one but the errors ware
> still present on the other.
>
> Tried to step by step eliminate all the differences and I believe its
> the libodbcinst.so.2 vs libodbcinst.so.1 which cause the difference. It
> works fine with unixodbc 1 but when I use a driver recompiled against
> unixodbc 2 then the error happens.
>
> Could You let me know which odbc libraries You use on your system? Is it
> possible for someone else to retest with odbc2 libraries?
I use what ships with Debian. Seems to be unixodbc 2.3.1.
Seems odd. I don't think the driver depends on libodbcinst.so. Could it
be caused by some kind of confusion between 32-bit and 64-bit versions
of libraries? Where did those libraries come from?
- 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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-07 08:09 Inoue, Hiroshi <inoue@tpf.co.jp>
parent: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
1 sibling, 2 replies; 8+ messages in thread
From: Inoue, Hiroshi @ 2014-03-07 08:09 UTC (permalink / raw)
To: Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>; +Cc: Heikki Linnakangas <hlinnakangas@vmware.com>; pgsql-odbc
(2014/03/07 2:05), Przemyslaw Rzepecki wrote:
> Hi,
>
> Thanks for the answer! I have compare my program with Yours didn't
> noticed any logical difference. Then tried rerun the tests on two
> different systems, any my tests ware passing on one but the errors ware
> still present on the other.
>
> Tried to step by step eliminate all the differences and I believe its
> the libodbcinst.so.2 vs libodbcinst.so.1 which cause the difference. It
> works fine with unixodbc 1 but when I use a driver recompiled against
> unixodbc 2 then the error happens.
Functions used in lib(i)odbcinst are SQLGetPrivateProfileString()
and SQLWritePrivateProfileString().
Could you please take the Mylog output of your failure case
by setting Debug=1 in your odbc.ini?
regards,
Hiroshi Inoue
--
I am using the free version of SPAMfighter.
SPAMfighter has removed 5505 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len
Do you have a slow PC? Try a Free scan
http://www.spamfighter.com/SLOW-PCfighter?cid=sigen
--
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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-07 09:48 Nick Gorham <nick@lurcher.org>
parent: Inoue, Hiroshi <inoue@tpf.co.jp>
1 sibling, 1 reply; 8+ messages in thread
From: Nick Gorham @ 2014-03-07 09:48 UTC (permalink / raw)
To: pgsql-odbc
On 07/03/14 08:09, Inoue, Hiroshi wrote:
> (2014/03/07 2:05), Przemyslaw Rzepecki wrote:
>> Hi,
>>
>> Thanks for the answer! I have compare my program with Yours didn't
>> noticed any logical difference. Then tried rerun the tests on two
>> different systems, any my tests ware passing on one but the errors ware
>> still present on the other.
>>
>> Tried to step by step eliminate all the differences and I believe its
>> the libodbcinst.so.2 vs libodbcinst.so.1 which cause the difference. It
>> works fine with unixodbc 1 but when I use a driver recompiled against
>> unixodbc 2 then the error happens.
>
> Functions used in lib(i)odbcinst are SQLGetPrivateProfileString()
> and SQLWritePrivateProfileString().
> Could you please take the Mylog output of your failure case
> by setting Debug=1 in your odbc.ini?
>
> regards,
> Hiroshi Inoue
>
>
Hi,
I hope you don't mind me posting to your list as a observer, but I
noticed the following in the original code
SQLINTEGER int_array[ARRAY_SIZE];
/* Bind */
rc = SQLBindCol(hstmt, 1, SQL_INTEGER, int_array, sizeof(SQLLEN),
ind_array);
CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt);
I would have thought
/* Bind */
rc = SQLBindCol(hstmt, 1, SQL_INTEGER, int_array,
sizeof(SQLINTEGER), ind_array);
CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt);
Was what it should have been. The driver will have written past the end
of int_array, and overwritten the handle (I guess).
--
Nick
--
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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-07 09:59 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: Nick Gorham <nick@lurcher.org>
0 siblings, 0 replies; 8+ messages in thread
From: Heikki Linnakangas @ 2014-03-07 09:59 UTC (permalink / raw)
To: Nick Gorham <nick@lurcher.org>; +Cc: pgsql-odbc
On 03/07/2014 11:48 AM, Nick Gorham wrote:
> I hope you don't mind me posting to your list as a observer, but I
> noticed the following in the original code
>
> SQLINTEGER int_array[ARRAY_SIZE];
>
> /* Bind */
> rc = SQLBindCol(hstmt, 1, SQL_INTEGER, int_array, sizeof(SQLLEN),
> ind_array);
> CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt);
>
> I would have thought
>
> /* Bind */
> rc = SQLBindCol(hstmt, 1, SQL_INTEGER, int_array,
> sizeof(SQLINTEGER), ind_array);
> CHECK_STMT_RESULT(rc, "SQLBindCol failed", hstmt);
>
> Was what it should have been. The driver will have written past the end
> of int_array, and overwritten the handle (I guess).
The buffer-length argument is ignored with fixed-length data. Although I
agree on readability grounds that it should be sizeof(SQLINTEGER), to
match SQL_INTEGER, or 0 to make it clear that it's ignored.
- 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] 8+ messages in thread
* Re: SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement.
@ 2014-03-07 12:47 Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
parent: Inoue, Hiroshi <inoue@tpf.co.jp>
1 sibling, 0 replies; 8+ messages in thread
From: Przemyslaw Rzepecki @ 2014-03-07 12:47 UTC (permalink / raw)
To: Inoue, Hiroshi <inoue@tpf.co.jp>; +Cc: Heikki Linnakangas <hlinnakangas@vmware.com>; pgsql-odbc
Hi,
The my logs attached. The test case pass when using: unixODBC 2.2.12
and fails with unixODBC 2.3.1
Thanks for Your help!
Przemek
On Fri, 2014-03-07 at 17:09 +0900, Inoue, Hiroshi wrote:
> (2014/03/07 2:05), Przemyslaw Rzepecki wrote:
> > Hi,
> >
> > Thanks for the answer! I have compare my program with Yours didn't
> > noticed any logical difference. Then tried rerun the tests on two
> > different systems, any my tests ware passing on one but the errors ware
> > still present on the other.
> >
> > Tried to step by step eliminate all the differences and I believe its
> > the libodbcinst.so.2 vs libodbcinst.so.1 which cause the difference. It
> > works fine with unixodbc 1 but when I use a driver recompiled against
> > unixodbc 2 then the error happens.
>
> Functions used in lib(i)odbcinst are SQLGetPrivateProfileString()
> and SQLWritePrivateProfileString().
> Could you please take the Mylog output of your failure case
> by setting Debug=1 in your odbc.ini?
>
> regards,
> Hiroshi Inoue
>
>
> --
> I am using the free version of SPAMfighter.
> SPAMfighter has removed 5505 of my spam emails to date.
> Get the free SPAMfighter here: http://www.spamfighter.com/len
>
> Do you have a slow PC? Try a Free scan
> http://www.spamfighter.com/SLOW-PCfighter?cid=sigen
>
>
>
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
mylog_root12815_success.log (text/x-log, 188.8K) download
mylog_root13353_failure.log (text/x-log, 124.2K) download
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2014-03-07 12:47 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26 08:13 SQLFetchScroll with SQL_ATTR_ROWS_FETCHED_PTR closing statement. Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
2014-03-04 14:21 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-03-06 17:05 ` Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.com>
2014-03-06 19:10 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-03-07 08:09 ` Inoue, Hiroshi <inoue@tpf.co.jp>
2014-03-07 09:48 ` Nick Gorham <nick@lurcher.org>
2014-03-07 09:59 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-03-07 12:47 ` Przemyslaw Rzepecki <przemyslaw.rzepecki@ericsson.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