pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Fix for  Declare/Fetch issue
6+ messages / 4 participants
[nested] [flat]

* Fix for  Declare/Fetch issue
@ 2005-10-26 06:23 Anoop Kumar <anoopk@pervasive-postgres.com>
  2005-10-27 05:47 ` Re: Fix for  Declare/Fetch issue Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 1 reply; 6+ messages in thread

From: Anoop Kumar @ 2005-10-26 06:23 UTC (permalink / raw)
  To: pgsql-odbc; dpage@vale-housing.co.uk; +Cc: Victor Rivero <vrivero@cantv.net>

Hi All,

Please find attached the patch for Declare/Fetch issue. Sorry for the
delay, but it took a while to get it right. 

Dave, please test it before I commit changes to CVS. 

My special thanks to Sivakumar and Vaidhy, for their contributions to
this fix.

Regards,
Anoop


> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-
> owner@postgresql.org] On Behalf Of Victor Rivero
> Sent: Wednesday, October 26, 2005 4:55 AM
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] Declare/Fetch "Get Well Soon"
> 
> 
> 
> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
> Sent: Jueves, 13 de Octubre de 2005 09:57 a.m.
> Hello Dave,
> 
> Any update on Declare/Fetch? News from Anoop?  Date?
> 
> Many thanks. Regards Victor Rivero
> 
> > -----Original Message-----
> > From: pgsql-odbc-owner@postgresql.org
> > [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Victor Rivero
> > Sent: 13 October 2005 14:34
> > To: pgsql-odbc@postgresql.org
> > Subject: Re: [ODBC] Problem with psqlODBC on "Cache Size"
> >
> > Thanks Dave.
> >
> > Any Expected Date available?
> >
> > We need this feature ASAP (not to rush anyone: stress on the
> > "AP" part of
> > it) for a live system that outgrew acceptable performance w/o
> > Declare/Fetch
> > (i.e. w/o cursors).
> >
> 
> I hope by the end of the month at the latest, however, I'll have to
> leave it for Anoop to give a more useful answer as he is the one
working
> on the problem.
> 
> Regards Dave
> 
> 
> ---------------------------(end of
broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

Attachments:

declare_fetch.patch (application/octet-stream, 6.7K) download Index: connection.c =================================================================== RCS file: /cvsroot/psqlodbc/psqlodbc/connection.c,v retrieving revision 1.120 diff -u -r1.120 connection.c --- connection.c 25 Oct 2005 07:35:19 -0000 1.120 +++ connection.c 25 Oct 2005 08:49:52 -0000 @@ -1925,6 +1925,10 @@ CI_set_field_info(qres->fields, i, PQfname(pgres,i), typid, (Int2)typlen, atttypmod); } + if (qres->manual_tuples) + { + TL_Destructor(qres->manual_tuples); + } qres->manual_tuples = TL_Constructor(num_attributes); qres->manual_tuples->num_tuples = (Int4)num_tuples; for(i=0;i < num_tuples;i++) Index: results.c =================================================================== RCS file: /cvsroot/psqlodbc/psqlodbc/results.c,v retrieving revision 1.81 diff -u -r1.81 results.c --- results.c 20 Oct 2005 13:06:10 -0000 1.81 +++ results.c 25 Oct 2005 09:08:10 -0000 @@ -842,24 +842,37 @@ return SQL_ERROR; } } - - if (stmt->manual_result || !SC_is_fetchcursor(stmt)) + if (stmt->manual_result) { - /* make sure we're positioned on a valid row */ - num_rows = QR_get_num_total_tuples(res); - if ((stmt->currTuple < 0) || - (stmt->currTuple >= num_rows)) + if(!SC_is_fetchcursor(stmt)) { - SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row for GetData."); - SC_log_error(func, "", stmt); - return SQL_ERROR; + /* make sure we're positioned on a valid row */ + num_rows = QR_get_num_total_tuples(res); + if ((stmt->currTuple < 0) || + (stmt->currTuple >= num_rows)) + { + SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row for GetData."); + SC_log_error(func, "", stmt); + return SQL_ERROR; + } + } + else + { + if (stmt->currTuple < 0) + { + SC_set_error(stmt, STMT_INVALID_CURSOR_STATE_ERROR, "Not positioned on a valid row for GetData."); + SC_log_error(func, "", stmt); + return SQL_ERROR; + } } - mylog(" num_rows = %d\n", num_rows); if (!get_bookmark) { if (stmt->manual_result) - value = QR_get_value_manual(res, stmt->currTuple, icol); + if(SC_is_fetchcursor(stmt)) + value = QR_get_value_manual(res, (stmt->currTuple % stmt->hdbc->connInfo.drivers.fetch_max), icol); + else + value = QR_get_value_manual(res, stmt->currTuple, icol); else { Int4 curt = GIdx2ResultIdx(stmt->currTuple, stmt, res); @@ -1405,9 +1418,12 @@ * Handle Declare Fetch style specially because the end is not really * the end... */ - if (SC_is_fetchcursor(stmt) && !stmt->manual_result) + if (SC_is_fetchcursor(stmt) ) { + if(!stmt->manual_result) + { return SQL_NO_DATA_FOUND; + } } else { Index: statement.c =================================================================== RCS file: /cvsroot/psqlodbc/psqlodbc/statement.c,v retrieving revision 1.102 diff -u -r1.102 statement.c --- statement.c 20 Oct 2005 13:06:10 -0000 1.102 +++ statement.c 26 Oct 2005 05:22:26 -0000 @@ -167,6 +167,8 @@ /* Free any cursors and discard any result info */ if (res = SC_get_Result(stmt), res) { + if(SC_is_fetchcursor(stmt)) + SC_set_handle(stmt,res); QR_Destructor(res); SC_set_Result(stmt, NULL); } @@ -205,6 +207,19 @@ /* + * For Declare/Fetch, setting the parameters to close the cursor. + */ +void +SC_set_handle(StatementClass *self,QResultClass *res) +{ + res->conn = self->hdbc; + if(!res->cursor) + res->cursor = malloc(sizeof(self->cursor_name)); + strcpy(res->cursor,self->cursor_name); +} + + +/* * StatementClass implementation */ void @@ -608,6 +623,8 @@ /* Free any cursors */ if (res = SC_get_Result(self), res) { + if(SC_is_fetchcursor(self)) + SC_set_handle(self,res); QR_Destructor(res); SC_set_Result(self, NULL); } @@ -894,6 +911,10 @@ lf; Oid type; char *value; + char fetch[128]; + + QueryInfo qi; + UDWORD qflag = 0; ColumnInfoClass *coli; BindInfoClass *bookmark; @@ -903,19 +924,42 @@ self->last_fetch_count = self->last_fetch_count_include_ommitted = 0; coli = QR_get_fields(res); /* the column info */ + /* Issue the fetch query here in case of declare fetch for subsequent rows */ + if (SC_is_fetchcursor(self) && ((self->currTuple % ci->drivers.fetch_max) >= QR_get_num_total_tuples(res) - 1)) + { + qi.result_in = NULL; + qi.cursor = self->cursor_name; + qi.row_size = ci->drivers.fetch_max; + sprintf(fetch, "fetch %d in %s",ci->drivers.fetch_max , self->cursor_name); + res = CC_send_query(self->hdbc, fetch, &qi, qflag); + SC_set_Result(self,res); + } + mylog("manual_result = %d, use_declarefetch = %d\n", self->manual_result, ci->drivers.use_declarefetch); - if (self->manual_result || !SC_is_fetchcursor(self)) + if (self->manual_result) { - if (self->currTuple >= QR_get_num_total_tuples(res) - 1 || - (self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1)) + if(!SC_is_fetchcursor(self)) { - /* - * if at the end of the tuples, return "no data found" and set - * the cursor past the end of the result set - */ - self->currTuple = QR_get_num_total_tuples(res); - return SQL_NO_DATA_FOUND; + if (self->currTuple >= QR_get_num_total_tuples(res) - 1 || + (self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1)) + { + /* + * if at the end of the tuples, return "no data found" and set + * the cursor past the end of the result set + */ + self->currTuple = QR_get_num_total_tuples(res); + return SQL_NO_DATA_FOUND; + } + } + else + { + if ((((self->currTuple + 1) % ci->drivers.fetch_max) >= QR_get_num_total_tuples(res)) && + QR_get_num_total_tuples(res) < ci->drivers.fetch_max) + { + self->currTuple = QR_get_num_total_tuples(res); + return SQL_NO_DATA_FOUND; + } } mylog("**** SC_fetch: manual_result\n"); @@ -940,6 +984,7 @@ return SQL_ERROR; } } + #ifdef DRIVER_CURSOR_IMPLEMENT if (res->haskeyset) { Index: statement.h =================================================================== RCS file: /cvsroot/psqlodbc/psqlodbc/statement.h,v retrieving revision 1.63 diff -u -r1.63 statement.h --- statement.h 20 Oct 2005 13:06:10 -0000 1.63 +++ statement.h 26 Oct 2005 05:22:32 -0000 @@ -306,6 +306,7 @@ #endif /* WIN_MULTITHREAD_SUPPORT */ /* Statement prototypes */ StatementClass *SC_Constructor(void); +void SC_set_handle(StatementClass *self,QResultClass *res); void InitializeStatementOptions(StatementOptions *opt); char SC_Destructor(StatementClass *self); BOOL SC_opencheck(StatementClass *self, const char *func);
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: Fix for  Declare/Fetch issue
  2005-10-26 06:23 Fix for  Declare/Fetch issue Anoop Kumar <anoopk@pervasive-postgres.com>
@ 2005-10-27 05:47 ` Dave Page <dpage@vale-housing.co.uk>
  2005-10-27 19:14   ` Re: Fix for  Declare/Fetch issue Marko Ristola <marko.ristola@kolumbus.fi>
  2005-10-30 14:07   ` Re: Fix for  Declare/Fetch issue Marko Ristola <Marko.Ristola@kolumbus.fi>
  0 siblings, 2 replies; 6+ messages in thread

