From 2a9494633abd62b41326404c375cc939ac5b9834 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Thu, 8 Oct 2009 07:57:43 +0000 Subject: [PATCH] removing tmptest files --- tmptest/Makefile | 59 ------------------------- tmptest/create.c | 119 --------------------------------------------------- tmptest/del.c | 40 ----------------- tmptest/example.java | 27 ------------ tmptest/select.c | 44 ------------------- tmptest/test.c | 112 ------------------------------------------------ tmptest/upd.c | 35 --------------- 7 files changed, 436 deletions(-) delete mode 100644 tmptest/Makefile delete mode 100644 tmptest/create.c delete mode 100644 tmptest/del.c delete mode 100644 tmptest/example.java delete mode 100644 tmptest/select.c delete mode 100644 tmptest/test.c delete mode 100644 tmptest/upd.c diff --git a/tmptest/Makefile b/tmptest/Makefile deleted file mode 100644 index 381754dd..00000000 --- a/tmptest/Makefile +++ /dev/null @@ -1,59 +0,0 @@ - -OSNAME = $(shell uname -s) -PlatForm=supported - -ifeq ($(OSNAME), SunOS) -CPlus = CC -CPlusFlags = -O2 -w -mt -xarch=v8 -SYSLIBS=-ldl -lnsl -lsocket -lposix4 -else -ifeq ($(OSNAME), Linux) -CPlus = g++ -CPlusFlags = -g -rdynamic -SYSLIBS= -lrt -lpthread -lcrypt -else -PlatForm=notsupported -all: - echo "CSQL is not supported on $(OSNAME) platform" -endif -endif - -INCL= -I$(CSQL_INSTALL_ROOT)/include -I../src/sql -LIBS= -L$(CSQL_INSTALL_ROOT)/lib -L.. -lcsql -lcsqlsql -lcsqlnw -lcsqlsqllog -lcsqlgw -#LIBS= -L$(CSQL_INSTALL_ROOT)/lib -L.. -lcsql - -TARGETS = \ - test \ - t \ - testproc \ - create\ - index\ - upd\ - del\ - select - - -ifeq ($(PlatForm), supported) -all: $(TARGETS) -endif - -test: test.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -t: t.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -testproc: testproc.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -del: del.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -upd: upd.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) - -create: create.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -index: index.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -select: select.c - $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) -clean: - rm -f $(TARGETS) - diff --git a/tmptest/create.c b/tmptest/create.c deleted file mode 100644 index 4282bd5b..00000000 --- a/tmptest/create.c +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by www.databasecache.com * - * Contact: praba_tuty@databasecache.com * - * * - * 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. * - * * - **************************************************************************/ -#include -#include -int main() -{ - //connect to the database first - Connection conn; - DbRetVal rv = conn.open("root", "manager"); - if (rv != OK) - { - printf("Error during connection %d\n", rv); - return -1; - } - - //get dbmgr to create table and index - DatabaseManager *dbMgr = conn.getDatabaseManager(); - if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} - - //create table with two fields, f1 integer and f2 string - TableDef tabDef; - tabDef.addField("f1", typeInt, 0, NULL, true); - tabDef.addField("f2", typeInt); - tabDef.addField("f3", typeInt); - tabDef.addField("f4", typeInt); - tabDef.addField("f5", typeInt); - rv = dbMgr->createTable("t1", tabDef); - if (rv != OK) { printf("Table creation failed\n"); return -1; } - printf("Table created\n"); - - //Creating hash index on field f1 of table t1 - HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); - strcpy(idxInfo->tableName, "t1"); - idxInfo->list.append("f1"); - idxInfo->indType = hashIndex; - rv = dbMgr->createIndex("indx1", idxInfo); - if (rv != OK) { printf("Index creation failed\n"); return -1; } - printf("Index created\n"); - - //open the table handle for doing DML operations - Table *table = dbMgr->openTable("t1"); - if (table == NULL) { printf("Unable to open table\n"); return -1; } - int id1 = 0, id2=0, id3=0, id4=0, id5=0; - table->bindFld("f1", &id1); - table->bindFld("f2", &id2); - table->bindFld("f3", &id3); - table->bindFld("f4", &id4); - table->bindFld("f5", &id5); - char *tuple; - int ret; - int i; - int icount =0; - - //insert 10 tuples into the table t1 - for(i = 0; i< 10; i++) - { - conn.startTransaction(); - id1= i; id2 = i +100; id3 = i+ 1000; id4=i%2; id5=i%3; - ret = table->insertTuple(); - if (ret != 0) break; - icount++; - conn.commit(); - } - char msgBuf[1024]; - sprintf(msgBuf,"Total rows inserted %d \n",icount); - os::write(1,msgBuf,strlen(msgBuf)); - dbMgr->closeTable(table); - table = dbMgr->openTable("t1"); - if (table == NULL) { printf("Unable to open table\n"); return -1; } - - //set the condition f1 >=5 - Condition p1; - int val1 = 2; - p1.setTerm("f1", OpGreaterThanEquals, &val1); - table->setCondition(&p1); - icount=0; - printf("Selection f1 >= 2 starts on table t1\n"); - AggTableImpl aggTable; - int group1=0, sum1=0, max1=0, cnt1=0; - aggTable.setTable(table); - //aggTable.setGroup("f4", &group1); - aggTable.bindFld("f1", AGG_AVG, &sum1); - aggTable.bindFld("f2", AGG_MAX, &max1); - aggTable.bindFld("f3", AGG_COUNT, &cnt1); - - conn.startTransaction(); - aggTable.execute(); - printf("Tuple values:\n"); - while(true) - { - tuple = (char*)aggTable.fetch() ; - if (tuple == NULL) { break; } - printf("grpfld=%d sumfld=%d maxfld=%d cntfld=%d\n", group1, sum1,max1,cnt1); - // printf("grpfld=%d sumfld=%d \n", group1, sum1); - icount++; - } - aggTable.closeScan(); - conn.commit(); - aggTable.close(); - - dbMgr->closeTable(table); - // dbMgr->dropTable("t1"); - printf("Table dropped\n"); - conn.close(); - return 0; -} diff --git a/tmptest/del.c b/tmptest/del.c deleted file mode 100644 index f2d12e7c..00000000 --- a/tmptest/del.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -int main() -{ - DbRetVal rv = OK; - SqlConnection *con = new SqlConnection(); - con->connect("praba", "manager"); - SqlStatement *stmt = new SqlStatement(); - stmt->setConnection(con); - char statement[1024]; - strcpy(statement, "DELETE FROM t1 WHERE f1 =0"); - int rows =0; - rv = stmt->prepare(statement); - if (rv != OK) {delete stmt; delete con; return 1; } - int id1 =100, id2 = 100; - int icount=0; - void *tuple; - NanoTimer timer; - timer.start(); - con->beginTrans(); - stmt->execute(rows); - printf(" Rows returned %d\n", rows); - /*while(true) - { - tuple = (char*)stmt->fetch() ; - if (tuple == NULL) { break; } - printf("f1=%d f2=%d\n", id1, id2); - icount++; - }*/ - con->commit(); - timer.stop(); - - printf("Select %d %lld %lld %lld\n", icount, timer.min(), timer.max(), timer.avg()); - - - stmt->free(); - delete stmt; - delete con; - return 0; -} diff --git a/tmptest/example.java b/tmptest/example.java deleted file mode 100644 index 6969b605..00000000 --- a/tmptest/example.java +++ /dev/null @@ -1,27 +0,0 @@ -import java.sql.*; - -public class example -{ - public static void main( String argv[] ) - { - try - { - Class.forName("csql.jdbc.JdbcSqlDriver"); - // Connection handle - Connection con = DriverManager.getConnection("jdbc:csql", "praba", "manager"); - // Statement handle - PreparedStatement stmt = con.prepareStatement("UPDATE t1 set f2 = ? WHERE f1 = ?"); - for (int i =0 ; i< 10 ; i++) { - stmt.setInt(1, i+200); - stmt.setInt(2, i); - stmt.executeUpdate(); - } - stmt.close(); - con.commit(); - con.close(); - }catch(Exception e) { - System.out.println("example: "+e); - e.getStackTrace(); - } - } -} diff --git a/tmptest/select.c b/tmptest/select.c deleted file mode 100644 index f4093b56..00000000 --- a/tmptest/select.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -int main() -{ - DbRetVal rv = OK; - SqlConnection *con = new SqlConnection(); - con->connect("root", "manager"); - SqlStatement *stmt = new SqlStatement(); - stmt->setConnection(con); - char statement[1024]; - strcpy(statement, "SELECT * from t1 where f1 = 5;"); - int rows =0; - rv = stmt->prepare(statement); - if (rv != OK) {delete stmt; delete con; return 1; } - int id1 =50, id2 = 100; - int icount=0; - rv = stmt->bindField(1, &id1); - if (rv != OK) {delete stmt; delete con; return 2; } - rv = stmt->bindField(2, &id2); - if (rv != OK) {delete stmt; delete con; return 3; } - void *tuple; - NanoTimer timer; - timer.start(); - con->beginTrans(); - stmt->execute(rows); - printf("\n"); - while(true) - { - tuple = (char*)stmt->fetch() ; - if (tuple == NULL) { break; } - printf("f1=%d f2=%d\n", id1, id2); - icount++; - } - con->commit(); - timer.stop(); - - printf("Select %d %lld %lld %lld\n", icount, timer.min(), timer.max(), timer.avg()); - - - stmt->free(); - delete stmt; - delete con; - return 0; -} diff --git a/tmptest/test.c b/tmptest/test.c deleted file mode 100644 index 714a0e23..00000000 --- a/tmptest/test.c +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by www.databasecache.com * - * Contact: praba_tuty@databasecache.com * - * * - * 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. * - * * - **************************************************************************/ -#include -#include -int main() -{ - //connect to the database first - Connection conn; - char *tuple; - int ret; - int i; - int icount =0; - DbRetVal rv = conn.open("root", "manager"); - if (rv != OK) - { - printf("Error during connection %d\n", rv); - return -1; - } - - //get dbmgr to create table and index - DatabaseManager *dbMgr = conn.getDatabaseManager(); - if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} -/* - //create table with two fields, f1 integer and f2 string - TableDef tabDef; - tabDef.addField("f1", typeInt, 0, NULL, true); - tabDef.addField("f2", typeInt); - rv = dbMgr->createTable("t1", tabDef); - if (rv != OK) { printf("Table creation failed\n"); return -1; } - printf("Table created\n"); - rv = dbMgr->createTable("t2", tabDef); - if (rv != OK) { printf("Table creation failed\n"); return -1; } -*/ - //open the table handle for doing DML operations - Table *table = dbMgr->openTable("t1"); - Table *table1 = dbMgr->openTable("t2"); -/* - if (table == NULL) { printf("Unable to open table\n"); return -1; } - int id1 = 0, id2=0; - table->bindFld("f1", &id1); - table1->bindFld("f1", &id1); - table->bindFld("f2", &id2); - table1->bindFld("f2", &id2); - - //insert 10 tuples into the table t1 - for(i = 0; i< 5; i++) - { - conn.startTransaction(); - id1= i; id2 = i %3; - ret = table->insertTuple(); - if (ret != 0) break; - ret = table1->insertTuple(); - if (ret != 0) break; - icount++; - conn.commit(); - } - char msgBuf[1024]; - sprintf(msgBuf,"Total rows inserted %d \n",icount); - os::write(1,msgBuf,strlen(msgBuf)); - dbMgr->closeTable(table); - dbMgr->closeTable(table1); - - table = dbMgr->openTable("t1"); - if (table == NULL) { printf("Unable to open table\n"); return -1; } - table1 = dbMgr->openTable("t2"); - if (table1 == NULL) { printf("Unable to open table\n"); return -1; } -*/ - - JoinTableImpl joinTable; - joinTable.setTable(table, table1); - int out1, out2, out3; - joinTable.bindFld("t1.f1", &out1); - joinTable.bindFld("t1.f2", &out2); - joinTable.bindFld("t2.f1", &out3); - - //joinTable.setJoinCondition("t1.f1", OpEquals, "t2.f1"); - - conn.startTransaction(); - joinTable.execute(); - printf("Tuple values:\n"); - int cnt=0; - while(true) - { - tuple = (char*)joinTable.fetch() ; - if (tuple == NULL) { break; } - printf("Tuple %d: %d %d %d\n", cnt++, out1, out2, out3); - icount++; - } - joinTable.closeScan(); - conn.commit(); - joinTable.close(); - - dbMgr->closeTable(table); - dbMgr->closeTable(table1); - // dbMgr->dropTable("t1"); - printf("Table dropped\n"); - conn.close(); - return 0; -} diff --git a/tmptest/upd.c b/tmptest/upd.c deleted file mode 100644 index 1dcfbf5b..00000000 --- a/tmptest/upd.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -int main() -{ - DbRetVal rv = OK; - SqlConnection *con = new SqlConnection(); - con->connect("root", "manager"); - SqlStatement *stmt = new SqlStatement(); - stmt->setConnection(con); - char statement[1024]; - //strcpy(statement, "UPDATE t1 SET f2 = 299 WHERE f1 >97"); - //strcpy(statement, "UPDATE t1 SET f1=290 WHERE f2 > ?"); - strcpy(statement, "UPDATE t1 SET f2 = 290 "); - int rows =0; - rv = stmt->prepare(statement); - if (rv != OK) {delete stmt; delete con; return 1; } - int id1 =160, id2 = 7; - //stmt->bindParam(1, &id1); - //stmt->bindParam(2, &id2); - int icount=0; - void *tuple; - NanoTimer timer; - timer.start(); - con->beginTrans(); - stmt->execute(rows); - con->commit(); - timer.stop(); - - printf("Update %d %lld %lld %lld\n", rows, timer.min(), timer.max(), timer.avg()); - - stmt->free(); - delete stmt; - delete con; - return 0; -} -- 2.11.4.GIT