]> granicus.if.org Git - postgresql/commitdiff
1) prevent setting of KSQO on 7.3+ servers(Thanks to Dave Page).
authorHiroshi Inoue <inoue@tpf.co.jp>
Fri, 28 Jun 2002 02:44:15 +0000 (02:44 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Fri, 28 Jun 2002 02:44:15 +0000 (02:44 +0000)
2) Allow LF->CR/LF conversion under UNICODE driver.

src/interfaces/odbc/connection.c
src/interfaces/odbc/convert.c
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/win_unicode.c

index c9b0c01c30c1c2b7ac7915e6dceb621a1eab3b1b..04de1c8e25d91b30c9bcde7c56465c7136ea8181 100644 (file)
@@ -952,6 +952,13 @@ another_version_retry:
         * Send any initial settings
         */
 
+       /* 
+        * Get the version number first so we can check it before sending options
+        * that are now obsolete. DJP 21/06/2002
+        */
+
+       CC_lookup_pg_version(self);             /* Get PostgreSQL version for
+                                                  SQLGetInfo use */
        /*
         * Since these functions allocate statements, and since the connection
         * is not established yet, it would violate odbc state transition
@@ -961,8 +968,6 @@ another_version_retry:
        CC_send_settings(self);
        CC_lookup_lo(self);                     /* a hack to get the oid of
                                                   our large object oid type */
-       CC_lookup_pg_version(self);             /* Get PostgreSQL version for
-                                                  SQLGetInfo use */
 
        /*
         *      Multibyte handling is available ?
@@ -1802,8 +1807,8 @@ CC_send_settings(ConnectionClass *self)
 
        }
 
-       /* KSQO */
-       if (ci->drivers.ksqo)
+       /* KSQO (not applicable to 7.1+ - DJP 21/06/2002) */
+       if (ci->drivers.ksqo && PG_VERSION_LT(self, 7.1))
        {
                result = PGAPI_ExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS);
                if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
index 60fdc54f9c34febf35ee5be89b9793b93f3215bf..15a1a23c73700750a95bbd5686ce319649f7c185 100644 (file)
@@ -702,7 +702,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
 #ifdef UNICODE_SUPPORT
                                        if (fCType == SQL_C_WCHAR)
                                        {
-                                               len = utf8_to_ucs2(neut_str, -1, NULL, 0);
+                                               len = utf8_to_ucs2_lf(neut_str, -1, lf_conv, NULL, 0);
                                                len *= 2;
                                                wchanged = changed = TRUE;
                                        }
@@ -728,7 +728,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
 #ifdef UNICODE_SUPPORT
                                                if (fCType == SQL_C_WCHAR)
                                                {
-                                                       utf8_to_ucs2(neut_str, -1, (SQLWCHAR *) pbic->ttlbuf, len / 2);
+                                                       utf8_to_ucs2_lf(neut_str, -1, lf_conv, (SQLWCHAR *) pbic->ttlbuf, len / 2);
                                                }
                                                else
 #endif /* UNICODE_SUPPORT */
index 167a35fa2f8f12b535d44c5703cf2492775ed6bf..431f6a4922f02763660964e5976e54ea37b5bf64 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Comments:           See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.67 2002/06/06 04:50:47 inoue Exp $
+ * $Id: psqlodbc.h,v 1.68 2002/06/28 02:44:15 inoue Exp $
  *
  */
 
@@ -255,7 +255,8 @@ void                logs_on_off(int cnopen, int, int);
 #ifdef UNICODE_SUPPORT
 UInt4  ucs2strlen(const SQLWCHAR *ucs2str);
 char   *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen);
-UInt4  utf8_to_ucs2(const char * utf8str, Int4 ilen, SQLWCHAR *ucs2str, UInt4 buflen);
+UInt4  utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
+#define        utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
 #endif /* UNICODE_SUPPORT */
 /*#define      _MEMORY_DEBUG_ */
 #ifdef _MEMORY_DEBUG_
index 3dfc9ff43d4e5ad2fcd79b54ab9713cebf217663..112ea18be195c7c7520c1d3120ed43f8146c7177 100644 (file)
@@ -82,7 +82,7 @@ char *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen)
 #define        byte3_m3        0x3f
 #define        byte2_m1        0x1f
 #define        byte2_m2        0x3f
-UInt4  utf8_to_ucs2(const char *utf8str, Int4 ilen, SQLWCHAR *ucs2str, UInt4 bufcount)
+UInt4  utf8_to_ucs2_lf(const char *utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 bufcount)
 {
        int     i;
        UInt4   ocount, wcode;
@@ -102,6 +102,13 @@ UInt4      utf8_to_ucs2(const char *utf8str, Int4 ilen, SQLWCHAR *ucs2str, UInt4 bufc
        {
                if (iswascii(*str))
                {
+                       if (lfconv && *str == '\n' &&
+                           (i == 0 || str[-1] != '\r'))
+                       {
+                               if (ocount < bufcount)
+                                       ucs2str[ocount] = '\r';
+                               ocount++;
+                       }
                        if (ocount < bufcount)
                                ucs2str[ocount] = *str;
                        ocount++;