From: Dave Page @ 2005-10-27 05:47 UTC (permalink / raw)
  To: Anoop Kumar <anoopk@pervasive-postgres.com>; pgsql-odbc; +Cc: Victor Rivero <vrivero@cantv.net>

Great, thanks Anoop.

Can anyone test this fairly quickly? I don't have the appropriate hardware
to hand for the next few days, and it would be helpful for a number of
reasons if we could get this committed before November.

Thanks, Dave.


On 26/10/05 7:23 am, "Anoop Kumar" <anoopk@pervasive-postgres.com> wrote:

> Hi All,
> 
> Please find attached the patch for Declare/Fetch issue. Sorry for the
> delay, but it took a while to get it right.
> 
> Dave, please test it before I commit changes to CVS.
> 
> My special thanks to Sivakumar and Vaidhy, for their contributions to
> this fix.
> 
> Regards,
> Anoop
> 
> 
>> -----Original Message-----
>> From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-
>> owner@postgresql.org] On Behalf Of Victor Rivero
>> Sent: Wednesday, October 26, 2005 4:55 AM
>> To: pgsql-odbc@postgresql.org
>> Subject: [ODBC] Declare/Fetch "Get Well Soon"
>> 
>> 
>> 
>> -----Original Message-----
>> From: pgsql-odbc-owner@postgresql.org
>> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
>> Sent: Jueves, 13 de Octubre de 2005 09:57 a.m.
>> Hello Dave,
>> 
>> Any update on Declare/Fetch? News from Anoop?  Date?
>> 
>> Many thanks. Regards Victor Rivero
>> 
>>> -----Original Message-----
>>> From: pgsql-odbc-owner@postgresql.org
>>> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Victor Rivero
>>> Sent: 13 October 2005 14:34
>>> To: pgsql-odbc@postgresql.org
>>> Subject: Re: [ODBC] Problem with psqlODBC on "Cache Size"
>>> 
>>> Thanks Dave.
>>> 
>>> Any Expected Date available?
>>> 
>>> We need this feature ASAP (not to rush anyone: stress on the
>>> "AP" part of
>>> it) for a live system that outgrew acceptable performance w/o
>>> Declare/Fetch
>>> (i.e. w/o cursors).
>>> 
>> 
>> I hope by the end of the month at the latest, however, I'll have to
>> leave it for Anoop to give a more useful answer as he is the one
> working
>> on the problem.
>> 
>> Regards Dave
>> 
>> 
>> ---------------------------(end of
> broadcast)---------------------------
>> TIP 5: don't forget to increase your free space map settings

