OK, finally think this SQLInfo unicode string length bug can be put to rest.
authorDave Page <dpage@pgadmin.org>
Fri, 8 Oct 2004 08:50:08 +0000 (08:50 +0000)
committerDave Page <dpage@pgadmin.org>
Fri, 8 Oct 2004 08:50:08 +0000 (08:50 +0000)
Tested and working in Access 2K3, MS ODBC Testsuite, and some of my own test and live project code.

info.c
info30.c

diff --git a/info.c b/info.c
index 2eea249018d00735e62a5178cac393e97c92c975..2d3386e0cf747e6a43fb419740ef22022c52306c 100644 (file)
--- a/info.c
+++ b/info.c
@@ -733,8 +733,6 @@ PGAPI_GetInfo(
 
    result = SQL_SUCCESS;
 
-   mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "<NULL>", len, value, cbInfoValueMax);
-
    /*
     * NOTE, that if rgbInfoValue is NULL, then no warnings or errors
     * should result and just pcbInfoValue is returned, which indicates
@@ -751,15 +749,12 @@ PGAPI_GetInfo(
                  * small.
                  */
                 if (conn->unicode)
-                    len = (len * WCLEN) - 1;
+                    len = len * WCLEN;
 
        if (rgbInfoValue)
        {
            if (conn->unicode)
-           {
                len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / 2);
-               len *= WCLEN;
-           }
            else
                strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax);
 
@@ -782,9 +777,12 @@ PGAPI_GetInfo(
        }
    }
 
-   if (pcbInfoValue)
-       *pcbInfoValue = len;            
 
+   if (pcbInfoValue)
+       *pcbInfoValue = len;        
+   
+   mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "<NULL>", len, value, cbInfoValueMax);
+   
    return result;
 }
 
index e9121bd5c0de10d656bf567c6e1eaab406f31fe9..06b0694db7a62902dabaff279750b47c502cccc3 100644 (file)
--- a/info30.c
+++ b/info30.c
@@ -356,7 +356,7 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
            return SQL_ERROR;
    }
    result = SQL_SUCCESS;
-   mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "<NULL>", len, value, cbInfoValueMax);
+
    if (p)
    {
        /* char/binary data */
@@ -368,16 +368,13 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
                  * small.
                  */
                 if (conn->unicode)
-                    len = (len * WCLEN) - 1;
+                    len = len * WCLEN;
                 
        if (rgbInfoValue)
        {
 
            if (conn->unicode)
-           {
                len = utf8_to_ucs2(p, len, (SQLWCHAR *) rgbInfoValue, cbInfoValueMax / 2);
-               len *= WCLEN;
-           }
            else
                strncpy_null((char *) rgbInfoValue, p, (size_t) cbInfoValueMax);
 
@@ -401,11 +398,10 @@ PGAPI_GetInfo30(HDBC hdbc, UWORD fInfoType, PTR rgbInfoValue,
    }
 
    if (pcbInfoValue)
-       if (conn->unicode)
-           *pcbInfoValue = len - 2;    
-       else
-           *pcbInfoValue = len;
-       
+       *pcbInfoValue = len;
+
+   mylog("%s: p='%s', len=%d, value=%d, cbMax=%d\n", func, p ? p : "<NULL>", len, value, cbInfoValueMax);
+   
    return result;
 }