diff --git a/UnitTest-CPP/UnitTest-CPP.sln b/UnitTest-CPP/UnitTest-CPP.sln new file mode 100644 index 0000000..1e7aa7e --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP.sln @@ -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 diff --git a/UnitTest-CPP/UnitTest-CPP/UnitTest-CPP.vcxproj b/UnitTest-CPP/UnitTest-CPP/UnitTest-CPP.vcxproj new file mode 100644 index 0000000..402cbaa --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP/UnitTest-CPP.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {FA19B10D-59A2-42F6-AD63-06C00122E9E6} + Win32Proj + UnitTestCPP + 10.0.15063.0 + NativeUnitTestProject + + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + DynamicLibrary + true + v141 + Unicode + false + + + DynamicLibrary + false + v141 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + + Use + Level3 + Disabled + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + + + Use + Level3 + Disabled + _DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + + + + + + + Create + Create + Create + Create + + + + + + {37e00a2e-bbc5-4736-90d9-a1b4271759bb} + + + {0092bd82-bce8-4e10-a9db-d083fc5c9d67} + + + + + + \ No newline at end of file diff --git a/UnitTest-CPP/UnitTest-CPP/UnitTest.cpp b/UnitTest-CPP/UnitTest-CPP/UnitTest.cpp new file mode 100644 index 0000000..de440b8 --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP/UnitTest.cpp @@ -0,0 +1,173 @@ +#include "stdafx.h" + +#include +#include +#include +#include +#include +#include + +#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); + } + }; +} \ No newline at end of file diff --git a/UnitTest-CPP/UnitTest-CPP/stdafx.cpp b/UnitTest-CPP/UnitTest-CPP/stdafx.cpp new file mode 100644 index 0000000..ce584f8 --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ǥ ϸ ִ ҽ Դϴ. +// UnitTest-CPP.pch ̸ ϵ ˴ϴ. +// stdafx.obj ̸ ϵ Ե˴ϴ. + +#include "stdafx.h" + +// TODO: ʿ ߰ +// ƴ STDAFX.H մϴ. diff --git a/UnitTest-CPP/UnitTest-CPP/stdafx.h b/UnitTest-CPP/UnitTest-CPP/stdafx.h new file mode 100644 index 0000000..7f5aac4 --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP/stdafx.h @@ -0,0 +1,13 @@ +// stdafx.h : ʴ +// ǥ ý Ǵ Ʈ +// ִ Դϴ. +// + +#pragma once + +#include "targetver.h" + +// CppUnitTest +#include "CppUnitTest.h" + +// TODO: α׷ ʿ ߰ ⿡ մϴ. diff --git a/UnitTest-CPP/UnitTest-CPP/targetver.h b/UnitTest-CPP/UnitTest-CPP/targetver.h new file mode 100644 index 0000000..3142091 --- /dev/null +++ b/UnitTest-CPP/UnitTest-CPP/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ϸ ְ 뼺 Windows ÷ ǵ˴ϴ. + +// Windows ÷ α׷ Ϸ 쿡 SDKDDKVer.h ϱ +// WinSDKVer.h ϰ _WIN32_WINNT ũθ Ϸ ÷ Ͻʽÿ. + +#include diff --git a/UnitTest/TestRunConfig.testrunconfig b/UnitTest/TestRunConfig.testrunconfig index f611a78..7e3ad42 100644 --- a/UnitTest/TestRunConfig.testrunconfig +++ b/UnitTest/TestRunConfig.testrunconfig @@ -1,5 +1,5 @@ - - + + This is a default test run configuration for a local test run. diff --git a/UnitTest/UnitTest/TestInterfaceGetData.cs b/UnitTest/UnitTest/TestInterfaceGetData.cs index e59e736..47f2758 100644 --- a/UnitTest/UnitTest/TestInterfaceGetData.cs +++ b/UnitTest/UnitTest/TestInterfaceGetData.cs @@ -22,7 +22,7 @@ public static void case_odbc_get_data() { } /// - /// Test OdbcTransaction class + /// Test OdbcInterface class /// public static void Test_GetData() { diff --git a/UnitTest/UnitTest/TestIssueCase.cs b/UnitTest/UnitTest/TestIssueCase.cs new file mode 100644 index 0000000..7e4fa25 --- /dev/null +++ b/UnitTest/UnitTest/TestIssueCase.cs @@ -0,0 +1,84 @@ +using System; +using System.Text; +using System.Data; +using System.Data.Odbc; +using System.Data.Common; +using System.Runtime.InteropServices; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UnitTest +{ + public partial class TestCases + { + /// + /// Test IssueCase class + /// + /// + + public static void Test_multibyte_columns() + { + using (OdbcCommand cmd = new OdbcCommand("Drop table if exists [인적사항]", conn)) + { + cmd.ExecuteNonQuery(); + } + + using (OdbcCommand cmd = new OdbcCommand("Create Table [인적사항] ([이름] varchar(16), [나이] integer)", conn)) + { + cmd.ExecuteNonQuery(); + } + + using (OdbcCommand cmd = new OdbcCommand("desc [인적사항]", conn)) + { + String column; + + OdbcDataReader reader = cmd.ExecuteReader(); + reader.Read(); //only two row will be available + column = reader.GetString(0); + Assert.IsTrue(column == "이름"); + reader.Read(); //only two row will be available + column = reader.GetString(0); + Assert.IsTrue(column == "나이"); + } + + using (OdbcCommand cmd = new OdbcCommand("drop table if exists [인적사항] ", conn)) + { + cmd.ExecuteNonQuery(); + } + } + + public static void Test_multibyte_binding() + { + using (OdbcCommand cmd = new OdbcCommand("Drop table if exists [인적사항]", conn)) + { + cmd.ExecuteNonQuery(); + } + + using (OdbcCommand cmd = new OdbcCommand("Create Table [인적사항] ([이름] varchar(16), [나이] integer)", conn)) + { + cmd.ExecuteNonQuery(); + } + + using (OdbcCommand cmd = new OdbcCommand("insert into [인적사항] values (?, ?)", conn)) + { + OdbcParameter name = new OdbcParameter("?", "홍길동"); + OdbcParameter age = new OdbcParameter("?", 19); + cmd.Parameters.Add(name); + cmd.Parameters.Add(age); + cmd.ExecuteNonQuery(); + } + + using (OdbcCommand cmd = new OdbcCommand("select * from [인적사항]", conn)) + { + OdbcDataReader reader = cmd.ExecuteReader(); + reader.Read(); + Assert.IsTrue(reader.GetString(0) == "홍길동"); + Assert.IsTrue(reader.GetInt32(1) == 19); + } + + using (OdbcCommand cmd = new OdbcCommand("drop table if exists [인적사항] ", conn)) + { + cmd.ExecuteNonQuery(); + } + } + } +} \ No newline at end of file diff --git a/UnitTest/UnitTest/UnitIssueCase.cs b/UnitTest/UnitTest/UnitIssueCase.cs index 6f53ff0..e3d14eb 100644 --- a/UnitTest/UnitTest/UnitIssueCase.cs +++ b/UnitTest/UnitTest/UnitIssueCase.cs @@ -1,181 +1,181 @@ -using System; -using System.Text; -using System.Data; -using System.Data.Odbc; -using System.Data.Common; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace UnitTest -{ - public partial class TestCases - { - private static readonly string connString = - "Driver={CUBRID Driver};server=test-db-server;port=30000;uid=dba;pwd=;db_name=demodb;"; - private static OdbcConnection conn = new OdbcConnection(); - - public static void TestCase_init() - { - conn.ConnectionString = connString; - conn.Open(); - } - - public static void TestCase_dinit() - { - conn.Close(); - } - - public static void case_select() - { - using (OdbcCommand cmd = new OdbcCommand("select * from code;", conn)) - { - OdbcDataReader reader = (OdbcDataReader)cmd.ExecuteReader(); - int i = 0; - while (reader.Read()) - { - i++; - // Console.WriteLine(reader.GetInt32(0)); - Console.WriteLine(reader.GetValue(0).ToString()); - Assert.IsNotNull(reader); - } - if (0 == i) - { - Console.WriteLine("no data."); - } - } - } - - static public void case_connect_properties() - { - OdbcConnection conn = new OdbcConnection(); - conn.ConnectionString = - "Driver={CUBRID Driver};server=1.1.1.1;port=30000;uid=dba;pwd=;db_name=demodb;Database=demodb;althosts=test-db-server:33000,2.3.4.5:33000;loginTimeout=600"; - conn.Open(); - - Assert.AreEqual(conn.State, ConnectionState.Open); - conn.Close(); - } - - public static void case_dataset() - { - OdbcDataAdapter da=new OdbcDataAdapter("select * from code;",conn); - - DataSet ds = new DataSet(); - da.Fill(ds); - - DisplayData(ds.Tables[0]); - } - - public static void case_datatable() - { - OdbcDataAdapter da = new OdbcDataAdapter("select * from code;", conn); - - DataTable dt = new DataTable(); - da.Fill(dt); - - DisplayData(dt); - } - - static public void case_GetInt16_OverBound_Max() - { - // Open Connection - string strConn = connString; - OdbcConnection connCubrid = conn; - - int test_int = Int16.MaxValue + 1; //Int32 32768 - string testTable = "t_type_int16_overbound"; - string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f_int INT)", testTable); - string strDropTable = string.Format("DROP TABLE {0}", testTable); - string strSqlInsert = string.Format("INSERT INTO {0}(f_int) VALUE({1})", testTable, test_int); - - ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert }); - - string strSqlSelect = string.Format("SELECT f_int FROM {0} ORDER BY id DESC;", testTable); - OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect); - // Int16 result = odbcReader.GetInt16(0); - Console.WriteLine(test_int); // output: 32768 - try - { - Console.WriteLine(odbcReader.GetInt16(0)); // output: -32768, expected result: OdbcException - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - - } - - static public void case_GetInt16_OverBound_Min() - { - // Open Connection - string strConn = connString; - OdbcConnection connCubrid = conn; - - // int test_int = Int32.MinValue; //Int32 -32769 - int test_int = Int32.MinValue; - string testTable = "t_type_int16_overbound"; - string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f_int INT)", testTable); - string strDropTable = string.Format("DROP TABLE {0}", testTable); - string strSqlInsert = string.Format("INSERT INTO {0}(f_int) VALUE({1})", testTable, test_int); - - ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert }); - - string strSqlSelect = string.Format("SELECT * FROM {0} ORDER BY id DESC;", testTable); - OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect); - - Console.WriteLine(test_int); // output: -32769 - try - { - Console.WriteLine(odbcReader.GetInt16(0)); // output: -32768, expected result: OdbcException - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - } - - static public void case_invalid_db() - { - // Invalid connection string - invalid db_name - try - { - String strConn2 = @"Dsn=CUBRID_ODBC;db_name=invalid_db;uid=dba;pwd=;server=test-db-server;port=33000;fetch_size=100"; - OdbcConnection connCubrid2 = new OdbcConnection(strConn2); - connCubrid2.Open(); - connCubrid2.Close(); - } - catch (OdbcException e) - { - Console.WriteLine("Error message is : "); - Console.WriteLine(e.Message); - } - - // Invalid connection string - invalid uid - try - { - String strConn3 = @"Dsn=CUBRID_ODBC;db_name=test_odbc;uid=invlid_uid;pwd=;server=test-db-server;port=33000;fetch_size=100"; - OdbcConnection connCubrid3 = new OdbcConnection(strConn3); - connCubrid3.Open(); - connCubrid3.Close(); - } - catch (OdbcException e) - { - Console.WriteLine("Error message is : "); - Console.WriteLine(e.Message); - } - - // Invalid connection string - invalid port - try - { - String strConn3 = @"Dsn=CUBRID_ODBC;db_name=test_odbc;uid=invlid_uid;pwd=;server=test-db-server;port=330001;fetch_size=100"; - OdbcConnection connCubrid3 = new OdbcConnection(strConn3); - connCubrid3.Open(); - connCubrid3.Close(); - } - catch (OdbcException e) - { - Console.WriteLine("Error message is : "); - Console.WriteLine(e.Message); - } - } - } -} +using System; +using System.Text; +using System.Data; +using System.Data.Odbc; +using System.Data.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UnitTest +{ + public partial class TestCases + { + private static readonly string connString = + "Driver={CUBRID Driver Unicode};server=localhost;port=33000;uid=dba;pwd=;db_name=demodb1;charset=utf-8;"; + private static OdbcConnection conn = new OdbcConnection(); + + public static void TestCase_init() + { + conn.ConnectionString = connString; + conn.Open(); + } + + public static void TestCase_dinit() + { + conn.Close(); + } + + public static void case_select() + { + using (OdbcCommand cmd = new OdbcCommand("select * from code;", conn)) + { + OdbcDataReader reader = (OdbcDataReader)cmd.ExecuteReader(); + int i = 0; + while (reader.Read()) + { + i++; + // Console.WriteLine(reader.GetInt32(0)); + Console.WriteLine(reader.GetValue(0).ToString()); + Assert.IsNotNull(reader); + } + if (0 == i) + { + Console.WriteLine("no data."); + } + } + } + + static public void case_connect_properties() + { + OdbcConnection conn = new OdbcConnection(); + conn.ConnectionString = + "Driver={CUBRID Driver};server=1.1.1.1;port=30000;uid=dba;pwd=;db_name=demodb;Database=demodb;althosts=test-db-server:33000,2.3.4.5:33000;loginTimeout=600"; + conn.Open(); + + Assert.AreEqual(conn.State, ConnectionState.Open); + conn.Close(); + } + + public static void case_dataset() + { + OdbcDataAdapter da=new OdbcDataAdapter("select * from code;",conn); + + DataSet ds = new DataSet(); + da.Fill(ds); + + DisplayData(ds.Tables[0]); + } + + public static void case_datatable() + { + OdbcDataAdapter da = new OdbcDataAdapter("select * from code;", conn); + + DataTable dt = new DataTable(); + da.Fill(dt); + + DisplayData(dt); + } + + static public void case_GetInt16_OverBound_Max() + { + // Open Connection + string strConn = connString; + OdbcConnection connCubrid = conn; + + int test_int = Int16.MaxValue + 1; //Int32 32768 + string testTable = "t_type_int16_overbound"; + string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f_int INT)", testTable); + string strDropTable = string.Format("DROP TABLE {0}", testTable); + string strSqlInsert = string.Format("INSERT INTO {0}(f_int) VALUE({1})", testTable, test_int); + + ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert }); + + string strSqlSelect = string.Format("SELECT f_int FROM {0} ORDER BY id DESC;", testTable); + OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect); + // Int16 result = odbcReader.GetInt16(0); + Console.WriteLine(test_int); // output: 32768 + try + { + Console.WriteLine(odbcReader.GetInt16(0)); // output: -32768, expected result: OdbcException + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + + } + + static public void case_GetInt16_OverBound_Min() + { + // Open Connection + string strConn = connString; + OdbcConnection connCubrid = conn; + + // int test_int = Int32.MinValue; //Int32 -32769 + int test_int = Int32.MinValue; + string testTable = "t_type_int16_overbound"; + string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f_int INT)", testTable); + string strDropTable = string.Format("DROP TABLE {0}", testTable); + string strSqlInsert = string.Format("INSERT INTO {0}(f_int) VALUE({1})", testTable, test_int); + + ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert }); + + string strSqlSelect = string.Format("SELECT * FROM {0} ORDER BY id DESC;", testTable); + OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect); + + Console.WriteLine(test_int); // output: -32769 + try + { + Console.WriteLine(odbcReader.GetInt16(0)); // output: -32768, expected result: OdbcException + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + static public void case_invalid_db() + { + // Invalid connection string - invalid db_name + try + { + String strConn2 = @"Dsn=CUBRID_ODBC;db_name=invalid_db;uid=dba;pwd=;server=test-db-server;port=33000;fetch_size=100"; + OdbcConnection connCubrid2 = new OdbcConnection(strConn2); + connCubrid2.Open(); + connCubrid2.Close(); + } + catch (OdbcException e) + { + Console.WriteLine("Error message is : "); + Console.WriteLine(e.Message); + } + + // Invalid connection string - invalid uid + try + { + String strConn3 = @"Dsn=CUBRID_ODBC;db_name=test_odbc;uid=invlid_uid;pwd=;server=test-db-server;port=33000;fetch_size=100"; + OdbcConnection connCubrid3 = new OdbcConnection(strConn3); + connCubrid3.Open(); + connCubrid3.Close(); + } + catch (OdbcException e) + { + Console.WriteLine("Error message is : "); + Console.WriteLine(e.Message); + } + + // Invalid connection string - invalid port + try + { + String strConn3 = @"Dsn=CUBRID_ODBC;db_name=test_odbc;uid=invlid_uid;pwd=;server=test-db-server;port=330001;fetch_size=100"; + OdbcConnection connCubrid3 = new OdbcConnection(strConn3); + connCubrid3.Open(); + connCubrid3.Close(); + } + catch (OdbcException e) + { + Console.WriteLine("Error message is : "); + Console.WriteLine(e.Message); + } + } + } +} diff --git a/UnitTest/UnitTest/UnitTest.csproj b/UnitTest/UnitTest/UnitTest.csproj index b9c6d5c..a144b22 100644 --- a/UnitTest/UnitTest/UnitTest.csproj +++ b/UnitTest/UnitTest/UnitTest.csproj @@ -1,4 +1,5 @@ - + + bin\x86\Release\ TRACE @@ -8,6 +9,7 @@ true GlobalSuppressions.cs prompt + false true @@ -18,6 +20,7 @@ true GlobalSuppressions.cs prompt + false Debug @@ -29,29 +32,38 @@ Properties UnitTest UnitTest - v3.5 + v4.5 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + 3.5 + - - true - full - false + + AnyCPU + bin\Release\ + false + + + AnyCPU bin\Debug\ - DEBUG;TRACE - prompt - 4 + false - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + x64 + bin\x64\Release\ + false + + + x64 + bin\x64\Debug\ + false - + 3.5 @@ -70,6 +82,7 @@ + diff --git a/UnitTest/UnitTest/UnitTestOdbc.cs b/UnitTest/UnitTest/UnitTestOdbc.cs index f9ded23..5b6910a 100644 --- a/UnitTest/UnitTest/UnitTestOdbc.cs +++ b/UnitTest/UnitTest/UnitTestOdbc.cs @@ -99,7 +99,12 @@ public void InterfaceCaseMethod() //TestCases.Test_GetDiagField(); //TestCases.Test_GetDescField(); //TestCases.Test_GetData(); - TestCases.case_odbc_get_info(); + /* + Temporarily test case is closed for incorrect test environment + This test case will be fixed and reopened in the future on correct environment + + TestCases.case_odbc_get_info(); + */ } [TestMethod] public void InitCaseMethod() @@ -126,5 +131,11 @@ public void TransactionCaseMethod() TestCases.Test_Transaction_Level(); } + [TestMethod] + public void IssueTestCaseMethod() + { + TestCases.Test_multibyte_columns(); + TestCases.Test_multibyte_binding(); + } } } diff --git a/UnitTest/UnitTest_14.sln b/UnitTest/UnitTest_14.sln new file mode 100644 index 0000000..29dff94 --- /dev/null +++ b/UnitTest/UnitTest_14.sln @@ -0,0 +1,96 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7DA479AF-23BA-456A-A5C7-6AA6406D01B6}" + ProjectSection(SolutionItems) = preProject + TestRunConfig.testrunconfig = TestRunConfig.testrunconfig + UnitTest1.vsmdi = UnitTest1.vsmdi + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{81F39664-1339-44AE-8068-0968E3C82806}" + ProjectSection(ProjectDependencies) = postProject + {37E00A2E-BBC5-4736-90D9-A1B4271759BB} = {37E00A2E-BBC5-4736-90D9-A1B4271759BB} + EndProjectSection +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|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Win32.ActiveCfg = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|Win32.Build.0 = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|x64.ActiveCfg = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|x64.Build.0 = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|x86.ActiveCfg = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Debug|x86.Build.0 = Debug|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Any CPU.Build.0 = Release|Any CPU + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Mixed Platforms.Build.0 = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Win32.ActiveCfg = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|Win32.Build.0 = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|x64.ActiveCfg = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|x86.ActiveCfg = Release|x86 + {81F39664-1339-44AE-8068-0968E3C82806}.Release|x86.Build.0 = Release|x86 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|Mixed Platforms.Build.0 = Debug|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|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|x64.Build.0 = Debug|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|x86.ActiveCfg = Debug|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Debug|x86.Build.0 = Debug|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|Any CPU.ActiveCfg = Release|Win32 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|Mixed Platforms.Build.0 = Release|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 + {37E00A2E-BBC5-4736-90D9-A1B4271759BB}.Release|x86.ActiveCfg = Release|x64 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {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}.Debug|x86.ActiveCfg = Debug|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Debug|x86.Build.0 = Debug|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|Any CPU.ActiveCfg = Release|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|Mixed Platforms.Build.0 = Release|Win32 + {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 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|x86.ActiveCfg = Release|Win32 + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = UnitTest1.vsmdi + EndGlobalSection +EndGlobal diff --git a/build_14.bat b/build_14.bat new file mode 100644 index 0000000..a23f73d --- /dev/null +++ b/build_14.bat @@ -0,0 +1,25 @@ +set WORKSPACE=%~dp0 +set INSTALL_DIRS=output +echo %INSTALL_DIRS% + +call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" +mkdir %INSTALL_DIRS% + +devenv cubrid_odbc_14.sln /rebuild "Release|Win32" +devenv cubrid_odbc_14.sln /rebuild "Release|x64" +devenv cubrid_odbc_14.sln /rebuild "Debug|Win32" +devenv cubrid_odbc_14.sln /rebuild "Debug|x64" + +copy build\Win32_Debug\cubrid_odbc.dll %INSTALL_DIRS%\cubrid_odbc32_d.dll +copy build\Win32_Release\cubrid_odbc.dll %INSTALL_DIRS%\cubrid_odbc32.dll +copy build\x64_Debug\cubrid_odbc.dll %INSTALL_DIRS%\cubrid_odbc64_d.dll +copy build\x64_Release\cubrid_odbc.dll %INSTALL_DIRS%\cubrid_odbc64.dll + +copy installer\installer.nsi %INSTALL_DIRS%\installer.nsi +copy installer\license.txt %INSTALL_DIRS%\license.txt +copy installer\README.txt %INSTALL_DIRS%\README.txt + +c: +cd C:\NSIS + +makensis %WORKSPACE%\%INSTALL_DIRS%\installer.nsi \ No newline at end of file diff --git a/build_unicode_14.bat b/build_unicode_14.bat new file mode 100644 index 0000000..7f48bfa --- /dev/null +++ b/build_unicode_14.bat @@ -0,0 +1,20 @@ +set WORKSPACE=%~dp0 +set INSTALL_DIRS=output +echo %INSTALL_DIRS% + +call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" +mkdir %INSTALL_DIRS% + +copy build\Win32_Debug_Unicode\cubrid_odbc_unicode.dll %INSTALL_DIRS%\cubrid_odbc32_d.dll +copy build\Win32_Release_Unicode\cubrid_odbc_unicode.dll %INSTALL_DIRS%\cubrid_odbc32.dll +copy build\x64_Debug_Unicode\cubrid_odbc_unicode.dll %INSTALL_DIRS%\cubrid_odbc64_d.dll +copy build\x64_Release_Unicode\cubrid_odbc_unicode.dll %INSTALL_DIRS%\cubrid_odbc64.dll + +copy installer\installer-unicode.nsi %INSTALL_DIRS%\installer-unicode.nsi +copy installer\license.txt %INSTALL_DIRS%\license.txt +copy installer\README.txt %INSTALL_DIRS%\README.txt + +c: +cd C:\NSIS + +makensis %WORKSPACE%\%INSTALL_DIRS%\installer-unicode.nsi diff --git a/cci/include/cas_cci.h b/cci/include/cas_cci.h index f2c7035..5fd8be3 100644 --- a/cci/include/cas_cci.h +++ b/cci/include/cas_cci.h @@ -35,11 +35,6 @@ #ifndef _CAS_CCI_H_ #define _CAS_CCI_H_ -#ifdef __cplusplus -extern "C" -{ -#endif - /************************************************************************ * IMPORTED SYSTEM HEADER FILES * ************************************************************************/ @@ -49,6 +44,7 @@ extern "C" * IMPORTED OTHER HEADER FILES * ************************************************************************/ #include "cas_error.h" +#include "dbtran_def.h" /************************************************************************ * EXPORTED DEFINITIONS * @@ -153,7 +149,7 @@ extern "C" #define CCI_PREPARE_XASL_CACHE_PINNED 0x10 #define CCI_PREPARE_CALL 0x40 -#define CCI_EXEC_ASYNC 0x01 +#define CCI_EXEC_ASYNC 0x01 /* obsoleted */ #define CCI_EXEC_QUERY_ALL 0x02 #define CCI_EXEC_QUERY_INFO 0x04 #define CCI_EXEC_ONLY_QUERY_PLAN 0x08 @@ -242,346 +238,349 @@ extern "C" #define CCI_TZ_SIZE 63 /* for cci auto_comit mode support */ - typedef enum - { - CCI_AUTOCOMMIT_FALSE = 0, - CCI_AUTOCOMMIT_TRUE - } CCI_AUTOCOMMIT_MODE; +typedef enum +{ + CCI_AUTOCOMMIT_FALSE = 0, + CCI_AUTOCOMMIT_TRUE +} CCI_AUTOCOMMIT_MODE; /* for cci cas_change mode support */ - typedef enum - { - CCI_CAS_CHANGE_MODE_UNKNOWN = 0, - CCI_CAS_CHANGE_MODE_AUTO = 1, - CCI_CAS_CHANGE_MODE_KEEP = 2 - } CCI_CAS_CHANGE_MODE_MODE; +typedef enum +{ + CCI_CAS_CHANGE_MODE_UNKNOWN = 0, + CCI_CAS_CHANGE_MODE_AUTO = 1, + CCI_CAS_CHANGE_MODE_KEEP = 2 +} CCI_CAS_CHANGE_MODE_MODE; #define SET_AUTOCOMMIT_FROM_CASINFO(c) \ (c)->autocommit_mode = \ (c)->cas_info[CAS_INFO_ADDITIONAL_FLAG] & CAS_INFO_FLAG_MASK_AUTOCOMMIT ? \ CCI_AUTOCOMMIT_TRUE : CCI_AUTOCOMMIT_FALSE - typedef enum - { - CCI_NO_BACKSLASH_ESCAPES_FALSE = -1, - CCI_NO_BACKSLASH_ESCAPES_TRUE = -2, - CCI_NO_BACKSLASH_ESCAPES_NOT_SET = -3 - } CCI_NO_BACKSLASH_ESCAPES_MODE; +typedef enum +{ + CCI_NO_BACKSLASH_ESCAPES_FALSE = -1, + CCI_NO_BACKSLASH_ESCAPES_TRUE = -2, + CCI_NO_BACKSLASH_ESCAPES_NOT_SET = -3 +} CCI_NO_BACKSLASH_ESCAPES_MODE; /************************************************************************ * EXPORTED TYPE DEFINITIONS * ************************************************************************/ - typedef struct - { - int err_code; - char err_msg[1024]; - } T_CCI_ERROR; - - typedef struct - { - int size; - char *buf; - } T_CCI_BIT; - - typedef struct - { - short yr; - short mon; - short day; - short hh; - short mm; - short ss; - short ms; - } T_CCI_DATE; - - typedef struct - { - short yr; - short mon; - short day; - short hh; - short mm; - short ss; - short ms; - char tz[CCI_TZ_SIZE + 1]; - } T_CCI_DATE_TZ; - - typedef struct - { - int result_count; - int stmt_type; - int err_no; - char *err_msg; - char oid[32]; - } T_CCI_QUERY_RESULT; - - typedef enum - { - CCI_U_TYPE_FIRST = 0, - CCI_U_TYPE_UNKNOWN = 0, - CCI_U_TYPE_NULL = 0, - - CCI_U_TYPE_CHAR = 1, - CCI_U_TYPE_STRING = 2, - CCI_U_TYPE_NCHAR = 3, - CCI_U_TYPE_VARNCHAR = 4, - CCI_U_TYPE_BIT = 5, - CCI_U_TYPE_VARBIT = 6, - CCI_U_TYPE_NUMERIC = 7, - CCI_U_TYPE_INT = 8, - CCI_U_TYPE_SHORT = 9, - CCI_U_TYPE_MONETARY = 10, - CCI_U_TYPE_FLOAT = 11, - CCI_U_TYPE_DOUBLE = 12, - CCI_U_TYPE_DATE = 13, - CCI_U_TYPE_TIME = 14, - CCI_U_TYPE_TIMESTAMP = 15, - CCI_U_TYPE_SET = 16, - CCI_U_TYPE_MULTISET = 17, - CCI_U_TYPE_SEQUENCE = 18, - CCI_U_TYPE_OBJECT = 19, - CCI_U_TYPE_RESULTSET = 20, - CCI_U_TYPE_BIGINT = 21, - CCI_U_TYPE_DATETIME = 22, - CCI_U_TYPE_BLOB = 23, - CCI_U_TYPE_CLOB = 24, - CCI_U_TYPE_ENUM = 25, - CCI_U_TYPE_USHORT = 26, - CCI_U_TYPE_UINT = 27, - CCI_U_TYPE_UBIGINT = 28, - CCI_U_TYPE_TIMESTAMPTZ = 29, - CCI_U_TYPE_TIMESTAMPLTZ = 30, - CCI_U_TYPE_DATETIMETZ = 31, - CCI_U_TYPE_DATETIMELTZ = 32, - /* Disabled type */ - CCI_U_TYPE_TIMETZ = 33, /* internal use only - RESERVED */ - /* end of disabled types */ - CCI_U_TYPE_LAST = CCI_U_TYPE_DATETIMELTZ - } T_CCI_U_TYPE; - - typedef unsigned char T_CCI_U_EXT_TYPE; - - typedef void *T_CCI_SET; - - typedef enum - { - CCI_A_TYPE_FIRST = 1, - CCI_A_TYPE_STR = 1, - CCI_A_TYPE_INT, - CCI_A_TYPE_FLOAT, - CCI_A_TYPE_DOUBLE, - CCI_A_TYPE_BIT, - CCI_A_TYPE_DATE, - CCI_A_TYPE_SET, - CCI_A_TYPE_BIGINT, - CCI_A_TYPE_BLOB, - CCI_A_TYPE_CLOB, - CCI_A_TYPE_REQ_HANDLE, - CCI_A_TYPE_UINT, - CCI_A_TYPE_UBIGINT, - CCI_A_TYPE_DATE_TZ, - CCI_A_TYPE_LAST = CCI_A_TYPE_DATE_TZ, - - CCI_A_TYTP_LAST = CCI_A_TYPE_LAST /* typo but backward compatibility */ - } T_CCI_A_TYPE; - - enum - { - UNMEASURED_LENGTH = -1 - }; - - typedef enum - { - CCI_PARAM_FIRST = 1, - CCI_PARAM_ISOLATION_LEVEL = 1, - CCI_PARAM_LOCK_TIMEOUT = 2, - CCI_PARAM_MAX_STRING_LENGTH = 3, - CCI_PARAM_AUTO_COMMIT = 4, - CCI_PARAM_LAST = CCI_PARAM_AUTO_COMMIT, - - /* below parameters are used internally */ - CCI_PARAM_NO_BACKSLASH_ESCAPES = 5 - } T_CCI_DB_PARAM; - - typedef enum - { - CCI_SCH_FIRST = 1, - CCI_SCH_CLASS = 1, - CCI_SCH_VCLASS, - CCI_SCH_QUERY_SPEC, - CCI_SCH_ATTRIBUTE, - CCI_SCH_CLASS_ATTRIBUTE, - CCI_SCH_METHOD, - CCI_SCH_CLASS_METHOD, - CCI_SCH_METHOD_FILE, - CCI_SCH_SUPERCLASS, - CCI_SCH_SUBCLASS, - CCI_SCH_CONSTRAINT, - CCI_SCH_TRIGGER, - CCI_SCH_CLASS_PRIVILEGE, - CCI_SCH_ATTR_PRIVILEGE, - CCI_SCH_DIRECT_SUPER_CLASS, - CCI_SCH_PRIMARY_KEY, - CCI_SCH_IMPORTED_KEYS, - CCI_SCH_EXPORTED_KEYS, - CCI_SCH_CROSS_REFERENCE, - CCI_SCH_LAST = CCI_SCH_CROSS_REFERENCE - } T_CCI_SCH_TYPE; - - typedef enum - { - CCI_ER_NO_ERROR = 0, - CCI_ER_DBMS = -20001, - CCI_ER_CON_HANDLE = -20002, - CCI_ER_NO_MORE_MEMORY = -20003, - CCI_ER_COMMUNICATION = -20004, - CCI_ER_NO_MORE_DATA = -20005, - CCI_ER_TRAN_TYPE = -20006, - CCI_ER_STRING_PARAM = -20007, - CCI_ER_TYPE_CONVERSION = -20008, - CCI_ER_BIND_INDEX = -20009, - CCI_ER_ATYPE = -20010, - CCI_ER_NOT_BIND = -20011, - CCI_ER_PARAM_NAME = -20012, - CCI_ER_COLUMN_INDEX = -20013, - CCI_ER_SCHEMA_TYPE = -20014, - CCI_ER_FILE = -20015, - CCI_ER_CONNECT = -20016, - - CCI_ER_ALLOC_CON_HANDLE = -20017, - CCI_ER_REQ_HANDLE = -20018, - CCI_ER_INVALID_CURSOR_POS = -20019, - CCI_ER_OBJECT = -20020, - CCI_ER_CAS = -20021, - CCI_ER_HOSTNAME = -20022, - CCI_ER_OID_CMD = -20023, - - CCI_ER_BIND_ARRAY_SIZE = -20024, - CCI_ER_ISOLATION_LEVEL = -20025, - - CCI_ER_SET_INDEX = -20026, - CCI_ER_DELETED_TUPLE = -20027, - - CCI_ER_SAVEPOINT_CMD = -20028, - CCI_ER_THREAD_RUNNING = -20029, - CCI_ER_INVALID_URL = -20030, - CCI_ER_INVALID_LOB_READ_POS = -20031, - CCI_ER_INVALID_LOB_HANDLE = -20032, - - CCI_ER_NO_PROPERTY = -20033, - - CCI_ER_PROPERTY_TYPE = -20034, - CCI_ER_INVALID_PROPERTY_VALUE = CCI_ER_PROPERTY_TYPE, - - CCI_ER_INVALID_DATASOURCE = -20035, - CCI_ER_DATASOURCE_TIMEOUT = -20036, - CCI_ER_DATASOURCE_TIMEDWAIT = -20037, - - CCI_ER_LOGIN_TIMEOUT = -20038, - CCI_ER_QUERY_TIMEOUT = -20039, - - CCI_ER_RESULT_SET_CLOSED = -20040, - - CCI_ER_INVALID_HOLDABILITY = -20041, - CCI_ER_NOT_UPDATABLE = -20042, - - CCI_ER_INVALID_ARGS = -20043, - CCI_ER_USED_CONNECTION = -20044, - - CCI_ER_NO_SHARD_AVAILABLE = -20045, - CCI_ER_INVALID_SHARD = -20046, - - CCI_ER_NOT_IMPLEMENTED = -20099, - CCI_ER_END = -20100 - } T_CCI_ERROR_CODE; +typedef struct +{ + int err_code; + char err_msg[1024]; +} T_CCI_ERROR; + +typedef struct +{ + int size; + char *buf; +} T_CCI_BIT; + +typedef struct +{ + short yr; + short mon; + short day; + short hh; + short mm; + short ss; + short ms; +} T_CCI_DATE; + +typedef struct +{ + short yr; + short mon; + short day; + short hh; + short mm; + short ss; + short ms; + char tz[CCI_TZ_SIZE + 1]; +} T_CCI_DATE_TZ; + +typedef struct +{ + int result_count; + int stmt_type; + int err_no; + char *err_msg; + char oid[32]; +} T_CCI_QUERY_RESULT; + +/* todo: T_CCI_U_TYPE duplicates db types. */ +typedef enum +{ + CCI_U_TYPE_FIRST = 0, + CCI_U_TYPE_UNKNOWN = 0, + CCI_U_TYPE_NULL = 0, + + CCI_U_TYPE_CHAR = 1, + CCI_U_TYPE_STRING = 2, + CCI_U_TYPE_NCHAR = 3, + CCI_U_TYPE_VARNCHAR = 4, + CCI_U_TYPE_BIT = 5, + CCI_U_TYPE_VARBIT = 6, + CCI_U_TYPE_NUMERIC = 7, + CCI_U_TYPE_INT = 8, + CCI_U_TYPE_SHORT = 9, + CCI_U_TYPE_MONETARY = 10, + CCI_U_TYPE_FLOAT = 11, + CCI_U_TYPE_DOUBLE = 12, + CCI_U_TYPE_DATE = 13, + CCI_U_TYPE_TIME = 14, + CCI_U_TYPE_TIMESTAMP = 15, + CCI_U_TYPE_SET = 16, + CCI_U_TYPE_MULTISET = 17, + CCI_U_TYPE_SEQUENCE = 18, + CCI_U_TYPE_OBJECT = 19, + CCI_U_TYPE_RESULTSET = 20, + CCI_U_TYPE_BIGINT = 21, + CCI_U_TYPE_DATETIME = 22, + CCI_U_TYPE_BLOB = 23, + CCI_U_TYPE_CLOB = 24, + CCI_U_TYPE_ENUM = 25, + CCI_U_TYPE_USHORT = 26, + CCI_U_TYPE_UINT = 27, + CCI_U_TYPE_UBIGINT = 28, + CCI_U_TYPE_TIMESTAMPTZ = 29, + CCI_U_TYPE_TIMESTAMPLTZ = 30, + CCI_U_TYPE_DATETIMETZ = 31, + CCI_U_TYPE_DATETIMELTZ = 32, + /* Disabled type */ + CCI_U_TYPE_TIMETZ = 33, /* internal use only - RESERVED */ + /* end of disabled types */ + CCI_U_TYPE_JSON = 34, + CCI_U_TYPE_LAST = CCI_U_TYPE_JSON +} T_CCI_U_TYPE; + +typedef unsigned char T_CCI_U_EXT_TYPE; + +typedef void *T_CCI_SET; + +typedef enum +{ + CCI_A_TYPE_FIRST = 1, + CCI_A_TYPE_STR = 1, + CCI_A_TYPE_INT, + CCI_A_TYPE_FLOAT, + CCI_A_TYPE_DOUBLE, + CCI_A_TYPE_BIT, + CCI_A_TYPE_DATE, + CCI_A_TYPE_SET, + CCI_A_TYPE_BIGINT, + CCI_A_TYPE_BLOB, + CCI_A_TYPE_CLOB, + CCI_A_TYPE_REQ_HANDLE, + CCI_A_TYPE_UINT, + CCI_A_TYPE_UBIGINT, + CCI_A_TYPE_DATE_TZ, + CCI_A_TYPE_LAST = CCI_A_TYPE_DATE_TZ, + + CCI_A_TYTP_LAST = CCI_A_TYPE_LAST /* typo but backward compatibility */ +} T_CCI_A_TYPE; + +enum +{ + UNMEASURED_LENGTH = -1 +}; + +typedef enum +{ + CCI_PARAM_FIRST = 1, + CCI_PARAM_ISOLATION_LEVEL = 1, + CCI_PARAM_LOCK_TIMEOUT = 2, + CCI_PARAM_MAX_STRING_LENGTH = 3, + CCI_PARAM_AUTO_COMMIT = 4, + CCI_PARAM_LAST = CCI_PARAM_AUTO_COMMIT, + + /* below parameters are used internally */ + CCI_PARAM_NO_BACKSLASH_ESCAPES = 5 +} T_CCI_DB_PARAM; + +typedef enum +{ + CCI_SCH_FIRST = 1, + CCI_SCH_CLASS = 1, + CCI_SCH_VCLASS, + CCI_SCH_QUERY_SPEC, + CCI_SCH_ATTRIBUTE, + CCI_SCH_CLASS_ATTRIBUTE, + CCI_SCH_METHOD, + CCI_SCH_CLASS_METHOD, + CCI_SCH_METHOD_FILE, + CCI_SCH_SUPERCLASS, + CCI_SCH_SUBCLASS, + CCI_SCH_CONSTRAINT, + CCI_SCH_TRIGGER, + CCI_SCH_CLASS_PRIVILEGE, + CCI_SCH_ATTR_PRIVILEGE, + CCI_SCH_DIRECT_SUPER_CLASS, + CCI_SCH_PRIMARY_KEY, + CCI_SCH_IMPORTED_KEYS, + CCI_SCH_EXPORTED_KEYS, + CCI_SCH_CROSS_REFERENCE, + CCI_SCH_LAST = CCI_SCH_CROSS_REFERENCE +} T_CCI_SCH_TYPE; + +typedef enum +{ + CCI_ER_NO_ERROR = 0, + CCI_ER_DBMS = -20001, + CCI_ER_CON_HANDLE = -20002, + CCI_ER_NO_MORE_MEMORY = -20003, + CCI_ER_COMMUNICATION = -20004, + CCI_ER_NO_MORE_DATA = -20005, + CCI_ER_TRAN_TYPE = -20006, + CCI_ER_STRING_PARAM = -20007, + CCI_ER_TYPE_CONVERSION = -20008, + CCI_ER_BIND_INDEX = -20009, + CCI_ER_ATYPE = -20010, + CCI_ER_NOT_BIND = -20011, + CCI_ER_PARAM_NAME = -20012, + CCI_ER_COLUMN_INDEX = -20013, + CCI_ER_SCHEMA_TYPE = -20014, + CCI_ER_FILE = -20015, + CCI_ER_CONNECT = -20016, + + CCI_ER_ALLOC_CON_HANDLE = -20017, + CCI_ER_REQ_HANDLE = -20018, + CCI_ER_INVALID_CURSOR_POS = -20019, + CCI_ER_OBJECT = -20020, + CCI_ER_CAS = -20021, + CCI_ER_HOSTNAME = -20022, + CCI_ER_OID_CMD = -20023, + + CCI_ER_BIND_ARRAY_SIZE = -20024, + CCI_ER_ISOLATION_LEVEL = -20025, + + CCI_ER_SET_INDEX = -20026, + CCI_ER_DELETED_TUPLE = -20027, + + CCI_ER_SAVEPOINT_CMD = -20028, + CCI_ER_THREAD_RUNNING = -20029, + CCI_ER_INVALID_URL = -20030, + CCI_ER_INVALID_LOB_READ_POS = -20031, + CCI_ER_INVALID_LOB_HANDLE = -20032, + + CCI_ER_NO_PROPERTY = -20033, + + CCI_ER_PROPERTY_TYPE = -20034, + CCI_ER_INVALID_PROPERTY_VALUE = CCI_ER_PROPERTY_TYPE, + + CCI_ER_INVALID_DATASOURCE = -20035, + CCI_ER_DATASOURCE_TIMEOUT = -20036, + CCI_ER_DATASOURCE_TIMEDWAIT = -20037, + + CCI_ER_LOGIN_TIMEOUT = -20038, + CCI_ER_QUERY_TIMEOUT = -20039, + + CCI_ER_RESULT_SET_CLOSED = -20040, + + CCI_ER_INVALID_HOLDABILITY = -20041, + CCI_ER_NOT_UPDATABLE = -20042, + + CCI_ER_INVALID_ARGS = -20043, + CCI_ER_USED_CONNECTION = -20044, + + CCI_ER_NO_SHARD_AVAILABLE = -20045, + CCI_ER_INVALID_SHARD = -20046, + + CCI_ER_NOT_IMPLEMENTED = -20099, + CCI_ER_END = -20100 +} T_CCI_ERROR_CODE; #if !defined(CAS) #ifdef DBDEF_HEADER_ - typedef int T_CCI_CUBRID_STMT; +typedef int T_CCI_CUBRID_STMT; #else - typedef enum - { - CUBRID_STMT_ALTER_CLASS, - CUBRID_STMT_ALTER_SERIAL, - CUBRID_STMT_COMMIT_WORK, - CUBRID_STMT_REGISTER_DATABASE, - CUBRID_STMT_CREATE_CLASS, - CUBRID_STMT_CREATE_INDEX, - CUBRID_STMT_CREATE_TRIGGER, - CUBRID_STMT_CREATE_SERIAL, - CUBRID_STMT_DROP_DATABASE, - CUBRID_STMT_DROP_CLASS, - CUBRID_STMT_DROP_INDEX, - CUBRID_STMT_DROP_LABEL, - CUBRID_STMT_DROP_TRIGGER, - CUBRID_STMT_DROP_SERIAL, - CUBRID_STMT_EVALUATE, - CUBRID_STMT_RENAME_CLASS, - CUBRID_STMT_ROLLBACK_WORK, - CUBRID_STMT_GRANT, - CUBRID_STMT_REVOKE, - CUBRID_STMT_UPDATE_STATS, - CUBRID_STMT_INSERT, - CUBRID_STMT_SELECT, - CUBRID_STMT_UPDATE, - CUBRID_STMT_DELETE, - CUBRID_STMT_CALL, - CUBRID_STMT_GET_ISO_LVL, - CUBRID_STMT_GET_TIMEOUT, - CUBRID_STMT_GET_OPT_LVL, - CUBRID_STMT_SET_OPT_LVL, - CUBRID_STMT_SCOPE, - CUBRID_STMT_GET_TRIGGER, - CUBRID_STMT_SET_TRIGGER, - CUBRID_STMT_SAVEPOINT, - CUBRID_STMT_PREPARE, - CUBRID_STMT_ATTACH, - CUBRID_STMT_USE, - CUBRID_STMT_REMOVE_TRIGGER, - CUBRID_STMT_RENAME_TRIGGER, - CUBRID_STMT_ON_LDB, - CUBRID_STMT_GET_LDB, - CUBRID_STMT_SET_LDB, - - CUBRID_STMT_GET_STATS, - CUBRID_STMT_CREATE_USER, - CUBRID_STMT_DROP_USER, - CUBRID_STMT_ALTER_USER, - CUBRID_STMT_SET_SYS_PARAMS, - CUBRID_STMT_ALTER_INDEX, - - CUBRID_STMT_CREATE_STORED_PROCEDURE, - CUBRID_STMT_DROP_STORED_PROCEDURE, - CUBRID_STMT_PREPARE_STATEMENT, - CUBRID_STMT_EXECUTE_PREPARE, - CUBRID_STMT_DEALLOCATE_PREPARE, - CUBRID_STMT_TRUNCATE, - CUBRID_STMT_DO, - CUBRID_STMT_SELECT_UPDATE, - CUBRID_STMT_SET_SESSION_VARIABLES, - CUBRID_STMT_DROP_SESSION_VARIABLES, - CUBRID_STMT_MERGE, - CUBRID_STMT_SET_NAMES, - CUBRID_STMT_ALTER_STORED_PROCEDURE, - CUBRID_STMT_ALTER_STORED_PROCEDURE_OWNER = - CUBRID_STMT_ALTER_STORED_PROCEDURE, - CUBRID_STMT_KILL, - - CUBRID_MAX_STMT_TYPE - } T_CCI_CUBRID_STMT; - - typedef int T_CCI_CONN; - typedef int T_CCI_REQ; - typedef struct PROPERTIES_T T_CCI_PROPERTIES; - typedef struct DATASOURCE_T T_CCI_DATASOURCE; +typedef enum +{ + CUBRID_STMT_NONE = -1, + CUBRID_STMT_ALTER_CLASS, + CUBRID_STMT_ALTER_SERIAL, + CUBRID_STMT_COMMIT_WORK, + CUBRID_STMT_REGISTER_DATABASE, + CUBRID_STMT_CREATE_CLASS, + CUBRID_STMT_CREATE_INDEX, + CUBRID_STMT_CREATE_TRIGGER, + CUBRID_STMT_CREATE_SERIAL, + CUBRID_STMT_DROP_DATABASE, + CUBRID_STMT_DROP_CLASS, + CUBRID_STMT_DROP_INDEX, + CUBRID_STMT_DROP_LABEL, + CUBRID_STMT_DROP_TRIGGER, + CUBRID_STMT_DROP_SERIAL, + CUBRID_STMT_EVALUATE, + CUBRID_STMT_RENAME_CLASS, + CUBRID_STMT_ROLLBACK_WORK, + CUBRID_STMT_GRANT, + CUBRID_STMT_REVOKE, + CUBRID_STMT_UPDATE_STATS, + CUBRID_STMT_INSERT, + CUBRID_STMT_SELECT, + CUBRID_STMT_UPDATE, + CUBRID_STMT_DELETE, + CUBRID_STMT_CALL, + CUBRID_STMT_GET_ISO_LVL, + CUBRID_STMT_GET_TIMEOUT, + CUBRID_STMT_GET_OPT_LVL, + CUBRID_STMT_SET_OPT_LVL, + CUBRID_STMT_SCOPE, + CUBRID_STMT_GET_TRIGGER, + CUBRID_STMT_SET_TRIGGER, + CUBRID_STMT_SAVEPOINT, + CUBRID_STMT_PREPARE, + CUBRID_STMT_ATTACH, + CUBRID_STMT_USE, + CUBRID_STMT_REMOVE_TRIGGER, + CUBRID_STMT_RENAME_TRIGGER, + CUBRID_STMT_ON_LDB, + CUBRID_STMT_GET_LDB, + CUBRID_STMT_SET_LDB, + + CUBRID_STMT_GET_STATS, + CUBRID_STMT_CREATE_USER, + CUBRID_STMT_DROP_USER, + CUBRID_STMT_ALTER_USER, + CUBRID_STMT_SET_SYS_PARAMS, + CUBRID_STMT_ALTER_INDEX, + + CUBRID_STMT_CREATE_STORED_PROCEDURE, + CUBRID_STMT_DROP_STORED_PROCEDURE, + CUBRID_STMT_PREPARE_STATEMENT, + CUBRID_STMT_EXECUTE_PREPARE, + CUBRID_STMT_DEALLOCATE_PREPARE, + CUBRID_STMT_TRUNCATE, + CUBRID_STMT_DO, + CUBRID_STMT_SELECT_UPDATE, + CUBRID_STMT_SET_SESSION_VARIABLES, + CUBRID_STMT_DROP_SESSION_VARIABLES, + CUBRID_STMT_MERGE, + CUBRID_STMT_SET_NAMES, + CUBRID_STMT_ALTER_STORED_PROCEDURE, + CUBRID_STMT_ALTER_STORED_PROCEDURE_OWNER = CUBRID_STMT_ALTER_STORED_PROCEDURE, + CUBRID_STMT_KILL, + CUBRID_STMT_VACUUM, + CUBRID_STMT_SET_TIMEZONE, + + CUBRID_MAX_STMT_TYPE +} T_CCI_CUBRID_STMT; + +typedef int T_CCI_CONN; +typedef int T_CCI_REQ; +typedef struct PROPERTIES_T T_CCI_PROPERTIES; +typedef struct DATASOURCE_T T_CCI_DATASOURCE; #endif #endif #define CUBRID_STMT_CALL_SP 0x7e #define CUBRID_STMT_UNKNOWN 0x7f - /* for backward compatibility */ #define T_CCI_SQLX_CMD T_CCI_CUBRID_STMT @@ -653,252 +652,198 @@ extern "C" #define SQLX_CMD_CALL_SP CUBRID_STMT_CALL_SP #define SQLX_CMD_UNKNOWN CUBRID_STMT_UNKNOWN - typedef enum - { - CCI_CURSOR_FIRST = 0, - CCI_CURSOR_CURRENT = 1, - CCI_CURSOR_LAST = 2 - } T_CCI_CURSOR_POS; - - typedef struct - { - T_CCI_U_EXT_TYPE ext_type; /* extended type : TCCT TTTT (T : set type, C: collection flags) */ - char is_non_null; - short scale; - int precision; - char *col_name; - char *real_attr; - char *class_name; - char *default_value; - char is_auto_increment; - char is_unique_key; - char is_primary_key; - char is_foreign_key; - char is_reverse_index; - char is_reverse_unique; - char is_shared; - } T_CCI_COL_INFO; - - typedef enum - { - CCI_OID_CMD_FIRST = 1, - - CCI_OID_DROP = 1, - CCI_OID_IS_INSTANCE = 2, - CCI_OID_LOCK_READ = 3, - CCI_OID_LOCK_WRITE = 4, - CCI_OID_CLASS_NAME = 5, - - CCI_OID_CMD_LAST = CCI_OID_CLASS_NAME - } T_CCI_OID_CMD; - - typedef enum - { - CCI_COL_CMD_FIRST = 1, - CCI_COL_GET = 1, - CCI_COL_SIZE = 2, - CCI_COL_SET_DROP = 3, - CCI_COL_SET_ADD = 4, - CCI_COL_SEQ_DROP = 5, - CCI_COL_SEQ_INSERT = 6, - CCI_COL_SEQ_PUT = 7, - CCI_COL_CMD_LAST = CCI_COL_SEQ_PUT - } T_CCI_COLLECTION_CMD; - - typedef enum - { - CCI_SP_CMD_FIRST = 1, - CCI_SP_SET = 1, - CCI_SP_ROLLBACK = 2, - CCI_SP_CMD_LAST = CCI_SP_ROLLBACK - } T_CCI_SAVEPOINT_CMD; - - typedef enum - { - CCI_DS_KEY_USER, - CCI_DS_KEY_PASSWORD, - CCI_DS_KEY_URL, - CCI_DS_KEY_POOL_SIZE, - CCI_DS_KEY_MAX_WAIT, - CCI_DS_KEY_POOL_PREPARED_STATEMENT, - CCI_DS_KEY_MAX_OPEN_PREPARED_STATEMENT, - CCI_DS_KEY_LOGIN_TIMEOUT, - CCI_DS_KEY_QUERY_TIMEOUT, - CCI_DS_KEY_DISCONNECT_ON_QUERY_TIMEOUT, - CCI_DS_KEY_DEFAULT_AUTOCOMMIT, - CCI_DS_KEY_DEFAULT_ISOLATION, - CCI_DS_KEY_DEFAULT_LOCK_TIMEOUT, - CCI_DS_KEY_MAX_POOL_SIZE - } T_CCI_DATASOURCE_KEY; - -#if !defined(CAS) -#ifdef DBDEF_HEADER_ - typedef int T_CCI_TRAN_ISOLATION; -#else - typedef enum - { - TRAN_UNKNOWN_ISOLATION = 0, - TRAN_ISOLATION_MIN = 4, +typedef enum +{ + CCI_CURSOR_FIRST = 0, + CCI_CURSOR_CURRENT = 1, + CCI_CURSOR_LAST = 2 +} T_CCI_CURSOR_POS; - TRAN_READ_COMMITTED = 4, - TRAN_REP_CLASS_COMMIT_INSTANCE = 4, /* for backward compatibility */ +typedef struct +{ + T_CCI_U_EXT_TYPE ext_type; /* extended type : TCCT TTTT (T : set type, C: collection flags) */ + char is_non_null; + short scale; + int precision; + char *col_name; + char *real_attr; + char *class_name; + char *default_value; + char is_auto_increment; + char is_unique_key; + char is_primary_key; + char is_foreign_key; + char is_reverse_index; + char is_reverse_unique; + char is_shared; +} T_CCI_COL_INFO; + +typedef enum +{ + CCI_OID_CMD_FIRST = 1, - TRAN_REPEATABLE_READ = 5, - TRAN_REP_CLASS_REP_INSTANCE = 5, /* for backward compatibility */ + CCI_OID_DROP = 1, + CCI_OID_IS_INSTANCE = 2, + CCI_OID_LOCK_READ = 3, + CCI_OID_LOCK_WRITE = 4, + CCI_OID_CLASS_NAME = 5, - TRAN_SERIALIZABLE = 6, + CCI_OID_CMD_LAST = CCI_OID_CLASS_NAME +} T_CCI_OID_CMD; - TRAN_ISOLATION_MAX = 6 - } T_CCI_TRAN_ISOLATION; -#endif -#endif +typedef enum +{ + CCI_COL_CMD_FIRST = 1, + CCI_COL_GET = 1, + CCI_COL_SIZE = 2, + CCI_COL_SET_DROP = 3, + CCI_COL_SET_ADD = 4, + CCI_COL_SEQ_DROP = 5, + CCI_COL_SEQ_INSERT = 6, + CCI_COL_SEQ_PUT = 7, + CCI_COL_CMD_LAST = CCI_COL_SEQ_PUT +} T_CCI_COLLECTION_CMD; + +typedef enum +{ + CCI_SP_CMD_FIRST = 1, + CCI_SP_SET = 1, + CCI_SP_ROLLBACK = 2, + CCI_SP_CMD_LAST = CCI_SP_ROLLBACK +} T_CCI_SAVEPOINT_CMD; - typedef enum - { - CCI_PARAM_MODE_UNKNOWN = 0, - CCI_PARAM_MODE_IN = 1, - CCI_PARAM_MODE_OUT = 2, - CCI_PARAM_MODE_INOUT = 3 - } T_CCI_PARAM_MODE; +typedef enum +{ + CCI_DS_KEY_USER, + CCI_DS_KEY_PASSWORD, + CCI_DS_KEY_URL, + CCI_DS_KEY_POOL_SIZE, + CCI_DS_KEY_MAX_WAIT, + CCI_DS_KEY_POOL_PREPARED_STATEMENT, + CCI_DS_KEY_MAX_OPEN_PREPARED_STATEMENT, + CCI_DS_KEY_LOGIN_TIMEOUT, + CCI_DS_KEY_QUERY_TIMEOUT, + CCI_DS_KEY_DISCONNECT_ON_QUERY_TIMEOUT, + CCI_DS_KEY_DEFAULT_AUTOCOMMIT, + CCI_DS_KEY_DEFAULT_ISOLATION, + CCI_DS_KEY_DEFAULT_LOCK_TIMEOUT, + CCI_DS_KEY_MAX_POOL_SIZE +} T_CCI_DATASOURCE_KEY; + +typedef DB_TRAN_ISOLATION T_CCI_TRAN_ISOLATION; // alias + +typedef enum +{ + CCI_PARAM_MODE_UNKNOWN = 0, + CCI_PARAM_MODE_IN = 1, + CCI_PARAM_MODE_OUT = 2, + CCI_PARAM_MODE_INOUT = 3 +} T_CCI_PARAM_MODE; /* delete or update action type for foreign key */ - typedef enum - { - CCI_FOREIGN_KEY_CASCADE = 0, - CCI_FOREIGN_KEY_RESTRICT = 1, - CCI_FOREIGN_KEY_NO_ACTION = 2, - CCI_FOREIGN_KEY_SET_NULL = 3 - } T_CCI_FOREIGN_KEY_ACTION; - - typedef struct - { - T_CCI_PARAM_MODE mode; - T_CCI_U_EXT_TYPE ext_type; /* extended type : TCCT TTTT (T : set type, C: collection flags) */ - short scale; - int precision; - } T_CCI_PARAM_INFO; - - typedef void *T_CCI_BLOB; - - typedef void *T_CCI_CLOB; - - typedef struct - { - int shard_id; - char *db_name; - char *db_server; - } T_CCI_SHARD_INFO; +typedef enum +{ + CCI_FOREIGN_KEY_CASCADE = 0, + CCI_FOREIGN_KEY_RESTRICT = 1, + CCI_FOREIGN_KEY_NO_ACTION = 2, + CCI_FOREIGN_KEY_SET_NULL = 3 +} T_CCI_FOREIGN_KEY_ACTION; + +typedef struct +{ + T_CCI_PARAM_MODE mode; + T_CCI_U_EXT_TYPE ext_type; /* extended type : TCCT TTTT (T : set type, C: collection flags) */ + short scale; + int precision; +} T_CCI_PARAM_INFO; + +typedef void *T_CCI_BLOB; + +typedef void *T_CCI_CLOB; + +typedef struct +{ + int shard_id; + char *db_name; + char *db_server; +} T_CCI_SHARD_INFO; /* memory allocators */ - typedef void *(*CCI_MALLOC_FUNCTION) (size_t); - typedef void *(*CCI_CALLOC_FUNCTION) (size_t, size_t); - typedef void *(*CCI_REALLOC_FUNCTION) (void *, size_t); - typedef void (*CCI_FREE_FUNCTION) (void *); +typedef void *(*CCI_MALLOC_FUNCTION) (size_t); +typedef void *(*CCI_CALLOC_FUNCTION) (size_t, size_t); +typedef void *(*CCI_REALLOC_FUNCTION) (void *, size_t); +typedef void (*CCI_FREE_FUNCTION) (void *); /************************************************************************ * EXPORTED FUNCTION PROTOTYPES * ************************************************************************/ #if !defined(CAS) + +#ifdef __cplusplus +extern "C" +{ +#endif + extern void cci_init (void); extern void cci_end (void); extern int cci_get_version_string (char *str, size_t len); extern int cci_get_version (int *major, int *minor, int *patch); - extern int CCI_CONNECT_INTERNAL_FUNC_NAME (char *ip, - int port, - char *db_name, - char *db_user, char *dbpasswd); - extern int cci_connect_ex (char *ip, int port, char *db, char *user, - char *pass, T_CCI_ERROR * err_buf); + extern int CCI_CONNECT_INTERNAL_FUNC_NAME (char *ip, int port, char *db_name, char *db_user, char *dbpasswd); + extern int cci_connect_ex (char *ip, int port, char *db, char *user, char *pass, T_CCI_ERROR * err_buf); extern int cci_connect_with_url (char *url, char *user, char *password); - extern int cci_connect_with_url_ex (char *url, char *user, char *pass, - T_CCI_ERROR * err_buf); + extern int cci_connect_with_url_ex (char *url, char *user, char *pass, T_CCI_ERROR * err_buf); extern int cci_disconnect (int con_handle, T_CCI_ERROR * err_buf); extern int cci_end_tran (int con_handle, char type, T_CCI_ERROR * err_buf); - extern int cci_prepare (int con_handle, - char *sql_stmt, char flag, T_CCI_ERROR * err_buf); + extern int cci_prepare (int con_handle, const char *sql_stmt, char flag, T_CCI_ERROR * err_buf); extern int cci_get_bind_num (int req_handle); - extern T_CCI_COL_INFO *cci_get_result_info (int req_handle, - T_CCI_CUBRID_STMT * cmd_type, - int *num); + extern T_CCI_COL_INFO *cci_get_result_info (int req_handle, T_CCI_CUBRID_STMT * cmd_type, int *num); extern int cci_bind_param (int req_handle, int index, T_CCI_A_TYPE a_type, void *value, T_CCI_U_TYPE u_type, char flag); extern int cci_bind_param_ex (int mapped_stmt_id, int index, - T_CCI_A_TYPE a_type, void *value, int length, - T_CCI_U_TYPE u_type, char flag); - extern int cci_execute (int req_handle, - char flag, int max_col_size, T_CCI_ERROR * err_buf); + T_CCI_A_TYPE a_type, void *value, int length, T_CCI_U_TYPE u_type, char flag); + extern int cci_execute (int req_handle, char flag, int max_col_size, T_CCI_ERROR * err_buf); extern int cci_prepare_and_execute (int con_handle, char *sql_stmt, - int max_col_size, int *exec_retval, - T_CCI_ERROR * err_buf); - extern int cci_get_db_parameter (int con_handle, T_CCI_DB_PARAM param_name, - void *value, T_CCI_ERROR * err_buf); - extern int cci_set_db_parameter (int con_handle, T_CCI_DB_PARAM param_name, - void *value, T_CCI_ERROR * err_buf); - extern int cci_set_cas_change_mode (int mapped_conn_id, int mode, - T_CCI_ERROR * err_buf); - extern long cci_escape_string (int con_h_id, char *to, const char *from, - unsigned long length, T_CCI_ERROR * err_buf); + int max_col_size, int *exec_retval, T_CCI_ERROR * err_buf); + extern int cci_get_db_parameter (int con_handle, T_CCI_DB_PARAM param_name, void *value, T_CCI_ERROR * err_buf); + extern int cci_set_db_parameter (int con_handle, T_CCI_DB_PARAM param_name, void *value, T_CCI_ERROR * err_buf); + extern int cci_set_cas_change_mode (int mapped_conn_id, int mode, T_CCI_ERROR * err_buf); + extern long cci_escape_string (int con_h_id, char *to, const char *from, unsigned long length, T_CCI_ERROR * err_buf); extern int cci_close_query_result (int req_handle, T_CCI_ERROR * err_buf); extern int cci_close_req_handle (int req_handle); - extern int cci_cursor (int req_handle, - int offset, - T_CCI_CURSOR_POS origin, T_CCI_ERROR * err_buf); + extern int cci_cursor (int req_handle, int offset, T_CCI_CURSOR_POS origin, T_CCI_ERROR * err_buf); extern int cci_fetch_size (int req_handle, int fetch_size); extern int cci_fetch (int req_handle, T_CCI_ERROR * err_buf); - extern int cci_get_data (int req_handle, - int col_no, int type, void *value, int *indicator); - extern int cci_schema_info (int con_handle, - T_CCI_SCH_TYPE type, - char *arg1, char *arg2, - char flag, T_CCI_ERROR * err_buf); + extern int cci_get_data (int req_handle, int col_no, int type, void *value, int *indicator); + extern int cci_schema_info (int con_handle, T_CCI_SCH_TYPE type, char *arg1, + char *arg2, char flag, T_CCI_ERROR * err_buf); extern int cci_get_cur_oid (int req_handle, char *oid_str_buf); - extern int cci_oid_get (int con_handle, - char *oid_str, - char **attr_name, T_CCI_ERROR * err_buf); - extern int cci_oid_put (int con_handle, - char *oid_str, - char **attr_name, - char **new_val, T_CCI_ERROR * err_buf); - extern int cci_oid_put2 (int con_h_id, - char *oid_str, - char **attr_name, - void **new_val, - int *a_type, T_CCI_ERROR * err_buf); + extern int cci_oid_get (int con_handle, char *oid_str, char **attr_name, T_CCI_ERROR * err_buf); + extern int cci_oid_put (int con_handle, char *oid_str, char **attr_name, char **new_val, T_CCI_ERROR * err_buf); + extern int cci_oid_put2 (int con_h_id, char *oid_str, char **attr_name, + void **new_val, int *a_type, T_CCI_ERROR * err_buf); extern int cci_get_db_version (int con_handle, char *out_buf, int buf_size); extern CCI_AUTOCOMMIT_MODE cci_get_autocommit (int con_handle); - extern int cci_set_autocommit (int con_handle, - CCI_AUTOCOMMIT_MODE autocommit_mode); + extern int cci_set_autocommit (int con_handle, CCI_AUTOCOMMIT_MODE autocommit_mode); extern int cci_set_holdability (int con_handle_id, int holdable); extern int cci_get_holdability (int con_handle_id); - extern int cci_set_login_timeout (int mapped_conn_id, int timeout, - T_CCI_ERROR * err_buf); - extern int cci_get_login_timeout (int mapped_conn_id, int *timeout, - T_CCI_ERROR * err_buf); + extern int cci_set_login_timeout (int mapped_conn_id, int timeout, T_CCI_ERROR * err_buf); + extern int cci_get_login_timeout (int mapped_conn_id, int *timeout, T_CCI_ERROR * err_buf); extern int cci_get_class_num_objs (int conn_handle, char *class_name, - int flag, int *num_objs, int *num_pages, - T_CCI_ERROR * err_buf); - extern int cci_oid (int con_h_id, T_CCI_OID_CMD cmd, char *oid_str, - T_CCI_ERROR * err_buf); + int flag, int *num_objs, int *num_pages, T_CCI_ERROR * err_buf); + extern int cci_oid (int con_h_id, T_CCI_OID_CMD cmd, char *oid_str, T_CCI_ERROR * err_buf); extern int cci_oid_get_class_name (int con_h_id, char *oid_str, - char *out_buf, int out_buf_len, - T_CCI_ERROR * err_buf); + char *out_buf, int out_buf_len, T_CCI_ERROR * err_buf); extern int cci_col_get (int con_h_id, char *oid_str, char *col_attr, - int *col_size, int *col_type, - T_CCI_ERROR * err_buf); - extern int cci_col_size (int con_h_id, char *oid_str, char *col_attr, - int *col_size, T_CCI_ERROR * err_buf); - extern int cci_col_set_drop (int con_h_id, char *oid_str, char *col_attr, - char *value, T_CCI_ERROR * err_buf); - extern int cci_col_set_add (int con_h_id, char *oid_str, char *col_attr, - char *value, T_CCI_ERROR * err_buf); - extern int cci_col_seq_drop (int con_h_id, char *oid_str, char *col_attr, - int index, T_CCI_ERROR * err_buf); + int *col_size, int *col_type, T_CCI_ERROR * err_buf); + extern int cci_col_size (int con_h_id, char *oid_str, char *col_attr, int *col_size, T_CCI_ERROR * err_buf); + extern int cci_col_set_drop (int con_h_id, char *oid_str, char *col_attr, char *value, T_CCI_ERROR * err_buf); + extern int cci_col_set_add (int con_h_id, char *oid_str, char *col_attr, char *value, T_CCI_ERROR * err_buf); + extern int cci_col_seq_drop (int con_h_id, char *oid_str, char *col_attr, int index, T_CCI_ERROR * err_buf); extern int cci_col_seq_insert (int con_h_id, char *oid_str, char *col_attr, - int index, char *value, - T_CCI_ERROR * err_buf); + int index, char *value, T_CCI_ERROR * err_buf); extern int cci_col_seq_put (int con_h_id, char *oid_str, char *col_attr, int index, char *value, T_CCI_ERROR * err_buf); @@ -906,97 +851,59 @@ extern "C" extern int cci_is_holdable (int req_h_id); extern int cci_next_result (int req_h_id, T_CCI_ERROR * err_buf); extern int cci_bind_param_array_size (int req_h_id, int array_size); - extern int cci_bind_param_array (int req_h_id, - int index, - T_CCI_A_TYPE a_type, - void *value, - int *null_ind, T_CCI_U_TYPE u_type); - extern int cci_execute_array (int req_h_id, - T_CCI_QUERY_RESULT ** qr, - T_CCI_ERROR * err_buf); + extern int cci_bind_param_array (int req_h_id, int index, + T_CCI_A_TYPE a_type, void *value, int *null_ind, T_CCI_U_TYPE u_type); + extern int cci_execute_array (int req_h_id, T_CCI_QUERY_RESULT ** qr, T_CCI_ERROR * err_buf); extern int cci_query_result_free (T_CCI_QUERY_RESULT * qr, int num_q); extern int cci_fetch_sensitive (int req_h_id, T_CCI_ERROR * err_buf); - extern int cci_cursor_update (int req_h_id, - int cursor_pos, - int index, - T_CCI_A_TYPE a_type, - void *value, T_CCI_ERROR * err_buf); - extern int cci_execute_batch (int con_h_id, - int num_query, - char **sql_stmt, - T_CCI_QUERY_RESULT ** qr, - T_CCI_ERROR * err_buf); + extern int cci_cursor_update (int req_h_id, int cursor_pos, int index, + T_CCI_A_TYPE a_type, void *value, T_CCI_ERROR * err_buf); + extern int cci_execute_batch (int con_h_id, int num_query, char **sql_stmt, + T_CCI_QUERY_RESULT ** qr, T_CCI_ERROR * err_buf); extern int cci_fetch_buffer_clear (int req_h_id); - extern int cci_execute_result (int req_h_id, - T_CCI_QUERY_RESULT ** qr, - T_CCI_ERROR * err_buf); - extern int cci_set_isolation_level (int con_id, - T_CCI_TRAN_ISOLATION val, - T_CCI_ERROR * err_buf); - extern int cci_set_lock_timeout (int con_id, int val, - T_CCI_ERROR * err_buf); + extern int cci_execute_result (int req_h_id, T_CCI_QUERY_RESULT ** qr, T_CCI_ERROR * err_buf); + extern int cci_set_isolation_level (int con_id, T_CCI_TRAN_ISOLATION val, T_CCI_ERROR * err_buf); + extern int cci_set_lock_timeout (int con_id, int val, T_CCI_ERROR * err_buf); extern void cci_set_free (T_CCI_SET set); extern int cci_set_size (T_CCI_SET set); extern int cci_set_element_type (T_CCI_SET set); - extern int cci_set_get (T_CCI_SET set, - int index, - T_CCI_A_TYPE a_type, void *value, int *indicator); - extern int cci_set_make (T_CCI_SET * set, - T_CCI_U_TYPE u_type, - int size, void *value, int *indicator); - extern int cci_get_attr_type_str (int con_h_id, - char *class_name, - char *attr_name, - char *buf, - int buf_size, T_CCI_ERROR * err_buf); + extern int cci_set_get (T_CCI_SET set, int index, T_CCI_A_TYPE a_type, void *value, int *indicator); + extern int cci_set_make (T_CCI_SET * set, T_CCI_U_TYPE u_type, int size, void *value, int *indicator); + extern int cci_get_attr_type_str (int con_h_id, char *class_name, + char *attr_name, char *buf, int buf_size, T_CCI_ERROR * err_buf); extern int cci_get_query_plan (int req_h_id, char **out_buf); extern int cci_query_info_free (char *out_buf); extern int cci_set_max_row (int req_h_id, int max_row); - extern int cci_savepoint (int con_h_id, - T_CCI_SAVEPOINT_CMD cmd, - char *savepoint_name, T_CCI_ERROR * err_buf); - extern int cci_get_param_info (int req_handle, - T_CCI_PARAM_INFO ** param, - T_CCI_ERROR * err_buf); + extern int cci_savepoint (int con_h_id, T_CCI_SAVEPOINT_CMD cmd, char *savepoint_name, T_CCI_ERROR * err_buf); + extern int cci_get_param_info (int req_handle, T_CCI_PARAM_INFO ** param, T_CCI_ERROR * err_buf); extern int cci_param_info_free (T_CCI_PARAM_INFO * param); - extern int cci_blob_new (int con_h_id, T_CCI_BLOB * blob, - T_CCI_ERROR * err_buf); + extern int cci_blob_new (int con_h_id, T_CCI_BLOB * blob, T_CCI_ERROR * err_buf); extern long long cci_blob_size (T_CCI_BLOB blob); extern int cci_blob_write (int con_h_id, T_CCI_BLOB blob, - long long start_pos, int length, - const char *buf, T_CCI_ERROR * err_buf); + long long start_pos, int length, const char *buf, T_CCI_ERROR * err_buf); extern int cci_blob_read (int con_h_id, T_CCI_BLOB blob, - long long start_pos, int length, char *buf, - T_CCI_ERROR * err_buf); + long long start_pos, int length, char *buf, T_CCI_ERROR * err_buf); extern int cci_blob_free (T_CCI_BLOB blob); - extern int cci_clob_new (int con_h_id, T_CCI_CLOB * clob, - T_CCI_ERROR * err_buf); + extern int cci_clob_new (int con_h_id, T_CCI_CLOB * clob, T_CCI_ERROR * err_buf); extern long long cci_clob_size (T_CCI_CLOB clob); extern int cci_clob_write (int con_h_id, T_CCI_CLOB clob, - long long start_pos, int length, - const char *buf, T_CCI_ERROR * err_buf); + long long start_pos, int length, const char *buf, T_CCI_ERROR * err_buf); extern int cci_clob_read (int con_h_id, T_CCI_CLOB clob, - long long start_pos, int length, char *buf, - T_CCI_ERROR * err_buf); + long long start_pos, int length, char *buf, T_CCI_ERROR * err_buf); extern int cci_clob_free (T_CCI_CLOB clob); extern int cci_get_dbms_type (int con_h_id); extern int cci_register_out_param (int req_h_id, int index); - extern int cci_register_out_param_ex (int req_h_id, int index, - T_CCI_U_TYPE u_type); + extern int cci_register_out_param_ex (int req_h_id, int index, T_CCI_U_TYPE u_type); extern int cci_cancel (int con_h_id); - extern int cci_get_error_msg (int err_code, T_CCI_ERROR * err_buf, - char *out_buf, int out_buf_size); + extern int cci_get_error_msg (int err_code, T_CCI_ERROR * err_buf, char *out_buf, int out_buf_size); extern int cci_get_err_msg (int err_code, char *buf, int bufsize); extern int cci_set_charset (int con_h_id, char *charset); - extern int cci_row_count (int con_h_id, int *row_count, - T_CCI_ERROR * err_buf); + extern int cci_row_count (int con_h_id, int *row_count, T_CCI_ERROR * err_buf); - extern int cci_get_shard_id_with_con_handle (int con_h_id, int *shard_id, - T_CCI_ERROR * err_buf); - extern int cci_get_shard_id_with_req_handle (int req_h_id, int *shard_id, - T_CCI_ERROR * err_buf); + extern int cci_get_shard_id_with_con_handle (int con_h_id, int *shard_id, T_CCI_ERROR * err_buf); + extern int cci_get_shard_id_with_req_handle (int req_h_id, int *shard_id, T_CCI_ERROR * err_buf); /* * IMPORTANT: cci_last_insert_id and cci_get_last_insert_id @@ -1013,48 +920,39 @@ extern "C" * So we deprecate cci_last_insert_id and strongly recommend to use * cci_get_last_insert_id. */ - extern int cci_last_insert_id (int con_h_id, void *value, - T_CCI_ERROR * err_buf); + extern int cci_last_insert_id (int con_h_id, void *value, T_CCI_ERROR * err_buf); - extern int cci_get_last_insert_id (int con_h_id, void *value, - T_CCI_ERROR * err_buf); + extern int cci_get_last_insert_id (int con_h_id, void *value, T_CCI_ERROR * err_buf); extern T_CCI_PROPERTIES *cci_property_create (void); extern void cci_property_destroy (T_CCI_PROPERTIES * properties); - extern int cci_property_set (T_CCI_PROPERTIES * properties, char *key, - char *value); - extern char *cci_property_get (T_CCI_PROPERTIES * properties, - const char *key); - - extern T_CCI_DATASOURCE *cci_datasource_create (T_CCI_PROPERTIES * - properties, - T_CCI_ERROR * err_buf); + extern int cci_property_set (T_CCI_PROPERTIES * properties, char *key, char *value); + extern char *cci_property_get (T_CCI_PROPERTIES * properties, const char *key); + + extern T_CCI_DATASOURCE *cci_datasource_create (T_CCI_PROPERTIES * properties, T_CCI_ERROR * err_buf); extern void cci_datasource_destroy (T_CCI_DATASOURCE * data_source); - extern T_CCI_CONN cci_datasource_borrow (T_CCI_DATASOURCE * date_source, - T_CCI_ERROR * err_buf); - extern int cci_datasource_release (T_CCI_DATASOURCE * date_source, - T_CCI_CONN conn, T_CCI_ERROR * err_buf); - extern int cci_datasource_change_property (T_CCI_DATASOURCE * ds, - const char *key, - const char *val); + extern T_CCI_CONN cci_datasource_borrow (T_CCI_DATASOURCE * date_source, T_CCI_ERROR * err_buf); + extern int cci_datasource_release (T_CCI_DATASOURCE * date_source, T_CCI_CONN conn, T_CCI_ERROR * err_buf); + extern int cci_datasource_change_property (T_CCI_DATASOURCE * ds, const char *key, const char *val); extern int cci_set_query_timeout (int req_h_id, int timeout); extern int cci_get_query_timeout (int req_h_id); extern int cci_set_allocators (CCI_MALLOC_FUNCTION malloc_func, CCI_FREE_FUNCTION free_func, - CCI_REALLOC_FUNCTION realloc_func, - CCI_CALLOC_FUNCTION calloc_func); + CCI_REALLOC_FUNCTION realloc_func, CCI_CALLOC_FUNCTION calloc_func); - extern int cci_get_shard_info (int con_h_id, T_CCI_SHARD_INFO ** shard_info, - T_CCI_ERROR * err_buf); + extern int cci_get_shard_info (int con_h_id, T_CCI_SHARD_INFO ** shard_info, T_CCI_ERROR * err_buf); extern int cci_shard_info_free (T_CCI_SHARD_INFO * shard_info); extern int cci_shard_schema_info (int con_h_id, int shard_id, T_CCI_SCH_TYPE type, char *class_name, - char *attr_name, char flag, - T_CCI_ERROR * err_buf); + char *attr_name, char flag, T_CCI_ERROR * err_buf); extern int cci_is_shard (int con_h_id, T_CCI_ERROR * err_buf); - extern int cci_get_cas_info (int mapped_conn_id, char *info_buf, - int buf_length, T_CCI_ERROR * err_buf); + extern int cci_get_cas_info (int mapped_conn_id, char *info_buf, int buf_length, T_CCI_ERROR * err_buf); + + extern T_CCI_ERROR_CODE map_open_otc(T_CCI_CONN connection_id, T_CCI_CONN * mapped_conn_id); +#ifdef __cplusplus +} +#endif #endif @@ -1062,8 +960,4 @@ extern "C" * EXPORTED VARIABLES * ************************************************************************/ -#ifdef __cplusplus -} -#endif - #endif /* _CAS_CCI_H_ */ diff --git a/cci/include/dbtran_def.h b/cci/include/dbtran_def.h new file mode 100644 index 0000000..fac7c6a --- /dev/null +++ b/cci/include/dbtran_def.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* + * Transaction isolation definitions + */ + +#ifndef _DBTRAN_DEF_H_ +#define _DBTRAN_DEF_H_ + +typedef enum +{ + TRAN_UNKNOWN_ISOLATION = 0x00, /* 0 0000 */ + + TRAN_READ_COMMITTED = 0x04, /* 0 0100 */ + TRAN_REP_CLASS_COMMIT_INSTANCE = 0x04, /* Alias of above */ + TRAN_CURSOR_STABILITY = 0x04, /* Alias of above */ + + TRAN_REPEATABLE_READ = 0x05, /* 0 0101 */ + TRAN_REP_READ = 0x05, /* Alias of above */ + TRAN_REP_CLASS_REP_INSTANCE = 0x05, /* Alias of above */ + TRAN_DEGREE_2_9999_CONSISTENCY = 0x05, /* Alias of above */ + + TRAN_SERIALIZABLE = 0x06, /* 0 0110 */ + TRAN_DEGREE_3_CONSISTENCY = 0x06, /* Alias of above */ + TRAN_NO_PHANTOM_READ = 0x06, /* Alias of above */ + + TRAN_DEFAULT_ISOLATION = TRAN_READ_COMMITTED, + MVCC_TRAN_DEFAULT_ISOLATION = TRAN_READ_COMMITTED, + + TRAN_MINVALUE_ISOLATION = 0x04, /* internal use only */ + TRAN_MAXVALUE_ISOLATION = 0x06, /* internal use only */ + + // aliases for CCI compatibility + TRAN_ISOLATION_MIN = 0x04, + TRAN_ISOLATION_MAX = 0x06, +} DB_TRAN_ISOLATION; + +#define IS_VALID_ISOLATION_LEVEL(isolation_level) \ + (TRAN_MINVALUE_ISOLATION <= (isolation_level) \ + && (isolation_level) <= TRAN_MAXVALUE_ISOLATION) + +#define TRAN_DEFAULT_ISOLATION_LEVEL() (TRAN_DEFAULT_ISOLATION) + +#define TRAN_ASYNC_WS_BIT 0x10 /* 1 0000 */ +#define TRAN_ISO_LVL_BITS 0x0F /* 0 1111 */ + +#endif // _DBTRAN_DEF_H_ diff --git a/cci/lib32/cas_cci_14.lib b/cci/lib32/cas_cci_14.lib new file mode 100644 index 0000000..a0ba9ba Binary files /dev/null and b/cci/lib32/cas_cci_14.lib differ diff --git a/cci/lib32/cas_cci_d_14.lib b/cci/lib32/cas_cci_d_14.lib new file mode 100644 index 0000000..1089f2d Binary files /dev/null and b/cci/lib32/cas_cci_d_14.lib differ diff --git a/cci/lib64/cas_cci_14.lib b/cci/lib64/cas_cci_14.lib new file mode 100644 index 0000000..ede2aa1 Binary files /dev/null and b/cci/lib64/cas_cci_14.lib differ diff --git a/cci/lib64/cas_cci_d_14.lib b/cci/lib64/cas_cci_d_14.lib new file mode 100644 index 0000000..bf92db4 Binary files /dev/null and b/cci/lib64/cas_cci_d_14.lib differ diff --git a/cubrid_odbc.rc b/cubrid_odbc.rc index ac67e35..513b33c 100644 --- a/cubrid_odbc.rc +++ b/cubrid_odbc.rc @@ -7,7 +7,11 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +//#include "afxres.h" + +#include "WinResrc.h" +#define IDC_STATIC -1 + #include "odbc_version.i" ///////////////////////////////////////////////////////////////////////////// diff --git a/cubrid_odbc_14.sln b/cubrid_odbc_14.sln new file mode 100644 index 0000000..f493b8d --- /dev/null +++ b/cubrid_odbc_14.sln @@ -0,0 +1,41 @@ + +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}") = "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}" + ProjectSection(ProjectDependencies) = postProject + {37E00A2E-BBC5-4736-90D9-A1B4271759BB} = {37E00A2E-BBC5-4736-90D9-A1B4271759BB} + EndProjectSection +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 + {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 diff --git a/cubrid_odbc_14.vcxproj b/cubrid_odbc_14.vcxproj new file mode 100644 index 0000000..15fa8c1 --- /dev/null +++ b/cubrid_odbc_14.vcxproj @@ -0,0 +1,307 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + cubrid_odbc + {37E00A2E-BBC5-4736-90D9-A1B4271759BB} + cubrid_odbc + + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + build\$(Platform)_$(Configuration)\ + temp\$(Platform)_$(Configuration)\ + false + + + build\$(Platform)_$(Configuration)\ + temp\$(Platform)_$(Configuration)\ + false + + + build\$(Platform)_$(Configuration)\ + temp\$(Platform)_$(Configuration)\ + false + + + build\$(Platform)_$(Configuration)\ + temp\$(Platform)_$(Configuration)\ + false + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + MultiThreaded + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_14.lib;regex38a.lib;Msvcrt.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib32;%(AdditionalLibraryDirectories) + cubrid_odbc.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX86 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Release/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreaded + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_14.lib;regex38a.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib64;%(AdditionalLibraryDirectories) + cubrid_odbc.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;CUBRID_ODBC_EXPORTS;__DEBUG_LOG;_CRT_SECURE_NO_WARNINGS.;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + Default + MultiThreadedDebug + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + ProgramDatabase + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_d_14.lib;regex38a_d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib32;%(AdditionalLibraryDirectories) + cubrid_odbc.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX86 + true + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Debug/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;CUBRID_ODBC_EXPORTS;__DEBUG_LOG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebug + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + ProgramDatabase + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_d_14.lib;regex38a_d.lib;legacy_stdio_definitions.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib64;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib\amd64;%(AdditionalLibraryDirectories) + cubrid_odbc.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX64 + + + false + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cubrid_odbc_unicode_14.vcxproj b/cubrid_odbc_unicode_14.vcxproj new file mode 100644 index 0000000..cce7763 --- /dev/null +++ b/cubrid_odbc_unicode_14.vcxproj @@ -0,0 +1,302 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + cubrid_odbc_unicode + {0092BD82-BCE8-4E10-A9DB-D083FC5C9D67} + cubrid_odbc + + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + DynamicLibrary + v141 + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + build\$(Platform)_$(Configuration)_Unicode\ + temp\$(Platform)_$(Configuration)_Unicode\ + false + + + build\$(Platform)_$(Configuration)_Unicode\ + temp\$(Platform)_$(Configuration)_Unicode\ + false + + + build\$(Platform)_$(Configuration)_Unicode\ + temp\$(Platform)_$(Configuration)_Unicode\ + false + + + build\$(Platform)_$(Configuration)_Unicode\ + temp\$(Platform)_$(Configuration)_Unicode\ + false + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;CUBRID_ODBC_UNICODE;%(PreprocessorDefinitions) + MultiThreaded + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_14.lib;regex38a.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib32;%(AdditionalLibraryDirectories) + cubrid_odbc_unicode.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX86 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Release/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;CUBRID_ODBC_UNICODE;%(PreprocessorDefinitions) + MultiThreaded + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_14.lib;regex38a.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib64;%(AdditionalLibraryDirectories) + cubrid_odbc_unicode.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;CUBRID_ODBC_EXPORTS;__DEBUG_LOG;_CRT_SECURE_NO_WARNINGS.;_USE_32BIT_TIME_T;CUBRID_ODBC_UNICODE;%(PreprocessorDefinitions) + Default + MultiThreadedDebug + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + ProgramDatabase + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_d_14.lib;regex38a_d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib32;%(AdditionalLibraryDirectories) + cubrid_odbc_unicode.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX86 + true + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Debug/cubrid_odbc.tlb + + + + Disabled + $(ProjectDir)\cci\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;CUBRID_ODBC_EXPORTS;__DEBUG_LOG;_CRT_SECURE_NO_WARNINGS;CUBRID_ODBC_UNICODE;%(PreprocessorDefinitions) + Default + MultiThreadedDebug + + $(IntDir)$(ProjectName).pch + .\$(IntDir) + .\$(IntDir) + .\$(IntDir) + true + Level3 + true + ProgramDatabase + CompileAsC + 4996;4274;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0412 + $(IntDir)cubrid_odbc.res + + + odbc32.lib;odbccp32.lib;wsock32.lib;cas_cci_d_14.lib;regex38a_d.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(ProjectDir)\cci\lib64;%(AdditionalLibraryDirectories) + cubrid_odbc_unicode.def + true + $(OutDir)$(ProjectName).pdb + Windows + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/installer/README.txt b/installer/README.txt index 3adee21..23a6532 100644 --- a/installer/README.txt +++ b/installer/README.txt @@ -4,10 +4,7 @@ INTRODUCTION ------------------------------------------------------------ The driver support 32-bit and 64-bit operating system you should use it against cubrid Database Server 8.4.1, -8.4.3,8.4.4, 9.1.0, 9.2.0, 9.3.0, 10.0.0. - -CUBRID ODBC Tutorials: -http://www.cubrid.org/wiki_apis/entry/cubrid-odbc-tutorials +8.4.3, 8.4.4, 9.1.0, 9.2.0, 9.3.0, 10.0.0, 10.1.0. For more information about cubrid, see http://www.cubrid.org/ diff --git a/installer/license.txt b/installer/license.txt index df68044..a89e90e 100644 --- a/installer/license.txt +++ b/installer/license.txt @@ -1,4 +1,4 @@ -Copyright (C) 2008-2015 Search Solution Corporation. All rights reserved. +Copyright (C) 2008-2017 Search Solution Corporation. All rights reserved. CUBRID is registered trademark of Search Solution Corporation. This Software is released under BSD according to its components. diff --git a/odbc_descriptor.c b/odbc_descriptor.c index 5ea484d..f7dd139 100644 --- a/odbc_descriptor.c +++ b/odbc_descriptor.c @@ -29,7 +29,8 @@ */ #include - +#include +#include #include "odbc_portable.h" #include "odbc_descriptor.h" #include "odbc_diag_record.h" @@ -402,7 +403,7 @@ odbc_get_desc_field (ODBC_DESC * desc, case SQL_DESC_BIND_OFFSET_PTR: if (value_ptr != NULL) - *(long **) value_ptr = desc->bind_offset_ptr; + *(long long **) value_ptr = desc->bind_offset_ptr; if (string_length_ptr != NULL) *string_length_ptr = sizeof (desc->bind_offset_ptr); @@ -418,7 +419,7 @@ odbc_get_desc_field (ODBC_DESC * desc, case SQL_DESC_ROWS_PROCESSED_PTR: if (value_ptr != NULL) - *(unsigned long **) value_ptr = desc->rows_processed_ptr; + *(unsigned long long **) value_ptr = desc->rows_processed_ptr; if (string_length_ptr != NULL) *string_length_ptr = sizeof (desc->rows_processed_ptr); @@ -484,9 +485,13 @@ odbc_get_desc_field (ODBC_DESC * desc, case SQL_DESC_CONCISE_TYPE: if (value_ptr != NULL) { - if(record->concise_type == SQL_BLOB || record->concise_type == SQL_CLOB) + if (record->concise_type == SQL_BLOB) + { + *(short *) value_ptr = SQL_LONGVARBINARY; + } + else if (record->concise_type == SQL_CLOB) { - *(short *) value_ptr = SQL_BINARY; + *(short *) value_ptr = SQL_LONGVARCHAR; } else { @@ -931,6 +936,7 @@ odbc_set_desc_field (ODBC_DESC * desc, if (is_driver != 1 && is_read_only_field (field_id) == _TRUE_) { odbc_set_diag (desc->diag, "HY091", 0, NULL); + DEBUG_TIMESTAMP(odbc_set_desc_field_NODATA); goto error; } @@ -943,6 +949,7 @@ odbc_set_desc_field (ODBC_DESC * desc, desc->alloc_type = (short) value_ptr; break; case SQL_DESC_ARRAY_SIZE: + DEBUG_TIMESTAMP(SQL_DESC_ARRAY_SIZE); desc->array_size = (unsigned long) value_ptr; break; case SQL_DESC_ARRAY_STATUS_PTR: @@ -1225,9 +1232,10 @@ odbc_set_desc_field (ODBC_DESC * desc, } } - + DEBUG_TIMESTAMP(FieldSetSuccess); return status; error: + DEBUG_TIMESTAMP(UnknownField); return ODBC_ERROR; } @@ -1367,30 +1375,37 @@ odbc_set_ird (ODBC_STATEMENT * stmt, if(IS_STRING_TYPE (type) || IS_BINARY_TYPE (type)) { #ifdef CUBRID_ODBC_UNICODE - if((_stricmp (stmt->conn->charset, "utf-8") == 0)) - { - if(type == SQL_LONGVARCHAR || precision > 4000) - { + if((_stricmp (stmt->conn->charset, "utf-8") == 0) || (_stricmp(stmt->conn->charset, "euc-kr") == 0)) + { + if(type == SQL_LONGVARCHAR || precision > 4000) + { type = SQL_WLONGVARCHAR; octet_length = display_size = MAX_CUBRID_CHAR_LEN; - } - else - { - type = SQL_WVARCHAR; - } + } + else + { + if (type == SQL_CHAR) + { + type = SQL_WCHAR; + } + else + { + type = SQL_WVARCHAR; + } + } } else { - if(type == SQL_LONGVARCHAR) + if(type == SQL_LONGVARCHAR) { - octet_length = display_size = MAX_CUBRID_CHAR_LEN; - } + octet_length = display_size = MAX_CUBRID_CHAR_LEN; + } } #else - if(type == SQL_LONGVARCHAR) - { - octet_length = display_size = MAX_CUBRID_CHAR_LEN; - } + if(type == SQL_LONGVARCHAR) + { + octet_length = display_size = MAX_CUBRID_CHAR_LEN; + } #endif } // set ird field diff --git a/odbc_descriptor.h b/odbc_descriptor.h index f578855..1805145 100644 --- a/odbc_descriptor.h +++ b/odbc_descriptor.h @@ -104,10 +104,10 @@ typedef struct st_odbc_desc unsigned long fetched_size; unsigned short *array_status_ptr; - long *bind_offset_ptr; + long long *bind_offset_ptr; long bind_type; short max_count; - unsigned long *rows_processed_ptr; + unsigned long long *rows_processed_ptr; struct st_odbc_record *records; diff --git a/odbc_diag_record.c b/odbc_diag_record.c index 515ab7a..c1755f6 100644 --- a/odbc_diag_record.c +++ b/odbc_diag_record.c @@ -509,14 +509,40 @@ odbc_get_diag_field (SQLSMALLINT handle_type, break; case SQL_DIAG_CONNECTION_NAME: /* yet not implemeted */ - if (diag_info_ptr && buffer_length > 0) - { - *((char *) diag_info_ptr) = '\0'; - *string_length_ptr=0; - return ODBC_SUCCESS; - } - else - return SQL_SUCCESS_WITH_INFO; + if (diag_info_ptr && buffer_length > 0) + { + int connhd = -1; + int cci_ret = 0; + T_CCI_ERROR cci_err_buf; + + if (handle_type == SQL_HANDLE_DBC) + { + connhd = ((ODBC_CONNECTION *) handle)->connhd; + } + else if (handle_type == SQL_HANDLE_STMT) + { + connhd = ((ODBC_STATEMENT *) handle)->conn->connhd; + } + + if (connhd >= 0) + { + cci_ret = cci_get_cas_info(connhd, (char *)diag_info_ptr, 32, &cci_err_buf); + } + if (connhd < 0 || cci_ret < 0) + { + *((char *) diag_info_ptr) = '\0'; + *string_length_ptr=0; + } + else + { + *string_length_ptr = strlen((char *)diag_info_ptr); + } + return ODBC_SUCCESS; + } + else + { + return SQL_SUCCESS_WITH_INFO; + } case SQL_DIAG_MESSAGE_TEXT: { diff --git a/odbc_interface.c b/odbc_interface.c index 9958e10..2a5656f 100644 --- a/odbc_interface.c +++ b/odbc_interface.c @@ -66,10 +66,15 @@ PUBLIC HINSTANCE hInstance; BOOL WINAPI DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + HMODULE hMd = NULL; if (ul_reason_for_call == DLL_PROCESS_ATTACH) { cci_init (); + DisableThreadLibraryCalls (hModule); + GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, + (LPCTSTR)SQLDriverConnect, + &hMd); } // hInstance is declared at resource_proc.c @@ -230,6 +235,8 @@ SQLCancel (SQLHSTMT StatementHandle) rc = odbc_cancel (stmt_handle); + stmt_handle->canceled = _TRUE_; + DEBUG_TIMESTAMP (END_SQLCancel); ODBC_RETURN (rc, StatementHandle); @@ -788,6 +795,18 @@ SQLExecDirect (SQLHSTMT StatementHandle, stStatementText = UT_MAKE_STRING (StatementText, TextLength); + if (stricmp(StatementText, "@QP@") == 0) + { + stmt_handle->query_plan = CCI_EXEC_ONLY_QUERY_PLAN; + return ODBC_SUCCESS; + } + + if (stricmp(StatementText, "@QE@") == 0) + { + stmt_handle->query_plan = CCI_EXEC_ONLY_QUERY_PLAN | CCI_EXEC_QUERY_ALL; + return ODBC_SUCCESS; + } + stmt_handle->is_prepared = _FALSE_; rc = odbc_prepare (stmt_handle, stStatementText); @@ -1038,6 +1057,11 @@ SQLGetData (SQLHSTMT StatementHandle, stmt_handle = (ODBC_STATEMENT *) StatementHandle; odbc_free_diag (stmt_handle->diag, RESET); + if (stmt_handle->canceled == _TRUE_) + { + ODBC_RETURN(rc, StatementHandle); + } + rc = odbc_get_data (stmt_handle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind); diff --git a/odbc_result.c b/odbc_result.c index 5f28b40..e37ce08 100644 --- a/odbc_result.c +++ b/odbc_result.c @@ -413,10 +413,21 @@ odbc_fetch (ODBC_STATEMENT * stmt, if (rc < 0) { if (rc == ODBC_NO_MORE_DATA) - return ODBC_NO_DATA; + { + if (stmt->query_plan) + { + stmt->query_plan = _FALSE_; + return ODBC_SUCCESS; + } + + return ODBC_NO_DATA; + } else - goto error; + { + goto error; + } } + current_tpl_pos = stmt->current_tpl_pos; for (i = bind_offset; @@ -570,6 +581,8 @@ odbc_get_data (ODBC_STATEMENT * stmt, int cci_ind; VALUE_CONTAINER c_value; + char *query_plan; + if (col_number > stmt->ird->max_count) { odbc_set_diag (stmt->diag, "07009", 0, NULL); @@ -584,6 +597,27 @@ odbc_get_data (ODBC_STATEMENT * stmt, } + if (col_number == 1 && target_type == SQL_C_DEFAULT) + { + int temp_length; + + cci_rc = cci_get_query_plan(stmt->stmthd, &query_plan); + + if (cci_rc < 0) + { + odbc_set_diag_by_cci(stmt->diag, cci_rc, NULL); + goto error; + } + + rc = + get_wide_char_result(query_plan, strlen(query_plan), (wchar_t **)&bound_ptr, + (int)buffer_length, &temp_length, stmt->conn->charset); + + *str_ind_ptr = temp_length; + + return rc; + } + if (col_number != stmt->column_data.column_no) { free_column_data (&stmt->column_data, RESET); @@ -992,7 +1026,7 @@ get_bind_info (ODBC_STATEMENT * stmt, SQLLEN ** strlen_ind_ptr) { long element_size; - long offset_size; + long long offset_size; element_size = stmt->ard->bind_type; /* 0 means single or column wise, >0 means row wise */ if (stmt->ard->bind_offset_ptr == NULL) @@ -1035,13 +1069,13 @@ get_bind_info (ODBC_STATEMENT * stmt, /* recalculating bount_ptr & strlen_ind_ptr */ if (stmt->ard->bind_type == SQL_BIND_BY_COLUMN) { - (long) *bound_ptr += offset_size + row_index * (*buffer_length); - (long) *strlen_ind_ptr += offset_size + row_index * sizeof (long); + (*(long long *)bound_ptr) += offset_size + row_index * (*buffer_length); + (*(long long *)strlen_ind_ptr) += offset_size + row_index * sizeof (long); } else { - (long) *bound_ptr += offset_size + row_index * element_size; - (long) *strlen_ind_ptr += offset_size + row_index * element_size; + (*(long long *)bound_ptr) += offset_size + row_index * element_size; + (*(long long *)strlen_ind_ptr) += offset_size + row_index * element_size; } return; diff --git a/odbc_statement.c b/odbc_statement.c index 4191b7f..d40a7b9 100644 --- a/odbc_statement.c +++ b/odbc_statement.c @@ -66,7 +66,7 @@ typedef struct __st_DescInfo { short type; long bind_type; - long offset_size; + long long offset_size; void *value_ptr; unsigned long length; long *ind_ptr; @@ -141,6 +141,7 @@ odbc_alloc_statement (ODBC_CONNECTION * conn, ODBC_STATEMENT ** stmt_ptr) goto error; } + s->canceled = _FALSE_; s->handle_type = SQL_HANDLE_STMT; s->stmthd = 0; s->conn = NULL; @@ -148,6 +149,7 @@ odbc_alloc_statement (ODBC_CONNECTION * conn, ODBC_STATEMENT ** stmt_ptr) s->cursor = NULL; s->sql_text = NULL; s->is_prepared = _FALSE_; + s->query_plan = _FALSE_; memset (&s->revised_sql, 0, sizeof (s->revised_sql)); s->result_type = NULL_RESULT; s->data_at_exec_state = STMT_NEED_NO_MORE_DATA; @@ -548,6 +550,7 @@ odbc_set_stmt_attr (ODBC_STATEMENT * stmt, case SQL_ATTR_ROW_ARRAY_SIZE: case SQL_ROWSET_SIZE: // for 2.x backward compatiablity + DEBUG_TIMESTAMP(SQL_ROWSET_SIZE); odbc_set_desc_field (stmt->ard, 0, SQL_DESC_ARRAY_SIZE, valueptr, sizeof (valueptr), 1); break; @@ -615,6 +618,7 @@ odbc_set_stmt_attr (ODBC_STATEMENT * stmt, return ODBC_SUCCESS; error: + DEBUG_TIMESTAMP(odbc_set_stmt_attr_ERROR); return ODBC_ERROR; } @@ -1860,10 +1864,10 @@ odbc_cancel (ODBC_STATEMENT * stmt) { /* CHECK : ̷ ؼ ߻ϴ ? */ if (stmt->stmthd > 0) - { - cci_close_req_handle (stmt->stmthd); - stmt->stmthd = -1; - } + { + cci_cancel(stmt->conn->connhd); + stmt->stmthd = -1; + } } return ODBC_SUCCESS; @@ -2791,6 +2795,11 @@ get_flag_of_cci_execute (ODBC_STATEMENT * stmt) if (stmt == NULL) return 0; + if (stmt->query_plan) + { + return stmt->query_plan; + } + if (stmt->attr_async_enable == SQL_ASYNC_ENABLE_ON) { return (CCI_EXEC_ASYNC | CCI_EXEC_QUERY_ALL); diff --git a/odbc_statement.h b/odbc_statement.h index a278333..5bd591c 100644 --- a/odbc_statement.h +++ b/odbc_statement.h @@ -150,7 +150,7 @@ typedef struct st_odbc_statement T_CCI_CUBRID_STMT stmt_type; PARAM_DATA param_data; /* For data at exec */ char is_prepared; // SQLPrepare ؼ prepare¿ δ. - + char query_plan; /* Supported attributes */ unsigned long attr_metadata_id; // Core @@ -177,6 +177,7 @@ typedef struct st_odbc_statement unsigned short *attr_row_operation_ptr; // 1 unsigned long attr_simulate_cursor; // 2 + char canceled; // Descriptor section diff --git a/odbc_type.c b/odbc_type.c index 0ae112d..9bcac13 100644 --- a/odbc_type.c +++ b/odbc_type.c @@ -426,6 +426,9 @@ PRIVATE int odbc_is_valid_sql_verbose_type (short odbc_type); PRIVATE int odbc_is_valid_c_common_type (short c_type); PRIVATE int odbc_is_valid_sql_common_type (short sql_type); +PRIVATE int odbc_is_valid_lob_type (short odbc_type); +PRIVATE int odbc_is_valid_sql_lob_type (short sql_type); + PRIVATE int odbc_is_valid_date_code (short code); PRIVATE int odbc_is_valid_internal_code (short code); @@ -435,10 +438,10 @@ PUBLIC int odbc_is_valid_type (short odbc_type) { return (odbc_is_valid_concise_type (odbc_type) || - odbc_is_valid_verbose_type (odbc_type)); + odbc_is_valid_verbose_type (odbc_type) || + odbc_is_valid_lob_type (odbc_type)); } - PUBLIC int odbc_is_valid_code (short code) { @@ -954,9 +957,12 @@ odbc_type_to_cci_u_type (short sql_type) { case SQL_CHAR: + case SQL_WCHAR: return CCI_U_TYPE_CHAR; case SQL_VARCHAR: + case SQL_WVARCHAR: case SQL_LONGVARCHAR: + case SQL_WLONGVARCHAR: return CCI_U_TYPE_STRING; case SQL_BINARY: @@ -1474,7 +1480,7 @@ cci_value_to_odbc (void *c_value, short concise_type, break; } - *(long *) c_value = cci_value->i; + *(long *)c_value = cci_value->i; length = sizeof (long); break; case SQL_C_ULONG: @@ -2363,6 +2369,18 @@ odbc_is_valid_sql_common_type (short sql_type) return seek_in_common_type_set (sql_common_type_set, set_size, sql_type); } +PRIVATE int +odbc_is_valid_lob_type (short odbc_type) +{ + return odbc_is_valid_sql_lob_type (odbc_type); +} + +PRIVATE int +odbc_is_valid_sql_lob_type (short sql_type) +{ + return ((sql_type == SQL_BLOB) || (sql_type == SQL_CLOB)); +} + PRIVATE int odbc_is_valid_date_code (short code) { diff --git a/odbc_type.h b/odbc_type.h index 6f2bdad..eaf32e7 100644 --- a/odbc_type.h +++ b/odbc_type.h @@ -36,7 +36,7 @@ #include "cas_cci.h" #define MAX_CUBRID_CHAR_LEN (1073741823) -#define DEFAULT_COL_PRECISION (256) +#define DEFAULT_COL_PRECISION (4*1024) #define SQL_UNI_MONETARY 30 #define SQL_C_UNI_MONETARY SQL_UNI_MONETARY diff --git a/odbc_util.c b/odbc_util.c index 9242546..8585679 100644 --- a/odbc_util.c +++ b/odbc_util.c @@ -39,8 +39,16 @@ #define UNIT_MEMORY_SIZE 256 #define STK_SIZE 100 +#ifndef CP_EUC_KR +#define CP_EUC_KR 51949 +#endif + static int is_korean (unsigned char ch); +#pragma comment(lib, "legacy_stdio_definitions.lib") + + + /************************************************************************ * name: InitStr * arguments: @@ -1298,6 +1306,50 @@ get_connect_attr (ODBC_CONNECTION_ATTR *attr, const char *conn_str_in, char *buf } } +/************************************************************************ +* name: encode_string_to_charset +* arguments: +* returns/side-effects: +* description: +* NOTE: +************************************************************************/ +int +encode_string_to_charset(wchar_t *str, int size, char **target, int* out_length, char *charset) +{ + int nLength; + char *tmp_string; + int wincode = CP_ACP; + + if (charset == NULL || _stricmp(charset, "utf-8") == 0) + { + wincode = CP_UTF8; + } + else if (_stricmp(charset, "euc-kr") == 0) + { + wincode = CP_EUC_KR; + } + + nLength = WideCharToMultiByte(wincode, 0, str, -1, NULL, 0, NULL, NULL); + tmp_string = (char *)ut_alloc(sizeof(char) * (nLength + 1)); + if (tmp_string == NULL) + { + return CCI_ER_NO_MORE_MEMORY; + } + + nLength = WideCharToMultiByte(wincode, 0, str, -1, tmp_string, nLength, NULL, NULL); + if (target) + { + *target = tmp_string; + } + + if (out_length) + { + *out_length = nLength; + } + + return ODBC_SUCCESS; +} + /************************************************************************ * name: encode_string_to_utf8 * arguments: @@ -1345,20 +1397,12 @@ encode_string_to_utf8 (wchar_t *str, int size, char **target, int* out_length) int wide_char_to_bytes (wchar_t *str, int size, char **target, int* out_length, char* characterset) { - char set[32] = {0}; if(size <= 0) - { - size = sqlwcharlen(str); - } - if(characterset == NULL || _stricmp (characterset, "utf-8") == 0) - { - return encode_string_to_utf8(str, size, target, out_length); - } - if(out_length) - { - * out_length = 0; - } - return ODBC_ERROR; + { + size = sqlwcharlen(str); + } + + return encode_string_to_charset(str, size, target, out_length, characterset); } /************************************************************************ @@ -1376,11 +1420,15 @@ bytes_to_wide_char (char *str, int size, wchar_t **buffer, int buffer_length, in wchar_t* temp_buffer = *buffer; int temp_buffer_length = buffer_length; - if (characterset != NULL && _stricmp (characterset, "utf-8") == 0) - { - wincode = CP_UTF8; - } - + if (characterset == NULL || _stricmp(characterset, "utf-8") == 0) + { + wincode = CP_UTF8; + } + else if (_stricmp(characterset, "euc-kr") == 0) + { + wincode = CP_EUC_KR; + } + if(str == NULL || buffer == NULL) { return ODBC_SUCCESS; @@ -1388,12 +1436,12 @@ bytes_to_wide_char (char *str, int size, wchar_t **buffer, int buffer_length, in temp_buffer_length = MultiByteToWideChar (wincode, 0, (LPCSTR) str, size, NULL, 0); if(buffer_length==0) // need to malloc buffer - { - temp_buffer = UT_ALLOC_BSTR (temp_buffer_length); - if (temp_buffer == NULL) - { - return CCI_ER_NO_MORE_MEMORY; - } + { + temp_buffer = UT_ALLOC_BSTR (temp_buffer_length); + if (temp_buffer == NULL) + { + return CCI_ER_NO_MORE_MEMORY; + } buffer_length = temp_buffer_length; } @@ -1402,13 +1450,13 @@ bytes_to_wide_char (char *str, int size, wchar_t **buffer, int buffer_length, in *buffer = temp_buffer; //SysFreeString (bstrCode); if(out_length != NULL) - { - *out_length = nLength * sizeof(wchar_t); - } + { + *out_length = nLength * sizeof(wchar_t); + } if ( buffer_length < temp_buffer_length) - { + { return ODBC_SUCCESS_WITH_INFO; - } + } return ODBC_SUCCESS; } @@ -1427,11 +1475,15 @@ get_wide_char_result (char *str, int size, wchar_t **buffer, int buffer_length, int temp_buffer_length = buffer_length; int rc = ODBC_SUCCESS; - if (characterset != NULL && _stricmp (characterset, "utf-8") == 0) - { - wincode = CP_UTF8; - } - + if (characterset == NULL || _stricmp (characterset, "utf-8") == 0) + { + wincode = CP_UTF8; + } + else if (_stricmp(characterset, "euc-kr") == 0) + { + wincode = CP_EUC_KR; + } + if(str == NULL || buffer == NULL) { return ODBC_SUCCESS; @@ -1456,3 +1508,126 @@ get_wide_char_result (char *str, int size, wchar_t **buffer, int buffer_length, } return ODBC_SUCCESS; } + +#ifdef CUBRID_ODBC_UNICODE +PRIVATE _BOOL_ is_odd_number (int num) +{ + return (num & 1) ? _TRUE_ : _FALSE_; +} + +PUBLIC int check_if_even_number (SQLUSMALLINT info_type, SQLSMALLINT buffer_length) +{ + if (buffer_length < 0) + { + /* ignore case */ + return ODBC_SUCCESS; + } + + switch (info_type) + { + /* info_type that returns a string */ + case SQL_ACCESSIBLE_PROCEDURES: + case SQL_ACCESSIBLE_TABLES: + case SQL_CATALOG_NAME: + case SQL_CATALOG_NAME_SEPARATOR: + case SQL_CATALOG_TERM: + case SQL_COLLATION_SEQ: + case SQL_COLUMN_ALIAS: + case SQL_DATA_SOURCE_NAME: + case SQL_DATA_SOURCE_READ_ONLY: + case SQL_DATABASE_NAME: + case SQL_DBMS_NAME: + case SQL_DBMS_VER: + case SQL_DESCRIBE_PARAMETER: + case SQL_DRIVER_NAME: + case SQL_DRIVER_ODBC_VER: + case SQL_DRIVER_VER: + case SQL_EXPRESSIONS_IN_ORDERBY: + case SQL_IDENTIFIER_QUOTE_CHAR: + case SQL_INTEGRITY: + case SQL_KEYWORDS: + case SQL_LIKE_ESCAPE_CLAUSE: + case SQL_MAX_ROW_SIZE_INCLUDES_LONG: + case SQL_MULT_RESULT_SETS: + case SQL_MULTIPLE_ACTIVE_TXN: + case SQL_NEED_LONG_DATA_LEN: + case SQL_ORDER_BY_COLUMNS_IN_SELECT: + case SQL_PROCEDURE_TERM: + case SQL_PROCEDURES: + case SQL_ROW_UPDATES: + case SQL_SCHEMA_TERM: + case SQL_SEARCH_PATTERN_ESCAPE: + case SQL_SERVER_NAME: + case SQL_SPECIAL_CHARACTERS: + case SQL_TABLE_TERM: + case SQL_USER_NAME: + case SQL_XOPEN_CLI_YEAR: + if (is_odd_number (buffer_length)) + { + return ODBC_ERROR; + } + + break; + + default: + break; + } + + return ODBC_SUCCESS; +} + +PUBLIC int decide_info_value_length (SQLUSMALLINT info_type, int buffer_length, int info_value_length) +{ + switch (info_type) + { + /* info_type that returns a string */ + case SQL_ACCESSIBLE_PROCEDURES: + case SQL_ACCESSIBLE_TABLES: + case SQL_CATALOG_NAME: + case SQL_CATALOG_NAME_SEPARATOR: + case SQL_CATALOG_TERM: + case SQL_COLLATION_SEQ: + case SQL_COLUMN_ALIAS: + case SQL_DATA_SOURCE_NAME: + case SQL_DATA_SOURCE_READ_ONLY: + case SQL_DATABASE_NAME: + case SQL_DBMS_NAME: + case SQL_DBMS_VER: + case SQL_DESCRIBE_PARAMETER: + case SQL_DRIVER_NAME: + case SQL_DRIVER_ODBC_VER: + case SQL_DRIVER_VER: + case SQL_EXPRESSIONS_IN_ORDERBY: + case SQL_IDENTIFIER_QUOTE_CHAR: + case SQL_INTEGRITY: + case SQL_KEYWORDS: + case SQL_LIKE_ESCAPE_CLAUSE: + case SQL_MAX_ROW_SIZE_INCLUDES_LONG: + case SQL_MULT_RESULT_SETS: + case SQL_MULTIPLE_ACTIVE_TXN: + case SQL_NEED_LONG_DATA_LEN: + case SQL_ORDER_BY_COLUMNS_IN_SELECT: + case SQL_PROCEDURE_TERM: + case SQL_PROCEDURES: + case SQL_ROW_UPDATES: + case SQL_SCHEMA_TERM: + case SQL_SEARCH_PATTERN_ESCAPE: + case SQL_SERVER_NAME: + case SQL_SPECIAL_CHARACTERS: + case SQL_TABLE_TERM: + case SQL_USER_NAME: + case SQL_XOPEN_CLI_YEAR: + if (info_value_length > buffer_length - sizeof (SQLWCHAR)) + { + info_value_length = buffer_length - sizeof (SQLWCHAR); + } + + break; + + default: + break; + } + + return info_value_length; +} +#endif diff --git a/odbc_util.h b/odbc_util.h index e9ec262..5ca4898 100644 --- a/odbc_util.h +++ b/odbc_util.h @@ -98,8 +98,8 @@ do { \ struct timeval now; \ FILE *fp = NULL; \ - char *pt; \ - pt = getenv(DEBUG_FILE_KEY); \ + char *pt = NULL; \ + pt = getenv(DEBUG_FILE_KEY) \ if ( pt != NULL ) { \ fp = fopen(pt, "a+"); \ gettimeofday(&now, NULL); \ @@ -111,9 +111,19 @@ #include #include -#define DEBUG_FILE_KEY "d:\\lsj1888\\time_log.txt" +#define DEBUG_DETAIL(value) \ + do {\ + struct _timeb now; \ + FILE *fp = NULL; \ + fp = fopen(DEBUG_FILE_KEY, "a+"); \ + _ftime(&now); \ + fprintf(fp, "### [%d] %ld.%07ld %s %d\n", value, now.time, now.millitm, __FILE__, __LINE__); \ + fclose(fp); \ + } while (0) + +#define DEBUG_FILE_KEY "d:\\temp\\time_log.txt" #define DEBUG_TIMESTAMP(value) -/* + #define DEBUG_TIMESTAMP(value) \ do { \ struct _timeb now; \ @@ -123,7 +133,6 @@ fprintf(fp,#value " %ld.%07ld %s %d\n", now.time, now.millitm, __FILE__, __LINE__); \ fclose(fp); \ } while(0) - */ #endif #else #define DEBUG_TIMESTAMP(value) @@ -254,4 +263,11 @@ PUBLIC int get_wide_char_result (char *str, int buffer_length, int* out_length, char* characterset); +/*--------------------------------------------------------------*/ + +#ifdef CUBRID_ODBC_UNICODE +PUBLIC int check_if_even_number (SQLUSMALLINT info_type, SQLSMALLINT buffer_length); +PUBLIC int decide_info_value_length (SQLUSMALLINT info_type, int buffer_length, int info_value_length); +#endif + #endif /* ! __CUBRID_ODBC_UTIL_HEADER */ diff --git a/unicode.c b/unicode.c index 50b2d91..5339741 100644 Binary files a/unicode.c and b/unicode.c differ