You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2018/12/04 23:00:48 UTC

[1/3] trafodion git commit: ODBC can not connect to server when the local language is gbk

Repository: trafodion
Updated Branches:
  refs/heads/master 3ce71cae6 -> f66c38528


ODBC can not connect to server when the local language is gbk


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/c914a3e0
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/c914a3e0
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/c914a3e0

Branch: refs/heads/master
Commit: c914a3e09ba2db36078c871e5805c54fa2e59404
Parents: f04ffee
Author: Weixin-Xu <10...@qq.com>
Authored: Wed Nov 28 11:08:47 2018 +0800
Committer: Weixin-Xu <10...@qq.com>
Committed: Wed Nov 28 11:08:47 2018 +0800

----------------------------------------------------------------------
 win-odbc64/odbcclient/drvr35/charsetconv.cpp    |  2 +-
 win-odbc64/odbcclient/drvr35/charsetconv.h      |  2 +-
 .../security_dll/native/source/secpwd.cpp       | 25 ++++++++++++++++++--
 3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/odbcclient/drvr35/charsetconv.cpp
----------------------------------------------------------------------
diff --git a/win-odbc64/odbcclient/drvr35/charsetconv.cpp b/win-odbc64/odbcclient/drvr35/charsetconv.cpp
index f53cc81..2b211b7 100644
--- a/win-odbc64/odbcclient/drvr35/charsetconv.cpp
+++ b/win-odbc64/odbcclient/drvr35/charsetconv.cpp
@@ -199,7 +199,7 @@ SQLRETURN UTF8ToWChar(char *st, int stlen, wchar_t *wst, int wstlen, int *transl
 // The fuction translates a string between UTF-8 and Client Locale. 
 // If the first argument is TRUE, the function converts the given string from UTF-8 to Locale.
 // If the first argument is FALSE, the function converts the given string from Locale to UTF-8
-SQLRETURN TranslateUTF8(bool forward, char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg)
+SQLRETURN TranslateUTF8(bool forward, const char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg)
 {
 	SQLRETURN rc = SQL_SUCCESS;
 	int len;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/odbcclient/drvr35/charsetconv.h
----------------------------------------------------------------------
diff --git a/win-odbc64/odbcclient/drvr35/charsetconv.h b/win-odbc64/odbcclient/drvr35/charsetconv.h
index 6216a69..5c28304 100644
--- a/win-odbc64/odbcclient/drvr35/charsetconv.h
+++ b/win-odbc64/odbcclient/drvr35/charsetconv.h
@@ -31,7 +31,7 @@ SQLRETURN UTF8ToWChar(char *st, int stlen, wchar_t *wst,  int wstlen, int *trans
 
 // If the first argument is TRUE, the function converts the given string from UTF-8 to Locale.
 // If the first argument is FALSE, the function converts the given string from Locale to UTF-8
-SQLRETURN TranslateUTF8(bool forward, char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg);
+SQLRETURN TranslateUTF8(bool forward, const char *inst, int inlen, char *outst, int outlen, int *translen, char *errorMsg);
 
 SQLRETURN WCharToLocale(wchar_t *wst, int wstlen, char *st, int stlen, int *translen, char* error = NULL, char *replacementChar = NULL);
 SQLRETURN LocaleToWChar(char *st, int stlen, wchar_t *wst, int wstlen,  int *translen, char* error = NULL);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/c914a3e0/win-odbc64/security_dll/native/source/secpwd.cpp
----------------------------------------------------------------------
diff --git a/win-odbc64/security_dll/native/source/secpwd.cpp b/win-odbc64/security_dll/native/source/secpwd.cpp
index 3af666e..c2bd427 100644
--- a/win-odbc64/security_dll/native/source/secpwd.cpp
+++ b/win-odbc64/security_dll/native/source/secpwd.cpp
@@ -175,6 +175,10 @@ SecPwd::SecPwd(const char *dir, const char* fileName,
 {
     char* dir_from_env = NULL;
     char  certDir[MAX_SQL_IDENTIFIER_LEN + 1];
+    char* serverNameGBKToUtf8 = NULL;
+    LCID lcid = GetSystemDefaultLCID();
+    int  translen = 0;
+    char transError[128] = { 0 };
 
     if (serverName == NULL)
         throw SecurityException (INPUT_PARAMETER_IS_NULL, " - serverName.");
@@ -217,8 +221,25 @@ SecPwd::SecPwd(const char *dir, const char* fileName,
     if(stat(certDir,&st) != 0)
         throw SecurityException(DIR_NOTFOUND, (char *)certDir);
 
-    certFile = buildName(certDir, fileName, serverName, CER);
-    activeCertFile = buildName(certDir, activeFileName, serverName, ACTIVE_CER);
+    if (lcid == 0x804) // if local charset is not utf8
+    {
+        serverNameGBKToUtf8 = (char *)malloc(MAX_SQL_IDENTIFIER_LEN + 1);
+        if (TranslateUTF8(TRUE, serverName, MAX_SQL_IDENTIFIER_LEN,
+            serverNameGBKToUtf8, MAX_SQL_IDENTIFIER_LEN, &translen, transError) != SQL_SUCCESS)
+        {
+            delete serverNameGBKToUtf8;
+            throw SecurityException(INPUT_PARAMETER_IS_NULL, " - serverName.");
+        }
+        certFile = buildName(certDir, fileName, serverNameGBKToUtf8, CER);
+        activeCertFile = buildName(certDir, activeFileName, serverNameGBKToUtf8, ACTIVE_CER);
+
+        delete serverNameGBKToUtf8;
+    }
+    else
+    {
+        certFile = buildName(certDir, fileName, serverName, CER);
+        activeCertFile = buildName(certDir, activeFileName, serverName, ACTIVE_CER);
+    }
 
     // If activeCertFile does not exist and certFile exist, create activeCertFile
     // by from copying certFile to activeCertFile


[2/3] trafodion git commit: ODBC add description for translate servername with gbk

Posted by db...@apache.org.
ODBC add description for translate servername with gbk


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/0d35111c
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/0d35111c
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/0d35111c

Branch: refs/heads/master
Commit: 0d35111c08161646c908225a211b30f2cfc97159
Parents: c914a3e
Author: Weixin-Xu <10...@qq.com>
Authored: Fri Nov 30 09:58:39 2018 +0800
Committer: Weixin-Xu <10...@qq.com>
Committed: Fri Nov 30 09:58:39 2018 +0800

----------------------------------------------------------------------
 win-odbc64/security_dll/native/source/secpwd.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/0d35111c/win-odbc64/security_dll/native/source/secpwd.cpp
----------------------------------------------------------------------
diff --git a/win-odbc64/security_dll/native/source/secpwd.cpp b/win-odbc64/security_dll/native/source/secpwd.cpp
index c2bd427..981c8ab 100644
--- a/win-odbc64/security_dll/native/source/secpwd.cpp
+++ b/win-odbc64/security_dll/native/source/secpwd.cpp
@@ -221,19 +221,21 @@ SecPwd::SecPwd(const char *dir, const char* fileName,
     if(stat(certDir,&st) != 0)
         throw SecurityException(DIR_NOTFOUND, (char *)certDir);
 
-    if (lcid == 0x804) // if local charset is not utf8
+    if (lcid == 0x804) // if local charset is gbk
     {
         serverNameGBKToUtf8 = (char *)malloc(MAX_SQL_IDENTIFIER_LEN + 1);
         if (TranslateUTF8(TRUE, serverName, MAX_SQL_IDENTIFIER_LEN,
             serverNameGBKToUtf8, MAX_SQL_IDENTIFIER_LEN, &translen, transError) != SQL_SUCCESS)
         {
-            delete serverNameGBKToUtf8;
+            free(serverNameGBKToUtf8);
+            serverNameGBKToUtf8 = NULL;
             throw SecurityException(INPUT_PARAMETER_IS_NULL, " - serverName.");
         }
         certFile = buildName(certDir, fileName, serverNameGBKToUtf8, CER);
         activeCertFile = buildName(certDir, activeFileName, serverNameGBKToUtf8, ACTIVE_CER);
 
-        delete serverNameGBKToUtf8;
+        free(serverNameGBKToUtf8);
+        serverNameGBKToUtf8 = NULL;
     }
     else
     {


[3/3] trafodion git commit: Merge [TRAFODION-3238] Support gbk local language for ODBC connections

Posted by db...@apache.org.
Merge [TRAFODION-3238] Support gbk local language for ODBC connections


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/f66c3852
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/f66c3852
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/f66c3852

Branch: refs/heads/master
Commit: f66c38528631ce2c93230a07b752ec3a1e29f889
Parents: 3ce71ca 0d35111
Author: Dave Birdsall <db...@apache.org>
Authored: Tue Dec 4 23:00:07 2018 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Tue Dec 4 23:00:07 2018 +0000

----------------------------------------------------------------------
 win-odbc64/odbcclient/drvr35/charsetconv.cpp    |  2 +-
 win-odbc64/odbcclient/drvr35/charsetconv.h      |  2 +-
 .../security_dll/native/source/secpwd.cpp       | 27 ++++++++++++++++++--
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------