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:58 UTC
[3/5] incubator-trafodion git commit: [TRAFODION-2386]Add UT code for
varchar 32k issue add source code, build files and readme files
[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