Skip to content

Commit

Permalink
Release/2019.09 (#38)
Browse files Browse the repository at this point in the history
* [#7] modification of the README.txt and license.txt files for 10.1 release (#8)

* [RND-269] SQLDescribeCol() function should return SQL_LONGVARBINARY and SQL_LONGVARCHAR for BLOB and CLOB data type rather than SQL_C_DEFAULT. (#10)

* in the UNICODE version of cubrid_odbc.dll, SQLDescribeCol() function should return SQL_WCHAR instead of SQL_WVARCHAR for the CHAR(n) database type under utf-8 charset. (#11)

* [APIS-759] To prevent application crash caused by health_checker thread, GET_MODULE_HANDLE_EX_FLAG_PIN flag was used when calling the GetModuleHandleEx function at DLL_PROCESS_ATTACH state in DllMain. (#12)

* [APIS-773] Modify/Remove broken link in README or Wiki at github/CUBRID repositories (#13)

* [APIS-776] fix SQLGetInfoW function standard(spec) violation (#14)

* The SQLGetInfoW function conform to the following odbc specification.

"If *InfoValuePtr is a Unicode string (when calling SQLGetInfoW), the
BufferLength argument must be an even number; if not, SQLSTATE HY090
(Invalid string or buffer length) is returned."

* The SQLGetInfoW function conform to the following odbc specification.

"If InfoValuePtr is NULL, StringLengthPtr will still return the total
number of bytes (excluding the null-termination character for character
data) available to reurn in the buffer pointed to by InfoValuePtr."

* The SQLGetInfoW function conform to the following odbc specification.

"For character data, if the number of bytes available to return is
greater than or equal to BufferLength, the information in *InfoValuePtr
is truncated to BufferLength bytes minus the length of a
null-termination character and is null-terminated by the driver."

* The SQLGetInfo and SQLGetInfoW functions conform to the following odbc
specification.

"StringLengthPtr argument - Pointer to a buffer in which to return the
total number of bytes (excluding the null-termination character for
character data) available to return in *InfoValuePtr."

* [APIS-785] Change unicode.c encoding to UTF8 (from UTF16) (#15)

* [APIS-788] sub-task [APIS-789] Upgrade build environment for Visual Studio (#16)

* [APIS-790] Invalid BufferLength in SQLGetDiagRecW(...) for wide char (#17)

* [APIS-791] SQLGetDiagRecW returns SQL State to S01000 for connection error. (#18)

* Apis 792 (#20)

* [APIS-792] Providing the session information for current connection via DiagField

* [APIS-792] Providing the session information for current connection via DiagField

* [APIS-793] Increasing default column length for derived column (#21)

* [APIS-796] Correct processing SQLCancel(...) (#24)

* [APIS-796] Correct processing SQLCancel(...)

* [APIS-796] revised: Correct processing SQLCancel(...)

* [APIS-795] Correct processing multi-bye binding in update query (#23)

* [APIS-795] Correct processing multi-bye binding in update query

* [APIS-795] revised: Correct processing multi-bye binding in update query

* [APIS-797] Processing to get the query-plan for any queries. (#25)

* [APIS-797] Processing to get the query-plan for any queries.

* [APIS-797] revised: Processing to get the query-plan for any queries.

* [APIS-794] Processing multi-byte (utf-8) column name (#22)

* [APIS-798] Correct processing multi-byte for native query (SQLNativeSql) (#26)

* [APIS-789] Upgrad build envrionment: compatibility for Legacy standard I/O Definition (#27)

* [APIS-799] Correct processing of string length for SUCCESS_WITH_INFO (#28)

* [APIS-799] Correct processing of string length for SUCCESS_WITH_INFO

* [APIS-799] revised: Correct processing of string length for SUCCESS_WITH_INFO

* [APIS-800] Correct processing for multi-byte to wide-char and vice-vesa. (#29)

* [APIS-800] Correct processing for multi-byte to wide-char and vice-versa.

* [APIS-800] revised: Correct processing for multi-byte to wide-char and vice-versa.

* [APIS-800] revised: Correct processing for multi-byte to wide-char and vice-versa.

* [APIS-802] Adding Test Case for ODBC update version (#30)

* [APIS-802] Adding Test Case for ODBC update version (CPP Case) (#31)

* [APIS-802] Adding Test Case for ODBC update version

* [APIS-802] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] Adding Test Case for ODBC update version (conn-string utf-8 modify)

* APIS-802 revised... (#32)

* [APIS-802] Adding Test Case for ODBC update version

* [APIS-802] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] Adding Test Case for ODBC update version (conn-string utf-8 modify)

* [APIS-802] [Revised] Adding Test Case for ODBC update version (CPP Case)

* [APIS 802] add unit test case for C++ (#33)

* [APIS-802] Adding Test Case for ODBC update version

* [APIS-802] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] Adding Test Case for ODBC update version (conn-string utf-8 modify)

* [APIS-802] [Revised] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] add unit test case (#34)

* [APIS-802] Adding Test Case for ODBC update version

* [APIS-802] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] Adding Test Case for ODBC update version (conn-string utf-8 modify)

* [APIS-802] [Revised] Adding Test Case for ODBC update version (CPP Case)

* [APIS-802] change connect (SQLConnto --> SQLDriverConnt) for user specify

* [APIS-802] add test cases for C++ (source code encoding EUC-KR) (#36)

* Add to test-code for under version to 9.2.x.
  • Loading branch information
swi0110 authored Oct 22, 2019
1 parent 78a9a7e commit b3e8ad2
Show file tree
Hide file tree
Showing 36 changed files with 1,902 additions and 278 deletions.
49 changes: 49 additions & 0 deletions UnitTest-CPP/UnitTest-CPP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest-CPP", "UnitTest-CPP\UnitTest-CPP.vcxproj", "{FA19B10D-59A2-42F6-AD63-06C00122E9E6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubrid_odbc", "..\cubrid_odbc_14.vcxproj", "{37E00A2E-BBC5-4736-90D9-A1B4271759BB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubrid_odbc_unicode", "..\cubrid_odbc_unicode_14.vcxproj", "{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Debug|Win32.ActiveCfg = Debug|Win32
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Debug|Win32.Build.0 = Debug|Win32
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Debug|Win32.Deploy.0 = Debug|Win32
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Debug|x64.ActiveCfg = Debug|x64
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Debug|x64.Build.0 = Debug|x64
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Release|Win32.ActiveCfg = Release|Win32
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Release|Win32.Build.0 = Release|Win32
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Release|x64.ActiveCfg = Release|x64
{FA19B10D-59A2-42F6-AD63-06C00122E9E6}.Release|x64.Build.0 = Release|x64
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|Win32.ActiveCfg = Debug|Win32
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|Win32.Build.0 = Debug|Win32
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|x64.ActiveCfg = Debug|x64
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|x64.Build.0 = Debug|x64
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|Win32.ActiveCfg = Release|Win32
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|Win32.Build.0 = Release|Win32
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|x64.ActiveCfg = Release|x64
{37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|x64.Build.0 = Release|x64
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|Win32.ActiveCfg = Debug|Win32
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|Win32.Build.0 = Debug|Win32
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|x64.ActiveCfg = Debug|x64
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|x64.Build.0 = Debug|x64
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|Win32.ActiveCfg = Release|Win32
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|Win32.Build.0 = Release|Win32
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|x64.ActiveCfg = Release|x64
{0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
170 changes: 170 additions & 0 deletions UnitTest-CPP/UnitTest-CPP/UnitTest-CPP.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{FA19B10D-59A2-42F6-AD63-06C00122E9E6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>UnitTestCPP</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</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 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 Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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|x64'">
<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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="UnitTest.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\cubrid-odbc.git\cubrid_odbc_14.vcxproj">
<Project>{37e00a2e-bbc5-4736-90d9-a1b4271759bb}</Project>
</ProjectReference>
<ProjectReference Include="..\..\cubrid_odbc_unicode_14.vcxproj">
<Project>{0092bd82-bce8-4e10-a9db-d083fc5c9d67}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
173 changes: 173 additions & 0 deletions UnitTest-CPP/UnitTest-CPP/UnitTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#include "stdafx.h"

#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <odbcss.h>

#define MAXBUFLEN 640
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTestCPP
{
TEST_CLASS(UnitTest)
{
public:
TEST_METHOD(TestClassInit)
{
}

TEST_METHOD(QueryPlan)
{
RETCODE retcode;

SQLWCHAR query_plan[32768] = { 0, };

SQLHENV env;
SQLHDBC dbc;
SQLHSTMT hStmt = SQL_NULL_HSTMT;
SWORD plm_pcbErrorMsg = 0;
SQLINTEGER diag_rec;

SQLLEN len;

/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *)SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);

//retcode = SQLDriverConnect(dbc, NULL, L"DSN=CUBRID Driver Unicode;DB_NAME=demodb;SERVER=test-db-server;PORT=33000;USER=dba;PWD=;CHARSET=utf-8;", SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);
retcode = SQLConnect(dbc, L"CUBRID Driver Unicode", SQL_NTS, L"dba", SQL_NTS, NULL, SQL_NTS);

if (retcode == SQL_ERROR) {
SQLGetDiagField(SQL_HANDLE_DBC, dbc, 0, SQL_DIAG_NUMBER, &diag_rec, 0, &plm_pcbErrorMsg);
}

Assert::AreNotEqual((int)retcode, SQL_ERROR);

// Allocate statement handle and execute a query
retcode = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &hStmt);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

retcode = SQLExecDirect(hStmt, L"SELECT name as \"user\", db_user, groups FROM db_user", SQL_NTS);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

retcode = SQLFetch(hStmt);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

// Get Query Plan
retcode = SQLGetData(hStmt, 1, SQL_C_DEFAULT, (SQLPOINTER)query_plan, 0, &len);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

if (retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLGetData(hStmt, 1, SQL_C_DEFAULT, (SQLPOINTER)query_plan, len, &len);
}

Assert::AreNotEqual((int)retcode, SQL_ERROR);

if (strlen((const char *)query_plan) > 0) {
int c = strncmp((const char *)query_plan, (const char *)L"Join graph", 10);
Assert::AreEqual(c, 0);
}
else {
Assert::Fail(L"Query Plan is null");
}
// Clean up.
SQLDisconnect(dbc);
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
}

TEST_METHOD(QueryPlanMultiByte)
{
RETCODE retcode;

SQLWCHAR query_plan[32768] = { 0, };

SQLHENV env;
SQLHDBC dbc;
SQLHSTMT hStmt = SQL_NULL_HSTMT;
SWORD plm_pcbErrorMsg = 0;
SQLINTEGER diag_rec;

SQLLEN len;

/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *)SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);

//retcode = SQLDriverConnect(dbc, NULL, L"DSN=CUBRID Driver Unicode;DB_NAME=demodb;SERVER=test-db-server;PORT=33000;USER=dba;PWD=;CHARSET=utf-8;", SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT);
retcode = SQLConnect(dbc, L"CUBRID Driver Unicode", SQL_NTS, L"dba", SQL_NTS, NULL, SQL_NTS);

if (retcode == SQL_ERROR) {
SQLGetDiagField(SQL_HANDLE_DBC, dbc, 0, SQL_DIAG_NUMBER, &diag_rec, 0, &plm_pcbErrorMsg);
}

Assert::AreNotEqual((int)retcode, SQL_ERROR);

// Allocate statement handle and execute a query
retcode = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &hStmt);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

retcode = SQLExecDirect(hStmt, L"DROP TABLE IF EXISTS [테이블] ", SQL_NTS);
Assert::AreNotEqual((int)retcode, SQL_ERROR);
retcode = SQLExecDirect(hStmt, L"CREATE TABLE [테이블] ([이름] varchar(16), [나이] integer)", SQL_NTS);
Assert::AreNotEqual((int)retcode, SQL_ERROR);
retcode = SQLExecDirect(hStmt, L"INSERT INTO [테이블] VALUES ('홍길동', 25)", SQL_NTS);
Assert::AreNotEqual((int)retcode, SQL_ERROR);
retcode = SQLExecDirect(hStmt, L"SELECT [이름], [나이] FROM [테이블] WHERE [나이] > 19", SQL_NTS);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

retcode = SQLFetch(hStmt);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

//MessageBox(NULL, L"Contents", L"Title", MB_OK);

// Get Query Plan
retcode = SQLGetData(hStmt, 1, SQL_C_DEFAULT, (SQLPOINTER)query_plan, 0, &len);
Assert::AreNotEqual((int)retcode, SQL_ERROR);

if (retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLGetData(hStmt, 1, SQL_C_DEFAULT, (SQLPOINTER)query_plan, len, &len);
}

Assert::AreNotEqual((int)retcode, SQL_ERROR);

if (strlen((const char *)query_plan) > 0) {
wchar_t expected_window[198] = L"Join graph segments (f indicates final):\r\nseg[0]: [0]\r\nseg[1]: 이름[0] (f)\r\nseg[2]: 나이[0] (f)\r\nJoin graph nodes:\r\nnode[0]: 테이블 테이블(1/1) (sargs 0) (loc 0)\r\nJoin graph terms:\r\nterm[0]: [테이블].[나이] range";
wchar_t expected_linux[198] = L"Join graph segments (f indicates final):\nseg[0]: [0]\nseg[1]: 이름[0] (f)\nseg[2]: 나이[0] (f)\nJoin graph nodes:\nnode[0]: 테이블 테이블(1/1) (sargs 0) (loc 0)\nJoin graph terms:\nterm[0]: [테이블].[나이] range";

//for windows
int c = wcsncmp(query_plan, expected_window, wcslen(expected_window));
if (c != 0) {
// for linux
c = wcsncmp(query_plan, expected_linux, wcslen(expected_linux));
}
if (c != 0) {
wchar_t* wc = (wchar_t*)query_plan;
std::wstring ws(wc);

//for under version to 9.2.x
if (((int)ws.find(L"테이블")) > 0 && ((int)ws.find(L"이름")) > 0 && ((int)ws.find(L"나이")) > 0){
c = 0;
}
}
Assert::AreEqual(c, 0);
}
else {
Assert::Fail(L"Query Plan is null");
}
// Clean up.
SQLDisconnect(dbc);
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
}
};
}
Loading

0 comments on commit b3e8ad2

Please sign in to comment.