diff -uNr psqlodbc-08.01.0102/execute.c psqlodbc-08.01.0102-1/execute.c --- psqlodbc-08.01.0102/execute.c 2005-12-01 12:03:54.000000000 +0300 +++ psqlodbc-08.01.0102-1/execute.c 2005-12-09 10:06:15.000000000 +0300 @@ -720,6 +720,7 @@ * the application. */ + ENTER_STMT_CS_CANCEL(stmt); #ifdef WIN32 if (ci->drivers.cancel_as_freestmt) { @@ -732,6 +733,7 @@ #else result = PGAPI_FreeStmt(hstmt, SQL_CLOSE); #endif + LEAVE_STMT_CS_CANCEL(stmt); mylog("PGAPI_Cancel: PGAPI_FreeStmt returned %d\n", result); diff -uNr psqlodbc-08.01.0102/odbcapi30.c psqlodbc-08.01.0102-1/odbcapi30.c --- psqlodbc-08.01.0102/odbcapi30.c 2005-10-20 17:06:10.000000000 +0400 +++ psqlodbc-08.01.0102-1/odbcapi30.c 2005-12-09 10:06:58.000000000 +0300 @@ -173,6 +173,7 @@ mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset); ENTER_STMT_CS(stmt); + ENTER_STMT_CS_CANCEL(stmt); SC_clear_error(stmt); if (FetchOrientation == SQL_FETCH_BOOKMARK) { @@ -197,6 +198,7 @@ pcRow, rowStatusArray, bkmarkoff, opts->size_of_rowset); stmt->transition_status = 6; } + LEAVE_STMT_CS_CANCEL(stmt); LEAVE_STMT_CS(stmt); if (ret != SQL_SUCCESS) mylog("%s return = %d\n", func, ret); diff -uNr psqlodbc-08.01.0102/odbcapi.c psqlodbc-08.01.0102-1/odbcapi.c --- psqlodbc-08.01.0102/odbcapi.c 2005-10-20 17:06:10.000000000 +0400 +++ psqlodbc-08.01.0102-1/odbcapi.c 2005-12-09 10:07:52.000000000 +0300 @@ -328,6 +328,7 @@ StatementClass *stmt = (StatementClass *) StatementHandle; ENTER_STMT_CS(stmt); + ENTER_STMT_CS_CANCEL(stmt); SC_clear_error(stmt); if (SC_get_conn(stmt)->driver_version >= 0x0300) { @@ -346,6 +347,7 @@ mylog("[%s]", func); ret = PGAPI_Fetch(StatementHandle); } + LEAVE_STMT_CS_CANCEL(stmt); LEAVE_STMT_CS(stmt); return ret; } @@ -864,9 +866,11 @@ mylog("[SQLExtendedFetch]"); ENTER_STMT_CS(stmt); + ENTER_STMT_CS_CANCEL(stmt); SC_clear_error(stmt); ret = PGAPI_ExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus, 0, SC_get_ARDF(stmt)->size_of_rowset_odbc2); stmt->transition_status = 7; + LEAVE_STMT_CS_CANCEL(stmt); LEAVE_STMT_CS(stmt); return ret; } diff -uNr psqlodbc-08.01.0102/statement.c psqlodbc-08.01.0102-1/statement.c --- psqlodbc-08.01.0102/statement.c 2005-12-01 12:03:55.000000000 +0300 +++ psqlodbc-08.01.0102-1/statement.c 2005-12-09 10:08:19.000000000 +0300 @@ -316,6 +316,7 @@ GetDataInfoInitialize(SC_get_GDTI(rv)); PutDataInfoInitialize(SC_get_PDTI(rv)); INIT_STMT_CS(rv); + INIT_STMT_CS_CANCEL(rv); } return rv; } @@ -373,6 +374,7 @@ GDATA_unbind_cols(SC_get_GDTI(self), TRUE); DELETE_STMT_CS(self); + DELETE_STMT_CS_CANCEL(self); if (self->pdata_info.pdata != 0) free(self->pdata_info.pdata); free(self); diff -uNr psqlodbc-08.01.0102/statement.h psqlodbc-08.01.0102-1/statement.h --- psqlodbc-08.01.0102/statement.h 2005-10-31 22:57:06.000000000 +0300 +++ psqlodbc-08.01.0102-1/statement.h 2005-12-09 10:12:19.000000000 +0300 @@ -224,8 +224,10 @@ NeedDataCallback *callbacks; #if defined(WIN_MULTITHREAD_SUPPORT) CRITICAL_SECTION cs; + CRITICAL_SECTION csc; /* CS for CANCEL */ #elif defined(POSIX_THREADMUTEX_SUPPORT) pthread_mutex_t cs; + pthread_mutex_t csc; /* CS for CANCEL */ #endif /* WIN_MULTITHREAD_SUPPORT */ }; @@ -293,16 +295,28 @@ #define ENTER_STMT_CS(x) EnterCriticalSection(&((x)->cs)) #define LEAVE_STMT_CS(x) LeaveCriticalSection(&((x)->cs)) #define DELETE_STMT_CS(x) DeleteCriticalSection(&((x)->cs)) +#define INIT_STMT_CS_CANCEL(x) InitializeCriticalSection(&((x)->csc)) +#define ENTER_STMT_CS_CANCEL(x) EnterCriticalSection(&((x)->csc)) +#define LEAVE_STMT_CS_CANCEL(x) LeaveCriticalSection(&((x)->csc)) +#define DELETE_STMT_CS_CANCEL(x) DeleteCriticalSection(&((x)->csc)) #elif defined(POSIX_THREADMUTEX_SUPPORT) #define INIT_STMT_CS(x) pthread_mutex_init(&((x)->cs),0) #define ENTER_STMT_CS(x) pthread_mutex_lock(&((x)->cs)) #define LEAVE_STMT_CS(x) pthread_mutex_unlock(&((x)->cs)) #define DELETE_STMT_CS(x) pthread_mutex_destroy(&((x)->cs)) +#define INIT_STMT_CS_CANCEL(x) pthread_mutex_init(&((x)->csc),0) +#define ENTER_STMT_CS_CANCEL(x) pthread_mutex_lock(&((x)->csc)) +#define LEAVE_STMT_CS_CANCEL(x) pthread_mutex_unlock(&((x)->csc)) +#define DELETE_STMT_CS_CANCEL(x) pthread_mutex_destroy(&((x)->csc)) #else #define INIT_STMT_CS(x) #define ENTER_STMT_CS(x) ((void)(0)) #define LEAVE_STMT_CS(x) ((void)(0)) #define DELETE_STMT_CS(x) +#define INIT_STMT_CS_CANCEL(x) +#define ENTER_STMT_CS_CANCEL(x) +#define LEAVE_STMT_CS_CANCEL(x) +#define DELETE_STMT_CS_CANCEL(x) #endif /* WIN_MULTITHREAD_SUPPORT */ /* Statement prototypes */ StatementClass *SC_Constructor(void); =