Regards, Dave 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix for  Declare/Fetch issue
  2005-10-26 06:23 Fix for  Declare/Fetch issue Anoop Kumar <anoopk@pervasive-postgres.com>
  2005-10-27 05:47 ` Re: Fix for  Declare/Fetch issue Dave Page <dpage@vale-housing.co.uk>
@ 2005-10-27 19:14   ` Marko Ristola <marko.ristola@kolumbus.fi>
  1 sibling, 0 replies; 6+ messages in thread

From: Marko Ristola @ 2005-10-27 19:14 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: Anoop Kumar <anoopk@pervasive-postgres.com>; pgsql-odbc; Victor Rivero <vrivero@cantv.net>


Great.

Thanks for Anoop and others.

I hope that although I have a busy weekend,
I would get a bit time for testing it under Linux.

I don't have a testing environment under Windows.

Regards, Marko

Dave Page wrote:

>Great, thanks Anoop.
>
>Can anyone test this fairly quickly? I don't have the appropriate hardware
>to hand for the next few days, and it would be helpful for a number of
>reasons if we could get this committed before November.
>
>Thanks, Dave.
>
>
>On 26/10/05 7:23 am, "Anoop Kumar" <anoopk@pervasive-postgres.com> wrote:
>
>  
>
>>Hi All,
>>
>>Please find attached the patch for Declare/Fetch issue. Sorry for the
>>delay, but it took a while to get it right.
>>
>>Dave, please test it before I commit changes to CVS.
>>
>>My special thanks to Sivakumar and Vaidhy, for their contributions to
>>this fix.
>>
>>Regards,
>>Anoop
>>
>>
>>    
>>
>>>-----Original Message-----
>>>From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-
>>>owner@postgresql.org] On Behalf Of Victor Rivero
>>>Sent: Wednesday, October 26, 2005 4:55 AM
>>>To: pgsql-odbc@postgresql.org
>>>Subject: [ODBC] Declare/Fetch "Get Well Soon"
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: pgsql-odbc-owner@postgresql.org
>>>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
>>>Sent: Jueves, 13 de Octubre de 2005 09:57 a.m.
>>>Hello Dave,
>>>
>>>Any update on Declare/Fetch? News from Anoop?  Date?
>>>
>>>Many thanks. Regards Victor Rivero
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: pgsql-odbc-owner@postgresql.org
>>>>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Victor Rivero
>>>>Sent: 13 October 2005 14:34
>>>>To: pgsql-odbc@postgresql.org
>>>>Subject: Re: [ODBC] Problem with psqlODBC on "Cache Size"
>>>>
>>>>Thanks Dave.
>>>>
>>>>Any Expected Date available?
>>>>
>>>>We need this feature ASAP (not to rush anyone: stress on the
>>>>"AP" part of
>>>>it) for a live system that outgrew acceptable performance w/o
>>>>Declare/Fetch
>>>>(i.e. w/o cursors).
>>>>
>>>>        
>>>>
>>>I hope by the end of the month at the latest, however, I'll have to
>>>leave it for Anoop to give a more useful answer as he is the one
>>>      
>>>
>>working
>>    
>>
>>>on the problem.
>>>
>>>Regards Dave
>>>
>>>
>>>---------------------------(end of
>>>      
>>>
>>broadcast)---------------------------
>>    
>>
>>>TIP 5: don't forget to increase your free space map settings
>>>      
>>>
>
>Regards, Dave 
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>  
>




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix for  Declare/Fetch issue
  2005-10-26 06:23 Fix for  Declare/Fetch issue Anoop Kumar <anoopk@pervasive-postgres.com>
  2005-10-27 05:47 ` Re: Fix for  Declare/Fetch issue Dave Page <dpage@vale-housing.co.uk>
@ 2005-10-30 14:07   ` Marko Ristola <Marko.Ristola@kolumbus.fi>
  1 sibling, 0 replies; 6+ messages in thread

