From 93e17f794fc66f106ba0f5c5c2bfcbf16c8f1c1c Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Mon, 11 Dec 2006 11:34:28 +0000 Subject: [PATCH] More changes for setup Dialog test button operation. Fix the bug SQLStatistics ORDINAL_POSITION starts at 2 for PK index. --- environ.h | 4 ++-- info.c | 2 +- setup.c | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/environ.h b/environ.h index 8f4f9e8..7b47012 100644 --- a/environ.h +++ b/environ.h @@ -45,10 +45,10 @@ void EN_log_error(const char *func, char *desc, EnvironmentClass *self); #define EN_OV_ODBC2 1L #define EN_CONN_POOLING (1L<<1) #define EN_is_odbc2(env) ((env->flag & EN_OV_ODBC2) != 0) -#define EN_is_odbc3(env) ((env->flag & EN_OV_ODBC2) == 0) +#define EN_is_odbc3(env) (env && (env->flag & EN_OV_ODBC2) == 0) #define EN_set_odbc2(env) (env->flag |= EN_OV_ODBC2) #define EN_set_odbc3(env) (env->flag &= ~EN_OV_ODBC2) -#define EN_is_pooling(env) ((env->flag & EN_CONN_POOLING) != 0) +#define EN_is_pooling(env) (env && (env->flag & EN_CONN_POOLING) != 0) #define EN_set_pooling(env) (env->flag |= EN_CONN_POOLING) #define EN_unset_pooling(env) (env->flag &= ~EN_CONN_POOLING) diff --git a/info.c b/info.c index 00e4081..0bc8c93 100644 --- a/info.c +++ b/info.c @@ -3217,7 +3217,7 @@ PGAPI_Statistics( set_tuplefield_int2(&tuple[STATS_TYPE], (Int2) (atoi(isclustered) ? SQL_INDEX_CLUSTERED : (!strncmp(ishash, "hash", 4)) ? SQL_INDEX_HASHED : SQL_INDEX_OTHER)); - set_tuplefield_int2(&tuple[STATS_SEQ_IN_INDEX], (Int2) (i + 1)); + set_tuplefield_int2(&tuple[STATS_SEQ_IN_INDEX], (Int2) i); attnum = fields_vector[i]; if (OID_ATTNUM == attnum) diff --git a/setup.c b/setup.c index 59c2d34..fca852f 100644 --- a/setup.c +++ b/setup.c @@ -15,6 +15,7 @@ #include "psqlodbc.h" +#include "environ.h" #include "connection.h" #include #include @@ -290,15 +291,19 @@ ConfigDlgProc(HWND hdlg, lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER); if (NULL != lpsetupdlg) { - ConnectionClass *conn=CC_Constructor(); + EnvironmentClass *env = EN_Constructor(); + ConnectionClass *conn = NULL; char szMsg[SQL_MAX_MESSAGE_LENGTH]; /* Get Dialog Values */ GetDlgStuff(hdlg, &lpsetupdlg->ci); + if (env) + conn = CC_Constructor(); if (conn) { char *emsg; + EN_add_connection(env, conn); memcpy(&conn->connInfo, &lpsetupdlg->ci, sizeof(ConnInfo)); CC_initialize_pg_version(conn); if (CC_connect(conn, AUTH_REQ_OK, NULL) > 0) @@ -313,9 +318,12 @@ ConfigDlgProc(HWND hdlg, CC_get_error(conn, &errnum, &emsg); } MessageBox(lpsetupdlg->hwndParent, emsg, "Connection Test", MB_ICONEXCLAMATION | MB_OK); + EN_remove_connection(env, conn); CC_Destructor(conn); - return TRUE; } + if (env) + EN_Destructor(env); + return TRUE; } break; } -- 2.39.5