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 2016/12/07 23:53:56 UTC
[1/5] incubator-trafodion git commit: [TRAFODION-2386]Add UT code for
varchar 32k issue add source code, build files and readme files
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 81005a720 -> 672b6d114
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.h
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.h b/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.h
new file mode 100644
index 0000000..7a1f643
--- /dev/null
+++ b/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.h
@@ -0,0 +1,52 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#pragma once
+#include "../../common/Global.h"
+#include "../../common/TestBase.h"
+#define LARGECOL
+class CLargeVarcharCol :public CTestBase
+{
+public:
+ CLargeVarcharCol(const char * chDsn, const char * chUID, const char * chPwd);
+ ~CLargeVarcharCol();
+private:
+ CLargeVarcharCol();
+
+private:
+ bool Prepare();
+ bool TestGo();
+ void CleanUp();
+
+ bool InsertCharToVarcharCol(int schema);
+ bool InsertWCharToVarcharCol(int schema);
+ bool InsertCharToLongVarcharCol(int schema);
+ bool InsertWCharToLongVarcharCol(int schema);
+ bool VarcharToULong(int schema);
+ bool VarcharToDate(int schema);
+ bool VarcharToDouble(int schema);
+ bool VarcharToTime(int schema);
+ bool VarcharToTimestamp(int schema);
+ bool VarcharToInterval(int schema);
+};
+
[4/5] incubator-trafodion git commit: [TRAFODION-2386]Add UT code for
varchar 32k issue avoid stack corrupt when convert char* to numeric and
modify tips for user
Posted by db...@apache.org.
[TRAFODION-2386]Add UT code for varchar 32k issue
avoid stack corrupt when convert char* to numeric and modify tips for user
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/416b81cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/416b81cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/416b81cc
Branch: refs/heads/master
Commit: 416b81ccc042ade34e94a222c8390112685f5a7b
Parents: ac833c4
Author: rwbzx <xi...@esgyn.cn>
Authored: Wed Dec 7 15:24:30 2016 +0800
Committer: rwbzx <xi...@esgyn.cn>
Committed: Wed Dec 7 15:24:30 2016 +0800
----------------------------------------------------------------------
dcs/src/test/odbc/README.txt | 17 ++++++++++++-----
dcs/src/test/odbc/src/Main.cpp | 4 ++--
dcs/src/test/odbc/src/common/Global.cpp | 2 +-
3 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/416b81cc/dcs/src/test/odbc/README.txt
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/README.txt b/dcs/src/test/odbc/README.txt
index 1b866dc..4533929 100644
--- a/dcs/src/test/odbc/README.txt
+++ b/dcs/src/test/odbc/README.txt
@@ -22,19 +22,26 @@
**************************************************************************/
To build odbc test on Windows:
-1.Enter directory [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
+1.Enter directory <WHERE_YOU_PLACE_ODBC_FOLDER>\odbc\build
2.Open odbc.vcxproj in Microsoft visual studio
3.Choose Platform as "x64" and Configuration as "Debug" in visual studio BUILD--Configuration Manager
4.Build project "odbc" in visual studio
To run odbc test on Windows using command line tool:
>cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build\x64\Debug
->odbc -d [<datasource>][-u <userid>][-p <password>]
+>odbc -d <datasource> -u <userid> -p <password>
To build odbc test on Linux:
->cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
+>cd <WHERE_YOU_PLACE_ODBC_FOLDER>\odbc\build
>make
To run odbc test on Linux:
->cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
->./odbc -d [<datasource>][-u <userid>][-p <password>]
\ No newline at end of file
+1.Add odbc configuration option "AppUnicodeType" as "utf16" in the installed TRAFDSN file like:
+================================
+[ODBC]
+......
+AppUnicodeType = utf16
+================================
+2.Type commands as follows:
+>cd <WHERE_YOU_PLACE_ODBC_FOLDER>\odbc\build
+>./odbc -d <datasource> -u <userid> -p <password>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/416b81cc/dcs/src/test/odbc/src/Main.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/Main.cpp b/dcs/src/test/odbc/src/Main.cpp
index 3afc4b9..e0e31e6 100644
--- a/dcs/src/test/odbc/src/Main.cpp
+++ b/dcs/src/test/odbc/src/Main.cpp
@@ -28,7 +28,7 @@ int main(int argc, char * argv[])
{
if (argc != 7)
{
- std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
+ std::cout << "Usage: " << argv[0] << " -d <datasource> -u <userid> -p <password>" << endl;
return -1;
}
char inputArgs[6][100];
@@ -37,7 +37,7 @@ int main(int argc, char * argv[])
if ((strcmp(inputArgs[0], "-d") != 0) || (strcmp(inputArgs[2], "-u") != 0) || (strcmp(inputArgs[4], "-p") != 0))
{
- std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
+ std::cout << "Usage: " << argv[0] << " -d <datasource> -u <userid> -p <password>" << endl;
return -1;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/416b81cc/dcs/src/test/odbc/src/common/Global.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/common/Global.cpp b/dcs/src/test/odbc/src/common/Global.cpp
index 4f52862..6e06214 100644
--- a/dcs/src/test/odbc/src/common/Global.cpp
+++ b/dcs/src/test/odbc/src/common/Global.cpp
@@ -44,7 +44,7 @@ int ConvertCharToCNumeric(SQL_NUMERIC_STRUCT& numericTmp, CHAR* cTmpBuf)
SQLCHAR tempSign;
SQLCHAR tmpVal[101];
- if (strlen(rTrim(cTmpBuf)) > sizeof(tmpVal))
+ if (strlen(rTrim(cTmpBuf)) >= sizeof(tmpVal))
return -1;
memset(tmpVal, 0, sizeof(tmpVal));
[2/5] incubator-trafodion git commit: [TRAFODION-2386]Add UT code for
varchar 32k issue add source code, build files and readme files
Posted by db...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.cpp b/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.cpp
new file mode 100644
index 0000000..5c43258
--- /dev/null
+++ b/dcs/src/test/odbc/src/test/varchar32k/LargeVarcharCol.cpp
@@ -0,0 +1,2639 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "LargeVarcharCol.h"
+
+CLargeVarcharCol::CLargeVarcharCol(const char * chDsn, const char * chUID, const char * chPwd)
+ :CTestBase(chDsn,chUID,chPwd)
+{
+ std::cout << "******************************" << endl;
+ std::cout << "*Varchar 32k Unit Test Begin *" << endl;
+ std::cout << "******************************" << endl;
+}
+
+CLargeVarcharCol::~CLargeVarcharCol()
+{
+}
+
+bool CLargeVarcharCol::Prepare()
+{
+ cout << "Preparing environment for upcoming test...this process may take a while..." <<endl;
+ SQLRETURN returnCode;
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create schema iso88591", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create schema iso88591)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create schema utf8", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create schema utf8)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create table iso88591.tvarchar(c1 varchar(200000))", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create table iso88591.tvarchar(c1 varchar(200000)))", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create table utf8.tvarchar(c1 varchar(50000) character set utf8)", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create table utf8.tvarchar(c1 varchar(50000) character set utf8))", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create table iso88591.tlongvarchar(c1 long varchar(2000))", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create table iso88591.tlongvarchar(c1 long varchar(2000)))", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"create table utf8.tlongvarchar(c1 long varchar(2000) character set utf8)", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, create table utf8.tlongvarchar(c1 long varchar(2000) character set utf8))", returnCode);
+ return false;
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::TestGo()
+{
+ if (!InsertCharToVarcharCol(TRAF_ALL))
+ return false;
+ if (!InsertWCharToVarcharCol(TRAF_ALL))
+ return false;
+ if (!InsertCharToLongVarcharCol(TRAF_ALL))
+ return false;
+ if (!InsertWCharToLongVarcharCol(TRAF_ALL))
+ return false;
+ if (!VarcharToULong(TRAF_ALL))
+ return false;
+ if (!VarcharToDate(TRAF_ALL))
+ return false;
+ if (!VarcharToDouble(TRAF_ALL))
+ return false;
+ if (!VarcharToTime(TRAF_ALL))
+ return false;
+ if (!VarcharToTimestamp(TRAF_ALL))
+ return false;
+ if (!VarcharToInterval(TRAF_ALL))
+ return false;
+
+ std::cout << "Test Result: Pass" << endl;
+ return true;
+}
+
+const char * strDictionary = (char *)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*0123456789012345678901234567890123456789";//100 Bytes
+const wchar_t wstrDictionary[200] = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*0123456789012345678901234567890123456789";//100 Characters
+unsigned char chInArray[200001];
+unsigned char chOutArray[200001];
+wchar_t wchInArray[200001];
+wchar_t wchOutArray[200001];
+
+bool CLargeVarcharCol::InsertCharToVarcharCol(int schema)
+{
+ SQLRETURN returnCode;
+ SQLLEN cbC1 = SQL_NTS;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+
+ memset(chInArray, 0, sizeof(chInArray));
+ memset(chOutArray, 0, sizeof(chOutArray));
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ std::cout << "char ==> iso88591-varchar:" << endl;
+#ifdef LARGECOL
+ for (int i = 0; i < 2000; i++)
+ {
+ strcat((char *)chInArray, strDictionary);
+ }
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+#endif
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ memset(chOutArray, 0, sizeof(chOutArray));
+ memset(chInArray, 0, sizeof(chInArray));
+ cbC1 = SQL_NTS;
+ strcat((char *)chInArray, (char *)strDictionary);
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(chInArray, 0, sizeof(chInArray));
+ memset(chOutArray, 0, sizeof(chOutArray));
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ std::cout << "char ==> utf8-varchar:" << endl;
+#ifdef LARGECOL
+ for (int i = 0; i < 2000; i++)
+ {
+ strcat((char *)chInArray, strDictionary);
+ }
+ cbC1 = SQL_NTS;
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0){
+ std::cout << "Succeeded." << endl;
+ }
+ else{
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+#endif
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ memset(chOutArray, 0, sizeof(chOutArray));
+ memset(chInArray, 0, sizeof(chInArray));
+ cbC1 = SQL_NTS;
+ strcat((char *)chInArray, (char *)strDictionary);
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0){
+ std::cout << "Succeeded." << endl;
+ }
+ else{
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::InsertWCharToVarcharCol(int schema)
+{
+ SQLRETURN returnCode;
+ SQLLEN cbC1 = SQL_NTS;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+
+ memset(wchInArray, 0, sizeof(wchInArray));
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ std::cout << "wchar ==> iso88591-varchar:" << endl;
+
+#ifdef LARGECOL
+ for (int i = 0; i < 2000; i++)
+ {
+ wcscat(wchInArray, wstrDictionary);
+ }
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+
+ if (memcmp(wchInArray, wchOutArray, sizeof(wchInArray)) == 0){
+ std::cout << "Succeeded." << endl;
+ }
+ else{
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+#endif
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+ memset(wchInArray, 0, sizeof(wchInArray));
+ wcscat(wchInArray, wstrDictionary);
+
+ cbC1 = SQL_NTS;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 0, 0, &wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(wchInArray, 0, sizeof(wchInArray));
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ std::cout << "wchar ==> utf8-varchar:" << endl;
+ cbC1 = SQL_NTS;
+#ifdef LARGECOL
+ for (int i = 0; i < 2000; i++)
+ {
+ wcscat(wchInArray, wstrDictionary);
+ }
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, &wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0){
+ std::cout << "Succeeded." << endl;
+ }
+ else{
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+#endif
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+ memset(wchInArray, 0, sizeof(wchInArray));
+ wcscat(wchInArray, wstrDictionary);
+ cbC1 = SQL_NTS;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::InsertCharToLongVarcharCol(int schema)
+{
+ SQLRETURN returnCode;
+ SQLLEN cbC1 = SQL_NTS;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+ memset(chInArray, 0, sizeof(chInArray));
+ memset(chOutArray, 0, sizeof(chOutArray));
+
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ std::cout << "char ==> iso88591-longvarchar:" << endl;
+ for (int i = 0; i < 20; i++)
+ {
+ strcat((char *)chInArray, strDictionary);
+ }
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tlongvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ memset(chOutArray, 0, sizeof(chOutArray));
+ memset(chInArray, 0, sizeof(chInArray));
+ cbC1 = SQL_NTS;
+ strcat((char *)chInArray, (char *)strDictionary);
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tlongvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(chInArray, 0, sizeof(chInArray));
+ memset(chOutArray, 0, sizeof(chOutArray));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ std::cout << "char ==> utf8-longvarchar:" << endl;
+ for (int i = 0; i < 20; i++)
+ {
+ strcat((char *)chInArray, strDictionary);
+ }
+ cbC1 = SQL_NTS;
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tlongvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* insert char */
+ /************************************************************************/
+ memset(chOutArray, 0, sizeof(chOutArray));
+ memset(chInArray, 0, sizeof(chInArray));
+ cbC1 = SQL_NTS;
+ strcat((char *)chInArray, (char *)strDictionary);
+ std::cout << "length: " << strlen((char *)chInArray) << " bytes..." << endl;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0, chInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_CHAR, &chOutArray, sizeof(chOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (strcmp((char *)chInArray, (char *)chOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tlongvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::InsertWCharToLongVarcharCol(int schema)
+{
+ SQLRETURN returnCode;
+ SQLLEN cbC1 = SQL_NTS;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+ memset(wchInArray, 0, sizeof(wchInArray));
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ std::cout << "wchar ==> iso88591-longvarchar:" << endl;
+ for (int i = 0; i < 20; i++)
+ {
+ wcscat(wchInArray, wstrDictionary);
+ }
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_LONGVARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, &wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else{
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tlongvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+ memset(wchInArray, 0, sizeof(wchInArray));
+ wcscat(wchInArray, wstrDictionary);
+ cbC1 = SQL_NTS;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_LONGVARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, &wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch iso88591.tlongvarchar", returnCode);
+ return false;
+ }
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tlongvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(wchInArray, 0, sizeof(wchInArray));
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ std::cout << "wchar ==> utf8-longvarchar:" << endl;
+ cbC1 = SQL_NTS;
+ for (int i = 0; i < 20; i++)
+ {
+ wcscat(wchInArray, wstrDictionary);
+ }
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_LONGVARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, &wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tlongvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+
+ /************************************************************************/
+ /* insert wchar */
+ /************************************************************************/
+ memset(wchOutArray, 0, sizeof(wchOutArray));
+ memset(wchInArray, 0, sizeof(wchInArray));
+ wcscat(wchInArray, wstrDictionary);
+ cbC1 = SQL_NTS;
+
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_LONGVARCHAR, 0, 0, wchInArray, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tlongvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* retrieve data to verify result */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tlongvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_WCHAR, wchOutArray, sizeof(wchOutArray), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (wcscmp(wchInArray, wchOutArray) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else{
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch utf8.tlongvarchar", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tlongvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tlongvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::VarcharToULong(int schema)
+{
+ SQLRETURN returnCode;
+ SQLUINTEGER ulInC1 = 3141592653;
+ SQLUINTEGER ulOutC1 = 0;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert ulong ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert ulong to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_VARCHAR, 0, 0, &ulInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select ul from varchar */
+ /************************************************************************/
+ std::cout << "select ulong from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_ULONG, &ulOutC1, sizeof(ulOutC1), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (ulInC1 == ulOutC1)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << ulOutC1 << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ ulOutC1 = 0;
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert ulong to varchar */
+ /************************************************************************/
+ std::cout << "insert ulong ==> utf8-varchar..." << endl;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_VARCHAR, 0, 0, &ulInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select ul from varchar */
+ /************************************************************************/
+ std::cout << "select ulong from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_ULONG, &ulOutC1, sizeof(ulOutC1), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (ulInC1 == ulOutC1)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << ulOutC1 << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+DATE_STRUCT dtInC1;
+DATE_STRUCT dtOutC1;
+bool CLargeVarcharCol::VarcharToDate(int schema)
+{
+ SQLRETURN returnCode;
+
+ dtInC1.year = 2015;
+ dtInC1.month = 8;
+ dtInC1.day = 31;
+ dtOutC1.year = 0;
+ dtOutC1.month = 0;
+ dtOutC1.day = 0;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert date ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert date to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_DATE, SQL_VARCHAR, 0, 0, &dtInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select date from varchar */
+ /************************************************************************/
+ std::cout << "select date from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_DATE, &dtOutC1, sizeof(DATE_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&dtInC1, &dtOutC1, sizeof(DATE_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << dtOutC1.year << ":" << dtOutC1.month << ":" << dtOutC1.day << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ dtOutC1.year = 0;
+ dtOutC1.month = 0;
+ dtOutC1.day = 0;
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert date to varchar */
+ /************************************************************************/
+ std::cout << "insert date ==> utf8-varchar..." << endl;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_DATE, SQL_VARCHAR, 0, 0, &dtInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select date from varchar */
+ /************************************************************************/
+ std::cout << "select date from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_DATE, &dtOutC1, sizeof(DATE_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+
+ if (memcmp(&dtInC1, &dtOutC1, sizeof(DATE_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << dtOutC1.year << ":" << dtOutC1.month << ":" << dtOutC1.day << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+TIME_STRUCT tmInC1;
+TIME_STRUCT tmOutC1;
+bool CLargeVarcharCol::VarcharToTime(int schema)
+{
+ SQLRETURN returnCode;
+
+ tmInC1.hour = 14;
+ tmInC1.minute = 9;
+ tmInC1.second = 13;
+ memset(&tmOutC1, 0, sizeof(TIME_STRUCT));
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert time ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert time to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIME, SQL_VARCHAR, 0, 0, &tmInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select time from varchar */
+ /************************************************************************/
+ std::cout << "select time from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_TIME, &tmOutC1, sizeof(TIME_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&tmInC1, &tmOutC1, sizeof(TIME_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(&tmOutC1, 0, sizeof(TIME_STRUCT));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ std::cout << "insert time ==> utf8-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert time to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIME, SQL_VARCHAR, 0, 0, &tmInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select time from varchar */
+ /************************************************************************/
+ std::cout << "select time from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_TIME, &tmOutC1, sizeof(TIME_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&tmInC1, &tmOutC1, sizeof(TIME_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CLargeVarcharCol::VarcharToDouble(int schema)
+{
+ SQLRETURN returnCode;
+ SQLDOUBLE dbInC1 = 3.141592653;
+ SQLDOUBLE dbOutC1 = 0;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert double ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert double to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_VARCHAR, 0, 0, &dbInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select double from varchar */
+ /************************************************************************/
+ std::cout << "select double from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_DOUBLE, &dbOutC1, sizeof(dbOutC1), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (fabs(dbInC1 - dbOutC1) < 0.0000000001)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << dbOutC1 << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ dbOutC1 = 0;
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert double to varchar */
+ /************************************************************************/
+ std::cout << "insert double ==> utf8-varchar..." << endl;
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_VARCHAR, 0, 0, &dbInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select double from varchar */
+ /************************************************************************/
+ std::cout << "select double from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_DOUBLE, &dbOutC1, sizeof(dbOutC1), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (fabs(dbInC1 - dbOutC1) < 0.0000000001)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ std::cout << "Out Data: " << dbOutC1 << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+TIMESTAMP_STRUCT tmstpInC1;
+TIMESTAMP_STRUCT tmstpOutC1;
+bool CLargeVarcharCol::VarcharToTimestamp(int schema)
+{
+ SQLRETURN returnCode;
+
+ tmstpInC1.year = 2015;
+ tmstpInC1.month = 8;
+ tmstpInC1.day = 31;
+ tmstpInC1.hour = 5;
+ tmstpInC1.minute = 4;
+ tmstpInC1.second = 3;
+ tmstpInC1.fraction = 2000;
+
+ memset(&tmstpOutC1, 0, sizeof(TIMESTAMP_STRUCT));
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert timestamp ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert timestamp to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_VARCHAR, 0, 0, &tmstpInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select timestamp from varchar */
+ /************************************************************************/
+ std::cout << "select timestamp from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_TIMESTAMP, &tmstpOutC1, sizeof(TIMESTAMP_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&tmstpInC1, &tmstpOutC1, sizeof(TIMESTAMP_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ }
+
+ memset(&tmstpOutC1, 0, sizeof(TIMESTAMP_STRUCT));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ std::cout << "insert timestamp ==> utf8-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert timestamp to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_VARCHAR, 0, 0, &tmstpInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select timestamp from varchar */
+ /************************************************************************/
+ std::cout << "select timestamp from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_TYPE_TIMESTAMP, &tmstpOutC1, sizeof(TIMESTAMP_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&tmstpInC1, &tmstpOutC1, sizeof(TIMESTAMP_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+
+SQL_INTERVAL_STRUCT intvalInC1;
+SQL_INTERVAL_STRUCT intvalOutC1;
+bool CLargeVarcharCol::VarcharToInterval(int schema)
+{
+ SQLRETURN returnCode;
+
+ memset(&intvalInC1, 0, sizeof(SQL_INTERVAL_STRUCT));
+ memset(&intvalOutC1, 0, sizeof(SQL_INTERVAL_STRUCT));
+
+ intvalInC1.interval_type = SQL_IS_YEAR_TO_MONTH;
+ intvalInC1.interval_sign = 1;
+ intvalInC1.intval.year_month.year = 1;
+ intvalInC1.intval.year_month.month = 2;
+
+ /************************************************************************/
+ /* Purge table data */
+ /************************************************************************/
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ if ((schema & TRAF_ISO88591) == TRAF_ISO88591)
+ {
+ std::cout << "insert interval ==> iso88591-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert interval to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTERVAL_YEAR_TO_MONTH, SQL_VARCHAR, 0, 0, &intvalInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into iso88591.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select interval from varchar */
+ /************************************************************************/
+ std::cout << "select interval from iso88591-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from iso88591.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_INTERVAL_YEAR_TO_MONTH, &intvalOutC1, sizeof(SQL_INTERVAL_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&intvalInC1, &intvalOutC1, sizeof(SQL_INTERVAL_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from iso88591.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from iso88591.tvarchar)", returnCode);
+ return false;
+ }
+
+ }
+
+ memset(&intvalOutC1, 0, sizeof(SQL_INTERVAL_STRUCT));
+
+ if ((schema & TRAF_UTF8) == TRAF_UTF8)
+ {
+ std::cout << "insert interval ==> utf8-varchar..." << endl;
+ SQLLEN cbC1 = SQL_NTS;
+ /************************************************************************/
+ /* insert interval to varchar */
+ /************************************************************************/
+ returnCode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_INTERVAL_YEAR_TO_MONTH, SQL_VARCHAR, 0, 0, &intvalInC1, 0, &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLBindParameter(SQL_HANDLE_STMT, SINGLEVARCHAR)", returnCode);
+ return false;
+ }
+ returnCode = SQLPrepare(hstmt,
+ (SQLCHAR *)"insert into utf8.tvarchar values (?)",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLPrepare(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecute(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecute(SQL_HANDLE_STMT, INSERT)", returnCode);
+ return false;
+ }
+ /************************************************************************/
+ /* select interval from varchar */
+ /************************************************************************/
+ std::cout << "select interval from utf8-varchar..." << endl;
+ returnCode = SQLExecDirect(hstmt,
+ (SQLCHAR *)"select c1 from utf8.tvarchar",
+ SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ returnCode = SQLFetch(hstmt);
+ if (returnCode == SQL_SUCCESS)
+ {
+ returnCode = SQLGetData(hstmt, 1, SQL_C_INTERVAL_YEAR_TO_MONTH, &intvalOutC1, sizeof(SQL_INTERVAL_STRUCT), &cbC1);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLGetData(SQL_HANDLE_STMT, SELECT)", returnCode);
+ return false;
+ }
+ if (memcmp(&intvalInC1, &intvalOutC1, sizeof(SQL_INTERVAL_STRUCT)) == 0)
+ {
+ std::cout << "Succeeded." << endl;
+ }
+ else
+ {
+ std::cout << "Failed: Data Comparation Failed." << endl;
+ return false;
+ }
+ }
+ else
+ {
+ std::cout << "Failed." << endl;
+ LogDiagnostics("SQLFetch(SQL_HANDLE_STMT)", returnCode);
+ return false;
+ }
+
+ returnCode = SQLCloseCursor(hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLCloseCursor(hstmt)", returnCode);
+ return false;
+ }
+ returnCode = SQLExecDirect(hstmt, (SQLCHAR *)"delete from utf8.tvarchar", SQL_NTS);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLExecDirect(hstmt, delete from utf8.tvarchar)", returnCode);
+ return false;
+ }
+ }
+ return true;
+}
+void CLargeVarcharCol::CleanUp()
+{
+ std::cout << "Cleaning up environment of previous test...this proces
<TRUNCATED>
[5/5] incubator-trafodion git commit: Merge [TRAFODION-2386] PR 868
ODBC unit test for large varchar issue
Posted by db...@apache.org.
Merge [TRAFODION-2386] PR 868 ODBC unit test for large varchar issue
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/672b6d11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/672b6d11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/672b6d11
Branch: refs/heads/master
Commit: 672b6d114dc7d64b26b9e996480aa8f069936e58
Parents: 81005a7 416b81c
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Dec 7 23:52:42 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Dec 7 23:52:42 2016 +0000
----------------------------------------------------------------------
.rat-excludes | 2 +
dcs/src/test/odbc/README.txt | 47 +
dcs/src/test/odbc/build/Makefile | 43 +
dcs/src/test/odbc/build/odbc.vcxproj | 157 ++
dcs/src/test/odbc/build/odbc.vcxproj.filters | 40 +
dcs/src/test/odbc/src/Main.cpp | 57 +
dcs/src/test/odbc/src/common/Global.cpp | 116 +
dcs/src/test/odbc/src/common/Global.h | 60 +
dcs/src/test/odbc/src/common/TestBase.cpp | 263 ++
dcs/src/test/odbc/src/common/TestBase.h | 55 +
.../src/test/varchar32k/LargeVarcharCol.cpp | 2639 ++++++++++++++++++
.../odbc/src/test/varchar32k/LargeVarcharCol.h | 52 +
12 files changed, 3531 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/672b6d11/.rat-excludes
----------------------------------------------------------------------
[3/5] incubator-trafodion git commit: [TRAFODION-2386]Add UT code for
varchar 32k issue add source code, build files and readme files
Posted by db...@apache.org.
[TRAFODION-2386]Add UT code for varchar 32k issue
add source code, build files and readme files
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/ac833c40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/ac833c40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/ac833c40
Branch: refs/heads/master
Commit: ac833c408e21394555725570053764d45ea64f52
Parents: ea16d38
Author: rwbzx <xi...@esgyn.cn>
Authored: Tue Dec 6 16:34:16 2016 +0800
Committer: rwbzx <xi...@esgyn.cn>
Committed: Tue Dec 6 16:34:16 2016 +0800
----------------------------------------------------------------------
.rat-excludes | 2 +
dcs/src/test/odbc/README.txt | 40 +
dcs/src/test/odbc/build/Makefile | 43 +
dcs/src/test/odbc/build/odbc.vcxproj | 157 ++
dcs/src/test/odbc/build/odbc.vcxproj.filters | 40 +
dcs/src/test/odbc/src/Main.cpp | 57 +
dcs/src/test/odbc/src/common/Global.cpp | 116 +
dcs/src/test/odbc/src/common/Global.h | 60 +
dcs/src/test/odbc/src/common/TestBase.cpp | 263 ++
dcs/src/test/odbc/src/common/TestBase.h | 55 +
.../src/test/varchar32k/LargeVarcharCol.cpp | 2639 ++++++++++++++++++
.../odbc/src/test/varchar32k/LargeVarcharCol.h | 52 +
12 files changed, 3524 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/.rat-excludes
----------------------------------------------------------------------
diff --git a/.rat-excludes b/.rat-excludes
index 3b8f9ab..41b8730 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -62,6 +62,8 @@ lic-.*-src
lic-.*-bin
note-.*-bin
# win generated
+odbc.vcxproj*
+odbc.vcxproj.*
SetCertificateDirReg_os.vcxproj*
SetCertificateDirReg_os.vcxproj.*
SetCertificateDirReg_os.sln*
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/README.txt
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/README.txt b/dcs/src/test/odbc/README.txt
new file mode 100644
index 0000000..1b866dc
--- /dev/null
+++ b/dcs/src/test/odbc/README.txt
@@ -0,0 +1,40 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+To build odbc test on Windows:
+1.Enter directory [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
+2.Open odbc.vcxproj in Microsoft visual studio
+3.Choose Platform as "x64" and Configuration as "Debug" in visual studio BUILD--Configuration Manager
+4.Build project "odbc" in visual studio
+
+To run odbc test on Windows using command line tool:
+>cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build\x64\Debug
+>odbc -d [<datasource>][-u <userid>][-p <password>]
+
+To build odbc test on Linux:
+>cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
+>make
+
+To run odbc test on Linux:
+>cd [<WHERE_YOU_PLACE_ODBC_FOLDER>]\odbc\build
+>./odbc -d [<datasource>][-u <userid>][-p <password>]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/build/Makefile
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/build/Makefile b/dcs/src/test/odbc/build/Makefile
new file mode 100644
index 0000000..e491dd2
--- /dev/null
+++ b/dcs/src/test/odbc/build/Makefile
@@ -0,0 +1,43 @@
+#/*************************************************************************
+#// @@@ START COPYRIGHT @@@
+#//
+#// Licensed to the Apache Software Foundation (ASF) under one
+#// or more contributor license agreements. See the NOTICE file
+#// distributed with this work for additional information
+#// regarding copyright ownership. The ASF licenses this file
+#// to you under the Apache License, Version 2.0 (the
+#// "License"); you may not use this file except in compliance
+#// with the License. You may obtain a copy of the License at
+#//
+#// http://www.apache.org/licenses/LICENSE-2.0
+#//
+#// Unless required by applicable law or agreed to in writing,
+#// software distributed under the License is distributed on an
+#// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#// KIND, either express or implied. See the License for the
+#// specific language governing permissions and limitations
+#// under the License.
+#//
+#// @@@ END COPYRIGHT @@@
+#**************************************************************************/
+
+LIB = -L${MY_SQROOT}/export/lib64 -ltrafodbc64
+CXX_FLAGS = -c -g -fshort-wchar -I/usr/include/odbc
+CC = /usr/bin/g++
+
+OBJ = Global.o TestBase.o LargeVarcharCol.o Main.o
+odbc : $(OBJ)
+ $(CC) $(LIB) -o odbc $(OBJ)
+
+Global.o :
+ $(CC) $(CXX_FLAGS) ../src/common/Global.cpp
+TestBase.o :
+ $(CC) $(CXX_FLAGS) ../src/common/TestBase.cpp
+LargeVarcharCol.o :
+ $(CC) $(CXX_FLAGS) ../src/test/varchar32k/LargeVarcharCol.cpp
+Main.o :
+ $(CC) $(CXX_FLAGS) ../src/Main.cpp
+
+.PHONY : clean
+clean :
+ rm odbc $(OBJ)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/build/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/build/odbc.vcxproj b/dcs/src/test/odbc/build/odbc.vcxproj
new file mode 100644
index 0000000..e35eb3d
--- /dev/null
+++ b/dcs/src/test/odbc/build/odbc.vcxproj
@@ -0,0 +1,157 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\src\common\Global.cpp" />
+ <ClCompile Include="..\src\common\TestBase.cpp" />
+ <ClCompile Include="..\src\Main.cpp" />
+ <ClCompile Include="..\src\test\Varchar32k\LargeVarcharCol.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\src\common\Global.h" />
+ <ClInclude Include="..\src\common\TestBase.h" />
+ <ClInclude Include="..\src\test\Varchar32k\LargeVarcharCol.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C6831450-503A-4580-89B1-5EF96652FAD0}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>odbc</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>$(IntDir)</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(IntDir)</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/build/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/build/odbc.vcxproj.filters b/dcs/src/test/odbc/build/odbc.vcxproj.filters
new file mode 100644
index 0000000..f1482fa
--- /dev/null
+++ b/dcs/src/test/odbc/build/odbc.vcxproj.filters
@@ -0,0 +1,40 @@
+\ufeff<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Common">
+ <UniqueIdentifier>{4551747b-2e0e-4676-a13f-3a30f4e3afc1}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Main">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Test">
+ <UniqueIdentifier>{01809a99-481d-4191-b93f-ac36eac257cc}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\src\common\Global.cpp">
+ <Filter>Common</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\common\TestBase.cpp">
+ <Filter>Common</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\Main.cpp">
+ <Filter>Main</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\test\Varchar32k\LargeVarcharCol.cpp">
+ <Filter>Test</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\src\common\Global.h">
+ <Filter>Common</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\common\TestBase.h">
+ <Filter>Common</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\test\Varchar32k\LargeVarcharCol.h">
+ <Filter>Test</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/Main.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/Main.cpp b/dcs/src/test/odbc/src/Main.cpp
new file mode 100644
index 0000000..3afc4b9
--- /dev/null
+++ b/dcs/src/test/odbc/src/Main.cpp
@@ -0,0 +1,57 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "common/Global.h"
+#include "test/varchar32k/LargeVarcharCol.h"
+
+int main(int argc, char * argv[])
+{
+ if (argc != 7)
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
+ return -1;
+ }
+ char inputArgs[6][100];
+ for (int i = 1; i < argc; i++)
+ strcpy(inputArgs[i - 1], argv[i]);
+
+ if ((strcmp(inputArgs[0], "-d") != 0) || (strcmp(inputArgs[2], "-u") != 0) || (strcmp(inputArgs[4], "-p") != 0))
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
+ return -1;
+ }
+
+ char chDsn[100];
+ char chUID[100];
+ char chPwd[100];
+ strcpy(chDsn, inputArgs[1]);
+ strcpy(chUID, inputArgs[3]);
+ strcpy(chPwd, inputArgs[5]);
+
+ CLargeVarcharCol * pTestItem = new CLargeVarcharCol(chDsn, chUID, chPwd);
+ pTestItem->Run();
+
+ delete pTestItem;
+ return 0;
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/common/Global.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/common/Global.cpp b/dcs/src/test/odbc/src/common/Global.cpp
new file mode 100644
index 0000000..4f52862
--- /dev/null
+++ b/dcs/src/test/odbc/src/common/Global.cpp
@@ -0,0 +1,116 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "Global.h"
+
+char *rTrim(char *string)
+{
+ char *strPtr;
+
+ for (strPtr = string + strlen(string) - 1;
+ strPtr >= string && (*strPtr == ' ' || *strPtr == '\t');
+ *(strPtr--) = '\0');
+ return(string);
+}
+
+int ConvertCharToCNumeric(SQL_NUMERIC_STRUCT& numericTmp, CHAR* cTmpBuf)
+{
+ unsigned char localBuf[101];
+ char* tempPtr = (char*)localBuf, *tempPtr1;
+ int i, j, a, b, current, calc, length;
+
+ SQLCHAR tempPrecision;
+ SQLCHAR tempScale;
+ SQLCHAR tempSign;
+ SQLCHAR tmpVal[101];
+
+ if (strlen(rTrim(cTmpBuf)) > sizeof(tmpVal))
+ return -1;
+
+ memset(tmpVal, 0, sizeof(tmpVal));
+
+ length = strlen(strcpy(tempPtr, cTmpBuf));
+ if (tempPtr[length - 1] == '.') tempPtr[length - 1] = '\0';
+
+ tempSign = (*tempPtr == '-') ? 0 : 1;
+
+ if (*tempPtr == '+' || *tempPtr == '-') tempPtr++;
+
+ if ((tempPtr1 = strchr(tempPtr, '.')) == NULL)
+ {
+ tempPrecision = strlen(tempPtr);
+ tempScale = 0;
+ }
+ else
+ {
+ tempPrecision = strlen(tempPtr) - 1;
+ tempScale = strlen(tempPtr1) - 1;
+ }
+
+ if (tempPrecision > ENDIAN_PRECISION_MAX)
+ return -1;
+
+ for (length = 0, tempPtr1 = (char*)localBuf; *tempPtr != 0; tempPtr++)
+ {
+ if (*tempPtr == '.') continue;
+ *tempPtr1++ = *tempPtr - '0';
+ length++;
+ }
+ memset(tempPtr1, 0, sizeof(localBuf) - length);
+
+ for (j = 0; j < 2 * sizeof(tmpVal); j++)
+ {
+ a = b = calc = 0;
+
+ for (i = 0; i < length; i++)
+ {
+ current = localBuf[i];
+ calc = calc * 10 + current;
+ a = calc % 16;
+ b = calc / 16;
+
+ localBuf[i] = b;
+ calc = a;
+ }
+ switch (j % 2)
+ {
+ case 0:
+ tmpVal[j / 2] = a;
+ break;
+ case 1:
+ tmpVal[j / 2] |= a << 4;
+ break;
+ }
+ }
+
+ for (i = sizeof(tmpVal) - 1; i > SQL_MAX_NUMERIC_LEN - 1; i--)
+ if (tmpVal[i] != 0)
+ return -1;
+
+ numericTmp.sign = tempSign;
+ numericTmp.precision = tempPrecision;
+ numericTmp.scale = tempScale;
+ memcpy(numericTmp.val, tmpVal, SQL_MAX_NUMERIC_LEN);
+
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/common/Global.h
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/common/Global.h b/dcs/src/test/odbc/src/common/Global.h
new file mode 100644
index 0000000..4ebcc8e
--- /dev/null
+++ b/dcs/src/test/odbc/src/common/Global.h
@@ -0,0 +1,60 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+#ifndef ODBC_GLOBAL_H
+#define ODBC_GLOBAL_H
+
+#ifdef _WIN64
+#include <windows.h>
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include <sql.h>
+#include <sqlext.h>
+#else
+#include <unistd.h>
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <stdio.h>
+#include <math.h>
+#endif // _WIN64
+
+using namespace std;
+
+#define MAX_SQLSTRING_LEN 1000
+#define STATE_SIZE 6
+#define MAX_CONNECT_STRING 256
+#define ENDIAN_PRECISION_MAX 39
+
+#define TRAF_ISO88591 0x0001
+#define TRAF_UTF8 0x0002
+#define TRAF_ALL TRAF_ISO88591|TRAF_UTF8
+
+/************************************************************************/
+/* conversion from char array to numeric */
+/************************************************************************/
+int ConvertCharToCNumeric(SQL_NUMERIC_STRUCT& numericTmp, CHAR* cTmpBuf);
+
+#endif // !ODBC_GLOBAL_H
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/common/TestBase.cpp
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/common/TestBase.cpp b/dcs/src/test/odbc/src/common/TestBase.cpp
new file mode 100644
index 0000000..a2fc55f
--- /dev/null
+++ b/dcs/src/test/odbc/src/common/TestBase.cpp
@@ -0,0 +1,263 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+#include "TestBase.h"
+
+
+CTestBase::CTestBase(const char * chDsn, const char * chUID, const char * chPwd)
+{
+ m_chDsn = new char[100];
+ m_chUID = new char[100];
+ m_chPwd = new char[100];
+
+ if (m_chDsn)
+ {
+ strcpy(m_chDsn, chDsn);
+ }
+
+ if (m_chUID)
+ {
+ strcpy(m_chUID, chUID);
+ }
+
+ if (m_chPwd)
+ {
+ strcpy(m_chPwd, chPwd);
+ }
+
+ henv = SQL_NULL_HANDLE;
+ hstmt = SQL_NULL_HANDLE;
+ hdbc = SQL_NULL_HANDLE;
+ hWnd = SQL_NULL_HANDLE;
+}
+
+
+CTestBase::~CTestBase()
+{
+ if (m_chDsn)
+ {
+ delete[] m_chDsn;
+ }
+
+ if (m_chUID)
+ {
+ delete[] m_chUID;
+ }
+
+ if (m_chPwd)
+ {
+ delete[] m_chPwd;
+ }
+}
+
+bool CTestBase::Run()
+{
+ if (!Connect())
+ return false;
+
+ if (!Prepare())
+ {
+ CleanUp();
+ Disconnect();
+ return false;
+ }
+ if (!TestGo())
+ {
+ CleanUp();
+ Disconnect();
+ return false;
+ }
+ CleanUp();
+ Disconnect();
+
+ return true;
+}
+
+bool CTestBase::Connect()
+{
+ unsigned char InConnStr[MAX_CONNECT_STRING];
+ unsigned char OutConnStr[MAX_CONNECT_STRING];
+ SQLRETURN returnCode;
+ SQLSMALLINT ConnStrLength;
+
+ sprintf((char *)InConnStr, "DSN=%s;UID=%s;PWD=%s", m_chDsn, m_chUID, m_chPwd);
+ // Allocate Environment Handle
+ returnCode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv)", returnCode);
+ return false;
+ }
+
+ // Set ODBC version to 3.0
+ returnCode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0)", returnCode);
+ return false;
+ }
+
+ // Allocate Connection handle
+ returnCode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc)", returnCode);
+ return false;
+ }
+
+ //Connect to the database
+ returnCode = SQLDriverConnect(hdbc, hWnd, InConnStr, SQL_NTS, OutConnStr, sizeof(OutConnStr), &ConnStrLength, SQL_DRIVER_NOPROMPT);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLDriverConnect", returnCode);
+ return false;
+ }
+
+ //Allocate Statement handle
+ returnCode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
+ if (returnCode != SQL_SUCCESS)
+ {
+ LogDiagnostics("SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt)", returnCode);
+ return false;
+ }
+
+ return true;
+}
+
+char *SqlRetText(int rc);
+void CTestBase::LogDiagnostics(const char *sqlFunction, SQLRETURN rc)
+{
+ SQLRETURN diagRC = SQL_SUCCESS;
+ SQLSMALLINT recordNumber;
+ SQLINTEGER nativeError;
+ SQLCHAR messageText[SQL_MAX_MESSAGE_LENGTH];
+ SQLCHAR sqlState[6];
+ int diagsPrinted = 0;
+ bool printedErrorLogHeader = false;
+ SQLSMALLINT totalNumber = 0;
+
+ std::cout << "Function " << sqlFunction << "returned : " << SqlRetText(rc) << endl;
+
+ /* Log any henv Diagnostics */
+ recordNumber = 1;
+ do{
+ diagRC = SQLGetDiagRec(SQL_HANDLE_ENV, henv, recordNumber, sqlState, &nativeError, messageText, SQL_NTS, NULL);
+ if (diagRC == SQL_SUCCESS)
+ {
+ if (!printedErrorLogHeader){
+ std::cout << "Diagnostics associated with environment handle:" << endl;
+ printedErrorLogHeader = true;
+ }
+ std::cout << "SQL Diag " << recordNumber << endl
+ << "Native Error : " << nativeError << endl
+ << "SQL State : " << sqlState << endl
+ << "Message: " << messageText << endl;
+ }
+ recordNumber++;
+ } while (diagRC == SQL_SUCCESS);
+
+ /* Log any hdbc Diagnostics */
+ recordNumber = 1;
+ printedErrorLogHeader = false;
+ do{
+ diagRC = SQLGetDiagRec(SQL_HANDLE_DBC, hdbc, recordNumber, sqlState, &nativeError, messageText, sizeof(messageText), &totalNumber);
+ if (diagRC == SQL_SUCCESS)
+ {
+ if (!printedErrorLogHeader){
+ std::cout << "Diagnostics associated with connection handle:" << endl;
+ printedErrorLogHeader = true;
+ }
+ std::cout << "SQL Diag " << recordNumber << endl
+ << dec << "Native Error : " << nativeError << endl
+ << "SQL State : " << sqlState << endl
+ << "Message: " << messageText << endl
+ << "TextLength: " << totalNumber << endl;
+ }
+ else if (diagRC == SQL_SUCCESS_WITH_INFO)
+ {
+ std::cout << "Error Msg Truncated, total number: " << dec << totalNumber << endl;
+ }
+ recordNumber++;
+ } while (diagRC == SQL_SUCCESS);
+
+ /* Log any hstmt Diagnostics */
+ recordNumber = 1;
+ printedErrorLogHeader = false;
+ do{
+ diagRC = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, recordNumber, sqlState, &nativeError, messageText, sizeof(messageText), &totalNumber);
+ if (diagRC == SQL_SUCCESS)
+ {
+ if (!printedErrorLogHeader){
+ std::cout << "Diagnostics associated with statmement handle:" << endl;
+ printedErrorLogHeader = true;
+ }
+ std::cout << "SQL Diag " << recordNumber << endl
+ << dec << "Native Error : " << nativeError << endl
+ << "SQL State : " << sqlState << endl
+ << "Message: " << messageText << endl
+ << "TextLength: " << totalNumber << endl;
+ }
+ else if (diagRC == SQL_SUCCESS_WITH_INFO)
+ {
+ std::cout << "Error Msg Truncated, total number: " << dec << totalNumber << endl;
+ }
+
+ recordNumber++;
+ } while (diagRC == SQL_SUCCESS);
+}
+
+void CTestBase::Disconnect()
+{
+ if (hstmt != SQL_NULL_HANDLE)
+ SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
+ if (hdbc != SQL_NULL_HANDLE)
+ {
+ SQLDisconnect(hdbc);
+ SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
+ }
+ if (henv != SQL_NULL_HANDLE)
+ SQLFreeHandle(SQL_HANDLE_ENV, henv);
+}
+
+char *SqlRetText(int rc)
+{
+ static char buffer[80];
+ switch (rc)
+ {
+ case SQL_SUCCESS:
+ return("SQL_SUCCESS");
+ case SQL_SUCCESS_WITH_INFO:
+ return("SQL_SUCCESS_WITH_INFO");
+ case SQL_NO_DATA:
+ return("SQL_NO_DATA");
+ case SQL_ERROR:
+ return("SQL_ERROR");
+ case SQL_INVALID_HANDLE:
+ return("SQL_INVALID_HANDLE");
+ case SQL_STILL_EXECUTING:
+ return("SQL_STILL_EXECUTING");
+ case SQL_NEED_DATA:
+ return("SQL_NEED_DATA");
+ }
+ sprintf(buffer, "SQL Error %d", rc);
+ return(buffer);
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac833c40/dcs/src/test/odbc/src/common/TestBase.h
----------------------------------------------------------------------
diff --git a/dcs/src/test/odbc/src/common/TestBase.h b/dcs/src/test/odbc/src/common/TestBase.h
new file mode 100644
index 0000000..b7f04cd
--- /dev/null
+++ b/dcs/src/test/odbc/src/common/TestBase.h
@@ -0,0 +1,55 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+#ifndef ODBC_TEST_BASE_H
+#define ODBC_TEST_BASE_H
+
+#include "Global.h"
+
+class CTestBase
+{
+protected:
+ char * m_chDsn;
+ char * m_chUID;
+ char * m_chPwd;
+ SQLHENV henv;
+ SQLHDBC hdbc;
+ SQLHSTMT hstmt;
+ SQLHWND hWnd;
+
+public:
+ CTestBase(const char * chDsn, const char * chUID, const char * chPwd);
+ virtual bool Run();
+ virtual ~CTestBase();
+
+private:
+ CTestBase();
+protected:
+ virtual bool Connect();
+ virtual bool Prepare() = 0;
+ virtual bool TestGo() = 0;
+ virtual void CleanUp() = 0;
+ virtual void Disconnect();
+ virtual void LogDiagnostics(const char *sqlFunction, SQLRETURN rc);
+};
+
+#endif // !ODBC_TEST_BASE_H
\ No newline at end of file