From: Marko Ristola @ 2005-10-30 14:07 UTC (permalink / raw)
  To: Dave Page <dpage@vale-housing.co.uk>; +Cc: Anoop Kumar <anoopk@pervasive-postgres.com>; pgsql-odbc; Victor Rivero <vrivero@cantv.net>


My test case failed.

I tested only column wise query.
It returned the correct number of rows, but only the first cursor fetch got
correct data.

The self contained test case is attached:
it creates a test table, inserts there six rows and fetches
those rows as column wise. Please use Fetch=2 with it.
Finally it drops the test table.
You need to change DATABASE, USERID and PASSWORD.

It worked without Declare/fetch as it should:

OK(UseDeclareFetch=0):

After colwise query: data[1] = { 4, 0001 }, data[2] = { 4, 1001 }
After colwise query: data[1] = { 4, 2001 }, data[2] = { 4, 3001 }
After colwise query: data[1] = { 4, 4001 }, data[2] = { 4, 5001 }
ok.
(4= number of characters. "0001" is a character string value.)

FAILED (UseDeclareFetch=1,Fetch=2):

After colwise query: data[1] = { 4, 0001 }, data[2] = { 4, 1001 }
After colwise query: data[1] = { -1, UNSET }, data[2] = { -1, UNSET }
After colwise query: data[1] = { -1, UNSET }, data[2] = { -1, UNSET }
ok.

