From 2ee5feaa929df5f2f309796d8bb8c49c5eaca301 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Sun, 19 Jun 2011 12:27:30 +0000 Subject: [PATCH] Fix compilation errors in case ODBC 2.5. --- catfunc.h | 2 +- info.c | 8 +++++++- odbcapi25w.c | 12 ++++++++---- pgtypes.c | 6 +++++- psqlodbc.h | 9 ++++++++- results.c | 2 ++ version.h | 2 +- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/catfunc.h b/catfunc.h index 5855658..44b7928 100644 --- a/catfunc.h +++ b/catfunc.h @@ -35,8 +35,8 @@ enum { ,COLUMNS_RADIX ,COLUMNS_NULLABLE ,COLUMNS_REMARKS + ,COLUMNS_COLUMN_DEF /* ODBC 3.0 but always use it */ #if (ODBCVER >= 0x0300) - ,COLUMNS_COLUMN_DEF ,COLUMNS_SQL_DATA_TYPE ,COLUMNS_SQL_DATETIME_SUB ,COLUMNS_CHAR_OCTET_LENGTH diff --git a/info.c b/info.c index 23e8f75..7cd50d7 100644 --- a/info.c +++ b/info.c @@ -162,7 +162,7 @@ mylog("SQL_CONVERT_ mask=" FORMAT_ULEN "\n", value); case SQL_CONVERT_VARBINARY: /* ODBC 1.0 */ case SQL_CONVERT_CHAR: case SQL_CONVERT_LONGVARCHAR: -#ifdef UNICODE_SUPPORT +#if defined(UNICODE_SUPPORT) && (ODBCVER >= 0x0300) case SQL_CONVERT_WCHAR: case SQL_CONVERT_WLONGVARCHAR: case SQL_CONVERT_WVARCHAR: @@ -630,9 +630,11 @@ mylog("CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value); case SQL_QUALIFIER_USAGE: /* ODBC 2.0 */ len = 4; +#if (ODBCVER >= 0x0300) if (CurrCat(conn)) value = SQL_CU_DML_STATEMENTS; else +#endif /* ODBCVER */ value = 0; break; @@ -1601,6 +1603,7 @@ retry_public_schema: */ /* make_string mallocs memory */ tableType = make_string(szTableType, cbTableType, NULL, 0); +#if (ODBCVER >= 0x0300) if (search_pattern && escTableName && '\0' == escTableName[0] && escCatName && escSchemaName) @@ -1617,6 +1620,7 @@ retry_public_schema: stricmp(escSchemaName, SQL_ALL_SCHEMAS) == 0) list_schemas = TRUE; } +#endif /* ODBCVER */ list_some = (list_cat || list_schemas || list_table_types); tables_query[0] = '\0'; @@ -1691,11 +1695,13 @@ retry_public_schema: show_regular_tables = TRUE; show_views = TRUE; } +#if (ODBCVER >= 0x0300) else if (list_some || stricmp(tableType, SQL_ALL_TABLE_TYPES) == 0) { show_regular_tables = TRUE; show_views = TRUE; } +#endif /* ODBCVER */ else { strcpy(table_types, tableType); diff --git a/odbcapi25w.c b/odbcapi25w.c index 89500c0..9ec5acc 100644 --- a/odbcapi25w.c +++ b/odbcapi25w.c @@ -41,11 +41,15 @@ RETCODE SQL_API SQLErrorW(HENV EnvironmentHandle, qst, NativeError, mtxt, buflen, &tlen); if (qst) utf8_to_ucs2(qst, strlen(qst), Sqlstate, 5); - if (TextLength) - *TextLength = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength); - free(qst); - if (mtxt) + if (NULL != mtxt) + { + SQLULEN tulen = utf8_to_ucs2(mtxt, tlen, MessageText, BufferLength); + if (NULL != TextLength) + *TextLength = tulen; free(mtxt); + } + if (qst) + free(qst); return ret; } diff --git a/pgtypes.c b/pgtypes.c index 0280799..bf094d6 100644 --- a/pgtypes.c +++ b/pgtypes.c @@ -148,7 +148,6 @@ pg_true_type(const ConnectionClass *conn, OID type, OID basetype) return basetype; } -#if (ODBCVER >= 0x0300) #define MONTH_BIT (1 << 17) #define YEAR_BIT (1 << 18) #define DAY_BIT (1 << 19) @@ -156,6 +155,7 @@ pg_true_type(const ConnectionClass *conn, OID type, OID basetype) #define MINUTE_BIT (1 << 27) #define SECOND_BIT (1 << 28) +#if (ODBCVER >= 0x0300) static SQLSMALLINT get_interval_type(Int4 atttypmod, const char **name) { @@ -471,6 +471,7 @@ getIntervalColumnSize(OID type, int atttypmod) mylog("%s: type=%d, atttypmod=%d\n", __FUNCTION__, type, atttypmod); ttl = leading_precision; +#if (ODBCVER >= 0x0300) switch (get_interval_type(atttypmod, NULL)) { case SQL_INTERVAL_DAY_TO_SECOND: @@ -487,6 +488,9 @@ getIntervalColumnSize(OID type, int atttypmod) ttl += 3; break; } +#else + ttl += 9; +#endif /* ODBCVER */ scale = getIntervalDecimalDigits(type, atttypmod); return (scale > 0) ? ttl + 1 + scale : ttl; } diff --git a/psqlodbc.h b/psqlodbc.h index 6b4314a..a5a6d43 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.134 2010/01/24 07:56:13 hinoue Exp $ + * $Id: psqlodbc.h,v 1.135 2011/06/19 12:27:30 hinoue Exp $ * */ @@ -101,6 +101,13 @@ typedef UInt4 OID; #define FORMAT_INT4 "%d" /* Int4 */ #define FORMAT_UINT4 "%u" /* UInt4 */ +#ifndef SQL_TRUE +#define SQL_TRUE TRUE +#endif /* SQL_TRUE */ +#ifndef SQL_FALSE +#define SQL_FALSE FALSE +#endif /* SQL_FALSE */ + #ifdef WIN32 #ifndef SSIZE_T_DEFINED #define ssize_t SSIZE_T diff --git a/results.c b/results.c index f42aa89..14c2cb2 100644 --- a/results.c +++ b/results.c @@ -943,6 +943,7 @@ PGAPI_GetData( return SQL_ERROR; } +#if (ODBCVER >= 0x0300) if (SQL_ARD_TYPE == fCType) { ARDFields *opts; @@ -966,6 +967,7 @@ PGAPI_GetData( } } else +#endif /* ODBCVER */ target_type = fCType; if (icol == 0) { diff --git a/version.h b/version.h index 649ef4f..fd22f31 100644 --- a/version.h +++ b/version.h @@ -12,6 +12,6 @@ #define POSTGRESDRIVERVERSION "09.00.0301" #define POSTGRES_RESOURCE_VERSION "09.00.0301\0" #define PG_DRVFILE_VERSION 9,0,03,01 -#define PG_BUILD_VERSION "201106190003" +#define PG_BUILD_VERSION "201106190004" #endif -- 2.39.5