From aac5691b39f7fe2846df9b779240f6c3cb4a4d62 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Wed, 11 Feb 2009 05:28:44 +0000 Subject: [PATCH] mysql for odbc --- test/performance/wisc/Makefile | 2 +- test/performance/wisc/README | 2 +- test/performance/wisc/odbcBench.c | 64 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/test/performance/wisc/Makefile b/test/performance/wisc/Makefile index b5256daf..d738755c 100644 --- a/test/performance/wisc/Makefile +++ b/test/performance/wisc/Makefile @@ -1,6 +1,6 @@ CC=g++ -O2 INCL= -I$(CSQL_INSTALL_ROOT)/include -#LIBS= -L$(CSQL_INSTALL_ROOT)/lib -L/home/praba/csql/mysql-connector-odbc-3.51.23-linux-x86-32bit/lib -lcrypt -lrt -lmyodbc3 +#LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcrypt -lrt -lodbc LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcrypt -lrt -lcsqlodbc -lcacheload ALL_CC_FLAG=$(INCL) $(LIBS) JAVAC = javac -g:none diff --git a/test/performance/wisc/README b/test/performance/wisc/README index 2f76b558..c9e47810 100644 --- a/test/performance/wisc/README +++ b/test/performance/wisc/README @@ -19,7 +19,7 @@ $java JDBCPopulate mysql To run odbc test $./odbcBench -For mysql, set the LD_LIBRARY_PATH and edit the Makefile to link with mysql odbc library +For mysql, edit(uncomment) Makefile to link with unixODBC library $./odbcBench mysql To run csql jdbc test diff --git a/test/performance/wisc/odbcBench.c b/test/performance/wisc/odbcBench.c index ee4617f1..b2cd35d4 100644 --- a/test/performance/wisc/odbcBench.c +++ b/test/performance/wisc/odbcBench.c @@ -9,6 +9,7 @@ #include "NanoTimer.h" #define ITERATION 100 using namespace std; +bool mysql; NanoTimer timer; long long int timevalues[30]={0}; @@ -93,6 +94,16 @@ void readOnlyTrans (SQLHDBC hdbc) void createHashIndex(SQLHANDLE hstmt,bool flag) { int rc; + if (mysql) { + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx1 USING HASH ON big1(unique1);", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx2 USING HASH ON big2(unique1);", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx3 USING HASH ON small(unique1)", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx4 USING HASH ON big1(stringu1)", SQL_NTS ); + checkrc (rc, __LINE__); + } else { rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx1 ON big1(unique1) HASH;", SQL_NTS ); checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx2 ON big2(unique1) HASH;", SQL_NTS ); @@ -101,10 +112,22 @@ void createHashIndex(SQLHANDLE hstmt,bool flag) checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx4 ON big1(stringu1) HASH", SQL_NTS ); checkrc (rc, __LINE__); + } } void createTreeIndex(SQLHANDLE hstmt,bool flag) { int rc; + if (mysql) + { + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx5 USING BTREE ON big1(unique1);", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx6 USING BTREE ON big2(unique1);", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx7 USING BTREE ON small(unique1);", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx8 USING BTREE ON big1(stringu1);", SQL_NTS ); + checkrc (rc, __LINE__); + }else { rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx5 ON big1(unique1) TREE;", SQL_NTS ); checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx6 ON big2(unique1) TREE;", SQL_NTS ); @@ -113,11 +136,22 @@ void createTreeIndex(SQLHANDLE hstmt,bool flag) checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "CREATE INDEX idx8 ON big1(stringu1) TREE;", SQL_NTS ); checkrc (rc, __LINE__); + } } void dropHashIndex(SQLHANDLE hstmt,bool flag) { int rc; + if (mysql) { + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx1 on big1 ;", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx2 on big2;", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx3 on small", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx4 on big1;", SQL_NTS ); + checkrc (rc, __LINE__); + } else { rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx1 ;", SQL_NTS ); checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx2 ;", SQL_NTS ); @@ -126,10 +160,22 @@ void dropHashIndex(SQLHANDLE hstmt,bool flag) checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx4 ;", SQL_NTS ); checkrc (rc, __LINE__); + } } void dropTreeIndex(SQLHANDLE hstmt,bool flag) { int rc; + if (mysql) + { + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx5 on big1 ;", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx6 on big2;", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx7 on small;", SQL_NTS ); + checkrc (rc, __LINE__); + rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx8 on big1;", SQL_NTS ); + checkrc (rc, __LINE__); + }else { rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx5 ;", SQL_NTS ); checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx6 ;", SQL_NTS ); @@ -138,6 +184,7 @@ void dropTreeIndex(SQLHANDLE hstmt,bool flag) checkrc (rc, __LINE__); rc = SQLExecDirect(hstmt, (SQLCHAR*) "DROP INDEX idx8 ;", SQL_NTS ); checkrc (rc, __LINE__); + } } @@ -448,7 +495,6 @@ void printTime() printf(" Join(10K*1K)1 \t %lld\t %lld \t %lld\n",timevalues[24],timevalues[25],timevalues[26]); printf(" Join(10K*10K*1K)1 \t %lld\t %lld \t %lld\n",timevalues[27],timevalues[28],timevalues[29]); printf("*******************************************************\n"); - } @@ -458,19 +504,31 @@ int main (int ac, char **av) SQLHENV henv; SQLHDBC hdbc; SQLHSTMT hstmt; - + mysql=false; + if (ac ==2) mysql = true; + //printf("Mysql Set %d \n", ac); return 0; rc = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); checkrc (rc, __LINE__); SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); rc = SQLAllocHandle (SQL_HANDLE_DBC, henv, &hdbc); checkrc (rc, __LINE__); - rc = SQLConnect (hdbc, + if (!mysql) { + rc = SQLConnect (hdbc, (SQLCHAR *) "test", (SQLSMALLINT) strlen ("test"), (SQLCHAR *) "root", (SQLSMALLINT) strlen ("root"), (SQLCHAR *) "manager", (SQLSMALLINT) strlen ("")); + }else { + + SQLCHAR outstr[1024]; + SQLSMALLINT outstrlen; + rc = SQLDriverConnect(hdbc, NULL, (SQLCHAR*)"DSN=myodbc3;", SQL_NTS, + outstr, sizeof(outstr), &outstrlen, + SQL_DRIVER_NOPROMPT); + } + if (SQL_SUCCEEDED(rc)) { printf("Connected\n"); -- 2.11.4.GIT