Fix compilation errors in case ODBC 2.5.
authorHiroshi Inoue <inoue@tpf.co.jp>
Sun, 19 Jun 2011 12:27:30 +0000 (12:27 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Sun, 19 Jun 2011 12:27:30 +0000 (12:27 +0000)
catfunc.h
info.c
odbcapi25w.c
pgtypes.c
psqlodbc.h
results.c
version.h

index 58556586ceda354a140833532677b1f746c01892..44b792877caa63ea0843cd2502f661d6c119e2c2 100644 (file)
--- 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 23e8f751cfd3f1f46a6d71a9c34e0fa5c8208f28..7cd50d73b1ef02fbb5c6b56af3e389eee89ce124 100644 (file)
--- 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);
index 89500c0d23d2c5fd4ad83ca30ea26b308261250d..9ec5accad50bf13adad3e5085ac28bc9222188cc 100644 (file)
@@ -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;
 }
 
index 028079951fb82cc15c215de660564fe8a25825b1..bf094d6aa27b25582f4d59cda128d1edd559c523 100644 (file)
--- 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;
 }
index 6b4314a3a811772b7f9006c0da77bf8ff1b96895..a5a6d433dd26b239fbe79b6e7576511b518a1675 100644 (file)
@@ -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
index f42aa89d589e764e41557d6b7a09e890095ee65b..14c2cb29566febb25185b7a78fb0881991f710fe 100644 (file)
--- 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)
    {
index 649ef4f78bd4de932fd75acd7c77be5d54617cb1..fd22f313cf8ef519b21653fb9e815d7e74bd5d16 100644 (file)
--- 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