From 8c26d4000d99e2bc9ae68cd6d7e415e557829d47 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Sun, 23 Nov 2008 01:00:53 +0000 Subject: [PATCH] The version is now 8.3.0401. 1) Avoid a crash on exit when using SSL connections by resetting CRTPTO_xx_callbacks before unloding libpq. 2) Correct the funtion name DiscardRollbackState pointed out by Zoltan Boszormenyi. 3) Correct the value of INDEX_QUALIFIER column which returned by SLQSTATISTICS(); --- info.c | 4 ++-- loadlib.c | 22 +++++++++++++++++++++- odbcapi.c | 2 +- psqlodbc.h | 6 +++--- version.h | 8 ++++---- win32.mak | 5 +++++ win64.mak | 9 +++++++-- 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/info.c b/info.c index 734444e..3f982f8 100644 --- a/info.c +++ b/info.c @@ -3241,7 +3241,7 @@ PGAPI_Statistics( set_tuplefield_int2(&tuple[STATS_NON_UNIQUE], (Int2) (ci->drivers.unique_index ? FALSE : TRUE)); /* no index qualifier */ - set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], CurrCat(conn)); + set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], GET_SCHEMA_NAME(table_schemaname)); snprintf(buf, sizeof(table_name), "%s_idx_fake_oid", table_name); set_tuplefield_string(&tuple[STATS_INDEX_NAME], buf); @@ -3286,7 +3286,7 @@ PGAPI_Statistics( set_tuplefield_int2(&tuple[STATS_NON_UNIQUE], TRUE); /* no index qualifier */ - set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], CurrCat(conn)); + set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], GET_SCHEMA_NAME(table_schemaname)); set_tuplefield_string(&tuple[STATS_INDEX_NAME], index_name); /* diff --git a/loadlib.c b/loadlib.c index 1ad6348..8442b38 100644 --- a/loadlib.c +++ b/loadlib.c @@ -15,6 +15,9 @@ #include #endif /* WIN32 */ #ifndef NOT_USE_LIBPQ +#ifdef RESET_CRYPTO_CALLBACKS +#include +#endif /* RESET_CRYPTO_CALLBACKS */ #include #endif /* NOT_USE_LIBPQ */ #include "loadlib.h" @@ -26,6 +29,9 @@ #ifndef NOT_USE_LIBPQ #pragma comment(lib, "libpq") #pragma comment(lib, "ssleay32") +#ifdef RESET_CRYPTO_CALLBACKS +#pragma comment(lib, "libeay32") +#endif /* RESET_CRYPTO_CALLBACKS */ #endif /* NOT_USE_LIBPQ */ #ifdef _HANDLE_ENLIST_IN_DTC_ #ifdef UNICODE_SUPPORT @@ -40,6 +46,9 @@ #ifndef NOT_USE_LIBPQ #pragma comment(linker, "/Delayload:libpq.dll") #pragma comment(linker, "/Delayload:ssleay32.dll") +#ifdef RESET_CRYPTO_CALLBACKS +#pragma comment(linker, "/Delayload:libeay32.dll") +#endif /* RESET_CRYPTO_CALLBACKS */ #endif /* NOT_USE_LIBPQ */ #ifdef UNICODE_SUPPORT #pragma comment(linker, "/Delayload:pgenlist.dll") @@ -115,7 +124,7 @@ DliErrorHook(unsigned dliNotify, int i; static const char * const libarray[] = {"libssl32", "ssleay32"}; - mylog("Dli%sHook Notify=%d %p\n", (dliFailLoadLib == dliNotify || dliFailGetProc == dliNotify) ? "Error" : "Notify", dliNotify, pdli); + mylog("Dli%sHook %s Notify=%d\n", (dliFailLoadLib == dliNotify || dliFailGetProc == dliNotify) ? "Error" : "Notify", NULL != pdli->szDll ? pdli->szDll : pdli->dlp.szProcName, dliNotify); switch (dliNotify) { case dliNotePreLoadLibrary: @@ -172,6 +181,17 @@ void CleanupDelayLoadedDLLs(void) /* The dll names are case sensitive for the unload helper */ if (loaded_libpq) { +#ifdef RESET_CRYPTO_CALLBACKS + /* + * May be needed to avoid crash on exit + * when libpq doesn't reset the callbacks. + */ + CRYPTO_set_locking_callback(NULL); + CRYPTO_set_id_callback(NULL); + mylog("passed RESET_CRYPTO_CALLBACKS\n"); +#else + mylog("not passed RESET_CRYPTO_CALLBACKS\n"); +#endif /* RESET_CRYPTO_CALLBACKS */ success = (*func)(libpqdll); mylog("%s unload success=%d\n", libpqdll, success); } diff --git a/odbcapi.c b/odbcapi.c index 8f8cadf..e07571d 100644 --- a/odbcapi.c +++ b/odbcapi.c @@ -573,7 +573,7 @@ SQLGetStmtOption(HSTMT StatementHandle, SC_clear_error(stmt); StartRollbackState(stmt); ret = PGAPI_GetStmtOption(StatementHandle, Option, Value, NULL, 64); - ret = DiscardRollbackState(stmt, ret, FALSE); + ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); return ret; } diff --git a/psqlodbc.h b/psqlodbc.h index df682b1..f38db0e 100644 --- a/psqlodbc.h +++ b/psqlodbc.h @@ -5,7 +5,7 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.123 2008/09/21 15:35:44 hinoue Exp $ + * $Id: psqlodbc.h,v 1.124 2008/11/23 01:00:53 hinoue Exp $ * */ @@ -119,8 +119,8 @@ typedef UInt4 OID; #define FORMAT_ULPTR "%lu" /* ULONG_PTR */ #endif /* _WIN64 */ #else -#define FORMAT_SIZE_T "%xu" /* size_t */ -#define FORMAT_SSIZE_T "%xd" /* ssize_t */ +#define FORMAT_SIZE_T "%zu" /* size_t */ +#define FORMAT_SSIZE_T "%zd" /* ssize_t */ #ifndef HAVE_SSIZE_T typedef long ssize_t #endif /* HAVE_SSIZE_T */ diff --git a/version.h b/version.h index f465ae3..31dcd0f 100644 --- a/version.h +++ b/version.h @@ -9,9 +9,9 @@ #ifndef __VERSION_H__ #define __VERSION_H__ -#define POSTGRESDRIVERVERSION "08.03.0400" -#define POSTGRES_RESOURCE_VERSION "08.03.0400\0" -#define PG_DRVFILE_VERSION 8,3,04,00 -#define PG_BUILD_VERSION "200811070001" +#define POSTGRESDRIVERVERSION "08.03.0401" +#define POSTGRES_RESOURCE_VERSION "08.03.0401\0" +#define PG_DRVFILE_VERSION 8,3,04,01 +#define PG_BUILD_VERSION "200811230001" #endif diff --git a/win32.mak b/win32.mak index a0996d4..45c0e42 100644 --- a/win32.mak +++ b/win32.mak @@ -70,6 +70,7 @@ SSL_LIB=C:\OpenSSL\lib\VC !IF "$(USE_LIBPQ)" != "no" SSL_DLL = "SSLEAY32.dll" +RESET_CRYPTO = yes ADD_DEFINES = $(ADD_DEFINES) /D "SSL_DLL=\"$(SSL_DLL)\"" /D USE_SSL !ELSE ADD_DEFINES = $(ADD_DEFINES) /D NOT_USE_LIBPQ @@ -94,6 +95,10 @@ VC_FLAGS=/GX /YX MSVC_VERSION=vc70 !IF "$(USE_LIBPQ)" != "no" VC07_DELAY_LOAD=/DelayLoad:libpq.dll /DelayLoad:$(SSL_DLL) +!IF "$(RESET_CRYPTO)" == "yes" +VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DelayLoad:libeay32.dll +ADD_DEFINES=$(ADD_DEFINES) /D RESET_CRYPTO_CALLBACKS +!ENDIF !ENDIF !IF "$(USE_SSPI)" == "yes" VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /Delayload:secur32.dll /Delayload:crypt32.dll diff --git a/win64.mak b/win64.mak index fbbfcb4..b4c4a94 100755 --- a/win64.mak +++ b/win64.mak @@ -69,6 +69,7 @@ SSL_LIB="C:\develop\lib\$(CPU)" !ENDIF SSL_DLL = "SSLEAY32.dll" +RESET_CRYPTO = yes ADD_DEFINES = $(ADD_DEFINES) /D "SSL_DLL=\"$(SSL_DLL)\"" /D USE_SSL !ELSE ADD_DEFINES = $(ADD_DEFINES) /D NOT_USE_LIBPQ @@ -90,12 +91,16 @@ VC07_DELAY_LOAD= MSDTC=no !ELSE !IF "$(USE_LIBPQ)" != "no" -VC07_DELAY_LOAD="/DelayLoad:libpq.dll /DelayLoad:$(SSL_DLL) +VC07_DELAY_LOAD=/DelayLoad:libpq.dll /DelayLoad:$(SSL_DLL) +!IF "$(RESET_CRYPTO)" == "yes" +VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DelayLoad:libeay32.dll +ADD_DEFINES=$(ADD_DEFINES) /D RESET_CRYPTO_CALLBACKS +!ENDIF !ENDIF !IF "$(USE_SSPI)" == "yes" VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DelayLoad:secur32.dll /Delayload:crypt32.dll !ENDIF -VC07_DELAY_LOAD=$(VC07_DELAY_LOAD) /DelayLoad:$(DTCDLL) /DELAY:UNLOAD" +VC07_DELAY_LOAD="$(VC07_DELAY_LOAD) /DelayLoad:$(DTCDLL) /DELAY:UNLOAD" !ENDIF ADD_DEFINES = $(ADD_DEFINES) /D "DYNAMIC_LOAD" -- 2.39.5