-1 means possibly a NULL value(?).
UNSET means that the string buffer is uninitialized after SQLFetchScroll.

Unfreed memory was a problem with this failed test case.
You can confirm that by setting the number of rows into 600 000 and
using Fetch=2 with Declare/Fetch.

The program prints
"INITIALIZATION OF 600000 ROWS DONE". Then the process's used memory
grows very fast.

Regards,
Marko Ristola.

Dave Page wrote:

>Great, thanks Anoop.
>
>Can anyone test this fairly quickly? I don't have the appropriate hardware
>to hand for the next few days, and it would be helpful for a number of
>reasons if we could get this committed before November.
>
>Thanks, Dave.
>
>  
>

Attachments:

TestColwiseQuery.c (text/x-csrc, 6.5K) download #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sql.h> #include <sqlext.h> #define NUMBEROF_TEST_ROWS (6) int CHECK(SQLSMALLINT handle_type,SQLHANDLE handle,SQLRETURN ret) { if (ret != SQL_SUCCESS && ret != SQL_NO_DATA) { SQLRETURN ret; SQLINTEGER i = 0; SQLCHAR state[32]; SQLINTEGER native; SQLCHAR text[512]; SQLSMALLINT text_len; int has_err = 0; do { i++; ret = SQLGetDiagRec(handle_type,handle,i,state,&native,text,sizeof(text), &text_len); fprintf(stderr,"message=%s\nstate=%s native error %d.\n",text,state,native); has_err=1; } while(ret == SQL_SUCCESS); if (!has_err) fprintf(stderr,"An unknonw error occurred\n"); } if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO || ret == SQL_NO_DATA) return 1; return 0; } // PREPARATIONS int CreateInitialData(SQLHANDLE m_env,SQLHANDLE m_conn) { int row; int nextVacuum=1024; SQLHANDLE stmt; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLSetConnectOption(m_conn,SQL_AUTOCOMMIT,0))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLAllocHandle(SQL_HANDLE_STMT,m_conn,&stmt))) return 1; if (!CHECK(SQL_HANDLE_STMT,stmt,SQLExecDirect(stmt,(SQLCHAR*)"CREATE TABLE test_testcolwisequery (" " key1 VARCHAR(250)," " key2 VARCHAR(250)," " value1 VARCHAR(250)," " value2 VARCHAR(250)," " primary key(key1,key2))",SQL_NTS))) goto fail; for (row=0; row < NUMBEROF_TEST_ROWS; row++) { char key1[200],key2[200],value1[200]; char sqlcmd[512]; sprintf(key1,"%d000",row); sprintf(key2,"%d001",row); sprintf(value1,"%d002",row); sprintf(sqlcmd,"INSERT INTO test_testcolwisequery(key1,key2,value1) values( '%s' , '%s' , '%s' )", key1,key2,value1); if (!CHECK(SQL_HANDLE_STMT,stmt,SQLExecDirect(stmt,(SQLCHAR*)sqlcmd,SQL_NTS))) goto fail; if (row % 10000 == 0) { if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) goto fail; } if (row == nextVacuum) { if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) goto fail; if (!CHECK(SQL_HANDLE_STMT,stmt,SQLExecDirect(stmt,(SQLCHAR*)"VACUUM ANALYZE test_testcolwisequery",SQL_NTS))) goto fail; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) goto fail; nextVacuum *=2; } } if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) goto fail; SQLFreeHandle(SQL_HANDLE_STMT,stmt); if (NUMBEROF_TEST_ROWS > 100) printf("INITIALIZATION OF %d ROWS DONE.\n",NUMBEROF_TEST_ROWS); return 1; fail: SQLFreeHandle(SQL_HANDLE_STMT,stmt); return 0; } int DropTestEnv(SQLHANDLE m_env,SQLHANDLE m_conn) { SQLHANDLE stmt; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLAllocHandle(SQL_HANDLE_STMT,m_conn,&stmt))) return 1; if (!CHECK(SQL_HANDLE_STMT,stmt,SQLExecDirect(stmt,(SQLCHAR*)"DROP TABLE test_testcolwisequery",SQL_NTS))) goto fail; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) goto fail; SQLFreeHandle(SQL_HANDLE_STMT,stmt); return 1; fail: SQLFreeHandle(SQL_HANDLE_STMT,stmt); return 0; } // PREPARATIONS END #define TEXT_SIZE 300 SQLINTEGER data_len[2]; char data[2][TEXT_SIZE]; void initBufs() { data_len[0]=-123; data_len[1]=-123; strcpy(data[0],"UNSET"); strcpy(data[1],"UNSET"); } void PrintData(char *msg,SQLUINTEGER nrows) { unsigned int i; printf("%s: ",msg); for (i=0; i<nrows; i++) { if (i) printf(", "); printf("data[%d] = { %d, %s }",i+1,(int)data_len[i],data[i]); } printf("\n"); fflush(stdout); } /* You need the following definition: * CREATE TABLE test_testcolwisequery(value1 VARCHAR(100)); * * */ #define USERID "marko" #define DATABASE "marko" #define PASSWORD "marko" int main(int argc, char **argv) { SQLHANDLE m_env; SQLHANDLE m_conn; SQLHANDLE m_stmt; SQLUINTEGER fetchedRows; SQLINTEGER statuses[2]; SQLRETURN rc; if (SQL_SUCCESS != SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&m_env)) { fprintf(stderr,"Allocating ENV handle failed.\n"); return 1; } if (!CHECK(SQL_HANDLE_ENV,m_env,SQLSetEnvAttr(m_env, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3,0))) return 1; if (!CHECK(SQL_HANDLE_ENV,m_env,SQLAllocHandle(SQL_HANDLE_DBC,m_env,&m_conn))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLConnect(m_conn,(SQLCHAR*) DATABASE, SQL_NTS,(SQLCHAR*) USERID,SQL_NTS,(SQLCHAR*) PASSWORD,SQL_NTS))) return 1; if (!CreateInitialData(m_env,m_conn)) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLAllocHandle(SQL_HANDLE_STMT,m_conn,&m_stmt))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLSetStmtAttr(m_stmt, SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN,0))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLSetStmtAttr(m_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (void*)2,0))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLSetStmtAttr(m_stmt, SQL_ATTR_ROW_STATUS_PTR, statuses,0))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLSetStmtAttr(m_stmt, SQL_ATTR_ROWS_FETCHED_PTR, &fetchedRows,0))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLBindCol(m_stmt,1, // Column number SQL_C_CHAR, // C data type &data[0], // parameter value ptr TEXT_SIZE, // buffer length (SQLINTEGER*)&data_len[0]))) // string length ptr return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLExecDirect(m_stmt,(SQLCHAR*) "SELECT key2 FROM test_testcolwisequery", SQL_NTS))) return 1; initBufs(); while ( (rc = SQLFetchScroll(m_stmt,SQL_FETCH_NEXT, 0)) != SQL_NO_DATA) { PrintData("After colwise query",fetchedRows); initBufs(); } if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLFreeStmt(m_stmt,SQL_CLOSE))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) return 1; // if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_ROLLBACK))) // return 1; if (!DropTestEnv(m_env,m_conn)) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLTransact(m_env,m_conn,SQL_COMMIT))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLFreeStmt(m_stmt,SQL_DROP))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLDisconnect(m_conn))) return 1; if (!CHECK(SQL_HANDLE_ENV,m_env,SQLFreeConnect(m_conn))) return 1; if (SQL_SUCCESS != SQLFreeEnv(m_env)) { fprintf(stderr,"Connect env freeing failed\n"); return 1; } fprintf(stderr,"ok.\n"); return 0; }
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: Fix for  Declare/Fetch issue
@ 2005-10-31 19:59 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 6+ messages in thread

