trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/3] trafodion git commit: ODBC can not connect to server when the local language is gbk
Date Tue, 04 Dec 2018 23:00:48 GMT
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 <1013438133@qq.com>
Authored: Wed Nov 28 11:08:47 2018 +0800
Committer: Weixin-Xu <1013438133@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


Mime
View raw message