From f2ec8019c738c4c3603087e9f06073478b7664ef Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Wed, 26 Dec 2007 13:28:36 +0000 Subject: [PATCH] *** empty log message *** --- connection.c | 36 ++++++++++++++++++++++++++---------- convert.c | 12 +++++++++--- dlg_specific.c | 29 ++++++++++++++++++++++------- dlg_specific.h | 2 ++ loadlib.c | 6 ++++-- multibyte.c | 2 +- options.c | 27 +++++++++++++++++++++++---- pgtypes.c | 3 ++- pgtypes.h | 2 ++ statement.c | 3 +-- version.h | 2 +- 11 files changed, 93 insertions(+), 31 deletions(-) diff --git a/connection.c b/connection.c index 6bf428c..1019e66 100644 --- a/connection.c +++ b/connection.c @@ -812,7 +812,7 @@ handle_error_message(ConnectionClass *self, char *msgbuf, size_t buflen, char *s } inolog("new_format=%d\n", new_format); - truncated = SOCK_get_string(sock, msgbuffer, sizeof(msgbuffer)); + truncated = SOCK_get_string(sock, new_format ? msgbuffer : msgbuf, new_format ? sizeof(msgbuffer) : buflen); if (new_format) { size_t msgl; @@ -870,14 +870,14 @@ inolog("new_format=%d\n", new_format); } else { - strncpy(msgbuf, msgbuffer, buflen); + msg_truncated = truncated; /* Remove a newline */ if (msgbuf[0] != '\0' && msgbuf[(int)strlen(msgbuf) - 1] == '\n') msgbuf[(int)strlen(msgbuf) - 1] = '\0'; mylog("%s: 'E' - %s\n", comment, msgbuf); qlog("ERROR from backend during %s: '%s'\n", comment, msgbuf); - for (truncated = msg_truncated; truncated;) + while (truncated) truncated = SOCK_get_string(sock, msgbuffer, sizeof(msgbuffer)); } abort_opt = 0; @@ -1813,7 +1813,7 @@ CC_connect(ConnectionClass *self, char password_req, char *salt_para) { ConnInfo *ci = &(self->connInfo); CSTR func = "CC_connect"; - char ret; + char ret, *saverr = NULL; #ifndef NOT_USE_LIBPQ BOOL call_libpq = FALSE; #endif /* NOT_USE_LIBPQ */ @@ -1878,6 +1878,8 @@ CC_connect(ConnectionClass *self, char password_req, char *salt_para) inolog("CC_send_settings\n"); CC_send_settings(self); + if (CC_get_errornumber(self) > 0) + saverr = strdup(CC_get_errormsg(self)); CC_clear_error(self); /* clear any error */ CC_lookup_lo(self); /* a hack to get the oid of our large object oid type */ @@ -1889,7 +1891,10 @@ inolog("CC_send_settings\n"); { CC_lookup_characterset(self); if (CC_get_errornumber(self) > 0) - return 0; + { + ret = 0; + goto cleanup; + } #ifdef UNICODE_SUPPORT if (CC_is_in_unicode_driver(self)) { @@ -1900,7 +1905,8 @@ inolog("CC_send_settings\n"); if (PG_VERSION_LT(self, 7.1)) { CC_set_error(self, CONN_NOT_IMPLEMENTED_ERROR, "UTF-8 conversion isn't implemented before 7.1", func); - return 0; + ret = 0; + goto cleanup; } if (self->original_client_encoding) free(self->original_client_encoding); @@ -1922,7 +1928,8 @@ inolog("CC_send_settings\n"); else if (CC_is_in_unicode_driver(self)) { CC_set_error(self, CONN_NOT_IMPLEMENTED_ERROR, "Unicode isn't supported before 6.4", func); - return 0; + ret = 0; + goto cleanup; } #endif /* UNICODE_SUPPORT */ ci->updatable_cursors = DISALLOW_UPDATABLE_CURSORS; @@ -1945,10 +1952,18 @@ inolog("CC_send_settings\n"); && 0 < ci->bde_environment) self->unicode |= CONN_DISALLOW_WCHAR; mylog("conn->unicode=%d\n", self->unicode); + ret = 1; - mylog("%s: returning...\n", func); +cleanup: + mylog("%s: returning...%d\n", func, ret); + if (NULL != saverr) + { + if (ret > 0 && CC_get_errornumber(self) <= 0) + CC_set_error(self, -1, saverr, func); + free(saverr); + } - return 1; + return ret; } @@ -2877,7 +2892,8 @@ cleanup: CC_set_errornumber(self, 0); else if (retres) { - if ((!CC_get_errormsg(self) || !CC_get_errormsg(self)[0])) + if (NULL == CC_get_errormsg(self) || + !CC_get_errormsg(self)[0]) CC_set_errormsg(self, QR_get_message(retres)); if (!self->sqlstate[0]) strcpy(self->sqlstate, retres->sqlstate); diff --git a/convert.c b/convert.c index 3599fa5..6be6707 100644 --- a/convert.c +++ b/convert.c @@ -652,9 +652,10 @@ mylog("null_cvt_date_string=%d\n", conn->connInfo.cvt_null_date_string); if (strnicmp(value, MINFINITY_STRING, 9) == 0) { std_time.infinity = -1; - std_time.m = 0; - std_time.d = 0; - std_time.y = 0; + std_time.m = 1; + std_time.d = 1; + // std_time.y = -4713; + std_time.y = -9999; std_time.hh = 0; std_time.mm = 0; std_time.ss = 0; @@ -817,9 +818,11 @@ inolog("2stime fr=%d\n", std_time.fr); case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: + case PG_TYPE_XML: case PG_TYPE_BPCHARARRAY: case PG_TYPE_VARCHARARRAY: case PG_TYPE_TEXTARRAY: + case PG_TYPE_XMLARRAY: text_handling = TRUE; break; } @@ -3771,6 +3774,7 @@ mylog("cvt_null_date_string=%d pgtype=%d buf=%p\n", conn->connInfo.cvt_null_date } if (!req_bind) { +mylog("!!param_type=%d\n", param_sqltype); switch (param_sqltype) { case SQL_INTEGER: @@ -3779,6 +3783,7 @@ mylog("cvt_null_date_string=%d pgtype=%d buf=%p\n", conn->connInfo.cvt_null_date case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: + case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: #ifdef UNICODE_SUPPORT @@ -3786,6 +3791,7 @@ mylog("cvt_null_date_string=%d pgtype=%d buf=%p\n", conn->connInfo.cvt_null_date case SQL_WVARCHAR: case SQL_WLONGVARCHAR: #endif /* UNICODE_SUPPORT */ +mylog("buf=%p flag=%d\n", buf, qb->flags); if (buf && (qb->flags & FLGB_LITERAL_EXTENSION) != 0) { CVT_APPEND_CHAR(qb, LITERAL_EXT); diff --git a/dlg_specific.c b/dlg_specific.c index 3fe352d..8e295fe 100644 --- a/dlg_specific.c +++ b/dlg_specific.c @@ -30,18 +30,21 @@ extern GLOBAL_VALUES globals; static void encode(const UCHAR *in, UCHAR *out); static void decode(const UCHAR *in, UCHAR *out); +#define OVR_EXTRA_BITS (BIT_FORCEABBREVCONNSTR | BIT_FAKE_MSS | BIT_BDE_ENVIRONMENT | BIT_CVT_NULL_DATE | BIT_ACCESSIBLE_ONLY) UInt4 getExtraOptions(const ConnInfo *ci) { - UInt4 flag = 0; + UInt4 flag = ci->extra_opts & (~OVR_EXTRA_BITS); - if (ci->force_abbrev_connstr) + if (ci->force_abbrev_connstr > 0) flag |= BIT_FORCEABBREVCONNSTR; - if (ci->fake_mss) + if (ci->fake_mss > 0) flag |= BIT_FAKE_MSS; - if (ci->bde_environment) + if (ci->bde_environment > 0) flag |= BIT_BDE_ENVIRONMENT; - if (ci->cvt_null_date_string) + if (ci->cvt_null_date_string > 0) flag |= BIT_CVT_NULL_DATE; + if (ci->accessible_only > 0) + flag |= BIT_ACCESSIBLE_ONLY; return flag; } @@ -51,6 +54,10 @@ CSTR dec_format = "%u"; CSTR octal_format = "%o"; static UInt4 replaceExtraOptions(ConnInfo *ci, UInt4 flag, BOOL overwrite) { + if (overwrite) + ci->extra_opts = flag; + else + ci->extra_opts |= (flag & ~(OVR_EXTRA_BITS)); if (overwrite || ci->force_abbrev_connstr < 0) ci->force_abbrev_connstr = (0 != (flag & BIT_FORCEABBREVCONNSTR)); if (overwrite || ci->fake_mss < 0) @@ -59,8 +66,10 @@ static UInt4 replaceExtraOptions(ConnInfo *ci, UInt4 flag, BOOL overwrite) ci->bde_environment = (0 != (flag & BIT_BDE_ENVIRONMENT)); if (overwrite || ci->cvt_null_date_string < 0) ci->cvt_null_date_string = (0 != (flag & BIT_CVT_NULL_DATE)); + if (overwrite || ci->accessible_only < 0) + ci->accessible_only = (0 != (flag & BIT_ACCESSIBLE_ONLY)); - return getExtraOptions(ci); + return (ci->extra_opts = getExtraOptions(ci)); } BOOL setExtraOptions(ConnInfo *ci, const char *optstr, const char *format) { @@ -96,6 +105,8 @@ BOOL setExtraOptions(ConnInfo *ci, const char *optstr, const char *format) } UInt4 add_removeExtraOptions(ConnInfo *ci, UInt4 aflag, UInt4 dflag) { + ci->extra_opts |= aflag; + ci->extra_opts &= (~dflag); if (0 != (aflag & BIT_FORCEABBREVCONNSTR)) ci->force_abbrev_connstr = TRUE; if (0 != (aflag & BIT_FAKE_MSS)) @@ -104,14 +115,18 @@ UInt4 add_removeExtraOptions(ConnInfo *ci, UInt4 aflag, UInt4 dflag) ci->bde_environment = TRUE; if (0 != (aflag & BIT_CVT_NULL_DATE)) ci->cvt_null_date_string = TRUE; + if (0 != (aflag & BIT_ACCESSIBLE_ONLY)) + ci->accessible_only = TRUE; if (0 != (dflag & BIT_FORCEABBREVCONNSTR)) ci->force_abbrev_connstr = FALSE; if (0 != (dflag & BIT_FAKE_MSS)) ci->fake_mss =FALSE; if (0 != (dflag & BIT_CVT_NULL_DATE)) ci->cvt_null_date_string = FALSE; + if (0 != (dflag & BIT_ACCESSIBLE_ONLY)) + ci->accessible_only = FALSE; - return getExtraOptions(ci); + return (ci->extra_opts = getExtraOptions(ci)); } void diff --git a/dlg_specific.h b/dlg_specific.h index aafb945..abeacff 100644 --- a/dlg_specific.h +++ b/dlg_specific.h @@ -188,6 +188,8 @@ const char *GetXaLibPath(); #define BIT_FAKE_MSS (1L << 1) #define BIT_BDE_ENVIRONMENT (1L << 2) #define BIT_CVT_NULL_DATE (1L << 3) +#define BIT_ACCESSIBLE_ONLY (1L << 4) +#define BIT_IGNORE_ROUND_TRIP_TIME (1L << 5) /* Connection Defaults */ #define DEFAULT_PORT "5432" diff --git a/loadlib.c b/loadlib.c index bd3be58..1ad6348 100644 --- a/loadlib.c +++ b/loadlib.c @@ -288,7 +288,7 @@ BOOL SSLLIB_check() mylog("checking libpq library\n"); /* First search the driver's folder */ -#ifdef NOT_USE_LIBPQ +#ifndef NOT_USE_LIBPQ if (NULL == (hmodule = MODULE_load_from_psqlodbc_path(libpq))) /* Second try the PATH ordinarily */ hmodule = LoadLibrary(libpq); @@ -296,8 +296,10 @@ BOOL SSLLIB_check() #endif /* NOT_USE_LIBPQ */ #ifdef USE_SSPI if (NULL == hmodule) + { hmodule = LoadLibrary("secur32.dll"); - mylog("secur32 hmodule=%p\n", hmodule); + mylog("secur32 hmodule=%p\n", hmodule); + } #endif /* USE_SSPI */ if (hmodule) FreeLibrary(hmodule); diff --git a/multibyte.c b/multibyte.c index e3e579e..e2cccf9 100644 --- a/multibyte.c +++ b/multibyte.c @@ -654,7 +654,7 @@ CC_lookup_characterset(ConnectionClass *self) { char msg[256]; - snprintf(msg, sizeof(msg), "would handle the encoding '%s' like ASCII", tencstr); + snprintf(msg, sizeof(msg), "would handle the encoding '%s' like ASCII", tencstr); CC_set_error(self, CONN_OPTION_VALUE_CHANGED, msg, func); } } diff --git a/options.c b/options.c index 910d3e0..97644ff 100644 --- a/options.c +++ b/options.c @@ -425,10 +425,18 @@ PGAPI_SetConnectOption( PG_VERSION_LE(conn, 7.0)) retval = SQL_ERROR; break; + case SQL_TXN_REPEATABLE_READ: + if (PG_VERSION_LT(conn, 8.0)) + retval = SQL_ERROR; + break; case SQL_TXN_READ_COMMITTED: if (PG_VERSION_LT(conn, 6.5)) retval = SQL_ERROR; break; + case SQL_TXN_READ_UNCOMMITTED: + if (PG_VERSION_LT(conn, 8.0)) + retval = SQL_ERROR; + break; default: retval = SQL_ERROR; } @@ -442,10 +450,21 @@ PGAPI_SetConnectOption( char *query; QResultClass *res; - if (vParam == SQL_TXN_SERIALIZABLE) - query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE"; - else - query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED"; + switch (vParam) + { + case SQL_TXN_SERIALIZABLE: + query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE"; + break; + case SQL_TXN_REPEATABLE_READ: + query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ"; + break; + case SQL_TXN_READ_UNCOMMITTED: + query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED"; + break; + default: + query = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED"; + break; + } res = CC_send_query(conn, query, NULL, 0, NULL); if (!QR_command_maybe_successful(res)) retval = SQL_ERROR; diff --git a/pgtypes.c b/pgtypes.c index 2aae4c2..418ed16 100644 --- a/pgtypes.c +++ b/pgtypes.c @@ -358,7 +358,8 @@ pgtype_to_concise_type(StatementClass *stmt, OID type, int col) return SQL_FLOAT; case PG_TYPE_BOOL: return ci->drivers.bools_as_char ? SQL_CHAR : SQL_BIT; - + case PG_TYPE_XML: + return CC_is_in_unicode_driver(conn) ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR; default: /* diff --git a/pgtypes.h b/pgtypes.h index 09d57fd..a013026 100644 --- a/pgtypes.h +++ b/pgtypes.h @@ -36,6 +36,8 @@ #define PG_TYPE_CID 29 #define PG_TYPE_OIDVECTOR 30 #define PG_TYPE_SET 32 +#define PG_TYPE_XML 142 +#define PG_TYPE_XMLARRAY 143 #define PG_TYPE_CHAR2 409 #define PG_TYPE_CHAR4 410 #define PG_TYPE_CHAR8 411 diff --git a/statement.c b/statement.c index a806d76..472b346 100644 --- a/statement.c +++ b/statement.c @@ -1663,6 +1663,7 @@ inolog("curt=%d\n", curt); } +#include "dlg_specific.h" RETCODE SC_execute(StatementClass *self) { @@ -1818,10 +1819,8 @@ inolog("get_Result=%p\n", res); sprintf(fetch, "%s " FORMAT_LEN " in \"%s\"", fetch_cmd, qi.row_size, SC_cursor_name(self)); qryi = &qi; appendq = fetch; -#ifdef NOT_USED if (0 != (ci->extra_opts & BIT_IGNORE_ROUND_TRIP_TIME)) qflag |= IGNORE_ROUND_TRIP; -#endif /* NOT_USED */ } res = CC_send_query_append(conn, self->stmt_with_params, qryi, qflag, SC_get_ancestor(self), appendq); if (SC_is_fetchcursor(self) && QR_command_maybe_successful(res)) diff --git a/version.h b/version.h index 451aa36..55a9ee9 100644 --- a/version.h +++ b/version.h @@ -12,6 +12,6 @@ #define POSTGRESDRIVERVERSION "08.02.0501" #define POSTGRES_RESOURCE_VERSION "08.02.0501\0" #define PG_DRVFILE_VERSION 8,2,05,01 -#define PG_BUILD_VERSION "200711030001" +#define PG_BUILD_VERSION "200712180001" #endif -- 2.39.5