From: Dave Page @ 2005-10-31 19:59 UTC (permalink / raw)
  To: Anoop Kumar <anoopk@pervasive-postgres.com>; pgsql-odbc; +Cc: Victor Rivero <vrivero@cantv.net>

 

> -----Original Message-----
> From: Anoop Kumar [mailto:anoopk@pervasive-postgres.com] 
> Sent: 26 October 2005 07:24
> To: pgsql-odbc@postgresql.org; Dave Page
> Cc: Victor Rivero
> Subject: Fix for Declare/Fetch issue
> 
> Hi All,
> 
> Please find attached the patch for Declare/Fetch issue. Sorry for the
> delay, but it took a while to get it right. 
> 
> Dave, please test it before I commit changes to CVS. 

OK, it appears OK in my simple tests, though I note that Marko has
spotted an issue. I've committed the fix for now, as it is definitely
better than it was.

Thanks guys.

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix for  Declare/Fetch issue
@ 2005-10-31 20:01 Dave Page <dpage@vale-housing.co.uk>
  0 siblings, 0 replies; 6+ messages in thread

From: Dave Page @ 2005-10-31 20:01 UTC (permalink / raw)
  To: Marko Ristola <Marko.Ristola@kolumbus.fi>; +Cc: Anoop Kumar <anoopk@pervasive-postgres.com>; pgsql-odbc; Victor Rivero <vrivero@cantv.net>

 

> -----Original Message-----
> From: Marko Ristola [mailto:Marko.Ristola@kolumbus.fi] 
> Sent: 30 October 2005 14:07
> To: Dave Page
> Cc: Anoop Kumar; pgsql-odbc@postgresql.org; Victor Rivero
> Subject: Re: [ODBC] Fix for Declare/Fetch issue
> 
> 
> My test case failed.
> 
> I tested only column wise query.
> It returned the correct number of rows, but only the first 
> cursor fetch got
> correct data.

Hmm, OK. I don't have time for at least a couple of days to look further
- Anoop, can you confirm/fix the bug? Just for info, we are hoping to
release 8.1 early next week, so I need to ideally get things sorted by
the end of this week.

Regards, Dave.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2005-10-31 20:01 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-26 06:23 Fix for  Declare/Fetch issue Anoop Kumar <anoopk@pervasive-postgres.com>
2005-10-27 05:47 ` Dave Page <dpage@vale-housing.co.uk>
2005-10-27 19:14   ` Marko Ristola <marko.ristola@kolumbus.fi>
2005-10-30 14:07   ` Marko Ristola <Marko.Ristola@kolumbus.fi>
2005-10-31 19:59 Re: Fix for  Declare/Fetch issue Dave Page <dpage@vale-housing.co.uk>
2005-10-31 20:01 Re: Fix for  Declare/Fetch issue Dave Page <dpage@vale-housing.co.uk>

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