From ad6a07f91ef71032261fd0cd4ba0a8705b20df11 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Thu, 4 Nov 2010 10:55:11 +0000 Subject: [PATCH] 1 --- test/dbapi/Connection/Makefile | 167 ++++++++++++ test/dbapi/Connection/common.h | 125 +++++++++ test/dbapi/Connection/conntest1.c | 21 ++ test/dbapi/Connection/conntest10.c | 69 +++++ test/dbapi/Connection/conntest11.c | 137 ++++++++++ test/dbapi/Connection/conntest12.c | 135 +++++++++ test/dbapi/Connection/conntest13.c | 127 +++++++++ test/dbapi/Connection/conntest14.c | 69 +++++ test/dbapi/Connection/conntest15.c | 81 ++++++ test/dbapi/Connection/conntest16.c | 81 ++++++ test/dbapi/Connection/conntest17.c | 130 +++++++++ test/dbapi/Connection/conntest3.c | 24 ++ test/dbapi/Connection/conntest4.c | 26 ++ test/dbapi/Connection/conntest5.c | 17 ++ test/dbapi/Connection/conntest6.c | 19 ++ test/dbapi/Connection/conntest7.c | 22 ++ test/dbapi/Connection/conntest8.c | 33 +++ test/dbapi/Connection/conntest9.c | 33 +++ test/dbapi/Connection/exp.test011 | 26 ++ test/dbapi/Connection/exp.test013 | 13 + test/dbapi/Connection/isotest1.c | 85 ++++++ test/dbapi/Connection/isotest10.c | 102 +++++++ test/dbapi/Connection/isotest11.c | 78 ++++++ test/dbapi/Connection/isotest12.c | 80 ++++++ test/dbapi/Connection/isotest13.c | 80 ++++++ test/dbapi/Connection/isotest14.c | 83 ++++++ test/dbapi/Connection/isotest15.c | 80 ++++++ test/dbapi/Connection/isotest16.c | 83 ++++++ test/dbapi/Connection/isotest17.c | 80 ++++++ test/dbapi/Connection/isotest18.c | 87 ++++++ test/dbapi/Connection/isotest19.c | 86 ++++++ test/dbapi/Connection/isotest2.c | 89 ++++++ test/dbapi/Connection/isotest20.c | 92 +++++++ test/dbapi/Connection/isotest21.c | 78 ++++++ test/dbapi/Connection/isotest22.c | 80 ++++++ test/dbapi/Connection/isotest23.c | 83 ++++++ test/dbapi/Connection/isotest24.c | 81 ++++++ test/dbapi/Connection/isotest25.c | 80 ++++++ test/dbapi/Connection/isotest26.c | 84 ++++++ test/dbapi/Connection/isotest27.c | 80 ++++++ test/dbapi/Connection/isotest28.c | 87 ++++++ test/dbapi/Connection/isotest29.c | 89 ++++++ test/dbapi/Connection/isotest3.c | 89 ++++++ test/dbapi/Connection/isotest30.c | 92 +++++++ test/dbapi/Connection/isotest4.c | 91 +++++++ test/dbapi/Connection/isotest5.c | 91 +++++++ test/dbapi/Connection/isotest6.c | 91 +++++++ test/dbapi/Connection/isotest7.c | 91 +++++++ test/dbapi/Connection/isotest8.c | 96 +++++++ test/dbapi/Connection/isotest9.c | 100 +++++++ test/dbapi/Connection/test002.ksh | 24 ++ test/dbapi/Connection/threadtest1.c | 60 ++++ test/dbapi/Connection/threadtest2.c | 63 +++++ test/dbapi/DataType/Makefile | 111 ++++++++ test/dbapi/DataType/byteinttest.c | 108 ++++++++ test/dbapi/DataType/chartest.c | 110 ++++++++ test/dbapi/DataType/datetest.c | 114 ++++++++ test/dbapi/DataType/doubletest.c | 109 ++++++++ test/dbapi/DataType/exp.test001 | 22 ++ test/dbapi/DataType/exp.test002 | 23 ++ test/dbapi/DataType/exp.test002a | 23 ++ test/dbapi/DataType/exp.test003 | 22 ++ test/dbapi/DataType/exp.test004 | 23 ++ test/dbapi/DataType/exp.test004a | 23 ++ test/dbapi/DataType/exp.test005 | 22 ++ test/dbapi/DataType/exp.test006 | 23 ++ test/dbapi/DataType/exp.test006a | 23 ++ test/dbapi/DataType/exp.test007 | 22 ++ test/dbapi/DataType/exp.test008 | 23 ++ test/dbapi/DataType/exp.test008a | 23 ++ test/dbapi/DataType/exp.test009 | 22 ++ test/dbapi/DataType/exp.test010 | 23 ++ test/dbapi/DataType/exp.test010a | 23 ++ test/dbapi/DataType/exp.test011 | 27 ++ test/dbapi/DataType/exp.test012a | 26 ++ test/dbapi/DataType/exp.test013 | 27 ++ test/dbapi/DataType/exp.test014a | 26 ++ test/dbapi/DataType/exp.test015 | 22 ++ test/dbapi/DataType/exp.test016 | 23 ++ test/dbapi/DataType/exp.test016a | 23 ++ test/dbapi/DataType/exp.test017 | 82 ++++++ test/dbapi/DataType/exp.test018 | 83 ++++++ test/dbapi/DataType/exp.test018a | 83 ++++++ test/dbapi/DataType/exp.test019 | 82 ++++++ test/dbapi/DataType/exp.test020 | 83 ++++++ test/dbapi/DataType/exp.test020a | 83 ++++++ test/dbapi/DataType/exp.test021 | 43 +++ test/dbapi/DataType/exp.test022a | 43 +++ test/dbapi/DataType/floattest.c | 112 ++++++++ test/dbapi/DataType/inttest.c | 108 ++++++++ test/dbapi/DataType/longlongtest.c | 109 ++++++++ test/dbapi/DataType/longtest.c | 109 ++++++++ test/dbapi/DataType/shorttest.c | 110 ++++++++ test/dbapi/DataType/timestamptest.c | 114 ++++++++ test/dbapi/DataType/timetest.c | 114 ++++++++ test/dbapi/DatabaseManager/Makefile | 41 +++ test/dbapi/DatabaseManager/getdbmanagertest.c | 10 + test/dbapi/Index/Makefile | 110 ++++++++ test/dbapi/Index/common.h | 134 +++++++++ test/dbapi/Index/compositekeyindex1.c | 42 +++ test/dbapi/Index/createindexnofld.c | 35 +++ test/dbapi/Index/createindexnotexist.c | 36 +++ test/dbapi/Index/dupindex1.c | 39 +++ test/dbapi/Index/dupindex2.c | 42 +++ test/dbapi/Index/exp.test004 | 37 +++ test/dbapi/Index/exp.test004a | 37 +++ test/dbapi/Index/exp.test004b | 37 +++ test/dbapi/Index/exp.test004c | 37 +++ test/dbapi/Index/exp.test005 | 36 +++ test/dbapi/Index/exp.test005a | 36 +++ test/dbapi/Index/exp.test005b | 36 +++ test/dbapi/Index/exp.test005c | 36 +++ test/dbapi/Index/index1.c | 23 ++ test/dbapi/Index/multiplecompositeindex1.c | 76 ++++++ test/dbapi/Index/primarynonunique.c | 36 +++ test/dbapi/Index/twoindex1.c | 140 ++++++++++ test/dbapi/Index/twoindex2.c | 132 +++++++++ test/dbapi/Index/uniqueindex1.c | 20 ++ test/dbapi/Index/uniqueindex2.c | 20 ++ test/dbapi/Index/uniqueindex3.c | 22 ++ test/dbapi/Makefile | 18 ++ test/dbapi/Predicate/Makefile | 152 +++++++++++ test/dbapi/Predicate/andandpredicate1.c | 61 +++++ test/dbapi/Predicate/andorandpredicate1.c | 45 +++ test/dbapi/Predicate/andorpredicate1.c | 59 ++++ test/dbapi/Predicate/andpredicate1.c | 102 +++++++ test/dbapi/Predicate/common.h | 72 +++++ test/dbapi/Predicate/exp.test001 | 22 ++ test/dbapi/Predicate/exp.test001a | 23 ++ test/dbapi/Predicate/exp.test001b | 23 ++ test/dbapi/Predicate/exp.test002 | 25 ++ test/dbapi/Predicate/exp.test002a | 26 ++ test/dbapi/Predicate/exp.test002b | 26 ++ test/dbapi/Predicate/exp.test003 | 9 + test/dbapi/Predicate/exp.test003a | 10 + test/dbapi/Predicate/exp.test003b | 10 + test/dbapi/Predicate/exp.test003c | 11 + test/dbapi/Predicate/exp.test003d | 10 + test/dbapi/Predicate/exp.test003e | 10 + test/dbapi/Predicate/exp.test003f | 11 + test/dbapi/Predicate/exp.test003g | 11 + test/dbapi/Predicate/exp.test003h | 11 + test/dbapi/Predicate/exp.test004 | 48 ++++ test/dbapi/Predicate/exp.test004a | 49 ++++ test/dbapi/Predicate/exp.test004b | 49 ++++ test/dbapi/Predicate/exp.test004c | 50 ++++ test/dbapi/Predicate/exp.test004d | 49 ++++ test/dbapi/Predicate/exp.test004e | 49 ++++ test/dbapi/Predicate/exp.test004f | 50 ++++ test/dbapi/Predicate/exp.test004g | 50 ++++ test/dbapi/Predicate/exp.test004h | 50 ++++ test/dbapi/Predicate/exp.test005 | 33 +++ test/dbapi/Predicate/exp.test005a | 34 +++ test/dbapi/Predicate/exp.test005b | 34 +++ test/dbapi/Predicate/exp.test005c | 35 +++ test/dbapi/Predicate/exp.test005d | 34 +++ test/dbapi/Predicate/exp.test005e | 34 +++ test/dbapi/Predicate/exp.test005f | 35 +++ test/dbapi/Predicate/exp.test005g | 35 +++ test/dbapi/Predicate/exp.test005h | 35 +++ test/dbapi/Predicate/exp.test006 | 24 ++ test/dbapi/Predicate/exp.test006a | 25 ++ test/dbapi/Predicate/exp.test006b | 25 ++ test/dbapi/Predicate/exp.test006c | 26 ++ test/dbapi/Predicate/exp.test006d | 25 ++ test/dbapi/Predicate/exp.test006e | 25 ++ test/dbapi/Predicate/exp.test006f | 26 ++ test/dbapi/Predicate/exp.test006g | 26 ++ test/dbapi/Predicate/exp.test006h | 26 ++ test/dbapi/Predicate/exp.test007 | 8 + test/dbapi/Predicate/exp.test008 | 10 + test/dbapi/Predicate/exp.test009 | 6 + test/dbapi/Predicate/exp.test010 | 24 ++ test/dbapi/Predicate/exp.test011 | 8 + test/dbapi/Predicate/exp.test012 | 9 + test/dbapi/Predicate/notandpredicate1.c | 113 ++++++++ test/dbapi/Predicate/notorpredicate1.c | 113 ++++++++ test/dbapi/Predicate/notpredicate1.c | 120 ++++++++ test/dbapi/Predicate/orandorpredicate1.c | 45 +++ test/dbapi/Predicate/orandpredicate1.c | 59 ++++ test/dbapi/Predicate/ororpredicate1.c | 61 +++++ test/dbapi/Predicate/orpredicate1.c | 100 +++++++ test/dbapi/Predicate/predicate1.c | 115 ++++++++ test/dbapi/Table/Makefile | 95 +++++++ test/dbapi/Table/bindtest1.c | 38 +++ test/dbapi/Table/bindtest2.c | 49 ++++ test/dbapi/Table/bindtest3.c | 81 ++++++ test/dbapi/Table/csql.conf | 161 +++++++++++ test/dbapi/Table/dbfull1.c | 85 ++++++ test/dbapi/Table/dbfull2.c | 97 +++++++ test/dbapi/Table/dbfull3.c | 101 +++++++ test/dbapi/Table/duptable1.c | 24 ++ test/dbapi/Table/exp.test001 | 43 +++ test/dbapi/Table/exp.test004 | 17 ++ test/dbapi/Table/exp.test005 | 10 + test/dbapi/Table/exp.test006 | 12 + test/dbapi/Table/exp.test007 | 22 ++ test/dbapi/Table/exp.test022 | 2 + test/dbapi/Table/exp.test024 | 10 + test/dbapi/Table/exp.test026 | 7 + test/dbapi/Table/exp.test027 | 32 +++ test/dbapi/Table/exp.test100 | 302 ++++++++++++++++++++ test/dbapi/Table/exp.test101 | 302 ++++++++++++++++++++ test/dbapi/Table/exp.test102 | 302 ++++++++++++++++++++ test/dbapi/Table/insertnulltest1.c | 69 +++++ test/dbapi/Table/insertnulltest2.c | 70 +++++ test/dbapi/Table/insertnulltest3.c | 67 +++++ test/dbapi/Table/insertnulltest4.c | 77 ++++++ test/dbapi/Table/insertnulltest5.c | 70 +++++ test/dbapi/Table/insertnulltest6.c | 73 +++++ test/dbapi/Table/insertnulltest7.c | 70 +++++ test/dbapi/Table/insertnulltest8.c | 145 ++++++++++ test/dbapi/Table/inserttest1.c | 79 ++++++ test/dbapi/Table/inserttest2.c | 55 ++++ test/dbapi/Table/inserttest3.c | 65 +++++ test/dbapi/Table/spaceusedtest.c | 43 +++ test/dbapi/Table/test003.ksh | 36 +++ test/dbapi/TableDef/Makefile | 70 +++++ test/dbapi/TableDef/csql.conf | 62 +++++ test/dbapi/TableDef/dupfieldname.c | 29 ++ test/dbapi/TableDef/fieldcasesensitive.c | 28 ++ test/dbapi/TableDef/fieldcount1.c | 23 ++ test/dbapi/TableDef/fieldcount2.c | 33 +++ test/dbapi/TableDef/fieldcount3.c | 39 +++ test/dbapi/TableDef/fieldname1.c | 43 +++ test/dbapi/TableDef/fieldname2.c | 28 ++ test/dbapi/TableDef/fieldname3.c | 59 ++++ test/dbapi/TableDef/tablename1.c | 27 ++ test/dbapi/TableDef/tuplesize1.c | 28 ++ test/dbapi/TableDef/withoutfieldname.c | 26 ++ test/dbapi/Threads/DMLThreadTest.c | 379 ++++++++++++++++++++++++++ test/dbapi/Threads/Makefile | 58 ++++ test/dbapi/Threads/autoincTest.c | 367 +++++++++++++++++++++++++ test/dbapi/Threads/test001.ksh | 24 ++ test/dbapi/Threads/test002.ksh | 26 ++ test/dbapi/Threads/test003.ksh | 25 ++ test/dbapi/Threads/test004.ksh | 24 ++ test/dbapi/Threads/test005.ksh | 24 ++ test/dbapi/Threads/test006.ksh | 24 ++ test/dbapi/Threads/test007.ksh | 24 ++ test/dbapi/Threads/test008.ksh | 24 ++ test/dbapi/Threads/test009.ksh | 24 ++ test/dbapi/UserManager/Makefile | 42 +++ test/dbapi/UserManager/usertest1.c | 47 ++++ 244 files changed, 14601 insertions(+) create mode 100644 test/dbapi/Connection/Makefile create mode 100644 test/dbapi/Connection/common.h create mode 100644 test/dbapi/Connection/conntest1.c create mode 100644 test/dbapi/Connection/conntest10.c create mode 100644 test/dbapi/Connection/conntest11.c create mode 100644 test/dbapi/Connection/conntest12.c create mode 100644 test/dbapi/Connection/conntest13.c create mode 100644 test/dbapi/Connection/conntest14.c create mode 100644 test/dbapi/Connection/conntest15.c create mode 100644 test/dbapi/Connection/conntest16.c create mode 100644 test/dbapi/Connection/conntest17.c create mode 100644 test/dbapi/Connection/conntest3.c create mode 100644 test/dbapi/Connection/conntest4.c create mode 100644 test/dbapi/Connection/conntest5.c create mode 100644 test/dbapi/Connection/conntest6.c create mode 100644 test/dbapi/Connection/conntest7.c create mode 100644 test/dbapi/Connection/conntest8.c create mode 100644 test/dbapi/Connection/conntest9.c create mode 100644 test/dbapi/Connection/exp.test011 create mode 100644 test/dbapi/Connection/exp.test013 create mode 100644 test/dbapi/Connection/isotest1.c create mode 100644 test/dbapi/Connection/isotest10.c create mode 100644 test/dbapi/Connection/isotest11.c create mode 100644 test/dbapi/Connection/isotest12.c create mode 100644 test/dbapi/Connection/isotest13.c create mode 100644 test/dbapi/Connection/isotest14.c create mode 100644 test/dbapi/Connection/isotest15.c create mode 100644 test/dbapi/Connection/isotest16.c create mode 100644 test/dbapi/Connection/isotest17.c create mode 100644 test/dbapi/Connection/isotest18.c create mode 100644 test/dbapi/Connection/isotest19.c create mode 100644 test/dbapi/Connection/isotest2.c create mode 100644 test/dbapi/Connection/isotest20.c create mode 100644 test/dbapi/Connection/isotest21.c create mode 100644 test/dbapi/Connection/isotest22.c create mode 100644 test/dbapi/Connection/isotest23.c create mode 100644 test/dbapi/Connection/isotest24.c create mode 100644 test/dbapi/Connection/isotest25.c create mode 100644 test/dbapi/Connection/isotest26.c create mode 100644 test/dbapi/Connection/isotest27.c create mode 100644 test/dbapi/Connection/isotest28.c create mode 100644 test/dbapi/Connection/isotest29.c create mode 100644 test/dbapi/Connection/isotest3.c create mode 100644 test/dbapi/Connection/isotest30.c create mode 100644 test/dbapi/Connection/isotest4.c create mode 100644 test/dbapi/Connection/isotest5.c create mode 100644 test/dbapi/Connection/isotest6.c create mode 100644 test/dbapi/Connection/isotest7.c create mode 100644 test/dbapi/Connection/isotest8.c create mode 100644 test/dbapi/Connection/isotest9.c create mode 100755 test/dbapi/Connection/test002.ksh create mode 100644 test/dbapi/Connection/threadtest1.c create mode 100644 test/dbapi/Connection/threadtest2.c create mode 100644 test/dbapi/DataType/Makefile create mode 100644 test/dbapi/DataType/byteinttest.c create mode 100644 test/dbapi/DataType/chartest.c create mode 100644 test/dbapi/DataType/datetest.c create mode 100644 test/dbapi/DataType/doubletest.c create mode 100644 test/dbapi/DataType/exp.test001 create mode 100644 test/dbapi/DataType/exp.test002 create mode 100644 test/dbapi/DataType/exp.test002a create mode 100644 test/dbapi/DataType/exp.test003 create mode 100644 test/dbapi/DataType/exp.test004 create mode 100644 test/dbapi/DataType/exp.test004a create mode 100644 test/dbapi/DataType/exp.test005 create mode 100644 test/dbapi/DataType/exp.test006 create mode 100644 test/dbapi/DataType/exp.test006a create mode 100644 test/dbapi/DataType/exp.test007 create mode 100644 test/dbapi/DataType/exp.test008 create mode 100644 test/dbapi/DataType/exp.test008a create mode 100644 test/dbapi/DataType/exp.test009 create mode 100644 test/dbapi/DataType/exp.test010 create mode 100644 test/dbapi/DataType/exp.test010a create mode 100644 test/dbapi/DataType/exp.test011 create mode 100644 test/dbapi/DataType/exp.test012a create mode 100644 test/dbapi/DataType/exp.test013 create mode 100644 test/dbapi/DataType/exp.test014a create mode 100644 test/dbapi/DataType/exp.test015 create mode 100644 test/dbapi/DataType/exp.test016 create mode 100644 test/dbapi/DataType/exp.test016a create mode 100644 test/dbapi/DataType/exp.test017 create mode 100644 test/dbapi/DataType/exp.test018 create mode 100644 test/dbapi/DataType/exp.test018a create mode 100644 test/dbapi/DataType/exp.test019 create mode 100644 test/dbapi/DataType/exp.test020 create mode 100644 test/dbapi/DataType/exp.test020a create mode 100644 test/dbapi/DataType/exp.test021 create mode 100644 test/dbapi/DataType/exp.test022a create mode 100644 test/dbapi/DataType/floattest.c create mode 100644 test/dbapi/DataType/inttest.c create mode 100644 test/dbapi/DataType/longlongtest.c create mode 100644 test/dbapi/DataType/longtest.c create mode 100644 test/dbapi/DataType/shorttest.c create mode 100644 test/dbapi/DataType/timestamptest.c create mode 100644 test/dbapi/DataType/timetest.c create mode 100644 test/dbapi/DatabaseManager/Makefile create mode 100644 test/dbapi/DatabaseManager/getdbmanagertest.c create mode 100644 test/dbapi/Index/Makefile create mode 100644 test/dbapi/Index/common.h create mode 100644 test/dbapi/Index/compositekeyindex1.c create mode 100644 test/dbapi/Index/createindexnofld.c create mode 100644 test/dbapi/Index/createindexnotexist.c create mode 100644 test/dbapi/Index/dupindex1.c create mode 100644 test/dbapi/Index/dupindex2.c create mode 100644 test/dbapi/Index/exp.test004 create mode 100644 test/dbapi/Index/exp.test004a create mode 100644 test/dbapi/Index/exp.test004b create mode 100644 test/dbapi/Index/exp.test004c create mode 100644 test/dbapi/Index/exp.test005 create mode 100644 test/dbapi/Index/exp.test005a create mode 100644 test/dbapi/Index/exp.test005b create mode 100644 test/dbapi/Index/exp.test005c create mode 100644 test/dbapi/Index/index1.c create mode 100644 test/dbapi/Index/multiplecompositeindex1.c create mode 100644 test/dbapi/Index/primarynonunique.c create mode 100644 test/dbapi/Index/twoindex1.c create mode 100644 test/dbapi/Index/twoindex2.c create mode 100644 test/dbapi/Index/uniqueindex1.c create mode 100644 test/dbapi/Index/uniqueindex2.c create mode 100644 test/dbapi/Index/uniqueindex3.c create mode 100644 test/dbapi/Makefile create mode 100644 test/dbapi/Predicate/Makefile create mode 100644 test/dbapi/Predicate/andandpredicate1.c create mode 100644 test/dbapi/Predicate/andorandpredicate1.c create mode 100644 test/dbapi/Predicate/andorpredicate1.c create mode 100644 test/dbapi/Predicate/andpredicate1.c create mode 100644 test/dbapi/Predicate/common.h create mode 100644 test/dbapi/Predicate/exp.test001 create mode 100644 test/dbapi/Predicate/exp.test001a create mode 100644 test/dbapi/Predicate/exp.test001b create mode 100644 test/dbapi/Predicate/exp.test002 create mode 100644 test/dbapi/Predicate/exp.test002a create mode 100644 test/dbapi/Predicate/exp.test002b create mode 100644 test/dbapi/Predicate/exp.test003 create mode 100644 test/dbapi/Predicate/exp.test003a create mode 100644 test/dbapi/Predicate/exp.test003b create mode 100644 test/dbapi/Predicate/exp.test003c create mode 100644 test/dbapi/Predicate/exp.test003d create mode 100644 test/dbapi/Predicate/exp.test003e create mode 100644 test/dbapi/Predicate/exp.test003f create mode 100644 test/dbapi/Predicate/exp.test003g create mode 100644 test/dbapi/Predicate/exp.test003h create mode 100644 test/dbapi/Predicate/exp.test004 create mode 100644 test/dbapi/Predicate/exp.test004a create mode 100644 test/dbapi/Predicate/exp.test004b create mode 100644 test/dbapi/Predicate/exp.test004c create mode 100644 test/dbapi/Predicate/exp.test004d create mode 100644 test/dbapi/Predicate/exp.test004e create mode 100644 test/dbapi/Predicate/exp.test004f create mode 100644 test/dbapi/Predicate/exp.test004g create mode 100644 test/dbapi/Predicate/exp.test004h create mode 100644 test/dbapi/Predicate/exp.test005 create mode 100644 test/dbapi/Predicate/exp.test005a create mode 100644 test/dbapi/Predicate/exp.test005b create mode 100644 test/dbapi/Predicate/exp.test005c create mode 100644 test/dbapi/Predicate/exp.test005d create mode 100644 test/dbapi/Predicate/exp.test005e create mode 100644 test/dbapi/Predicate/exp.test005f create mode 100644 test/dbapi/Predicate/exp.test005g create mode 100644 test/dbapi/Predicate/exp.test005h create mode 100644 test/dbapi/Predicate/exp.test006 create mode 100644 test/dbapi/Predicate/exp.test006a create mode 100644 test/dbapi/Predicate/exp.test006b create mode 100644 test/dbapi/Predicate/exp.test006c create mode 100644 test/dbapi/Predicate/exp.test006d create mode 100644 test/dbapi/Predicate/exp.test006e create mode 100644 test/dbapi/Predicate/exp.test006f create mode 100644 test/dbapi/Predicate/exp.test006g create mode 100644 test/dbapi/Predicate/exp.test006h create mode 100644 test/dbapi/Predicate/exp.test007 create mode 100644 test/dbapi/Predicate/exp.test008 create mode 100644 test/dbapi/Predicate/exp.test009 create mode 100644 test/dbapi/Predicate/exp.test010 create mode 100644 test/dbapi/Predicate/exp.test011 create mode 100644 test/dbapi/Predicate/exp.test012 create mode 100644 test/dbapi/Predicate/notandpredicate1.c create mode 100644 test/dbapi/Predicate/notorpredicate1.c create mode 100644 test/dbapi/Predicate/notpredicate1.c create mode 100644 test/dbapi/Predicate/orandorpredicate1.c create mode 100644 test/dbapi/Predicate/orandpredicate1.c create mode 100644 test/dbapi/Predicate/ororpredicate1.c create mode 100644 test/dbapi/Predicate/orpredicate1.c create mode 100644 test/dbapi/Predicate/predicate1.c create mode 100644 test/dbapi/Table/Makefile create mode 100644 test/dbapi/Table/bindtest1.c create mode 100644 test/dbapi/Table/bindtest2.c create mode 100644 test/dbapi/Table/bindtest3.c create mode 100644 test/dbapi/Table/csql.conf create mode 100644 test/dbapi/Table/dbfull1.c create mode 100644 test/dbapi/Table/dbfull2.c create mode 100644 test/dbapi/Table/dbfull3.c create mode 100644 test/dbapi/Table/duptable1.c create mode 100644 test/dbapi/Table/exp.test001 create mode 100644 test/dbapi/Table/exp.test004 create mode 100644 test/dbapi/Table/exp.test005 create mode 100644 test/dbapi/Table/exp.test006 create mode 100644 test/dbapi/Table/exp.test007 create mode 100644 test/dbapi/Table/exp.test022 create mode 100644 test/dbapi/Table/exp.test024 create mode 100644 test/dbapi/Table/exp.test026 create mode 100644 test/dbapi/Table/exp.test027 create mode 100644 test/dbapi/Table/exp.test100 create mode 100644 test/dbapi/Table/exp.test101 create mode 100644 test/dbapi/Table/exp.test102 create mode 100644 test/dbapi/Table/insertnulltest1.c create mode 100644 test/dbapi/Table/insertnulltest2.c create mode 100644 test/dbapi/Table/insertnulltest3.c create mode 100644 test/dbapi/Table/insertnulltest4.c create mode 100644 test/dbapi/Table/insertnulltest5.c create mode 100644 test/dbapi/Table/insertnulltest6.c create mode 100644 test/dbapi/Table/insertnulltest7.c create mode 100644 test/dbapi/Table/insertnulltest8.c create mode 100644 test/dbapi/Table/inserttest1.c create mode 100644 test/dbapi/Table/inserttest2.c create mode 100644 test/dbapi/Table/inserttest3.c create mode 100644 test/dbapi/Table/spaceusedtest.c create mode 100755 test/dbapi/Table/test003.ksh create mode 100644 test/dbapi/TableDef/Makefile create mode 100644 test/dbapi/TableDef/csql.conf create mode 100644 test/dbapi/TableDef/dupfieldname.c create mode 100644 test/dbapi/TableDef/fieldcasesensitive.c create mode 100644 test/dbapi/TableDef/fieldcount1.c create mode 100644 test/dbapi/TableDef/fieldcount2.c create mode 100644 test/dbapi/TableDef/fieldcount3.c create mode 100644 test/dbapi/TableDef/fieldname1.c create mode 100644 test/dbapi/TableDef/fieldname2.c create mode 100644 test/dbapi/TableDef/fieldname3.c create mode 100644 test/dbapi/TableDef/tablename1.c create mode 100644 test/dbapi/TableDef/tuplesize1.c create mode 100644 test/dbapi/TableDef/withoutfieldname.c create mode 100644 test/dbapi/Threads/DMLThreadTest.c create mode 100644 test/dbapi/Threads/Makefile create mode 100644 test/dbapi/Threads/autoincTest.c create mode 100755 test/dbapi/Threads/test001.ksh create mode 100755 test/dbapi/Threads/test002.ksh create mode 100755 test/dbapi/Threads/test003.ksh create mode 100755 test/dbapi/Threads/test004.ksh create mode 100755 test/dbapi/Threads/test005.ksh create mode 100755 test/dbapi/Threads/test006.ksh create mode 100755 test/dbapi/Threads/test007.ksh create mode 100755 test/dbapi/Threads/test008.ksh create mode 100755 test/dbapi/Threads/test009.ksh create mode 100644 test/dbapi/UserManager/Makefile create mode 100644 test/dbapi/UserManager/usertest1.c diff --git a/test/dbapi/Connection/Makefile b/test/dbapi/Connection/Makefile new file mode 100644 index 00000000..52cdbb53 --- /dev/null +++ b/test/dbapi/Connection/Makefile @@ -0,0 +1,167 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 test003 test004 test005 test006 test007 test008 \ + test009 test010 test011 test012 test013 test014 test015 test016 \ + test017 \ + test051 test052 test053 test054 test055 test056 test057 test058 \ + test059 test060 \ + test061 test062 test063 test064 test065 test066 test067 test068 \ + test069 test070 \ + test071 test072 test073 test074 test075 test076 test077 test078 \ + test079 test080 \ + test081 test082 test083 test084 test085 test086 test087 test088 \ + test089 test090 \ + test101 test102 + + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: conntest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003: conntest3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004: conntest4.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005: conntest5.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006: conntest6.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007: conntest7.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008: conntest8.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009: conntest9.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010: conntest10.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test011: conntest11.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012: conntest12.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test013: conntest13.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test014: conntest14.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test015: conntest15.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test016: conntest16.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test017: conntest17.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test051: isotest1.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test052: isotest2.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test053: isotest3.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test054: isotest4.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test055: isotest5.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test056: isotest6.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test057: isotest7.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test058: isotest8.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test059: isotest9.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test060: isotest10.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test061: isotest1.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test062: isotest2.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test063: isotest3.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test064: isotest4.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test065: isotest5.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test066: isotest6.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test067: isotest7.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test068: isotest8.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test069: isotest9.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test070: isotest10.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test071: isotest11.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test072: isotest12.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test073: isotest13.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test074: isotest14.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test075: isotest15.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test076: isotest16.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test077: isotest17.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test078: isotest18.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test079: isotest19.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test080: isotest20.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test081: isotest21.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test082: isotest22.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test083: isotest23.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test084: isotest24.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test085: isotest25.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test086: isotest26.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test087: isotest27.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test088: isotest28.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test089: isotest29.c common.h + $(CPlus) -DDEFAULT $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test090: isotest30.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test101: threadtest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test102: threadtest2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/Connection/common.h b/test/dbapi/Connection/common.h new file mode 100644 index 00000000..bb772960 --- /dev/null +++ b/test/dbapi/Connection/common.h @@ -0,0 +1,125 @@ +#include +DbRetVal createTable(DatabaseManager *dbMgr) +{ + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + DbRetVal rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return ErrUnknown; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { + printf("Index creation failed\n"); + delete idxInfo; + return ErrUnknown; + } + delete idxInfo; + return OK; +} +DbRetVal insert(DatabaseManager *dbMgr, int val, bool isSleep) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return ErrUnknown; } + int id = val ; + char name[196] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + ret = table->insertTuple(); + if (ret != 0) { dbMgr->closeTable(table); return ErrLockTimeOut; } + printf("Inserted tuple : %d %s\n", val, name); + if (isSleep) ::sleep(5); + dbMgr->closeTable(table); + return OK; +} +DbRetVal select(DatabaseManager *dbMgr, int val, bool isSleep, bool checkUpd=false) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return ErrUnknown; } + int id = 0; + char name[196]; + table->bindFld("f1", &id); + table->bindFld("f2", name); + Condition p1; + int val1 = val; + p1.setTerm("f1", OpEquals, &val1); + table->setCondition(&p1); + char *tuple; + DbRetVal rv = table->execute(); + if (rv != OK) { dbMgr->closeTable(table); return ErrUnknown; } + tuple = (char*)table->fetch(rv) ; + if (rv != OK) { dbMgr->closeTable(table); return rv; } // dont remove this line + if (tuple == NULL) { + printf("Tuple not found\n"); + dbMgr->closeTable(table); + return ErrUnknown; + } + printf("ThreadID: %lu Tuple %d %s\n", os::getthrid(), id, name); + if (isSleep) ::sleep(5); + dbMgr->closeTable(table); + if ( checkUpd && strcmp(name, "KANCHANA") != 0) return ErrUnknown; + return OK; +} +DbRetVal update(DatabaseManager *dbMgr, int val, bool isSleep, char *updname = NULL) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return ErrUnknown; } + int id = 0; + char name[196]; + table->bindFld("f1", &id); + table->bindFld("f2", name); + Condition p1; + int val1 = val; + p1.setTerm("f1", OpEquals, &val1); + table->setCondition(&p1); + char *tuple; + DbRetVal rv = table->execute(); + if (rv != OK) { dbMgr->closeTable(table); return ErrUnknown; } + tuple = (char*)table->fetch(rv); + if (rv != OK) { dbMgr->closeTable(table); return rv; } // do not remove this line + if (tuple == NULL) {dbMgr->closeTable(table); return ErrUnknown; } + if (!updname) strcpy(name, "KANCHANA"); + else strcpy(name, updname); + rv = table->updateTuple(); + if (rv != OK) { dbMgr->closeTable(table); return ErrUnknown; } + printf("ThreadID: %lu Updated Tuple %d %s\n", os::getthrid(), id, name); + + if (isSleep) ::sleep(2); + dbMgr->closeTable(table); + return OK; +} +DbRetVal remove(DatabaseManager *dbMgr, int val, bool isSleep) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return ErrUnknown; } + int id = 0; + char name[196]; + table->bindFld("f1", &id); + table->bindFld("f2", name); + Condition p1; + int val1 = val; + p1.setTerm("f1", OpEquals, &val1); + table->setCondition(&p1); + char *tuple; + DbRetVal rv = table->execute(); + if (rv != OK) { dbMgr->closeTable(table); return ErrUnknown; } + tuple = (char*)table->fetch(rv); + if (rv != OK) { dbMgr->closeTable(table); return rv; } + if (tuple == NULL) {dbMgr->closeTable(table); return ErrUnknown; } + rv = table->deleteTuple(); + if (rv != OK) { dbMgr->closeTable(table); return ErrUnknown; } + printf("ThreadID: %lu Deleted Tuple %d %s\n", os::getthrid(), id, name); + + if (isSleep) ::sleep(2); + dbMgr->closeTable(table); + return OK; +} + + diff --git a/test/dbapi/Connection/conntest1.c b/test/dbapi/Connection/conntest1.c new file mode 100644 index 00000000..79901545 --- /dev/null +++ b/test/dbapi/Connection/conntest1.c @@ -0,0 +1,21 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("wrongusername", "manager"); + if (rv == OK) + { + conn.close(); + return 1; + } + printf("wrong username test passed Return value %d \n", rv); + rv = conn.open("root", "wrongpasswd"); + if (rv == OK) + { + conn.close(); + return 2; + } + printf("wrong password test passed Return value %d \n", rv); + conn.close(); + return 0; +} diff --git a/test/dbapi/Connection/conntest10.c b/test/dbapi/Connection/conntest10.c new file mode 100644 index 00000000..d0168997 --- /dev/null +++ b/test/dbapi/Connection/conntest10.c @@ -0,0 +1,69 @@ +//Insert a tuple in a transaction and commit it +//scan should display the tuple + +#include +#include +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + int icount =0; + + conn.startTransaction(); + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed \n"); + return 5; + } + conn.commit(); + + conn.startTransaction(); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + void *fld2ptr, *tuple; + + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("Binded Tuple value is %d %s \n", id, name); + + } + conn.commit(); + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + printf("test passed successfully\n"); + return 0; +} diff --git a/test/dbapi/Connection/conntest11.c b/test/dbapi/Connection/conntest11.c new file mode 100644 index 00000000..c423b2c6 --- /dev/null +++ b/test/dbapi/Connection/conntest11.c @@ -0,0 +1,137 @@ +//Update a tuple in a transation and commit it. +// Next scan should display the update tuple. + +#include +#include +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 3; } + int id; + char name[200]="PRABA"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int icount = 0; + int i; + + conn.startTransaction(); + for (i=0;i<10;i++) + { + id=i; + rv=table->insertTuple(); + if(rv!=OK) + { + printf("Insertion failed at %d th tuple",i); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + } + conn.commit(); + + conn.startTransaction(); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + printf("Scan before updation\n"); + printf("********************\n"); + void *fld2ptr, *tuple; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("Binded Tuple value is %d %s \n", id, name); + + } + conn.commit(); + rv=table->closeScan(); + if(rv!=OK){ printf("Error in closing the table\n"); return 3;} + + Condition p1; + int val1 = 5; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + conn.startTransaction(); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + +// char *tuple; + //printf("Scan After:\n"); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + strcpy(name,"Kanchana"); + table->updateTuple(); + printf(" f1=%d f2=%s\n", id, name); + // icount++; + } + conn.commit(); + table->closeScan(); + + + conn.startTransaction(); + + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + printf("Scan After updation\n"); + printf("********************\n"); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("Binded Tuple value is %d %s \n", id, name); + + } + conn.commit(); + + //unset the condtion set as we need to delete all rows + table->setCondition(NULL); + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + // printf("Test script passed "); + return 0; +} diff --git a/test/dbapi/Connection/conntest12.c b/test/dbapi/Connection/conntest12.c new file mode 100644 index 00000000..24858d43 --- /dev/null +++ b/test/dbapi/Connection/conntest12.c @@ -0,0 +1,135 @@ +//Update a tuple in a transation and commit it. +// Next scan should display the update tuple. + +#include +#include +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 3; } + int id; + char name[200]="PRABA"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int icount = 0; + int i; + + conn.startTransaction(); + for (i=0;i<10;i++) + { + id=i; + rv=table->insertTuple(); + if(rv!=OK) + { + printf("Insertion failed at %d th tuple",i); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + } + conn.commit(); + + conn.startTransaction(); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + printf("Scan before Deletion\n"); + printf("********************\n"); + void *fld2ptr, *tuple; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("Binded Tuple value is %d %s \n", id, name); + + } + conn.commit(); + rv=table->closeScan(); + if(rv!=OK){ printf("Error in closing the table\n"); return 3;} + + Condition p1; + int val1 = 5; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + conn.startTransaction(); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + +// char *tuple; + //printf("Scan After:\n"); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + //strcpy(name,"Kanchana"); + table->deleteTuple(); + } + conn.commit(); + table->closeScan(); + + + conn.startTransaction(); + + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + printf("Scan After Deletion\n"); + printf("********************\n"); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("Binded Tuple value is %d %s \n", id, name); + + } + conn.commit(); + + //unset the condtion set as we need to delete all rows + table->setCondition(NULL); + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + printf("Test script passed "); + return 0; +} diff --git a/test/dbapi/Connection/conntest13.c b/test/dbapi/Connection/conntest13.c new file mode 100644 index 00000000..a43900d2 --- /dev/null +++ b/test/dbapi/Connection/conntest13.c @@ -0,0 +1,127 @@ +//In a transaction mix insert, update and delete a tuple. +//All should take effect in a transaction + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Unable to open database\n"); return 1;} + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + // int icount =0; + + conn.startTransaction(); + + //Inserts 10 tuples into the table + for (i=0; i<10; i++) + { + id = i; + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed\n"); + dbMgr->dropTable("t1"); + conn.close(); + return 5; + } + //icount++; + } + printf("%d tuples are inserted into the dababase\n", i); + + //Updates the tuple having f1=5 + Condition p1; + int val1 = 5; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + void *tuple; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + strcpy(name,"Kanchana"); + rv = table->updateTuple(); + if (rv != OK) + { + printf("Error during updation"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 5; + } + } + table->closeScan(); + printf("Updated successfully\n"); + + //Delets the tuple having f1=8 + table->setCondition(NULL); + val1 = 8; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + rv = table->deleteTuple(); + if (rv != OK) + { + printf("Error during deletion"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + } + table->closeScan(); + printf("Deleted successfully"); + + conn.commit(); + + conn.startTransaction(); + //Displays the database after the transaction + table->setCondition(NULL); + table->execute(); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("\nBinded Tuple value is %d %s", id, name); + } + conn.commit(); + + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Connection/conntest14.c b/test/dbapi/Connection/conntest14.c new file mode 100644 index 00000000..61108d1c --- /dev/null +++ b/test/dbapi/Connection/conntest14.c @@ -0,0 +1,69 @@ +//Insert a tuple in a transaction and abort it +//scan should not display the inserted tuple. + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Unable to open database\n"); return 1;} + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "ARVIND KOTHI"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + for (i=0; i<10; i++) + { + id=i; + conn.startTransaction(); + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed at %d th tuple", i+1); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 5; + } + conn.commit(); + } + printf("%d tuples are inserted into the dababase\n", i); + + id=100; + conn.startTransaction(); + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed at %d th tuple", i+1); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 6; + } + conn.rollback(); + void *tuple; + table->setCondition(NULL); + table->execute(); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("\nBinded Tuple value is %d %s", id, name); + } + + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + diff --git a/test/dbapi/Connection/conntest15.c b/test/dbapi/Connection/conntest15.c new file mode 100644 index 00000000..f951d2a9 --- /dev/null +++ b/test/dbapi/Connection/conntest15.c @@ -0,0 +1,81 @@ +//Update a tuple in a transaction and abort it +//scan should not display the inserted tuple. + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Unable to open database\n"); return 1;} + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "ARVIND KOTHI"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + for (i=0; i<10; i++) + { + id=i; + conn.startTransaction(); + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed at %d th tuple", i+1); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 5; + } + conn.commit(); + } + printf("%d tuples are inserted into the dababase\n", i); + + conn.startTransaction(); + Condition p; + int val = 3; + p.setTerm("f1", OpEquals, &val); + table->setCondition(&p); + table->execute(); + void *tuple; + while(true) + { + tuple=(char*)table->fetch(); + if (tuple == NULL) break; + strcpy(name,"Kanchana"); + rv = table->updateTuple(); + if (rv != OK) + { + printf("Updation failed "); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 6; + } + printf("Updated tuple value is %d %s",id,name); + } + table->closeScan(); + conn.rollback(); + table->setCondition(NULL); + table->execute(); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("\nBinded Tuple value is %d %s", id, name); + } + + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + diff --git a/test/dbapi/Connection/conntest16.c b/test/dbapi/Connection/conntest16.c new file mode 100644 index 00000000..744f46e1 --- /dev/null +++ b/test/dbapi/Connection/conntest16.c @@ -0,0 +1,81 @@ +//Delete a tuple in a transaction and abort it +//scan should not display the inserted tuple. + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Unable to open database\n"); return 1;} + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "ARVIND KOTHI"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + for (i=0; i<10; i++) + { + id=i; + conn.startTransaction(); + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed at %d th tuple", i+1); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 5; + } + conn.commit(); + } + printf("%d tuples are inserted into the dababase\n", i); + + conn.startTransaction(); + Condition p; + int val = 3; + p.setTerm("f1", OpEquals, &val); + table->setCondition(&p); + table->execute(); + void *tuple; + while(true) + { + tuple=(char*)table->fetch(); + if (tuple == NULL) break; + // strcpy(name,"Kanchana"); + rv = table->deleteTuple(); + if (rv != OK) + { + printf("Deletion failed "); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 6; + } + // printf("Updated tuple value is %d %s",id,name); + } + table->closeScan(); + conn.rollback(); + table->setCondition(NULL); + table->execute(); + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("\nBinded Tuple value is %d %s", id, name); + } + + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + diff --git a/test/dbapi/Connection/conntest17.c b/test/dbapi/Connection/conntest17.c new file mode 100644 index 00000000..e9d9e2bb --- /dev/null +++ b/test/dbapi/Connection/conntest17.c @@ -0,0 +1,130 @@ +//In a transaction mix insert, update and delete a tuple and abort it +//All should not take effect in a transaction + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Unable to open database\n"); return 1;} + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + int id = 0; + char name[196] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + int i; + // int icount =0; + + conn.startTransaction(); + + //Inserts 10 tuples into the table + for (i=0; i<10; i++) + { + id = i; + rv = table->insertTuple(); + if (rv != OK) + { + printf("Insertion failed\n"); + dbMgr->dropTable("t1"); + conn.close(); + return 5; + } + //icount++; + } + printf("%d tuples are inserted into the dababase\n", i); + + //Updates the tuple having f1=5 + Condition p1; + int val1 = 5; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + void *tuple; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + strcpy(name,"Kanchana"); + rv = table->updateTuple(); + if (rv != OK) + { + printf("Error during updation"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 5; + } + } + table->closeScan(); + printf("Updated successfully\n"); + + //Delets the tuple having f1=8 + table->setCondition(NULL); + val1 = 8; + p1.setTerm("f1",OpEquals, &val1); + table->setCondition(&p1); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) { break; } + rv = table->deleteTuple(); + if (rv != OK) + { + printf("Error during deletion"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 6; + } + } + table->closeScan(); + printf("Deleted successfully"); + + conn.rollback(); + + conn.startTransaction(); + //Displays the database after the transaction + table->setCondition(NULL); + table->execute(); + int count =0; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + printf("\nBinded Tuple value is %d %s", id, name); + count++; + } + conn.commit(); + + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + if (count !=0) return 100; + return 0; +} diff --git a/test/dbapi/Connection/conntest3.c b/test/dbapi/Connection/conntest3.c new file mode 100644 index 00000000..1468d36b --- /dev/null +++ b/test/dbapi/Connection/conntest3.c @@ -0,0 +1,24 @@ +//Open connection twice using the same object without closing the connection inbetween. +// Is should fail. + +#include +int main() +{ + Connection conn; + DbRetVal rv1 = conn.open("root", "manager"); + if (rv1!= OK) + { + printf("Unable to open the database"); + return 1; + } + + DbRetVal rv2 = conn.open("root", "manager"); + if(rv2==OK) + { + printf("Test failed"); + return 2; + } + + printf("Opening connection twice w/o closing inbetween passed return value %d \n",rv1); + return 0; +} diff --git a/test/dbapi/Connection/conntest4.c b/test/dbapi/Connection/conntest4.c new file mode 100644 index 00000000..343a2561 --- /dev/null +++ b/test/dbapi/Connection/conntest4.c @@ -0,0 +1,26 @@ +//open connection +//close it and reopen the connection using the same object +//It should pass + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) + { + return 1; + } + rv=conn.close(); + if(rv!=OK) + { + return 2; + } + rv=conn.open("root","manager"); + if(rv!=OK) + { + return 3; + } + printf("test 3 passed return value %d\n",rv); + return 0; +} diff --git a/test/dbapi/Connection/conntest5.c b/test/dbapi/Connection/conntest5.c new file mode 100644 index 00000000..57364840 --- /dev/null +++ b/test/dbapi/Connection/conntest5.c @@ -0,0 +1,17 @@ +//commit a transaction without starting it and it should fail + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) return 1; + rv=conn.commit(); + if(rv==OK) + { + printf("test script failed"); + return 2; + } + printf("Test script passed return value %d\n",rv); + return 0; +} diff --git a/test/dbapi/Connection/conntest6.c b/test/dbapi/Connection/conntest6.c new file mode 100644 index 00000000..85a95dfb --- /dev/null +++ b/test/dbapi/Connection/conntest6.c @@ -0,0 +1,19 @@ +//abort a transaction without starting it +//it should fail + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) return 1; + rv=conn.rollback(); + if(rv!=OK) + { + printf("Test script failed"); + return 2; + } + printf("Test script passed return value %d\n",rv); + return 0; +} + diff --git a/test/dbapi/Connection/conntest7.c b/test/dbapi/Connection/conntest7.c new file mode 100644 index 00000000..58ed8947 --- /dev/null +++ b/test/dbapi/Connection/conntest7.c @@ -0,0 +1,22 @@ +//Create transaction twice without committing it or aborting it on the same +//object, It should fail + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) + { + return 1; + } + rv=conn.startTransaction(); + rv=conn.startTransaction(); + if(rv!=OK) + { + printf("Test script passed return value %d\n",rv); + return 0; + } + printf("test script failed return value %d\n",rv); + return 2; +} diff --git a/test/dbapi/Connection/conntest8.c b/test/dbapi/Connection/conntest8.c new file mode 100644 index 00000000..78db24f8 --- /dev/null +++ b/test/dbapi/Connection/conntest8.c @@ -0,0 +1,33 @@ +//Create a transaction and commit it for one million times +//it should succeed + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) + { + return 1; + } + if(rv!=OK) + { + printf("unable to start transaction"); + return 2; + } + for(int i=0;i<1000000;i++) + { + rv=conn.startTransaction(); + if(rv!=OK) return 3; + rv=conn.commit(); + if(rv!=OK) + { + printf("Test script failed return value %d\n",rv); + return 4; + } + } + printf("test script passed return value %d\n",rv); + return 0; +} + + diff --git a/test/dbapi/Connection/conntest9.c b/test/dbapi/Connection/conntest9.c new file mode 100644 index 00000000..d2c00c5a --- /dev/null +++ b/test/dbapi/Connection/conntest9.c @@ -0,0 +1,33 @@ +//Create a transaction and abort it for one million times +//it should succeed + +#include +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) + { + return 1; + } + if(rv!=OK) + { + printf("unable to start transaction"); + return 2; + } + for(int i=0;i<1000000;i++) + { + rv=conn.startTransaction(); + if(rv!=OK) return 3; + rv=conn.rollback(); + if(rv!=OK) + { + printf("Test script failed return value %d\n",rv); + return 4; + } + } + printf("test script passed return value %d\n",rv); + return 0; +} + + diff --git a/test/dbapi/Connection/exp.test011 b/test/dbapi/Connection/exp.test011 new file mode 100644 index 00000000..f5729443 --- /dev/null +++ b/test/dbapi/Connection/exp.test011 @@ -0,0 +1,26 @@ +Table created +Scan before updation +******************** +Binded Tuple value is 0 PRABA +Binded Tuple value is 1 PRABA +Binded Tuple value is 2 PRABA +Binded Tuple value is 3 PRABA +Binded Tuple value is 4 PRABA +Binded Tuple value is 5 PRABA +Binded Tuple value is 6 PRABA +Binded Tuple value is 7 PRABA +Binded Tuple value is 8 PRABA +Binded Tuple value is 9 PRABA + f1=5 f2=Kanchana +Scan After updation +******************** +Binded Tuple value is 0 PRABA +Binded Tuple value is 1 PRABA +Binded Tuple value is 2 PRABA +Binded Tuple value is 3 PRABA +Binded Tuple value is 4 PRABA +Binded Tuple value is 5 Kanchana +Binded Tuple value is 6 PRABA +Binded Tuple value is 7 PRABA +Binded Tuple value is 8 PRABA +Binded Tuple value is 9 PRABA diff --git a/test/dbapi/Connection/exp.test013 b/test/dbapi/Connection/exp.test013 new file mode 100644 index 00000000..ed119798 --- /dev/null +++ b/test/dbapi/Connection/exp.test013 @@ -0,0 +1,13 @@ +Table created +10 tuples are inserted into the dababase +Updated successfully +Deleted successfully +Binded Tuple value is 0 PRABAKARAN +Binded Tuple value is 1 PRABAKARAN +Binded Tuple value is 2 PRABAKARAN +Binded Tuple value is 3 PRABAKARAN +Binded Tuple value is 4 PRABAKARAN +Binded Tuple value is 5 Kanchana +Binded Tuple value is 6 PRABAKARAN +Binded Tuple value is 7 PRABAKARAN +Binded Tuple value is 9 PRABAKARAN \ No newline at end of file diff --git a/test/dbapi/Connection/isotest1.c b/test/dbapi/Connection/isotest1.c new file mode 100644 index 00000000..bb2793e1 --- /dev/null +++ b/test/dbapi/Connection/isotest1.c @@ -0,0 +1,85 @@ +#include "common.h" +//READ_COMMITTED isolation testing +//T1 and T2 both inserting, T2 will fail saying unique key constraint + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + dbMgr->dropTable("t1"); + conn.close(); + if (*status1 != 0 || *status2 != 0) return 1; + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return 0; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + + rv = insert(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to insert\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + ::sleep(2); + rv = insert(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest10.c b/test/dbapi/Connection/isotest10.c new file mode 100644 index 00000000..e3bcc209 --- /dev/null +++ b/test/dbapi/Connection/isotest10.c @@ -0,0 +1,102 @@ +#include "common.h" +//READ_COMMITTED isolation testing +// T1 T2 +// ------------------------- +// Read +// Update +// Read +// T1 should read updated tuple by T2 +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int selectDone =0, updateDone=0, allDone=0; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread read failed \n"); *p1RetVal = 1; } + selectDone = 1; + while (updateDone != 1) {::sleep(1); } + rv = select(dbMgr, 100, true, true); + if (rv == OK) { printf("Test Failed:first thread read succeeded \n"); *p1RetVal = 1; } + allDone = 1; + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (selectDone != 1) {::sleep(1); } + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:second thread failed to update\n"); *p2RetVal = 1; } + updateDone = 1; + while (allDone !=1) ::sleep(1); + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest11.c b/test/dbapi/Connection/isotest11.c new file mode 100644 index 00000000..07b421f8 --- /dev/null +++ b/test/dbapi/Connection/isotest11.c @@ -0,0 +1,78 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +//T1 and T2 both inserting, T2 will fail saying unique key constraint + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + + rv = insert(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to insert\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + + rv = insert(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest12.c b/test/dbapi/Connection/isotest12.c new file mode 100644 index 00000000..5f621216 --- /dev/null +++ b/test/dbapi/Connection/isotest12.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +// T1 and T2 both doing select for same tuple + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to select\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest13.c b/test/dbapi/Connection/isotest13.c new file mode 100644 index 00000000..83e4b33b --- /dev/null +++ b/test/dbapi/Connection/isotest13.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_UNCOMMITTED Isolation testing +//T1 doing insert and T2 doing select for same tuple + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = insert(dbMgr, 200, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 200, false); + if (rv != OK) { printf("Test Failed:second thread could not select\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest14.c b/test/dbapi/Connection/isotest14.c new file mode 100644 index 00000000..78c4eb90 --- /dev/null +++ b/test/dbapi/Connection/isotest14.c @@ -0,0 +1,83 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +//T1 doing select and T2 doing update for same tuple +//Both should succeed + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to update\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest15.c b/test/dbapi/Connection/isotest15.c new file mode 100644 index 00000000..69f5b8d0 --- /dev/null +++ b/test/dbapi/Connection/isotest15.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +//T1 doing select and T1 doing delete for same tuple +//Both should succeed. + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to delete\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} diff --git a/test/dbapi/Connection/isotest16.c b/test/dbapi/Connection/isotest16.c new file mode 100644 index 00000000..eed76dfd --- /dev/null +++ b/test/dbapi/Connection/isotest16.c @@ -0,0 +1,83 @@ +#include "common.h" +//READ_UNCOMMITTED +//T1 doing delete and T2 doing insert for same tuple +//Insert should fail +int deleteDone=0, allDone=0; +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to delete\n"); *p1RetVal = 1; } + deleteDone = 1; + while (allDone !=1) ::sleep(1); + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (deleteDone != 1) {::sleep(1); } + p2RetVal = new int(); + *p2RetVal = 0; + rv = insert(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + allDone =1; + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest17.c b/test/dbapi/Connection/isotest17.c new file mode 100644 index 00000000..1967a95c --- /dev/null +++ b/test/dbapi/Connection/isotest17.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +//T1 doing update and T2 doing delete for same tuple +//delete should fail + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread deleted\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest18.c b/test/dbapi/Connection/isotest18.c new file mode 100644 index 00000000..d94fefb7 --- /dev/null +++ b/test/dbapi/Connection/isotest18.c @@ -0,0 +1,87 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +// T1 T2 +// ------------------------- +// Update +// Update +// Read +// T1 should read updated tuple by T1 + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + + rv = select(dbMgr, 100, true, true); + if (rv != OK) { printf("Test Failed:first thread read wrong value \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true, "RITHISH"); + if (rv == OK) { printf("Test Failed:second thread updated\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest19.c b/test/dbapi/Connection/isotest19.c new file mode 100644 index 00000000..471a4c03 --- /dev/null +++ b/test/dbapi/Connection/isotest19.c @@ -0,0 +1,86 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +// T1 T2 +// ------------------------- +// Read +// Delete +// Read +// T1 second read should fail saying "tuple not found" +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + rv = select(dbMgr, 100, true); + if (rv == OK) { printf("Test Failed:first thread read succeeded \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:second thread failed to delete\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest2.c b/test/dbapi/Connection/isotest2.c new file mode 100644 index 00000000..eb97edcb --- /dev/null +++ b/test/dbapi/Connection/isotest2.c @@ -0,0 +1,89 @@ +#include "common.h" +//READ_COMMITTED isolation testing +// T1 and T2 both doing select for same tuple + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to select\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest20.c b/test/dbapi/Connection/isotest20.c new file mode 100644 index 00000000..c253076d --- /dev/null +++ b/test/dbapi/Connection/isotest20.c @@ -0,0 +1,92 @@ +#include "common.h" +//READ_UNCOMMITTED isolation testing +// T1 T2 +// ------------------------- +// Read +// Update +// Read +// T1 should read updated tuple by T2 +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int selectDone=0, updateDone=0, allDone=0; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread read failed \n"); *p1RetVal = 1; } + selectDone=1; + while (updateDone != 1) {::sleep(1); } + rv = select(dbMgr, 100, true, true); + if (rv == OK) { printf("Test passed:first thread read succeeded \n"); *p1RetVal = 0; } + allDone =1; + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_UNCOMMITTED); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (selectDone != 1) {::sleep(1); } + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:second thread failed to update\n"); *p2RetVal = 1; } + updateDone = 1; + while (allDone !=1) ::sleep(1); + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest21.c b/test/dbapi/Connection/isotest21.c new file mode 100644 index 00000000..9833d038 --- /dev/null +++ b/test/dbapi/Connection/isotest21.c @@ -0,0 +1,78 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +//T1 and T2 both inserting, T2 will fail saying unique key constraint + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + + rv = insert(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to insert\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + + rv = insert(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + + conn.commit(); + rv = conn.close(); + printf("conn closed %d for Thread and pid is %d %lu\n", rv, os::getpid(), os::getthrid()); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest22.c b/test/dbapi/Connection/isotest22.c new file mode 100644 index 00000000..297e93f7 --- /dev/null +++ b/test/dbapi/Connection/isotest22.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +// T1 and T2 both doing select for same tuple + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to select\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest23.c b/test/dbapi/Connection/isotest23.c new file mode 100644 index 00000000..b9f20906 --- /dev/null +++ b/test/dbapi/Connection/isotest23.c @@ -0,0 +1,83 @@ +#include "common.h" +//READ_REPEATABLE Isolation testing +//T1 doing insert and T2 doing select for same tuple +int insertDone =0,selectDone=0; +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = insert(dbMgr, 200, true); + if (rv != OK) { printf("Test Failed:first thread failed to insert\n"); *p1RetVal = 1; } + insertDone =1; + while(selectDone !=1) ::sleep(1); + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (insertDone != 1) ::sleep(1); + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 200, false); + if (rv != OK) { printf("Test Passed:second thread could not select\n"); *p2RetVal = 0; } + if (rv == OK) { printf("Test Failed:second thread could select\n"); *p2RetVal = 1; } + selectDone = 1; + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest24.c b/test/dbapi/Connection/isotest24.c new file mode 100644 index 00000000..0f4b5d48 --- /dev/null +++ b/test/dbapi/Connection/isotest24.c @@ -0,0 +1,81 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +//T1 doing select and T2 doing update for same tuple +//Both should succeed + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread updated\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest25.c b/test/dbapi/Connection/isotest25.c new file mode 100644 index 00000000..b457de09 --- /dev/null +++ b/test/dbapi/Connection/isotest25.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +//T1 doing select and T1 doing delete for same tuple +//Both should succeed. + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread deleted\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} diff --git a/test/dbapi/Connection/isotest26.c b/test/dbapi/Connection/isotest26.c new file mode 100644 index 00000000..f780c5f3 --- /dev/null +++ b/test/dbapi/Connection/isotest26.c @@ -0,0 +1,84 @@ +#include "common.h" +//READ_REPEATABLE +//T1 doing delete and T2 doing insert for same tuple +//Insert should fail +int deleteDone=0, insertDone=0; +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to delete\n"); *p1RetVal = 1; } + deleteDone =1; + while(insertDone !=1) ::sleep(1); + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while(deleteDone !=1) ::sleep(1); + p2RetVal = new int(); + *p2RetVal = 0; + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Test Passed:second thread did not insert\n"); *p2RetVal = 0; } + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + insertDone = 1; + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest27.c b/test/dbapi/Connection/isotest27.c new file mode 100644 index 00000000..d11511c7 --- /dev/null +++ b/test/dbapi/Connection/isotest27.c @@ -0,0 +1,80 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +//T1 doing update and T2 doing delete for same tuple +//delete should fail + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread deleted\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest28.c b/test/dbapi/Connection/isotest28.c new file mode 100644 index 00000000..167369e4 --- /dev/null +++ b/test/dbapi/Connection/isotest28.c @@ -0,0 +1,87 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +// T1 T2 +// ------------------------- +// Update +// Update +// Read +// T1 should read updated tuple by T1 + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + + rv = select(dbMgr, 100, true, true); + if (rv != OK) { printf("Test Failed:first thread read wrong value \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true, "RITHISH"); + if (rv == OK) { printf("Test Failed:second thread updated\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest29.c b/test/dbapi/Connection/isotest29.c new file mode 100644 index 00000000..c2b7a7c8 --- /dev/null +++ b/test/dbapi/Connection/isotest29.c @@ -0,0 +1,89 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +// T1 T2 +// ------------------------- +// Read +// Delete +// Read +// T1 second read should fail saying "tuple not found" +int selectDone=0, deleteDone=0; +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + selectDone = 1; + while (deleteDone !=1) ::sleep(1); + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread read failed \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (selectDone !=1) ::sleep(1); + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Passed: second thread did not delete\n"); *p2RetVal = 0; } + if (rv == OK) { printf("Test Failed:second thread deleted\n"); *p2RetVal = 1; } + conn.commit(); + deleteDone =1; + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest3.c b/test/dbapi/Connection/isotest3.c new file mode 100644 index 00000000..8a845180 --- /dev/null +++ b/test/dbapi/Connection/isotest3.c @@ -0,0 +1,89 @@ +#include "common.h" +//READ_COMMITTED Isolation testing +//T1 doing insert and T2 doing select for same tuple + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = insert(dbMgr, 200, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = select(dbMgr, 200, false); + if (rv == OK) { printf("Test Failed:second thread could select\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest30.c b/test/dbapi/Connection/isotest30.c new file mode 100644 index 00000000..932826e2 --- /dev/null +++ b/test/dbapi/Connection/isotest30.c @@ -0,0 +1,92 @@ +#include "common.h" +//READ_REPEATABLE isolation testing +// T1 T2 +// ------------------------- +// Read +// Update +// Read +// T1 should fail to get read lock +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int selectDone =0, updateDone=0, select2Done=0; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread first read failed \n"); *p1RetVal = 1; } + selectDone = 1; + while (updateDone !=1) ::sleep(1); + rv = select(dbMgr, 100, true, false); + if (rv != OK) { printf("Test Failed:first thread second read failed %d \n", rv); *p1RetVal = 1; } + select2Done=1; + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + rv = conn.startTransaction(READ_REPEATABLE); + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (selectDone !=1) ::sleep(1); + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Passed:second thread did not update\n"); *p2RetVal = 0; } + if (rv == OK) { printf("Test Failed:second thread updated\n"); *p2RetVal = 1; } + updateDone = 1; + while(select2Done !=1) ::sleep(1); + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest4.c b/test/dbapi/Connection/isotest4.c new file mode 100644 index 00000000..fdb1d1ea --- /dev/null +++ b/test/dbapi/Connection/isotest4.c @@ -0,0 +1,91 @@ +#include "common.h" +//READ_COMMITTED isolation testing +//T1 doing select and T2 doing update for same tuple +//Both should succeed + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to update\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest5.c b/test/dbapi/Connection/isotest5.c new file mode 100644 index 00000000..fedaa5f0 --- /dev/null +++ b/test/dbapi/Connection/isotest5.c @@ -0,0 +1,91 @@ +#include "common.h" +//READ_COMMITTED isolation testing +//T1 doing select and T1 doing delete for same tuple +//Both should succeed. + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv != OK) { printf("Test Failed:second thread failed to delete\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest6.c b/test/dbapi/Connection/isotest6.c new file mode 100644 index 00000000..a277f983 --- /dev/null +++ b/test/dbapi/Connection/isotest6.c @@ -0,0 +1,91 @@ +#include "common.h" +//READ_COMMITTED +//T1 doing delete and T2 doing insert for same tuple +//Insert should fail + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to delete\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = insert(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread inserted\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest7.c b/test/dbapi/Connection/isotest7.c new file mode 100644 index 00000000..e518cd1c --- /dev/null +++ b/test/dbapi/Connection/isotest7.c @@ -0,0 +1,91 @@ +#include "common.h" +//READ_COMMITTED isolation testing +//T1 doing update and T2 doing delete for same tuple +//delete should fail + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, false); + if (rv == OK) { printf("Test Failed:second thread deleted\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest8.c b/test/dbapi/Connection/isotest8.c new file mode 100644 index 00000000..0bef9eff --- /dev/null +++ b/test/dbapi/Connection/isotest8.c @@ -0,0 +1,96 @@ +#include "common.h" +//READ_COMMITTED isolation testing +// T1 T2 +// ------------------------- +// Update +// Update +// Read +// T1 should read updated tuple by T1 + +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = update(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to update\n"); *p1RetVal = 1; } + + rv = select(dbMgr, 100, true, true); + if (rv != OK) { printf("Test Failed:first thread read wrong value \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + + p2RetVal = new int(); + *p2RetVal = 0; + rv = update(dbMgr, 100, true, "RITHISH"); + if (rv == OK) { printf("Test Failed:second thread updated\n"); *p2RetVal = 1; } + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/isotest9.c b/test/dbapi/Connection/isotest9.c new file mode 100644 index 00000000..5333ad29 --- /dev/null +++ b/test/dbapi/Connection/isotest9.c @@ -0,0 +1,100 @@ +#include "common.h" +//READ_COMMITTED isolation testing +// T1 T2 +// ------------------------- +// Read +// Delete +// Read +// T1 second read should fail saying "tuple not found" +void* runTest1(void *p); +void* runTest2(void *p); +int *p1RetVal = NULL; +int *p2RetVal = NULL; +int selectDone = 0, deleteDone =0; +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return 1; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + int ret = createTable(dbMgr); + if (ret != 0) { return 1; } + + rv = conn.startTransaction(); + if (rv != OK) {printf ("Unable to start trans\n"); return 1; } + rv = insert(dbMgr, 100, false); + if (rv != OK) { printf("Unable to insert\n"); return 2; } + conn.commit(); + printf("Tuple inserted\n"); + + pthread_t thr[2]; + int *status1, *status2; + pthread_create (&thr[0], NULL, &runTest1, NULL); + pthread_create (&thr[1], NULL, &runTest2, NULL); + printf("All threads started\n"); + + pthread_join(thr[0], (void**)&status1); + pthread_join(thr[1], (void**)&status2); + ret = 0; + if (*status1 != 0 || *status2 != 0) ret = 1; + dbMgr->dropTable("t1"); + conn.close(); + if (p1RetVal) { delete p1RetVal; p1RetVal = NULL; } + if (p2RetVal) { delete p2RetVal; p2RetVal = NULL; } + return ret; +} +void* runTest1(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + p1RetVal = new int(); + *p1RetVal = 0; + rv = select(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:first thread failed to select\n"); *p1RetVal = 1; } + selectDone = 1; + while (deleteDone != 1) {::sleep(1); } + rv = select(dbMgr, 100, true); + if (rv == OK) { printf("Test Failed:first thread read succeeded \n"); *p1RetVal = 1; } + conn.commit(); + rv = conn.close(); + pthread_exit(p1RetVal); +} +void* runTest2(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) { printf("Error during connection %d\n", rv); return NULL; } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} +#ifndef DEFAULT + rv = conn.startTransaction(READ_COMMITTED); +#else + rv = conn.startTransaction(); +#endif + + if (rv != OK) return NULL; + printf("Thread and pid is %d %lu\n", os::getpid(), os::getthrid()); + while (selectDone != 1) {::sleep(1); } + + p2RetVal = new int(); + *p2RetVal = 0; + rv = remove(dbMgr, 100, true); + if (rv != OK) { printf("Test Failed:second thread failed to delete\n"); *p2RetVal = 1; } + deleteDone =1; + conn.commit(); + conn.close(); + pthread_exit(p2RetVal); +} + diff --git a/test/dbapi/Connection/test002.ksh b/test/dbapi/Connection/test002.ksh new file mode 100755 index 00000000..1f551939 --- /dev/null +++ b/test/dbapi/Connection/test002.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +# TestCase: + +CSQL_CONFIG_FILE= + + + +#Run this test only under csql/test or on this directory. +#Otherwise, it may fail +executable=${PWD}/dbapi/Connection/serverOff +REL_PATH=. +if [ -s "$executable" ] +then + REL_PATH=${PWD}/dbapi/Connection +fi + +${REL_PATH}/serverOff + +if [ $? -ne 0 ] +then + exit 1; +fi + +exit 0 diff --git a/test/dbapi/Connection/threadtest1.c b/test/dbapi/Connection/threadtest1.c new file mode 100644 index 00000000..55f081b7 --- /dev/null +++ b/test/dbapi/Connection/threadtest1.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +void* print_message_function (void *ptr); +int flag=0; +int main (int argc, char **argv) +{ + Connection conn; + DbRetVal rv = conn.open("root","manager"); + if (rv != 0) return 1; + pthread_t thread1, thread2; + char *message1 = "Thread 1"; + char *message2 = "Thread 2"; + long status1, status2; + pthread_create (&thread1, NULL, + &print_message_function, (void *) message1); + pthread_create (&thread2, NULL, + &print_message_function, (void *) message2); + + pthread_join(thread1, (void **)&status1); + pthread_join(thread2, (void **)&status2); + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed \n"); conn.close(); return NULL; } + rv = dbMgr->dropTable("t1"); + if ( rv != OK ) return 2; + rv = conn.close(); + if (rv != 0) return 3; + + if( 1 == (status1 + status2) ) return 0; + else return -1; +} + + +void* print_message_function(void *ptr) +{ + //if (flag == 0) {flag =1; sleep(2); } + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv!=OK) + { + printf("Thread Return value of open %d %d\n", rv, getpid()); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); conn.close(); return NULL;} + + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeInt); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return (void*) 1; } + printf("Table created %d %lu\n", os::getpid(), os::getthrid()); + + rv = conn.close(); + if (rv != OK) { printf("Thread Return value of close %d %d\n", rv, getpid()); } + return NULL; +} diff --git a/test/dbapi/Connection/threadtest2.c b/test/dbapi/Connection/threadtest2.c new file mode 100644 index 00000000..6bf69b4b --- /dev/null +++ b/test/dbapi/Connection/threadtest2.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +void* print_message_function (void *ptr); +int flag=0; +int main (int argc, char **argv) +{ + Connection conn; + DbRetVal rv = conn.open("root","manager"); + printf ("Main open Returned %d\n", rv); + pthread_t thread1, thread2; + int message1 =1; + int message2 =2; + int status; + + pthread_create (&thread1, NULL, + &print_message_function, (void *) &message1); + pthread_create (&thread2, NULL, + &print_message_function, (void *) &message2); + + pthread_join(thread1, (void **)&status); + pthread_join(thread2, (void **)&status); + + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + dbMgr->dropTable("T1"); + dbMgr->dropTable("T2"); + + rv = conn.close(); + printf ("Main Returned %d\n", rv); + exit (0); +} + + +void* print_message_function(void *ptr) +{ + //if (flag == 0) {flag =1; sleep(2); } + char tblname[20]; + sprintf(tblname, "T%d", *(int*)ptr ); + Connection conn; + DbRetVal rv=conn.open("root","manager"); + printf("Thread Return value of open %d %d\n", rv, getpid()); + if(rv!=OK) + { + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + + + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeInt); + rv = dbMgr->createTable(tblname, tabDef); + if (rv != OK) { printf("Table creation failed\n"); return NULL; } + printf("Table created\n"); + + rv = conn.close(); + printf("Thread Return value of close %d %d\n", rv, getpid()); +} diff --git a/test/dbapi/DataType/Makefile b/test/dbapi/DataType/Makefile new file mode 100644 index 00000000..cc017b47 --- /dev/null +++ b/test/dbapi/DataType/Makefile @@ -0,0 +1,111 @@ + +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 test002 test003 test004 test005 test006 test007 \ + test008 test009 test010 test011 test012 test013 test014 \ + test015 test016 test017 test018 test019 test020 test021 \ + test022 test002a test004a test006a test008a test010a \ + test012a test014a test016a test018a test020a test022a + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + + +test001: inttest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002: inttest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002a: inttest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003: longtest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004: longtest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004a: longtest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005: longlongtest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006: longlongtest.c + $(CPlus) $(CPlusFlags) -DWITHINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006a: longlongtest.c + $(CPlus) $(CPlusFlags) -DWITHTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007: shorttest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008: shorttest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008a: shorttest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009: byteinttest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010: byteinttest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010a: byteinttest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test011: floattest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012: floattest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012a: floattest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test013: doubletest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test014: doubletest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test014a: doubletest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test015: chartest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test016: chartest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test016a: chartest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test017: datetest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test018: datetest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test018a: datetest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test019: timetest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test020: timetest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test020a: timetest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test021: timestamptest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test022: timestamptest.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test022a: timestamptest.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/DataType/byteinttest.c b/test/dbapi/DataType/byteinttest.c new file mode 100644 index 00000000..da64404d --- /dev/null +++ b/test/dbapi/DataType/byteinttest.c @@ -0,0 +1,108 @@ +#include + +ByteInt id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + ByteInt val1 = 3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ( table->fetch() ) { + printf("tuple value is %d %s \n", (int)id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeByteInt, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + ByteInt i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/chartest.c b/test/dbapi/DataType/chartest.c new file mode 100644 index 00000000..44f41992 --- /dev/null +++ b/test/dbapi/DataType/chartest.c @@ -0,0 +1,110 @@ +#include + +char id[30]; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + char val1[30] = "Value3"; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %s %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeString, 30, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + // id= i; + sprintf(id, "Value%d",i); + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/datetest.c b/test/dbapi/DataType/datetest.c new file mode 100644 index 00000000..41f99e67 --- /dev/null +++ b/test/dbapi/DataType/datetest.c @@ -0,0 +1,114 @@ +#include + +Date id; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + Date val1(1981, 12, 22); + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is "); + AllDataType::printVal(&id, typeDate,0); + printf(" %s \n", name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeDate, 0 ,NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + delete idxInfo; + printf("Index created\n"); +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + delete idxInfo; + printf("Index created\n"); +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + long i; + rv =conn.startTransaction(); + for(i = 8; i< 13; i++) + { + if (rv != OK) exit(5); + for (int j =20 ; j <25; j++) { + id.set(1981, i, j); + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/doubletest.c b/test/dbapi/DataType/doubletest.c new file mode 100644 index 00000000..78082f9a --- /dev/null +++ b/test/dbapi/DataType/doubletest.c @@ -0,0 +1,109 @@ +#include + +double id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + double val1 = 1.3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %g %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeDouble, 0 , NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) { printf("Index creation passed\n"); return 1; } + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return 0; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + delete idxInfo; +#endif + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + double i; + rv =conn.startTransaction(); + for(i = 1.0; i< 1.5; i = i + 0.1) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + printf("Tuple inserted %g\n", i); + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/exp.test001 b/test/dbapi/DataType/exp.test001 new file mode 100644 index 00000000..507a836d --- /dev/null +++ b/test/dbapi/DataType/exp.test001 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test002 b/test/dbapi/DataType/exp.test002 new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test002 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test002a b/test/dbapi/DataType/exp.test002a new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test002a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test003 b/test/dbapi/DataType/exp.test003 new file mode 100644 index 00000000..507a836d --- /dev/null +++ b/test/dbapi/DataType/exp.test003 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test004 b/test/dbapi/DataType/exp.test004 new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test004 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test004a b/test/dbapi/DataType/exp.test004a new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test004a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test005 b/test/dbapi/DataType/exp.test005 new file mode 100644 index 00000000..507a836d --- /dev/null +++ b/test/dbapi/DataType/exp.test005 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test006 b/test/dbapi/DataType/exp.test006 new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test006 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test006a b/test/dbapi/DataType/exp.test006a new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test006a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test007 b/test/dbapi/DataType/exp.test007 new file mode 100644 index 00000000..507a836d --- /dev/null +++ b/test/dbapi/DataType/exp.test007 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test008 b/test/dbapi/DataType/exp.test008 new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test008 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test008a b/test/dbapi/DataType/exp.test008a new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test008a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test009 b/test/dbapi/DataType/exp.test009 new file mode 100644 index 00000000..507a836d --- /dev/null +++ b/test/dbapi/DataType/exp.test009 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test010 b/test/dbapi/DataType/exp.test010 new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test010 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test010a b/test/dbapi/DataType/exp.test010a new file mode 100644 index 00000000..4fd575dd --- /dev/null +++ b/test/dbapi/DataType/exp.test010a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test011 b/test/dbapi/DataType/exp.test011 new file mode 100644 index 00000000..6f65f4a3 --- /dev/null +++ b/test/dbapi/DataType/exp.test011 @@ -0,0 +1,27 @@ +Table created +Tuple inserted 1.000000 +Tuple inserted 1.100000 +Tuple inserted 1.200000 +Tuple inserted 1.300000 +Tuple inserted 1.400000 +Operator test for 0 +Operator test for 1 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +tuple value is 1.300000 PRABAKARAN0123456750590 +tuple value is 1.400000 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1.300000 PRABAKARAN0123456750590 +tuple value is 1.400000 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1.300000 PRABAKARAN0123456750590 +tuple value is 1.400000 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test012a b/test/dbapi/DataType/exp.test012a new file mode 100644 index 00000000..86f0a5d3 --- /dev/null +++ b/test/dbapi/DataType/exp.test012a @@ -0,0 +1,26 @@ +Table created +Tuple inserted 1.000000 +Tuple inserted 1.100000 +Tuple inserted 1.200000 +Tuple inserted 1.300000 +Tuple inserted 1.400000 +Operator test for 0 +Operator test for 1 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +tuple value is 1.300000 PRABAKARAN0123456750590 +tuple value is 1.400000 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1.000000 PRABAKARAN0123456750590 +tuple value is 1.100000 PRABAKARAN0123456750590 +tuple value is 1.200000 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1.400000 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1.300000 PRABAKARAN0123456750590 +tuple value is 1.400000 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test013 b/test/dbapi/DataType/exp.test013 new file mode 100644 index 00000000..49096a43 --- /dev/null +++ b/test/dbapi/DataType/exp.test013 @@ -0,0 +1,27 @@ +Table created +Tuple inserted 1 +Tuple inserted 1.1 +Tuple inserted 1.2 +Tuple inserted 1.3 +Tuple inserted 1.4 +Operator test for 0 +Operator test for 1 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +tuple value is 1.3 PRABAKARAN0123456750590 +tuple value is 1.4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1.3 PRABAKARAN0123456750590 +tuple value is 1.4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1.3 PRABAKARAN0123456750590 +tuple value is 1.4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test014a b/test/dbapi/DataType/exp.test014a new file mode 100644 index 00000000..c703add8 --- /dev/null +++ b/test/dbapi/DataType/exp.test014a @@ -0,0 +1,26 @@ +Table created +Tuple inserted 1 +Tuple inserted 1.1 +Tuple inserted 1.2 +Tuple inserted 1.3 +Tuple inserted 1.4 +Operator test for 0 +Operator test for 1 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +tuple value is 1.3 PRABAKARAN0123456750590 +tuple value is 1.4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 1.1 PRABAKARAN0123456750590 +tuple value is 1.2 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1.4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1.3 PRABAKARAN0123456750590 +tuple value is 1.4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test015 b/test/dbapi/DataType/exp.test015 new file mode 100644 index 00000000..453648fd --- /dev/null +++ b/test/dbapi/DataType/exp.test015 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is Value3 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test016 b/test/dbapi/DataType/exp.test016 new file mode 100644 index 00000000..d38c4cc7 --- /dev/null +++ b/test/dbapi/DataType/exp.test016 @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is Value3 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test016a b/test/dbapi/DataType/exp.test016a new file mode 100644 index 00000000..d38c4cc7 --- /dev/null +++ b/test/dbapi/DataType/exp.test016a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is Value0 PRABAKARAN0123456750590 +tuple value is Value1 PRABAKARAN0123456750590 +tuple value is Value2 PRABAKARAN0123456750590 +tuple value is Value3 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is Value4 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is Value3 PRABAKARAN0123456750590 +tuple value is Value4 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test017 b/test/dbapi/DataType/exp.test017 new file mode 100644 index 00000000..ac6c33f3 --- /dev/null +++ b/test/dbapi/DataType/exp.test017 @@ -0,0 +1,82 @@ +Table created +Operator test for 0 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test018 b/test/dbapi/DataType/exp.test018 new file mode 100644 index 00000000..19206a82 --- /dev/null +++ b/test/dbapi/DataType/exp.test018 @@ -0,0 +1,83 @@ +Table created +Index created +Operator test for 0 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test018a b/test/dbapi/DataType/exp.test018a new file mode 100644 index 00000000..19206a82 --- /dev/null +++ b/test/dbapi/DataType/exp.test018a @@ -0,0 +1,83 @@ +Table created +Index created +Operator test for 0 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1981/8/20 PRABAKARAN0123456750590 +tuple value is 1981/8/21 PRABAKARAN0123456750590 +tuple value is 1981/8/22 PRABAKARAN0123456750590 +tuple value is 1981/8/23 PRABAKARAN0123456750590 +tuple value is 1981/8/24 PRABAKARAN0123456750590 +tuple value is 1981/9/20 PRABAKARAN0123456750590 +tuple value is 1981/9/21 PRABAKARAN0123456750590 +tuple value is 1981/9/22 PRABAKARAN0123456750590 +tuple value is 1981/9/23 PRABAKARAN0123456750590 +tuple value is 1981/9/24 PRABAKARAN0123456750590 +tuple value is 1981/10/20 PRABAKARAN0123456750590 +tuple value is 1981/10/21 PRABAKARAN0123456750590 +tuple value is 1981/10/22 PRABAKARAN0123456750590 +tuple value is 1981/10/23 PRABAKARAN0123456750590 +tuple value is 1981/10/24 PRABAKARAN0123456750590 +tuple value is 1981/11/20 PRABAKARAN0123456750590 +tuple value is 1981/11/21 PRABAKARAN0123456750590 +tuple value is 1981/11/22 PRABAKARAN0123456750590 +tuple value is 1981/11/23 PRABAKARAN0123456750590 +tuple value is 1981/11/24 PRABAKARAN0123456750590 +tuple value is 1981/12/20 PRABAKARAN0123456750590 +tuple value is 1981/12/21 PRABAKARAN0123456750590 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1981/12/22 PRABAKARAN0123456750590 +tuple value is 1981/12/23 PRABAKARAN0123456750590 +tuple value is 1981/12/24 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test019 b/test/dbapi/DataType/exp.test019 new file mode 100644 index 00000000..5fb7e1c1 --- /dev/null +++ b/test/dbapi/DataType/exp.test019 @@ -0,0 +1,82 @@ +Table created +Operator test for 0 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test020 b/test/dbapi/DataType/exp.test020 new file mode 100644 index 00000000..6746f6ae --- /dev/null +++ b/test/dbapi/DataType/exp.test020 @@ -0,0 +1,83 @@ +Table created +Index created +Operator test for 0 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test020a b/test/dbapi/DataType/exp.test020a new file mode 100644 index 00000000..6746f6ae --- /dev/null +++ b/test/dbapi/DataType/exp.test020a @@ -0,0 +1,83 @@ +Table created +Index created +Operator test for 0 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 10:29:30.0 PRABAKARAN0123456750590 +tuple value is 10:30:30.0 PRABAKARAN0123456750590 +tuple value is 10:31:30.0 PRABAKARAN0123456750590 +tuple value is 10:32:30.0 PRABAKARAN0123456750590 +tuple value is 10:33:30.0 PRABAKARAN0123456750590 +tuple value is 11:29:30.0 PRABAKARAN0123456750590 +tuple value is 11:30:30.0 PRABAKARAN0123456750590 +tuple value is 11:31:30.0 PRABAKARAN0123456750590 +tuple value is 11:32:30.0 PRABAKARAN0123456750590 +tuple value is 11:33:30.0 PRABAKARAN0123456750590 +tuple value is 12:29:30.0 PRABAKARAN0123456750590 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 12:30:30.0 PRABAKARAN0123456750590 +tuple value is 12:31:30.0 PRABAKARAN0123456750590 +tuple value is 12:32:30.0 PRABAKARAN0123456750590 +tuple value is 12:33:30.0 PRABAKARAN0123456750590 +tuple value is 13:29:30.0 PRABAKARAN0123456750590 +tuple value is 13:30:30.0 PRABAKARAN0123456750590 +tuple value is 13:31:30.0 PRABAKARAN0123456750590 +tuple value is 13:32:30.0 PRABAKARAN0123456750590 +tuple value is 13:33:30.0 PRABAKARAN0123456750590 +tuple value is 14:29:30.0 PRABAKARAN0123456750590 +tuple value is 14:30:30.0 PRABAKARAN0123456750590 +tuple value is 14:31:30.0 PRABAKARAN0123456750590 +tuple value is 14:32:30.0 PRABAKARAN0123456750590 +tuple value is 14:33:30.0 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test021 b/test/dbapi/DataType/exp.test021 new file mode 100644 index 00000000..be7a2758 --- /dev/null +++ b/test/dbapi/DataType/exp.test021 @@ -0,0 +1,43 @@ +Table created +Inserted 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +Inserted 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +Inserted 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Inserted 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +Inserted 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +Inserted 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +Inserted 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +Inserted 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +Inserted 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 0 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/exp.test022a b/test/dbapi/DataType/exp.test022a new file mode 100644 index 00000000..be7a2758 --- /dev/null +++ b/test/dbapi/DataType/exp.test022a @@ -0,0 +1,43 @@ +Table created +Inserted 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +Inserted 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +Inserted 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Inserted 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +Inserted 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +Inserted 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +Inserted 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +Inserted 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +Inserted 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 0 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 1981/12/22 12:30:28.0 PRABAKARAN0123456750590 +tuple value is 1981/12/23 12:30:29.0 PRABAKARAN0123456750590 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 1981/12/24 12:30:30.0 PRABAKARAN0123456750590 +tuple value is 1981/12/25 12:30:31.0 PRABAKARAN0123456750590 +tuple value is 1981/12/26 12:30:32.0 PRABAKARAN0123456750590 +tuple value is 1981/12/27 12:30:33.0 PRABAKARAN0123456750590 +tuple value is 1981/12/28 12:30:34.0 PRABAKARAN0123456750590 +tuple value is 1981/12/29 12:30:35.0 PRABAKARAN0123456750590 +tuple value is 1981/12/30 12:30:36.0 PRABAKARAN0123456750590 diff --git a/test/dbapi/DataType/floattest.c b/test/dbapi/DataType/floattest.c new file mode 100644 index 00000000..6cfe1732 --- /dev/null +++ b/test/dbapi/DataType/floattest.c @@ -0,0 +1,112 @@ +#include + +float id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + float val1, i = 1.3; + val1=i; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %f %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeFloat, 0 , NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) { printf("Index creation passed\n"); return 1; } + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return 0; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + float i; + rv =conn.startTransaction(); + for(i = 1.0; i< 1.5; i = i + 0.1) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + printf("Tuple inserted %f\n", i); + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/inttest.c b/test/dbapi/DataType/inttest.c new file mode 100644 index 00000000..b036468b --- /dev/null +++ b/test/dbapi/DataType/inttest.c @@ -0,0 +1,108 @@ +#include + +int id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + int val1 = 3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %d %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/longlongtest.c b/test/dbapi/DataType/longlongtest.c new file mode 100644 index 00000000..75ec5962 --- /dev/null +++ b/test/dbapi/DataType/longlongtest.c @@ -0,0 +1,109 @@ +#include + +long long id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + long long val1 = 3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %lld %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeLongLong, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + long long i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/longtest.c b/test/dbapi/DataType/longtest.c new file mode 100644 index 00000000..b0819809 --- /dev/null +++ b/test/dbapi/DataType/longtest.c @@ -0,0 +1,109 @@ +#include + +long id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + long val1 = 3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %ld %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeLong, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + long i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/shorttest.c b/test/dbapi/DataType/shorttest.c new file mode 100644 index 00000000..f3a4a125 --- /dev/null +++ b/test/dbapi/DataType/shorttest.c @@ -0,0 +1,110 @@ +#include + +short id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + short val1 = 3; + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %hd %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeShort, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + short i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/timestamptest.c b/test/dbapi/DataType/timestamptest.c new file mode 100644 index 00000000..5e484c36 --- /dev/null +++ b/test/dbapi/DataType/timestamptest.c @@ -0,0 +1,114 @@ +#include + +TimeStamp id; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + TimeStamp val1(1981, 12, 24, 12, 30, 30); + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is "); + AllDataType::printVal(&id, typeTimeStamp,0); + printf(" %s \n", name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeTimeStamp, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) { printf("Index creation passed\n"); return 1; } + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return 0; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + delete idxInfo; +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + rv =conn.startTransaction(); + if (rv != OK) exit(5); + for(i = 1; i< 10; i++) { + id.setDate(1981, 12, 21+i ); + id.setTime(12, 30, 27 +i); + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + printf("Inserted "); + AllDataType::printVal(&id, typeTimeStamp,0); + printf(" %s \n", name); + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DataType/timetest.c b/test/dbapi/DataType/timetest.c new file mode 100644 index 00000000..cc47404a --- /dev/null +++ b/test/dbapi/DataType/timetest.c @@ -0,0 +1,114 @@ +#include + +Time id; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + Time val1(12, 30, 30); + p1.setTerm("f1", op, &val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is "); + AllDataType::printVal(&id, typeTime,0); + printf(" %s \n", name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeTime, 0, NULL, true); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + delete idxInfo; + printf("Index created\n"); +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + delete idxInfo; + printf("Index created\n"); +#endif + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + long i; + rv =conn.startTransaction(); + for(i = 10; i< 15; i++) + { + if (rv != OK) exit(5); + for (int j =29 ; j <34; j++) { + id.set(i, j, 30); + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/DatabaseManager/Makefile b/test/dbapi/DatabaseManager/Makefile new file mode 100644 index 00000000..e53d7d5a --- /dev/null +++ b/test/dbapi/DatabaseManager/Makefile @@ -0,0 +1,41 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: getdbmanagertest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/DatabaseManager/getdbmanagertest.c b/test/dbapi/DatabaseManager/getdbmanagertest.c new file mode 100644 index 00000000..f412ecb3 --- /dev/null +++ b/test/dbapi/DatabaseManager/getdbmanagertest.c @@ -0,0 +1,10 @@ +#include +int main() +{ + Connection conn; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr != NULL) { printf("Database found without opening Connection\n"); printf("Test failed\n");return 1;} + printf("Test passed\n"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Index/Makefile b/test/dbapi/Index/Makefile new file mode 100644 index 00000000..bd9def3b --- /dev/null +++ b/test/dbapi/Index/Makefile @@ -0,0 +1,110 @@ + +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 \ + test002 \ + test004 \ + test005 \ + test006 test006a \ + test007 test007a \ + test008 test008a \ + test009 test009a \ + test010 test010a \ + test011 test003 \ + test012 test012a test013 \ + test001a test002a test003a \ + test004a test004b test004c \ + test005a test005b test005c + + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + + +test001: uniqueindex1.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test001a: uniqueindex1.c common.h + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002: uniqueindex2.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002a: uniqueindex2.c common.h + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003: uniqueindex3.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003a: uniqueindex3.c common.h + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004: twoindex1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004a: twoindex1.c + $(CPlus) $(CPlusFlags) -DF1TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004b: twoindex1.c + $(CPlus) $(CPlusFlags) -DF2TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004c: twoindex1.c + $(CPlus) $(CPlusFlags) -DF1TREE -DF2TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005: twoindex2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005a: twoindex2.c + $(CPlus) $(CPlusFlags) -DF1TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005b: twoindex2.c + $(CPlus) $(CPlusFlags) -DF2TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005c: twoindex2.c + $(CPlus) $(CPlusFlags) -DF1TREE -DF2TREE -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006: dupindex1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006a: dupindex1.c + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007: dupindex2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007a: dupindex2.c + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008: compositekeyindex1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008a: compositekeyindex1.c + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009: createindexnotexist.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009a: createindexnotexist.c + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010: createindexnofld.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010a: createindexnofld.c + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test011: primarynonunique.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012: index1.c common.h + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012a: index1.c common.h + $(CPlus) $(CPlusFlags) -DTREEINDEX -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test013:multiplecompositeindex1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/Index/common.h b/test/dbapi/Index/common.h new file mode 100644 index 00000000..3e203682 --- /dev/null +++ b/test/dbapi/Index/common.h @@ -0,0 +1,134 @@ +#include +int createIndex(DatabaseManager *dbMgr, bool unique) +{ + //Creating hash index on field f1 of table t1 + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#else + idxInfo->indType = hashIndex; +#endif +#ifndef DEFAULT + idxInfo->isUnique = unique; +#endif + DbRetVal rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return 1; } + printf("Index created\n"); + delete idxInfo; + return 0; +} +int createTable(DatabaseManager *dbMgr) +{ + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 20); + DbRetVal rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 1; } + printf("Table created\n"); + return 0; +} +int insertTupleWithSameValue(DatabaseManager *dbMgr, Connection &conn) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + DbRetVal rv = OK; + for (int i = 0 ; i < 10 ; i++) + { + conn.startTransaction(); + id1= 10; + rv = table->insertTuple(); + if (rv != OK) break; + icount++; + conn.commit(); + + } + printf("Total Tuples inserted is %d\n", icount); + dbMgr->closeTable(table); + return icount; +} + + +int insertTuplef2NUL(DatabaseManager *dbMgr, Connection &conn) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + int id1 = 0, id2; + int count=0; + table->bindFld("f1", &id1); + //table->bindFld("f2", &id2); + DbRetVal rv = OK; + for( int i=10;i<=20;i=i+10) + { + conn.startTransaction(); + id1= i; + rv = table->insertTuple(); + if (rv != OK) { printf("Insertion failed "); break; } + count++; + conn.commit(); + } + printf("Tuple inserted is %d \n",count); + dbMgr->closeTable(table); + return 0; +} + +int creatTable(DatabaseManager *dbMgr) +{ + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + DbRetVal rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 1; } + printf("Table created\n"); + return 0; +} +int createIndex(DatabaseManager *dbMgr) +{ + //Creating hash index on field f1 of table t1 + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#else + idxInfo->indType = hashIndex; +#endif + + DbRetVal rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return 1; } + printf("Index created for t1(f1)\n"); + + //Creating hash index on field f2 of table t1 + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.remove("f1"); + idxInfo->list.append("f2"); +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#else + idxInfo->indType = hashIndex; +#endif + + rv = dbMgr->createIndex("indx2", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return 1; } + printf("Index created for t1(f2)\n"); + + delete idxInfo; + return 0; +} + diff --git a/test/dbapi/Index/compositekeyindex1.c b/test/dbapi/Index/compositekeyindex1.c new file mode 100644 index 00000000..fbf8e10e --- /dev/null +++ b/test/dbapi/Index/compositekeyindex1.c @@ -0,0 +1,42 @@ +#include +//creating index with two fields +//It should be Passed +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeInt); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->list.append("f2"); + idxInfo->indType = hashIndex; +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx1", idxInfo); +#ifdef TREEINDEX + if(rv == OK) { printf("Composite Index creation Passed\n"); return 1; } + printf("Composite Index failed as expected\n"); +#else + if(rv != OK) { printf("Composite Index creation Failed\n"); return 1; } + printf("Composite Index created\n"); +#endif + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Index/createindexnofld.c b/test/dbapi/Index/createindexnofld.c new file mode 100644 index 00000000..321ec811 --- /dev/null +++ b/test/dbapi/Index/createindexnofld.c @@ -0,0 +1,35 @@ +#include +//creating index with non existing field +//It should fail +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL); + tabDef.addField("f2", typeInt); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->indType = hashIndex; +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#endif + int ret =0; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) ret =1; + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Index/createindexnotexist.c b/test/dbapi/Index/createindexnotexist.c new file mode 100644 index 00000000..309eadc0 --- /dev/null +++ b/test/dbapi/Index/createindexnotexist.c @@ -0,0 +1,36 @@ +#include +//creating index with non existing field +//It should fail +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + 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"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("notexist"); + idxInfo->indType = hashIndex; +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#endif + int ret =0; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) ret =1; + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Index/dupindex1.c b/test/dbapi/Index/dupindex1.c new file mode 100644 index 00000000..7930055d --- /dev/null +++ b/test/dbapi/Index/dupindex1.c @@ -0,0 +1,39 @@ +#include +//creating two index of same type on same field. +//It should fail +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + 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"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f1\n"); + int ret =0; + rv = dbMgr->createIndex("indx2", idxInfo); + if (rv == OK) ret =1; + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Index/dupindex2.c b/test/dbapi/Index/dupindex2.c new file mode 100644 index 00000000..d590a482 --- /dev/null +++ b/test/dbapi/Index/dupindex2.c @@ -0,0 +1,42 @@ +#include +//creating two index of same type on different field with same name +//It should fail +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + 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"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; +#ifdef TREEINDEX + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f1\n"); + + idxInfo->list.remove("f1"); + idxInfo->list.append("f2"); + int ret =0; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv == OK) ret =1; + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Index/exp.test004 b/test/dbapi/Index/exp.test004 new file mode 100644 index 00000000..cfd274c1 --- /dev/null +++ b/test/dbapi/Index/exp.test004 @@ -0,0 +1,37 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 100 +I:tuple value is 1 101 +I:tuple value is 2 102 +I:tuple value is 3 103 +I:tuple value is 4 104 +I:tuple value is 5 105 +I:tuple value is 6 106 +I:tuple value is 7 107 +I:tuple value is 8 108 +I:tuple value is 9 109 +II:tuple value is 0 100 +II:tuple value is 1 101 +II:tuple value is 2 102 +II:tuple value is 3 103 +II:tuple value is 4 104 +II:tuple value is 5 105 +II:tuple value is 6 106 +II:tuple value is 7 107 +II:tuple value is 8 108 +II:tuple value is 9 109 +deleted record +tuple value is 0 100 +tuple value is 3 103 +tuple value is 4 104 +tuple value is 5 105 +tuple value is 6 106 +tuple value is 7 107 +tuple value is 8 108 +tuple value is 9 109 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test004a b/test/dbapi/Index/exp.test004a new file mode 100644 index 00000000..cfd274c1 --- /dev/null +++ b/test/dbapi/Index/exp.test004a @@ -0,0 +1,37 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 100 +I:tuple value is 1 101 +I:tuple value is 2 102 +I:tuple value is 3 103 +I:tuple value is 4 104 +I:tuple value is 5 105 +I:tuple value is 6 106 +I:tuple value is 7 107 +I:tuple value is 8 108 +I:tuple value is 9 109 +II:tuple value is 0 100 +II:tuple value is 1 101 +II:tuple value is 2 102 +II:tuple value is 3 103 +II:tuple value is 4 104 +II:tuple value is 5 105 +II:tuple value is 6 106 +II:tuple value is 7 107 +II:tuple value is 8 108 +II:tuple value is 9 109 +deleted record +tuple value is 0 100 +tuple value is 3 103 +tuple value is 4 104 +tuple value is 5 105 +tuple value is 6 106 +tuple value is 7 107 +tuple value is 8 108 +tuple value is 9 109 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test004b b/test/dbapi/Index/exp.test004b new file mode 100644 index 00000000..cfd274c1 --- /dev/null +++ b/test/dbapi/Index/exp.test004b @@ -0,0 +1,37 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 100 +I:tuple value is 1 101 +I:tuple value is 2 102 +I:tuple value is 3 103 +I:tuple value is 4 104 +I:tuple value is 5 105 +I:tuple value is 6 106 +I:tuple value is 7 107 +I:tuple value is 8 108 +I:tuple value is 9 109 +II:tuple value is 0 100 +II:tuple value is 1 101 +II:tuple value is 2 102 +II:tuple value is 3 103 +II:tuple value is 4 104 +II:tuple value is 5 105 +II:tuple value is 6 106 +II:tuple value is 7 107 +II:tuple value is 8 108 +II:tuple value is 9 109 +deleted record +tuple value is 0 100 +tuple value is 3 103 +tuple value is 4 104 +tuple value is 5 105 +tuple value is 6 106 +tuple value is 7 107 +tuple value is 8 108 +tuple value is 9 109 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test004c b/test/dbapi/Index/exp.test004c new file mode 100644 index 00000000..cfd274c1 --- /dev/null +++ b/test/dbapi/Index/exp.test004c @@ -0,0 +1,37 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 100 +I:tuple value is 1 101 +I:tuple value is 2 102 +I:tuple value is 3 103 +I:tuple value is 4 104 +I:tuple value is 5 105 +I:tuple value is 6 106 +I:tuple value is 7 107 +I:tuple value is 8 108 +I:tuple value is 9 109 +II:tuple value is 0 100 +II:tuple value is 1 101 +II:tuple value is 2 102 +II:tuple value is 3 103 +II:tuple value is 4 104 +II:tuple value is 5 105 +II:tuple value is 6 106 +II:tuple value is 7 107 +II:tuple value is 8 108 +II:tuple value is 9 109 +deleted record +tuple value is 0 100 +tuple value is 3 103 +tuple value is 4 104 +tuple value is 5 105 +tuple value is 6 106 +tuple value is 7 107 +tuple value is 8 108 +tuple value is 9 109 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test005 b/test/dbapi/Index/exp.test005 new file mode 100644 index 00000000..c0e94789 --- /dev/null +++ b/test/dbapi/Index/exp.test005 @@ -0,0 +1,36 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 Aruna:0 +I:tuple value is 1 Aruna:1 +I:tuple value is 2 Aruna:2 +I:tuple value is 3 Aruna:3 +I:tuple value is 4 Aruna:4 +I:tuple value is 5 Aruna:5 +I:tuple value is 6 Aruna:6 +I:tuple value is 7 Aruna:7 +I:tuple value is 8 Aruna:8 +I:tuple value is 9 Aruna:9 +II:tuple value is 0 Aruna:0 +II:tuple value is 1 Aruna:1 +II:tuple value is 2 Aruna:2 +II:tuple value is 3 Aruna:3 +II:tuple value is 4 Aruna:4 +II:tuple value is 5 Aruna:5 +II:tuple value is 6 Aruna:6 +II:tuple value is 7 Aruna:7 +II:tuple value is 8 Aruna:8 +II:tuple value is 9 Aruna:9 +tuple value is 0 Aruna:0 +tuple value is 3 Aruna:3 +tuple value is 4 Aruna:4 +tuple value is 5 Aruna:5 +tuple value is 6 Aruna:6 +tuple value is 7 Aruna:7 +tuple value is 8 Aruna:8 +tuple value is 9 Aruna:9 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test005a b/test/dbapi/Index/exp.test005a new file mode 100644 index 00000000..c0e94789 --- /dev/null +++ b/test/dbapi/Index/exp.test005a @@ -0,0 +1,36 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 Aruna:0 +I:tuple value is 1 Aruna:1 +I:tuple value is 2 Aruna:2 +I:tuple value is 3 Aruna:3 +I:tuple value is 4 Aruna:4 +I:tuple value is 5 Aruna:5 +I:tuple value is 6 Aruna:6 +I:tuple value is 7 Aruna:7 +I:tuple value is 8 Aruna:8 +I:tuple value is 9 Aruna:9 +II:tuple value is 0 Aruna:0 +II:tuple value is 1 Aruna:1 +II:tuple value is 2 Aruna:2 +II:tuple value is 3 Aruna:3 +II:tuple value is 4 Aruna:4 +II:tuple value is 5 Aruna:5 +II:tuple value is 6 Aruna:6 +II:tuple value is 7 Aruna:7 +II:tuple value is 8 Aruna:8 +II:tuple value is 9 Aruna:9 +tuple value is 0 Aruna:0 +tuple value is 3 Aruna:3 +tuple value is 4 Aruna:4 +tuple value is 5 Aruna:5 +tuple value is 6 Aruna:6 +tuple value is 7 Aruna:7 +tuple value is 8 Aruna:8 +tuple value is 9 Aruna:9 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test005b b/test/dbapi/Index/exp.test005b new file mode 100644 index 00000000..c0e94789 --- /dev/null +++ b/test/dbapi/Index/exp.test005b @@ -0,0 +1,36 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 Aruna:0 +I:tuple value is 1 Aruna:1 +I:tuple value is 2 Aruna:2 +I:tuple value is 3 Aruna:3 +I:tuple value is 4 Aruna:4 +I:tuple value is 5 Aruna:5 +I:tuple value is 6 Aruna:6 +I:tuple value is 7 Aruna:7 +I:tuple value is 8 Aruna:8 +I:tuple value is 9 Aruna:9 +II:tuple value is 0 Aruna:0 +II:tuple value is 1 Aruna:1 +II:tuple value is 2 Aruna:2 +II:tuple value is 3 Aruna:3 +II:tuple value is 4 Aruna:4 +II:tuple value is 5 Aruna:5 +II:tuple value is 6 Aruna:6 +II:tuple value is 7 Aruna:7 +II:tuple value is 8 Aruna:8 +II:tuple value is 9 Aruna:9 +tuple value is 0 Aruna:0 +tuple value is 3 Aruna:3 +tuple value is 4 Aruna:4 +tuple value is 5 Aruna:5 +tuple value is 6 Aruna:6 +tuple value is 7 Aruna:7 +tuple value is 8 Aruna:8 +tuple value is 9 Aruna:9 +Total rows selected 8 diff --git a/test/dbapi/Index/exp.test005c b/test/dbapi/Index/exp.test005c new file mode 100644 index 00000000..c0e94789 --- /dev/null +++ b/test/dbapi/Index/exp.test005c @@ -0,0 +1,36 @@ +Table created +Index created for f1 +size of index field list 1 +size of index field list 0 +size of index field list 1 +Index created for f2 +Total tuples inserted: 10 +I:tuple value is 0 Aruna:0 +I:tuple value is 1 Aruna:1 +I:tuple value is 2 Aruna:2 +I:tuple value is 3 Aruna:3 +I:tuple value is 4 Aruna:4 +I:tuple value is 5 Aruna:5 +I:tuple value is 6 Aruna:6 +I:tuple value is 7 Aruna:7 +I:tuple value is 8 Aruna:8 +I:tuple value is 9 Aruna:9 +II:tuple value is 0 Aruna:0 +II:tuple value is 1 Aruna:1 +II:tuple value is 2 Aruna:2 +II:tuple value is 3 Aruna:3 +II:tuple value is 4 Aruna:4 +II:tuple value is 5 Aruna:5 +II:tuple value is 6 Aruna:6 +II:tuple value is 7 Aruna:7 +II:tuple value is 8 Aruna:8 +II:tuple value is 9 Aruna:9 +tuple value is 0 Aruna:0 +tuple value is 3 Aruna:3 +tuple value is 4 Aruna:4 +tuple value is 5 Aruna:5 +tuple value is 6 Aruna:6 +tuple value is 7 Aruna:7 +tuple value is 8 Aruna:8 +tuple value is 9 Aruna:9 +Total rows selected 8 diff --git a/test/dbapi/Index/index1.c b/test/dbapi/Index/index1.c new file mode 100644 index 00000000..3dda26b3 --- /dev/null +++ b/test/dbapi/Index/index1.c @@ -0,0 +1,23 @@ +//create table t1(f1 int,f2 int) +//create index idx1 on t1(f1) +//create index idx2 on t1(f2) +//insert null records for f2 and check whether the system is stable after that. + +#include +#include"common.h" +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if(rv != OK) return 1; + DatabaseManager *dbmgr=conn.getDatabaseManager(); + if(dbmgr == NULL) { printf("Authentication Failed\n"); return 2; } + + if( creatTable(dbmgr) !=0 ) { conn.close(); return 3; } + if( createIndex(dbmgr) != 0 ) { dbmgr->dropTable("t1"); conn.close(); return 4; } + int flag = insertTuplef2NUL(dbmgr,conn); + if( flag != 0 ) { dbmgr->dropTable("t1"); conn.close(); return 5; } + dbmgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Index/multiplecompositeindex1.c b/test/dbapi/Index/multiplecompositeindex1.c new file mode 100644 index 00000000..d312d3cd --- /dev/null +++ b/test/dbapi/Index/multiplecompositeindex1.c @@ -0,0 +1,76 @@ +// create table t1(f1 int,f2 int,f3 int) +// create composite index cmpidx on t1(f1,f2,f3) +// create composite index cmpidx1 on t1(f1,f2) +// create composite index cmpidx2 on t1(f2,f3); + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root","manager"); + if(rv!=OK) + { + printf("Connection Failed with return value %d\n",rv); + return 1; + } + DatabaseManager *dbmgr=conn.getDatabaseManager(); + if(dbmgr==NULL) { printf("Authentication Failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1",typeInt,0,NULL,true); + tabDef.addField("f2",typeInt); + tabDef.addField("f3",typeInt); + rv=dbmgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); + + HashIndexInitInfo *idx1 = new HashIndexInitInfo(); + strcpy(idx1->tableName, "t1"); + idx1->list.append("f1"); + idx1->list.append("f2"); + idx1->list.append("f3"); + idx1->indType = hashIndex; + rv = dbmgr->createIndex("cmpidx", idx1); + if(rv != OK) { printf("Composite Index creation Failed\n"); return 4; } + printf("Composite Index 'cmpidx' created on t1(f1,f2,f3)\n"); + delete idx1; + + HashIndexInitInfo *idx2 = new HashIndexInitInfo(); + strcpy(idx2->tableName, "t1"); + idx2->list.append("f1"); + idx2->list.append("f2"); + idx2->indType = hashIndex; + rv = dbmgr->createIndex("cmpidx1", idx2); + if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; } + printf("Composite Index 'cmpidx1' created on t1(f1,f2)\n"); + delete idx2; + + HashIndexInitInfo *idx3 = new HashIndexInitInfo(); + strcpy(idx3->tableName, "t1"); + idx3->list.append("f2"); + idx3->list.append("f3"); + idx3->indType = hashIndex; + rv = dbmgr->createIndex("cmpidx2", idx3); + if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; } + printf("Composite Index 'cmpidx2' created on t1(f2,f3)\n"); + delete idx3; + + HashIndexInitInfo *idx4 = new HashIndexInitInfo(); + strcpy(idx4->tableName, "t1"); + idx4->list.append("f1"); + idx4->list.append("f3"); + idx4->indType = hashIndex; + rv = dbmgr->createIndex("cmpidx3", idx4); + if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; } + printf("Composite Index 'cmpidx3' created on t1(f1,f3)\n"); + delete idx4; + dbmgr->dropTable("t1"); + conn.close(); + return 0; +} + + + + + + + diff --git a/test/dbapi/Index/primarynonunique.c b/test/dbapi/Index/primarynonunique.c new file mode 100644 index 00000000..9b5fc078 --- /dev/null +++ b/test/dbapi/Index/primarynonunique.c @@ -0,0 +1,36 @@ +#include +//creating index with primary attribute set but unique unset +//It should fail +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt); + tabDef.addField("f2", typeInt); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->list.append("f2"); + idxInfo->indType = hashIndex; + idxInfo->isUnique = false; + idxInfo->isPrimary = true; + rv = dbMgr->createIndex("indx1", idxInfo); + int ret = 0; + if (rv == OK) ret =1; + delete idxInfo; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Index/twoindex1.c b/test/dbapi/Index/twoindex1.c new file mode 100644 index 00000000..a71e0f8c --- /dev/null +++ b/test/dbapi/Index/twoindex1.c @@ -0,0 +1,140 @@ +#include +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt, 0, NULL, true); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isUnique = true; + idxInfo->isPrimary = true; + idxInfo->indType = hashIndex; +#ifdef F1TREE + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f1\n"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->list.remove("f1"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->list.append("f2"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->indType = hashIndex; +#ifdef F2TREE + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx2", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f2\n"); + delete idxInfo; + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + int id1 = 0, id2=0; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + char *tuple; + int ret; + int i; + int icount =0; + rv = conn.startTransaction(); + if (rv != OK) exit(1); + for(i = 0; i< 10; i++) + { + id1= i; + id2= i+100; + ret = table->insertTuple(); + if (ret != 0) break; + icount++; + } + conn.commit(); + printf("Total tuples inserted: %d\n", icount); + Condition p1, p2; + int val1 = 0; + p1.setTerm("f1", OpEquals, &val1); + p2.setTerm("f2", OpEquals, &val1); + table->setCondition(&p1); + rv =conn.startTransaction(); + if (rv != OK) exit(1); + for(i = 0; i< 10; i++) + { + val1 = i; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) {printf("loop break in %d\n", i);table->closeScan();break;} + printf("I:tuple value is %d %d \n", id1, id2); + table->closeScan(); + } + + table->setCondition(&p2); + for(i = 0; i< 10; i++) + { + val1 = i+100; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) {printf("loop break in %d\n", i);table->closeScan();break;} + printf("II:tuple value is %d %d \n", id1, id2); + table->closeScan(); + } + conn.commit(); + + rv = conn.startTransaction(); + if (rv != OK) exit (1); + table->setCondition(&p1); + val1 = 1; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple != NULL) { + table->deleteTuple(); + } + table->closeScan(); + printf("deleted record\n"); + + + table->setCondition(&p2); + val1 = 102; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple != NULL) { + table->deleteTuple(); + } + table->closeScan(); + conn.commit(); + + dbMgr->closeTable(table); + table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + int count =0; + rv = conn.startTransaction(); + table->setCondition(NULL); + if (rv != OK) exit (1); + table->execute(); + while((tuple = (char*)table->fetch())!= NULL) { + printf("tuple value is %d %d \n", id1, id2); + count++; + } + table->closeScan(); + conn.commit(); + printf("Total rows selected %d\n", count); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/Index/twoindex2.c b/test/dbapi/Index/twoindex2.c new file mode 100644 index 00000000..a4c5fa47 --- /dev/null +++ b/test/dbapi/Index/twoindex2.c @@ -0,0 +1,132 @@ +#include +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeString, 50); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; +#ifdef F1TREE + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f1\n"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->list.remove("f1"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->list.append("f2"); + printf("size of index field list %d\n", idxInfo->list.size()); + idxInfo->indType = hashIndex; +#ifdef F2TREE + idxInfo->indType = treeIndex; +#endif + rv = dbMgr->createIndex("indx2", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created for f2\n"); + delete idxInfo; + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + int id1 = 0; + char id2[50] ="Aruna"; + table->bindFld("f1", &id1); + table->bindFld("f2", id2); + char *tuple; + int ret; + int i; + int icount =0; + rv = conn.startTransaction(); + if (rv != OK) exit(1); + for(i = 0; i< 10; i++) + { + id1= i; + sprintf(id2, "Aruna:%d", i); + ret = table->insertTuple(); + if (ret != 0) break; + icount++; + } + conn.commit(); + printf("Total tuples inserted: %d\n", icount); + Condition p1, p2; + int val1 = 0; + char val2[50]; + p1.setTerm("f1", OpEquals, &val1); + p2.setTerm("f2", OpEquals, &val2); + table->setCondition(&p1); + rv =conn.startTransaction(); + if (rv != OK) exit(1); + for(i = 0; i< 10; i++) + { + val1 = i; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) {printf("loop break in %d\n", i);table->closeScan();break;} + printf("I:tuple value is %d %s \n", id1, id2); + table->closeScan(); + } + + table->setCondition(&p2); + for(i = 0; i< 10; i++) + { + sprintf(val2, "Aruna:%d", i); + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) {printf("loop break in %d\n", i);table->closeScan();break;} + printf("II:tuple value is %d %s \n", id1, id2); + table->closeScan(); + } + conn.commit(); + + rv =conn.startTransaction(); + if (rv != OK) exit(1); + table->setCondition(&p1); + val1 = 1; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple != NULL) { + table->deleteTuple(); + } + table->closeScan(); + table->setCondition(&p2); + sprintf(val2, "Aruna:%d", 2); + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple != NULL) { + table->deleteTuple(); + } + table->closeScan(); + conn.commit(); + + int count =0; + rv = conn.startTransaction(); + table->setCondition(NULL); + if (rv != OK) exit (1); + table->execute(); + while((tuple = (char*)table->fetch())!= NULL) { + printf("tuple value is %d %s \n", id1, id2); + count++; + } + table->closeScan(); + conn.commit(); + printf("Total rows selected %d\n", count); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/Index/uniqueindex1.c b/test/dbapi/Index/uniqueindex1.c new file mode 100644 index 00000000..e7aa7479 --- /dev/null +++ b/test/dbapi/Index/uniqueindex1.c @@ -0,0 +1,20 @@ +#include +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + if ( createIndex(dbMgr, true) != 0 ) { dbMgr->dropTable("t1");conn.close(); return 4; + } + int inscount = insertTupleWithSameValue(dbMgr, conn); + if (inscount != 1 ) { dbMgr->dropTable("t1"); conn.close(); return 5; } + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} diff --git a/test/dbapi/Index/uniqueindex2.c b/test/dbapi/Index/uniqueindex2.c new file mode 100644 index 00000000..9615d6d2 --- /dev/null +++ b/test/dbapi/Index/uniqueindex2.c @@ -0,0 +1,20 @@ +#include +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + if ( createIndex(dbMgr, false) != 0 ) { dbMgr->dropTable("t1");conn.close(); return 4; + } + int inscount = insertTupleWithSameValue(dbMgr, conn); + if (inscount != 10 ) { dbMgr->dropTable("t1"); conn.close(); return 5; } + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} diff --git a/test/dbapi/Index/uniqueindex3.c b/test/dbapi/Index/uniqueindex3.c new file mode 100644 index 00000000..4586d627 --- /dev/null +++ b/test/dbapi/Index/uniqueindex3.c @@ -0,0 +1,22 @@ +#include +#define DEFAULT +#include "common.h" +//test with default value for isUnique of IndexInitInfo +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + if ( createIndex(dbMgr, false) != 0 ) { dbMgr->dropTable("t1");conn.close(); return 4; + } + int inscount = insertTupleWithSameValue(dbMgr, conn); + if (inscount != 10 ) { dbMgr->dropTable("t1"); conn.close(); return 5; } + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} diff --git a/test/dbapi/Makefile b/test/dbapi/Makefile new file mode 100644 index 00000000..8b8aa8e0 --- /dev/null +++ b/test/dbapi/Makefile @@ -0,0 +1,18 @@ +OSNAME = $(shell uname -s) +MAKE=gmake + +all: + @for i in *; \ + do \ + if [ -d $$i ];\ + then cd $$i; $(MAKE); cd ..;\ + fi;\ + done + +clean: + @for i in *; \ + do \ + if [ -d $$i ];\ + then cd $$i; $(MAKE) clean; cd ..;\ + fi;\ + done diff --git a/test/dbapi/Predicate/Makefile b/test/dbapi/Predicate/Makefile new file mode 100644 index 00000000..18569354 --- /dev/null +++ b/test/dbapi/Predicate/Makefile @@ -0,0 +1,152 @@ + +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 test001a test002 test002a\ + test003 test003a test003b test003c \ + test004 test004a test004b test004c \ + test005 test005a test005b test005c \ + test006 test006a test006b test006c \ + test007 test008 test009 test010 \ + test011 test012 \ + test001b test002b test003d test003e \ + test003f test003g test003h test005d \ + test005f test005g test005h test005e \ + test004f test004g test004h test004e \ + test004d test006g test006h test006e \ + test006f test006d + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: notpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test001a: notpredicate1.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test001b: notpredicate1.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002: predicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002a:predicate1.c + $(CPlus) -DWITHINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002b:predicate1.c + $(CPlus) -DWITHTREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003: andpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003a: andpredicate1.c + $(CPlus) -DWITHF1INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003b: andpredicate1.c + $(CPlus) -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003c: andpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003d: andpredicate1.c + $(CPlus) -DWITHF1TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003e: andpredicate1.c + $(CPlus) -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003f: andpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003g: andpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003h: andpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +test004: notandpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004a: notandpredicate1.c + $(CPlus) -DWITHF1INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004b: notandpredicate1.c + $(CPlus) -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004c: notandpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004d: notandpredicate1.c + $(CPlus) -DWITHF1TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004e: notandpredicate1.c + $(CPlus) -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004f: notandpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004g: notandpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004h: notandpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +test005: orpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005a: orpredicate1.c + $(CPlus) -DWITHF1INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005b: orpredicate1.c + $(CPlus) -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005c: orpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005d: orpredicate1.c + $(CPlus) -DWITHF1TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005e: orpredicate1.c + $(CPlus) -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005f: orpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005g: orpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005h: orpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +test006: notorpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006a: notorpredicate1.c + $(CPlus) -DWITHF1INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006b: notorpredicate1.c + $(CPlus) -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006c: notorpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006d: notorpredicate1.c + $(CPlus) -DWITHF1TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006e: notorpredicate1.c + $(CPlus) -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006f: notorpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006g: notorpredicate1.c + $(CPlus) -DWITHF1INDEX -DWITHF2TREEINDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006h: notorpredicate1.c + $(CPlus) -DWITHF1TREEINDEX -DWITHF2INDEX $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +test007: andorpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008: orandpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009: andandpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010: ororpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test011: andorandpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test012: orandorpredicate1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/Predicate/andandpredicate1.c b/test/dbapi/Predicate/andandpredicate1.c new file mode 100644 index 00000000..452f853e --- /dev/null +++ b/test/dbapi/Predicate/andandpredicate1.c @@ -0,0 +1,61 @@ +//Testing AND with AND operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 5; + p1.setTerm("f1", OpEquals, &val2); + p2.setTerm("f2", OpGreaterThan, &val1); + p3.setTerm("f3", OpNotEquals, &val3); + p4.setTerm("f4", OpLessThan, &val3); + p5.setTerm("f5", OpGreaterThanEquals, &val2); + + + Condition cond1, cond1a, cond1b, cond1c; + cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpAnd, p3.getPredicate()); + cond1b.setTerm(cond1a.getPredicate(), OpAnd, p4.getPredicate()); + cond1c.setTerm(cond1b.getPredicate(), OpAnd, p5.getPredicate()); + table->setCondition(&cond1c); + printf("Predicate: (f1 ==3 AND f2 > 2 AND f3 !=5 AND f4 <5 AND f5 >=3 ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a, cond2b; + cond2.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + cond2a.setTerm(p3.getPredicate(), OpAnd, p4.getPredicate()); + cond2b.setTerm(cond2.getPredicate(), OpAnd, cond2a.getPredicate()); + table->setCondition(&cond2b); + printf("Predicate: (f1 ==3 AND f2 > 2) AND (f3 !=5 AND f4 <5) ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/andorandpredicate1.c b/test/dbapi/Predicate/andorandpredicate1.c new file mode 100644 index 00000000..80a3d2b1 --- /dev/null +++ b/test/dbapi/Predicate/andorandpredicate1.c @@ -0,0 +1,45 @@ +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4; + int val1 = 2, val2 = 3, val3 = 5; + p1.setTerm("f1", OpEquals, &val2); + p2.setTerm("f2", OpGreaterThan, &val1); + p3.setTerm("f3", OpNotEquals, &val3); + p4.setTerm("f4", OpLessThan, &val3); + + Condition cond2, cond2a, cond2b; + cond2.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + cond2a.setTerm(p3.getPredicate(), OpAnd, p4.getPredicate()); + cond2b.setTerm(cond2.getPredicate(), OpOr, cond2a.getPredicate()); + table->setCondition(&cond2b); + printf("Predicate: (f1 ==3 AND f2 > 2) OR (f3 !=3 AND f4 <5) ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/andorpredicate1.c b/test/dbapi/Predicate/andorpredicate1.c new file mode 100644 index 00000000..40bb6f83 --- /dev/null +++ b/test/dbapi/Predicate/andorpredicate1.c @@ -0,0 +1,59 @@ +//Testing AND with OR operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with AND operator with OR operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val1); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1, cond1a; + cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpOr, p4.getPredicate()); + table->setCondition(&cond1a); + printf("Predicate: (f1 ==4 AND f2 >3) OR (f1< 2) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a; + cond2.setTerm(p4.getPredicate(), OpAnd, p2.getPredicate()); + cond2a.setTerm(cond1.getPredicate(), OpOr, cond2.getPredicate()); + table->setCondition(&cond2a); + printf("Predicate: (f1 ==4 AND f2 >3) OR (f1< 2 AND f2 > 4) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/andpredicate1.c b/test/dbapi/Predicate/andpredicate1.c new file mode 100644 index 00000000..1f39eab5 --- /dev/null +++ b/test/dbapi/Predicate/andpredicate1.c @@ -0,0 +1,102 @@ +//Testing AND operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with AND operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } +#ifdef WITHF1INDEX + if (createIndex(dbMgr, "f1", "idx1") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF1TREEINDEX + if (createIndex(dbMgr, "f1", "idx1", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + +#ifdef WITHF2INDEX + if (createIndex(dbMgr, "f2", "idx2") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + + +#ifdef WITHF2TREEINDEX + if (createIndex(dbMgr, "f2", "idx2", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val3); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1; + cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + table->setCondition(&cond1); + printf("Predicate: f1 ==4 AND f2 >3 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2; + cond2.setTerm(p1.getPredicate(), OpAnd, p3.getPredicate()); + table->setCondition(&cond2); + printf("Predicate: f1 ==4 AND f2 ==4 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond3; + cond3.setTerm(p4.getPredicate(), OpAnd, p5.getPredicate()); + table->setCondition(&cond3); + printf("Predicate: f1 <4 AND f1 >2 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + + Condition cond4; + cond4.setTerm(p4.getPredicate(), OpAnd, p2.getPredicate()); + table->setCondition(&cond4); + printf("Predicate: f1 <4 AND f2 >3 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/common.h b/test/dbapi/Predicate/common.h new file mode 100644 index 00000000..4b9203bd --- /dev/null +++ b/test/dbapi/Predicate/common.h @@ -0,0 +1,72 @@ +#include +DbRetVal createIndex(DatabaseManager *dbMgr, char *fldname, char *indname, bool flag=false) +{ + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append(fldname); + if (flag) + idxInfo->indType = treeIndex; + else + idxInfo->indType = hashIndex; + DbRetVal rv = dbMgr->createIndex(indname, idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return rv; } + printf("Index created for %s\n", fldname); + delete idxInfo; + return OK; +} +DbRetVal createTable(DatabaseManager *dbMgr) +{ + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt, 0, NULL, true); + tabDef.addField("f3", typeInt); + tabDef.addField("f4", typeInt); + tabDef.addField("f5", typeInt); + DbRetVal rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return rv; } + printf("Table created\n"); + return OK; +} +int insertTuple(DatabaseManager *dbMgr, Connection &conn) +{ + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + int id1 = 0; + table->bindFld("f1", &id1); + table->bindFld("f2", &id1); + table->bindFld("f3", &id1); + table->bindFld("f4", &id1); + table->bindFld("f5", &id1); + int icount =0; + DbRetVal rv = OK; + rv = conn.startTransaction(); + if (rv != OK) { dbMgr->closeTable(table); return 1; } + for (int i = 0 ; i < 10 ; i++) + { + id1= i; + rv = table->insertTuple(); + if (rv != OK) break; + icount++; + + } + conn.commit(); + printf("Total Tuples inserted is %d\n", icount); + dbMgr->closeTable(table); + return icount; +} +DbRetVal execAndPrint(Table *table) +{ + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + char *t = (char*) tuple; + printf("tuple value is %d %d %d %d %d\n", *(int*)t, *(int*)(t+4), + *(int*)(t+8),*(int*)(t+12),*(int*)(t+16)); + } + table->closeScan(); + return OK; +} diff --git a/test/dbapi/Predicate/exp.test001 b/test/dbapi/Predicate/exp.test001 new file mode 100644 index 00000000..fe01b9b8 --- /dev/null +++ b/test/dbapi/Predicate/exp.test001 @@ -0,0 +1,22 @@ +Table created +Operator test for 0 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 diff --git a/test/dbapi/Predicate/exp.test001a b/test/dbapi/Predicate/exp.test001a new file mode 100644 index 00000000..0d6cd70a --- /dev/null +++ b/test/dbapi/Predicate/exp.test001a @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 diff --git a/test/dbapi/Predicate/exp.test001b b/test/dbapi/Predicate/exp.test001b new file mode 100644 index 00000000..0d6cd70a --- /dev/null +++ b/test/dbapi/Predicate/exp.test001b @@ -0,0 +1,23 @@ +Table created +Index created +Operator test for 0 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 1 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 2 +tuple value is 3 PRABAKARAN0123456750590 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 3 +tuple value is 4 PRABAKARAN0123456750590 +Operator test for 4 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 +tuple value is 3 PRABAKARAN0123456750590 +Operator test for 5 +tuple value is 0 PRABAKARAN0123456750590 +tuple value is 1 PRABAKARAN0123456750590 +tuple value is 2 PRABAKARAN0123456750590 diff --git a/test/dbapi/Predicate/exp.test002 b/test/dbapi/Predicate/exp.test002 new file mode 100644 index 00000000..f4cf561a --- /dev/null +++ b/test/dbapi/Predicate/exp.test002 @@ -0,0 +1,25 @@ +Table created +Operator Test for 0 +Tuple is 10 NIHAR10 +Operator Test for 1 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 11 NIHAR11 +Operator Test for 2 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Operator Test for 3 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 10 NIHAR10 +Operator Test for 4 +Tuple is 11 NIHAR11 +Operator Test for 5 +Tuple is 10 NIHAR10 +Tuple is 11 NIHAR11 diff --git a/test/dbapi/Predicate/exp.test002a b/test/dbapi/Predicate/exp.test002a new file mode 100644 index 00000000..3704e01e --- /dev/null +++ b/test/dbapi/Predicate/exp.test002a @@ -0,0 +1,26 @@ +Table created +Index created +Operator Test for 0 +Tuple is 10 NIHAR10 +Operator Test for 1 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 11 NIHAR11 +Operator Test for 2 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Operator Test for 3 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 10 NIHAR10 +Operator Test for 4 +Tuple is 11 NIHAR11 +Operator Test for 5 +Tuple is 10 NIHAR10 +Tuple is 11 NIHAR11 diff --git a/test/dbapi/Predicate/exp.test002b b/test/dbapi/Predicate/exp.test002b new file mode 100644 index 00000000..3704e01e --- /dev/null +++ b/test/dbapi/Predicate/exp.test002b @@ -0,0 +1,26 @@ +Table created +Index created +Operator Test for 0 +Tuple is 10 NIHAR10 +Operator Test for 1 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 11 NIHAR11 +Operator Test for 2 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Operator Test for 3 +Tuple is 6 NIHAR6 +Tuple is 7 NIHAR7 +Tuple is 8 NIHAR8 +Tuple is 9 NIHAR9 +Tuple is 10 NIHAR10 +Operator Test for 4 +Tuple is 11 NIHAR11 +Operator Test for 5 +Tuple is 10 NIHAR10 +Tuple is 11 NIHAR11 diff --git a/test/dbapi/Predicate/exp.test003 b/test/dbapi/Predicate/exp.test003 new file mode 100644 index 00000000..249740a3 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003 @@ -0,0 +1,9 @@ +Table created +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003a b/test/dbapi/Predicate/exp.test003a new file mode 100644 index 00000000..21d93215 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003a @@ -0,0 +1,10 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003b b/test/dbapi/Predicate/exp.test003b new file mode 100644 index 00000000..a5185fa9 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003b @@ -0,0 +1,10 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003c b/test/dbapi/Predicate/exp.test003c new file mode 100644 index 00000000..798f6c02 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003c @@ -0,0 +1,11 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003d b/test/dbapi/Predicate/exp.test003d new file mode 100644 index 00000000..21d93215 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003d @@ -0,0 +1,10 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003e b/test/dbapi/Predicate/exp.test003e new file mode 100644 index 00000000..a5185fa9 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003e @@ -0,0 +1,10 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003f b/test/dbapi/Predicate/exp.test003f new file mode 100644 index 00000000..798f6c02 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003f @@ -0,0 +1,11 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003g b/test/dbapi/Predicate/exp.test003g new file mode 100644 index 00000000..798f6c02 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003g @@ -0,0 +1,11 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test003h b/test/dbapi/Predicate/exp.test003h new file mode 100644 index 00000000..798f6c02 --- /dev/null +++ b/test/dbapi/Predicate/exp.test003h @@ -0,0 +1,11 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 AND f2 >3 +tuple value is 4 4 4 4 4 +Predicate: f1 ==4 AND f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 AND f1 >2 +tuple value is 3 3 3 3 3 +Predicate: f1 <4 AND f2 >3 diff --git a/test/dbapi/Predicate/exp.test004 b/test/dbapi/Predicate/exp.test004 new file mode 100644 index 00000000..09ea9d97 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004 @@ -0,0 +1,48 @@ +Table created +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004a b/test/dbapi/Predicate/exp.test004a new file mode 100644 index 00000000..b970b095 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004a @@ -0,0 +1,49 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004b b/test/dbapi/Predicate/exp.test004b new file mode 100644 index 00000000..4fc30b78 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004b @@ -0,0 +1,49 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004c b/test/dbapi/Predicate/exp.test004c new file mode 100644 index 00000000..136aa582 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004c @@ -0,0 +1,50 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004d b/test/dbapi/Predicate/exp.test004d new file mode 100644 index 00000000..b970b095 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004d @@ -0,0 +1,49 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004e b/test/dbapi/Predicate/exp.test004e new file mode 100644 index 00000000..4fc30b78 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004e @@ -0,0 +1,49 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004f b/test/dbapi/Predicate/exp.test004f new file mode 100644 index 00000000..136aa582 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004f @@ -0,0 +1,50 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004g b/test/dbapi/Predicate/exp.test004g new file mode 100644 index 00000000..136aa582 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004g @@ -0,0 +1,50 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test004h b/test/dbapi/Predicate/exp.test004h new file mode 100644 index 00000000..136aa582 --- /dev/null +++ b/test/dbapi/Predicate/exp.test004h @@ -0,0 +1,50 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 ==4 AND f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f1 >2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 AND f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: ( f1 <4 AND (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test005 b/test/dbapi/Predicate/exp.test005 new file mode 100644 index 00000000..35379255 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005 @@ -0,0 +1,33 @@ +Table created +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005a b/test/dbapi/Predicate/exp.test005a new file mode 100644 index 00000000..d4562d75 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005a @@ -0,0 +1,34 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005b b/test/dbapi/Predicate/exp.test005b new file mode 100644 index 00000000..1cef0824 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005b @@ -0,0 +1,34 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005c b/test/dbapi/Predicate/exp.test005c new file mode 100644 index 00000000..75657971 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005c @@ -0,0 +1,35 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005d b/test/dbapi/Predicate/exp.test005d new file mode 100644 index 00000000..d4562d75 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005d @@ -0,0 +1,34 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005e b/test/dbapi/Predicate/exp.test005e new file mode 100644 index 00000000..1cef0824 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005e @@ -0,0 +1,34 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005f b/test/dbapi/Predicate/exp.test005f new file mode 100644 index 00000000..75657971 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005f @@ -0,0 +1,35 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005g b/test/dbapi/Predicate/exp.test005g new file mode 100644 index 00000000..75657971 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005g @@ -0,0 +1,35 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test005h b/test/dbapi/Predicate/exp.test005h new file mode 100644 index 00000000..75657971 --- /dev/null +++ b/test/dbapi/Predicate/exp.test005h @@ -0,0 +1,35 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: f1 ==4 OR f2 >3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 ==4 OR f2 ==4 +tuple value is 4 4 4 4 4 +Predicate: f1 <4 OR f1 >2 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: f1 <4 OR f2 >3 +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test006 b/test/dbapi/Predicate/exp.test006 new file mode 100644 index 00000000..09b8c6fc --- /dev/null +++ b/test/dbapi/Predicate/exp.test006 @@ -0,0 +1,24 @@ +Table created +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006a b/test/dbapi/Predicate/exp.test006a new file mode 100644 index 00000000..d8c9bd74 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006a @@ -0,0 +1,25 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006b b/test/dbapi/Predicate/exp.test006b new file mode 100644 index 00000000..46fd4e09 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006b @@ -0,0 +1,25 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006c b/test/dbapi/Predicate/exp.test006c new file mode 100644 index 00000000..c3715638 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006c @@ -0,0 +1,26 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006d b/test/dbapi/Predicate/exp.test006d new file mode 100644 index 00000000..d8c9bd74 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006d @@ -0,0 +1,25 @@ +Table created +Index created for f1 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006e b/test/dbapi/Predicate/exp.test006e new file mode 100644 index 00000000..46fd4e09 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006e @@ -0,0 +1,25 @@ +Table created +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006f b/test/dbapi/Predicate/exp.test006f new file mode 100644 index 00000000..c3715638 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006f @@ -0,0 +1,26 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006g b/test/dbapi/Predicate/exp.test006g new file mode 100644 index 00000000..c3715638 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006g @@ -0,0 +1,26 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test006h b/test/dbapi/Predicate/exp.test006h new file mode 100644 index 00000000..c3715638 --- /dev/null +++ b/test/dbapi/Predicate/exp.test006h @@ -0,0 +1,26 @@ +Table created +Index created for f1 +Index created for f2 +Total Tuples inserted is 10 +Predicate: NOT(f1 ==4 OR f2 >3) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +Predicate: NOT( f1 ==4 OR f2 ==4) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: NOT( f1 <4 OR f1 >2) +Predicate: NOT( f1 <4 OR f2 >3) +Predicate: ( f1 <4 OR (NOT(f2 >3)) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test007 b/test/dbapi/Predicate/exp.test007 new file mode 100644 index 00000000..a301bf96 --- /dev/null +++ b/test/dbapi/Predicate/exp.test007 @@ -0,0 +1,8 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==4 AND f2 >3) OR (f1< 2) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 4 4 4 4 4 +Predicate: (f1 ==4 AND f2 >3) OR (f1< 2 AND f2 > 4) +tuple value is 4 4 4 4 4 diff --git a/test/dbapi/Predicate/exp.test008 b/test/dbapi/Predicate/exp.test008 new file mode 100644 index 00000000..45a38d67 --- /dev/null +++ b/test/dbapi/Predicate/exp.test008 @@ -0,0 +1,10 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==4 OR f2 >3) AND (f1< 4) +Predicate: (f1 ==4 OR f2 >3) AND (f1< 4 OR f2 > 2) +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test009 b/test/dbapi/Predicate/exp.test009 new file mode 100644 index 00000000..efd3fbce --- /dev/null +++ b/test/dbapi/Predicate/exp.test009 @@ -0,0 +1,6 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==3 AND f2 > 2 AND f3 !=5 AND f4 <5 AND f5 >=3 ) +tuple value is 3 3 3 3 3 +Predicate: (f1 ==3 AND f2 > 2) AND (f3 !=5 AND f4 <5) ) +tuple value is 3 3 3 3 3 diff --git a/test/dbapi/Predicate/exp.test010 b/test/dbapi/Predicate/exp.test010 new file mode 100644 index 00000000..f2be2bbb --- /dev/null +++ b/test/dbapi/Predicate/exp.test010 @@ -0,0 +1,24 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==3 OR f2 > 2 OR f3 !=5 OR f4 <5 OR f5 >=3 ) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 +Predicate: (f1 ==3 OR f2 > 2) OR (f3 !=5 OR f4 <5) ) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 5 5 5 5 5 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/exp.test011 b/test/dbapi/Predicate/exp.test011 new file mode 100644 index 00000000..b1be2a8d --- /dev/null +++ b/test/dbapi/Predicate/exp.test011 @@ -0,0 +1,8 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==3 AND f2 > 2) OR (f3 !=3 AND f4 <5) ) +tuple value is 0 0 0 0 0 +tuple value is 1 1 1 1 1 +tuple value is 2 2 2 2 2 +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 diff --git a/test/dbapi/Predicate/exp.test012 b/test/dbapi/Predicate/exp.test012 new file mode 100644 index 00000000..390376ab --- /dev/null +++ b/test/dbapi/Predicate/exp.test012 @@ -0,0 +1,9 @@ +Table created +Total Tuples inserted is 10 +Predicate: (f1 ==3 OR f2 > 2) AND (f3 !=5 OR f4 <5) ) +tuple value is 3 3 3 3 3 +tuple value is 4 4 4 4 4 +tuple value is 6 6 6 6 6 +tuple value is 7 7 7 7 7 +tuple value is 8 8 8 8 8 +tuple value is 9 9 9 9 9 diff --git a/test/dbapi/Predicate/notandpredicate1.c b/test/dbapi/Predicate/notandpredicate1.c new file mode 100644 index 00000000..9965a525 --- /dev/null +++ b/test/dbapi/Predicate/notandpredicate1.c @@ -0,0 +1,113 @@ +//Testing NOT with AND operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with AND operator with NOT operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } +#ifdef WITHF1INDEX + if (createIndex(dbMgr, "f1", "idx1") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF1TREEINDEX + if (createIndex(dbMgr, "f1", "idx1", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + +#ifdef WITHF2INDEX + if (createIndex(dbMgr, "f2", "idx2") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF2TREEINDEX + if (createIndex(dbMgr, "f2", "idx2", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val3); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1, cond1a; + cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpNot); + table->setCondition(&cond1a); + printf("Predicate: NOT(f1 ==4 AND f2 >3) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a; + cond2.setTerm(p1.getPredicate(), OpAnd, p3.getPredicate()); + cond2a.setTerm(cond2.getPredicate(), OpNot); + table->setCondition(&cond2a); + printf("Predicate: NOT( f1 ==4 AND f2 ==4) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond3, cond3a; + cond3.setTerm(p4.getPredicate(), OpAnd, p5.getPredicate()); + cond3a.setTerm(cond3.getPredicate(), OpNot); + table->setCondition(&cond3a); + printf("Predicate: NOT( f1 <4 AND f1 >2) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + + Condition cond4, cond4a; + cond4.setTerm(p4.getPredicate(), OpAnd, p2.getPredicate()); + cond4a.setTerm(cond4.getPredicate(), OpNot); + table->setCondition(&cond4a); + printf("Predicate: NOT( f1 <4 AND f2 >3) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond5, cond5a; + cond5.setTerm(p2.getPredicate(), OpNot); + cond5a.setTerm(p4.getPredicate(), OpAnd, cond5.getPredicate()); + table->setCondition(&cond5a); + printf("Predicate: ( f1 <4 AND (NOT(f2 >3)) \n"); + conn.startTransaction(); + execAndPrint(table); + + conn.commit(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/notorpredicate1.c b/test/dbapi/Predicate/notorpredicate1.c new file mode 100644 index 00000000..e3d43219 --- /dev/null +++ b/test/dbapi/Predicate/notorpredicate1.c @@ -0,0 +1,113 @@ +//Testing NOT with OR operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with OR operator with NOT operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } +#ifdef WITHF1INDEX + if (createIndex(dbMgr, "f1", "idx1") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF1TREEINDEX + if (createIndex(dbMgr, "f1", "idx1", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + +#ifdef WITHF2INDEX + if (createIndex(dbMgr, "f2","idx2") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF2TREEINDEX + if (createIndex(dbMgr, "f2","idx2", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val3); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1, cond1a; + cond1.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpNot); + table->setCondition(&cond1a); + printf("Predicate: NOT(f1 ==4 OR f2 >3) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a; + cond2.setTerm(p1.getPredicate(), OpOr, p3.getPredicate()); + cond2a.setTerm(cond2.getPredicate(), OpNot); + table->setCondition(&cond2a); + printf("Predicate: NOT( f1 ==4 OR f2 ==4) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond3, cond3a; + cond3.setTerm(p4.getPredicate(), OpOr, p5.getPredicate()); + cond3a.setTerm(cond3.getPredicate(), OpNot); + table->setCondition(&cond3a); + printf("Predicate: NOT( f1 <4 OR f1 >2) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + + Condition cond4, cond4a; + cond4.setTerm(p4.getPredicate(), OpOr, p2.getPredicate()); + cond4a.setTerm(cond4.getPredicate(), OpNot); + table->setCondition(&cond4a); + printf("Predicate: NOT( f1 <4 OR f2 >3) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond5, cond5a; + cond5.setTerm(p2.getPredicate(), OpNot); + cond5a.setTerm(p4.getPredicate(), OpOr, cond5.getPredicate()); + table->setCondition(&cond5a); + printf("Predicate: ( f1 <4 OR (NOT(f2 >3)) \n"); + conn.startTransaction(); + execAndPrint(table); + + conn.commit(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/notpredicate1.c b/test/dbapi/Predicate/notpredicate1.c new file mode 100644 index 00000000..4165c009 --- /dev/null +++ b/test/dbapi/Predicate/notpredicate1.c @@ -0,0 +1,120 @@ +//Testing Not operator with all comparision operator on int data type. +//Five tuples are inserted and then selected using single term predicates +//all with NOT operator +/* +a. NOT(f1 = 3) +b. NOT(f1 != 3) +c. NOT(f1 < 3) +d. NOT(f1 <= 3) +e. NOT(f1 > 3) +f. NOT(f1 >=10) +(notpredicate1.c) + */ +#include + +int id = 0; +char name[196] = "PRABAKARAN"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator test for %d\n", op); + Condition p1; + int val1 = 3; + p1.setTerm("f1", op, &val1); + Condition p2; + p2.setTerm(p1.getPredicate(), OpNot); + table->setCondition(&p2); + table->execute(); + void *tuple; + while ((tuple = (char*) table->fetch())) { + printf("tuple value is %d %s \n", id, name); + } + table->closeScan(); + return 0; +} + +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true ); + tabDef.addField("f2", typeString, 196); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + 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"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + rv =conn.startTransaction(); + for(i = 0; i< 5; i++) + { + if (rv != OK) exit(5); + id= i; + strcpy(name, "PRABAKARAN0123456750590"); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} diff --git a/test/dbapi/Predicate/orandorpredicate1.c b/test/dbapi/Predicate/orandorpredicate1.c new file mode 100644 index 00000000..dec1425b --- /dev/null +++ b/test/dbapi/Predicate/orandorpredicate1.c @@ -0,0 +1,45 @@ + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + Condition p1,p2,p3,p4; + int val1 = 2, val2 = 3, val3 = 5; + p1.setTerm("f1", OpEquals, &val2); + p2.setTerm("f2", OpGreaterThan, &val1); + p3.setTerm("f3", OpNotEquals, &val3); + p4.setTerm("f4", OpLessThan, &val3); + + + Condition cond2, cond2a, cond2b; + cond2.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + cond2a.setTerm(p3.getPredicate(), OpOr, p4.getPredicate()); + cond2b.setTerm(cond2.getPredicate(), OpAnd, cond2a.getPredicate()); + table->setCondition(&cond2b); + printf("Predicate: (f1 ==3 OR f2 > 2) AND (f3 !=5 OR f4 <5) ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/orandpredicate1.c b/test/dbapi/Predicate/orandpredicate1.c new file mode 100644 index 00000000..27c08707 --- /dev/null +++ b/test/dbapi/Predicate/orandpredicate1.c @@ -0,0 +1,59 @@ +//Testing OR with AND operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with AND operator with OR operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val3); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1, cond1a; + cond1.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpAnd, p4.getPredicate()); + table->setCondition(&cond1a); + printf("Predicate: (f1 ==4 OR f2 >3) AND (f1< 4) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a; + cond2.setTerm(p4.getPredicate(), OpOr, p2.getPredicate()); + cond2a.setTerm(cond1.getPredicate(), OpAnd, cond2.getPredicate()); + table->setCondition(&cond2a); + printf("Predicate: (f1 ==4 OR f2 >3) AND (f1< 4 OR f2 > 2) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/ororpredicate1.c b/test/dbapi/Predicate/ororpredicate1.c new file mode 100644 index 00000000..50f1a9d6 --- /dev/null +++ b/test/dbapi/Predicate/ororpredicate1.c @@ -0,0 +1,61 @@ +//Testing OR with OR operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 5; + p1.setTerm("f1", OpEquals, &val2); + p2.setTerm("f2", OpGreaterThan, &val1); + p3.setTerm("f3", OpNotEquals, &val3); + p4.setTerm("f4", OpLessThan, &val3); + p5.setTerm("f5", OpGreaterThanEquals, &val2); + + + Condition cond1, cond1a, cond1b, cond1c; + cond1.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + cond1a.setTerm(cond1.getPredicate(), OpOr, p3.getPredicate()); + cond1b.setTerm(cond1a.getPredicate(), OpOr, p4.getPredicate()); + cond1c.setTerm(cond1b.getPredicate(), OpOr, p5.getPredicate()); + table->setCondition(&cond1c); + printf("Predicate: (f1 ==3 OR f2 > 2 OR f3 !=5 OR f4 <5 OR f5 >=3 ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2, cond2a, cond2b; + cond2.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + cond2a.setTerm(p3.getPredicate(), OpOr, p4.getPredicate()); + cond2b.setTerm(cond2.getPredicate(), OpOr, cond2a.getPredicate()); + table->setCondition(&cond2b); + printf("Predicate: (f1 ==3 OR f2 > 2) OR (f3 !=5 OR f4 <5) ) \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/orpredicate1.c b/test/dbapi/Predicate/orpredicate1.c new file mode 100644 index 00000000..9e3ec04f --- /dev/null +++ b/test/dbapi/Predicate/orpredicate1.c @@ -0,0 +1,100 @@ +//Testing OR operator with all comparision operator on int data type. +//Five tuples are inserted and then selected by setting predicates +//with OR operator + +#include "common.h" +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + if ( createTable(dbMgr) != 0 ) { conn.close(); return 3; } +#ifdef WITHF1INDEX + if (createIndex(dbMgr, "f1", "idx1") != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF1TREEINDEX + if (createIndex(dbMgr, "f1", "idx1", true) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + +#ifdef WITHF2INDEX + if (createIndex(dbMgr, "f2", "idx2" ) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif +#ifdef WITHF2TREEINDEX + if (createIndex(dbMgr, "f2", "idx2",true ) != 0) {dbMgr->dropTable("t1"); + conn.close(); + return 4; + } +#endif + + int inscount = insertTuple(dbMgr, conn); + //check the inscount and return error + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + return 0; + } + + + Condition p1,p2,p3,p4,p5; + int val1 = 2, val2 = 3, val3 = 4; + p1.setTerm("f1", OpEquals, &val3); + p2.setTerm("f2", OpGreaterThan, &val2); + p3.setTerm("f2", OpEquals, &val3); + p4.setTerm("f1", OpLessThan, &val3); + p5.setTerm("f1", OpGreaterThan, &val1); + + + Condition cond1; + cond1.setTerm(p1.getPredicate(), OpOr, p2.getPredicate()); + table->setCondition(&cond1); + printf("Predicate: f1 ==4 OR f2 >3 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond2; + cond2.setTerm(p1.getPredicate(), OpOr, p3.getPredicate()); + table->setCondition(&cond2); + printf("Predicate: f1 ==4 OR f2 ==4 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + Condition cond3; + cond3.setTerm(p4.getPredicate(), OpOr, p5.getPredicate()); + table->setCondition(&cond3); + printf("Predicate: f1 <4 OR f1 >2 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + + Condition cond4; + cond4.setTerm(p4.getPredicate(), OpOr, p2.getPredicate()); + table->setCondition(&cond4); + printf("Predicate: f1 <4 OR f2 >3 \n"); + conn.startTransaction(); + execAndPrint(table); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; + +} + diff --git a/test/dbapi/Predicate/predicate1.c b/test/dbapi/Predicate/predicate1.c new file mode 100644 index 00000000..81aceb35 --- /dev/null +++ b/test/dbapi/Predicate/predicate1.c @@ -0,0 +1,115 @@ +/* +a. f1=10 +b. f1!= 10 +c. f1<10 +d. f1<=10 +e. f1>10 +f. f1>=10 +*/ +#include +int id=0; +char name[100];//="NIHAR"; +int select(Table *table, ComparisionOp op) +{ + printf("Operator Test for %d\n",op); + Condition p1; + int val1=10; + p1.setTerm("f1",op,&val1); + table->setCondition(&p1); + table->execute(); + void *tuple; + while((tuple=(char*) table->fetch())) + { + printf("Tuple is %d %s \n",id,name); + } + table->closeScan(); + return 0; +} + +int main() +{ + Connection conn; + DbRetVal rv=conn.open("root","manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return 1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true ); + tabDef.addField("f2", typeString, 100); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return 3; } + printf("Table created\n"); +#ifdef WITHINDEX + 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"); + delete idxInfo; +#endif +#ifdef WITHTREEINDEX + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + delete idxInfo; +#endif + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return 4; } + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + char nam[100]; + rv =conn.startTransaction(); + for(i = 6; i< 12; i++) + { + if (rv != OK) exit(5); + id= i; + sprintf(nam,"%s%d","NIHAR",i); + strcpy(name, nam); + ret = table->insertTuple(); + if (ret != 0) break; + } + conn.commit(); + conn.startTransaction(); + select(table, OpEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpNotEquals); + conn.commit(); + + conn.startTransaction(); + select(table, OpLessThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpLessThanEquals); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThan); + conn.commit(); + + conn.startTransaction(); + select( table, OpGreaterThanEquals); + conn.commit(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + + conn.close(); + return 0; +} + diff --git a/test/dbapi/Table/Makefile b/test/dbapi/Table/Makefile new file mode 100644 index 00000000..74c72fe4 --- /dev/null +++ b/test/dbapi/Table/Makefile @@ -0,0 +1,95 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 \ + test002 \ + insert \ + test004 \ + test005 \ + test006 \ + test007 \ + test010 \ + test020 \ + test021 \ + test022 \ + test023 \ + test024 \ + test025 \ + test026 \ + test027 \ + test100 test101 test102 + + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: inserttest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002: inserttest2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +insert: inserttest3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004: insertnulltest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005: insertnulltest2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006: insertnulltest3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007:insertnulltest4.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +test010: duptable1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test020: bindtest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test021: bindtest2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test022:bindtest3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test023 :spaceusedtest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test024 :insertnulltest5.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test025 :insertnulltest6.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test026 :insertnulltest7.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test027 :insertnulltest8.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test100 :dbfull1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test101 :dbfull2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test102 :dbfull3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/Table/bindtest1.c b/test/dbapi/Table/bindtest1.c new file mode 100644 index 00000000..909a6bf3 --- /dev/null +++ b/test/dbapi/Table/bindtest1.c @@ -0,0 +1,38 @@ +#include +//bind non exisiting field +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 20); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + int ret =0; + char name[20] = "PRAVEEN"; + rv = table->bindFld("f1", &id1); + if (rv != OK) ret = 1; + rv = table->bindFld("f5", &id2); + if (rv == OK) ret = 1; + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Table/bindtest2.c b/test/dbapi/Table/bindtest2.c new file mode 100644 index 00000000..62d3a61b --- /dev/null +++ b/test/dbapi/Table/bindtest2.c @@ -0,0 +1,49 @@ +#include +//bind twice the same field. +//the later should have the effect +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + 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"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 1, id2 = 5, id3 = 8; + int ret =0; + char name[20] = "PRAVEEN"; + rv = table->bindFld("f1", &id1); + if (rv != OK) ret = 1; + rv = table->bindFld("f2", &id2); + if (rv != OK) ret = 2; + rv = table->bindFld("f2", &id3); + if (rv != OK) ret = 3; + conn.startTransaction(); + rv = table->insertTuple(); + conn.commit(); + conn.startTransaction(); + table->execute(); + char *tuple = (char*)table->fetch(); + int value = *(int*)((char*)tuple + 4); + if (value !=8) ret = 5; + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Table/bindtest3.c b/test/dbapi/Table/bindtest3.c new file mode 100644 index 00000000..26c54491 --- /dev/null +++ b/test/dbapi/Table/bindtest3.c @@ -0,0 +1,81 @@ +/* create table with two fields f1(not null) and f2 + * f1 field in not binded + * when fetching count variable should be zero. + +* Author : Jitendra Lenka +*/ + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root","manager"); + if(rv!=OK)return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if(dbMgr == NULL) + { + printf("Auth failed\n"); + return 2; + } + + 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 3; + } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if(table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + + int id1=0; + table->bindFld("f2",&id1); + int count=0; + for(int i=0;i<5;i++) + { + conn.startTransaction(); + id1=i; + rv = table->insertTuple(); + if(rv!=OK) { conn.rollback(); break; } + count++; + conn.commit(); + } + + printf("Total row inserted=%d\n",count); + + void *tuple, *fld; + count=0; + table->setCondition(NULL); + conn.startTransaction(); + rv = table->execute(); + if(rv!=OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + while(1) + { + tuple = (char*)table->fetch(); + if(tuple == NULL){break;} + fld = (char*)tuple + os::align(sizeof(int)); + printf("Tuple value is %d %d\n",*((int*)tuple),*((int*)fld)); + } + table->closeScan(); + conn.commit(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/csql.conf b/test/dbapi/Table/csql.conf new file mode 100644 index 00000000..6b245b65 --- /dev/null +++ b/test/dbapi/Table/csql.conf @@ -0,0 +1,161 @@ +# CSQL System Configuration File + +#####################################Server Section######################## + +# Site ID for this CSQL server +SITE_ID=1 + +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined + +# Page size. Each database is logically divided into pages and allocation happens +# in this unit of pages. Increasing this value will reduce frequent allocation of pages. +PAGE_SIZE= 8192 + +#Total number of client process which can connect and work with the +# database concurrently +MAX_PROCS = 100 + +# Maximum size of the system database. +MAX_SYS_DB_SIZE=10485760 + +#Maximum size of the user database file. +MAX_DB_SIZE=335544320 + +#Shared memory key to be used by the system to create and locate system database. +SYS_DB_KEY=7117 + +#Shared memory key to be used by the system to create and locate user database. +USER_DB_KEY=1771 + +#Log level 0->no logging 1->Fine 2->Finer 3->Finest +LOG_LEVEL=0 + +#Give full path for the log file where important system actions are stored. +LOG_FILE=/tmp/csql/log/log.out + +#The virtual memory start address at which the shared memory segment +# will be created and attached. +MAP_ADDRESS=400000000 + +# Whether to enable durability +DURABILITY=false + +#checkpoint server interval in seconds +CHECKPOINT_SECS=600 + +#minimum redo log size for checkpoint to be initiated +CHECKPOINT_LOG_SIZE=10485760 + +# Whether to enable memory map architecture for user database +MMAP=true + +# Specifies the durability mode for redo log generation +# Valid values are +# 1 ->uses standard redo logging with O_APPEND mode +# 2 ->uses standard logging with serialization +# 3 ->uses O_SYNC flag +# 4 ->uses O_DIRECT flag + +DURABLE_MODE=1 + +#Give full path for the database file where table and record information will +#be stored for durability +DATABASE_FILE=/tmp/csql/db + +#Important: For Server section parameters, make sure that the value is same for the server process and all the csql client process which connects to it. otherwise, behavior is undefined + +# Give full path for the std error file to store all the errors during database operations +STDERR_FILE=stderr + +#Restarts auxillary servers (SQL, Cache,etc), if they crash +MONITOR_SERVERS=false + +#####################################Client Section######################## + +#Mutex timeout interval seconds +MUTEX_TIMEOUT_SECS=0 +MUTEX_TIMEOUT_USECS=5000 +MUTEX_TIMEOUT_RETRIES=10 + +#Lock timeout interval seconds +LOCK_TIMEOUT_SECS=0 +LOCK_TIMEOUT_USECS=5000 +LOCK_TIMEOUT_RETRIES=10 + +#Statement Cache Size +STMT_CACHE_SIZE=10 + +#Enable statement cache for statements with no parameters +#Only SELECT statement with no date, time, timestamp fields will be cached. +STMT_CACHE_NOPARAM=false + +#####################################Cache Section######################## + +#Whether to enable caching of tables from target database +CACHE_TABLE=false + +#DSN Name to connect to the target database. +#This should be present in ~/odbc.ini file +DSN=myodbc3 + +# Whethere to enable bidirectional updates for cached tables. +ENABLE_BIDIRECTIONAL_CACHE=false + +CACHE_RECEIVER_WAIT_SECS=10 + +#Mode of operation SYNC or ASYNC +CACHE_MODE=SYNC + +# If CACHE_MODE=OFFLINE then size of OfflineLogFile +OFFLINE_FILE_SIZE=1048576 + +##########################SqlNetworkServer Section######################## + +# Whether to enable SqlNetwork server +CSQL_SQL_SERVER=false + +#Set port for Network access +PORT=5678 + +# Max number of seconds that the network layer waits to receive a pkt +NETWORK_RESPONSE_TIMEOUT=3 + +# Max number of seconds that the network layer waits to connect to sql server +NETWORK_CONNECT_TIMEOUT=5 + +#Whether to enable Replication across the sites +REPLICATION=false + +#No of sites to replicate +REPLICATION_SITES=16 + +#Give full path for the file where all the table information is stored +TABLE_CONFIG_FILE=/tmp/csql/csqltable.conf + +#Give full path of the file where all the DSN information is stored +DS_CONFIG_FILE=/tmp/csql/csqlds.conf + +#Give full path for the file where all the peer site information is stored +NETWORK_CONFIG_FILE=/tmp/csql/csqlnw.conf + +# Give full path for conflict Resolution file +CONFL_RESOL_FILE=/tmp/csql/conflResoFile.txt + +# MSGKEY for creating msg queue for MsgQueue Server +MSG_KEY=2525 + +# Maximum message that the message queue server is able to handle for +# asynchronous updates. This value is is default value of 'kernel.msgmax' +# parameter. +ASYNC_MSGMAX=8192 + +# Maximum number of messages that the message queue server will hold for a site +# that is down in the replication group. +MAX_QUEUE_LOGS=100 + +# Shared memory key for id generators +ID_SHM_KEY=1947 +#####################################End Section######################## + diff --git a/test/dbapi/Table/dbfull1.c b/test/dbapi/Table/dbfull1.c new file mode 100644 index 00000000..b7061a8c --- /dev/null +++ b/test/dbapi/Table/dbfull1.c @@ -0,0 +1,85 @@ +// Test Case: DB Full test with only table +// Create table +// Insert 4000 records +// Note:Each page can hold 4 records. +// For 100 iterations, delete and insert 1000 records +// Result:In all 100 iterations operations should succeed + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 2000); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int i=0; + for (i = 0 ; i < 4000; i++) + { + conn.startTransaction(); + id1= i; + rv = table->insertTuple(); + if (rv != OK) break; + conn.commit(); + } + printf("%d records inserted\n", i); + for (int k=0; k <100; k++) { + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) { + printf("table execute failed rv:%d\n", rv); + dbMgr->closeTable(table); + conn.close(); + return 1; + } + void *tuple = NULL; + for (i = 0 ; i < 1000 ; i++) + { + conn.startTransaction(); + tuple = table->fetchNoBind(); + if (tuple == NULL) { printf("No more records\n"); break; } + rv = table->deleteTuple(); + if (rv != OK) { printf("Delete tuple failed\n"); break;} + conn.commit(); + } + table->closeScan(); + printf("Iteration:%d \n %d records deleted\n", k, i); + i=0; + for (i = 0 ; i < 1000 ; i++) + { + conn.startTransaction(); + id1= i; + rv = table->insertTuple(); + if (rv != OK) break; + conn.commit(); + } + printf("%d records inserted\n", i); + } + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/dbfull2.c b/test/dbapi/Table/dbfull2.c new file mode 100644 index 00000000..5596d56c --- /dev/null +++ b/test/dbapi/Table/dbfull2.c @@ -0,0 +1,97 @@ +// Test Case: DB Full test with table and two index(hash and tree) +// Create table +// Insert 4000 records +// Note:Each page can hold 4 records. +// For 100 iterations, delete and insert 1000 records +// Result:In all 100 iterations operations should succeed + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt, 0, NULL, true); + tabDef.addField("f3", typeString, 2000); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + idxInfo->list.remove("f1"); + idxInfo->list.append("f2"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx2", idxInfo); + delete idxInfo; + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int i=0; + for (i = 0 ; i < 4000 ; i++) + { + conn.startTransaction(); + id1= i; + id2= i; + rv = table->insertTuple(); + if (rv != OK) break; + conn.commit(); + } + printf("%d records inserted\n", i); + for (int k=0; k <100; k++) { + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) { + printf("table execute failed rv:%d\n", rv); + dbMgr->closeTable(table); + conn.close(); + return 1; + } + void *tuple = NULL; + for (i = 0 ; i < 1000 ; i++) + { + conn.startTransaction(); + tuple = table->fetchNoBind(); + if (tuple == NULL) { printf("No more records\n"); break; } + rv = table->deleteTuple(); + if (rv != OK) { printf("Delete tuple failed\n"); break;} + conn.commit(); + } + table->closeScan(); + printf("Iteration:%d \n %d records deleted\n", k, i); + i=0; + for (i = 0 ; i < 1000 ; i++) + { + conn.startTransaction(); + id1= i; + id2= i; + rv = table->insertTuple(); + if (rv != OK) break; + conn.commit(); + } + printf("%d records inserted\n", i); + } + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/dbfull3.c b/test/dbapi/Table/dbfull3.c new file mode 100644 index 00000000..8aee457b --- /dev/null +++ b/test/dbapi/Table/dbfull3.c @@ -0,0 +1,101 @@ +// Test Case: DB Full test with table and two index(hash and tree) +// Create table +// Insert 4000 records +// Note:Each page can hold 4 records. +// For 100 iterations, delete and insert 4000 records +// Result:In all 100 iterations operations should succeed + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt, 0, NULL, true); + tabDef.addField("f3", typeString, 2000); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + idxInfo->list.remove("f1"); + idxInfo->list.append("f2"); + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx2", idxInfo); + delete idxInfo; + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int i=0; + for (i = 0 ; i < 4000 ; i++) + { + conn.startTransaction(); + id1= i; + id2= i; + rv = table->insertTuple(); + if (rv != OK) break; + conn.commit(); + } + printf("%d records inserted\n", i); + //sleep(10); + for (int k=0; k <100; k++) { + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) { + printf("table execute failed rv:%d\n", rv); + dbMgr->closeTable(table); + conn.close(); + return 1; + } + void *tuple = NULL; + conn.startTransaction(); + for (i = 0 ; i < 4000 ; i++) + { + tuple = table->fetchNoBind(); + if (tuple == NULL) { printf("No more records\n"); break; } + rv = table->deleteTuple(); + if (rv != OK) { printf("Delete tuple failed\n"); break;} + if (i%50 == 0) { conn.commit(); conn.startTransaction(); } + } + conn.commit(); + table->closeScan(); + printf("Iteration:%d \n %d records deleted\n", k, i); + i=0; + conn.startTransaction(); + for (i = 0 ; i < 4000 ; i++) + { + id1= i; + id2= i; + rv = table->insertTuple(); + if (rv != OK) break; + if (i%50 == 0) { conn.commit(); conn.startTransaction(); } + } + conn.commit(); + printf("%d records inserted\n", i); + } + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/duptable1.c b/test/dbapi/Table/duptable1.c new file mode 100644 index 00000000..b48a8c14 --- /dev/null +++ b/test/dbapi/Table/duptable1.c @@ -0,0 +1,24 @@ +#include +//create two table with same name +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 20); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + int ret =0; + rv = dbMgr->createTable("t1", tabDef); + if (rv == OK) ret =1; + dbMgr->dropTable("t1"); + conn.close(); + return ret; +} diff --git a/test/dbapi/Table/exp.test001 b/test/dbapi/Table/exp.test001 new file mode 100644 index 00000000..a84c214f --- /dev/null +++ b/test/dbapi/Table/exp.test001 @@ -0,0 +1,43 @@ +Table created +Tuples inserted in 1/txn is 10 +Tuples inserted in 10/txn is 10 +Tuple value is 0 5 PRAVEEN +Binded Tuple value is 0 5 PRAVEEN +Tuple value is 1 5 PRAVEEN +Binded Tuple value is 1 5 PRAVEEN +Tuple value is 2 5 PRAVEEN +Binded Tuple value is 2 5 PRAVEEN +Tuple value is 3 5 PRAVEEN +Binded Tuple value is 3 5 PRAVEEN +Tuple value is 4 5 PRAVEEN +Binded Tuple value is 4 5 PRAVEEN +Tuple value is 5 5 PRAVEEN +Binded Tuple value is 5 5 PRAVEEN +Tuple value is 6 5 PRAVEEN +Binded Tuple value is 6 5 PRAVEEN +Tuple value is 7 5 PRAVEEN +Binded Tuple value is 7 5 PRAVEEN +Tuple value is 8 5 PRAVEEN +Binded Tuple value is 8 5 PRAVEEN +Tuple value is 9 5 PRAVEEN +Binded Tuple value is 9 5 PRAVEEN +Tuple value is 20 5 PRAVEEN +Binded Tuple value is 20 5 PRAVEEN +Tuple value is 21 5 PRAVEEN +Binded Tuple value is 21 5 PRAVEEN +Tuple value is 22 5 PRAVEEN +Binded Tuple value is 22 5 PRAVEEN +Tuple value is 23 5 PRAVEEN +Binded Tuple value is 23 5 PRAVEEN +Tuple value is 24 5 PRAVEEN +Binded Tuple value is 24 5 PRAVEEN +Tuple value is 25 5 PRAVEEN +Binded Tuple value is 25 5 PRAVEEN +Tuple value is 26 5 PRAVEEN +Binded Tuple value is 26 5 PRAVEEN +Tuple value is 27 5 PRAVEEN +Binded Tuple value is 27 5 PRAVEEN +Tuple value is 28 5 PRAVEEN +Binded Tuple value is 28 5 PRAVEEN +Tuple value is 29 5 PRAVEEN +Binded Tuple value is 29 5 PRAVEEN diff --git a/test/dbapi/Table/exp.test004 b/test/dbapi/Table/exp.test004 new file mode 100644 index 00000000..1c924587 --- /dev/null +++ b/test/dbapi/Table/exp.test004 @@ -0,0 +1,17 @@ +Table created +Tuples inserted in 1/txn is 10 +Column 2 is null +Binded Tuple value is 0 5 PRAVEEN +Binded Tuple value is 1 5 PRAVEEN +Column 2 is null +Binded Tuple value is 2 5 PRAVEEN +Binded Tuple value is 3 5 PRAVEEN +Column 2 is null +Binded Tuple value is 4 5 PRAVEEN +Binded Tuple value is 5 5 PRAVEEN +Column 2 is null +Binded Tuple value is 6 5 PRAVEEN +Binded Tuple value is 7 5 PRAVEEN +Column 2 is null +Binded Tuple value is 8 5 PRAVEEN +Binded Tuple value is 9 5 PRAVEEN diff --git a/test/dbapi/Table/exp.test005 b/test/dbapi/Table/exp.test005 new file mode 100644 index 00000000..f046c484 --- /dev/null +++ b/test/dbapi/Table/exp.test005 @@ -0,0 +1,10 @@ +Table created +Tuples inserted in 1/txn is 5 +Column 3 is null +Binded Tuple value is 0 5 PRAVEEN +Binded Tuple value is 1 5 PRAVEEN +Column 3 is null +Binded Tuple value is 2 5 PRAVEEN +Binded Tuple value is 3 5 PRAVEEN +Column 3 is null +Binded Tuple value is 4 5 PRAVEEN diff --git a/test/dbapi/Table/exp.test006 b/test/dbapi/Table/exp.test006 new file mode 100644 index 00000000..3b9a0c55 --- /dev/null +++ b/test/dbapi/Table/exp.test006 @@ -0,0 +1,12 @@ +Table created +Tuples inserted in 1/txn is 5 +Column 3 is null +Binded Tuple value is 0 5 unchangedvalue +Column 3 is null +Binded Tuple value is 1 5 unchangedvalue +Column 3 is null +Binded Tuple value is 2 5 unchangedvalue +Column 3 is null +Binded Tuple value is 3 5 unchangedvalue +Column 3 is null +Binded Tuple value is 4 5 unchangedvalue diff --git a/test/dbapi/Table/exp.test007 b/test/dbapi/Table/exp.test007 new file mode 100644 index 00000000..f47c4ba8 --- /dev/null +++ b/test/dbapi/Table/exp.test007 @@ -0,0 +1,22 @@ +Table created +Tuples inserted in 1/txn is 10 +Column 2 is null +Binded Tuple value is 0 5 +Column 2 is null +Binded Tuple value is 1 5 +Column 2 is null +Binded Tuple value is 2 5 +Column 2 is null +Binded Tuple value is 3 5 +Column 2 is null +Binded Tuple value is 4 5 +Column 2 is null +Binded Tuple value is 5 5 +Column 2 is null +Binded Tuple value is 6 5 +Column 2 is null +Binded Tuple value is 7 5 +Column 2 is null +Binded Tuple value is 8 5 +Column 2 is null +Binded Tuple value is 9 5 diff --git a/test/dbapi/Table/exp.test022 b/test/dbapi/Table/exp.test022 new file mode 100644 index 00000000..029e6bb9 --- /dev/null +++ b/test/dbapi/Table/exp.test022 @@ -0,0 +1,2 @@ +Table created +Total row inserted=0 diff --git a/test/dbapi/Table/exp.test024 b/test/dbapi/Table/exp.test024 new file mode 100644 index 00000000..f046c484 --- /dev/null +++ b/test/dbapi/Table/exp.test024 @@ -0,0 +1,10 @@ +Table created +Tuples inserted in 1/txn is 5 +Column 3 is null +Binded Tuple value is 0 5 PRAVEEN +Binded Tuple value is 1 5 PRAVEEN +Column 3 is null +Binded Tuple value is 2 5 PRAVEEN +Binded Tuple value is 3 5 PRAVEEN +Column 3 is null +Binded Tuple value is 4 5 PRAVEEN diff --git a/test/dbapi/Table/exp.test026 b/test/dbapi/Table/exp.test026 new file mode 100644 index 00000000..1ecc12b8 --- /dev/null +++ b/test/dbapi/Table/exp.test026 @@ -0,0 +1,7 @@ +Table created +Tuples inserted in 1/txn is 5 +Binded Tuple value is 1 6 +Binded Tuple value is 3 11 +Binded Tuple value is 5 20 +Binded Tuple value is 7 33 +Binded Tuple value is 9 50 diff --git a/test/dbapi/Table/exp.test027 b/test/dbapi/Table/exp.test027 new file mode 100644 index 00000000..41f941af --- /dev/null +++ b/test/dbapi/Table/exp.test027 @@ -0,0 +1,32 @@ +Table created +Tuples inserted in 1/txn is 6 +Binded Tuple value is 0 5 10 +Column 3 is null +Binded Tuple value is 1 5 10 +Column 2 is null +Binded Tuple value is 2 5 10 +Column 3 is null +Binded Tuple value is 3 5 10 +Column 2 is null +Binded Tuple value is 4 5 10 +Column 3 is null +Binded Tuple value is 5 5 10 +NULL Violation +NULL Violation +NULL Violation +NULL Violation +Scan after updation +******************** +f1 | f2 | f3 +-------------------------- +0 | 5 | 10 +Column 3 is null +1 | 5 | 10 +Column 2 is null +2 | 5 | 10 +Column 3 is null +3 | 5 | 10 +Column 2 is null +4 | 5 | 10 +Column 3 is null +5 | 5 | 10 diff --git a/test/dbapi/Table/exp.test100 b/test/dbapi/Table/exp.test100 new file mode 100644 index 00000000..442eca9d --- /dev/null +++ b/test/dbapi/Table/exp.test100 @@ -0,0 +1,302 @@ +Table created +4000 records inserted +Iteration:0 + 1000 records deleted +1000 records inserted +Iteration:1 + 1000 records deleted +1000 records inserted +Iteration:2 + 1000 records deleted +1000 records inserted +Iteration:3 + 1000 records deleted +1000 records inserted +Iteration:4 + 1000 records deleted +1000 records inserted +Iteration:5 + 1000 records deleted +1000 records inserted +Iteration:6 + 1000 records deleted +1000 records inserted +Iteration:7 + 1000 records deleted +1000 records inserted +Iteration:8 + 1000 records deleted +1000 records inserted +Iteration:9 + 1000 records deleted +1000 records inserted +Iteration:10 + 1000 records deleted +1000 records inserted +Iteration:11 + 1000 records deleted +1000 records inserted +Iteration:12 + 1000 records deleted +1000 records inserted +Iteration:13 + 1000 records deleted +1000 records inserted +Iteration:14 + 1000 records deleted +1000 records inserted +Iteration:15 + 1000 records deleted +1000 records inserted +Iteration:16 + 1000 records deleted +1000 records inserted +Iteration:17 + 1000 records deleted +1000 records inserted +Iteration:18 + 1000 records deleted +1000 records inserted +Iteration:19 + 1000 records deleted +1000 records inserted +Iteration:20 + 1000 records deleted +1000 records inserted +Iteration:21 + 1000 records deleted +1000 records inserted +Iteration:22 + 1000 records deleted +1000 records inserted +Iteration:23 + 1000 records deleted +1000 records inserted +Iteration:24 + 1000 records deleted +1000 records inserted +Iteration:25 + 1000 records deleted +1000 records inserted +Iteration:26 + 1000 records deleted +1000 records inserted +Iteration:27 + 1000 records deleted +1000 records inserted +Iteration:28 + 1000 records deleted +1000 records inserted +Iteration:29 + 1000 records deleted +1000 records inserted +Iteration:30 + 1000 records deleted +1000 records inserted +Iteration:31 + 1000 records deleted +1000 records inserted +Iteration:32 + 1000 records deleted +1000 records inserted +Iteration:33 + 1000 records deleted +1000 records inserted +Iteration:34 + 1000 records deleted +1000 records inserted +Iteration:35 + 1000 records deleted +1000 records inserted +Iteration:36 + 1000 records deleted +1000 records inserted +Iteration:37 + 1000 records deleted +1000 records inserted +Iteration:38 + 1000 records deleted +1000 records inserted +Iteration:39 + 1000 records deleted +1000 records inserted +Iteration:40 + 1000 records deleted +1000 records inserted +Iteration:41 + 1000 records deleted +1000 records inserted +Iteration:42 + 1000 records deleted +1000 records inserted +Iteration:43 + 1000 records deleted +1000 records inserted +Iteration:44 + 1000 records deleted +1000 records inserted +Iteration:45 + 1000 records deleted +1000 records inserted +Iteration:46 + 1000 records deleted +1000 records inserted +Iteration:47 + 1000 records deleted +1000 records inserted +Iteration:48 + 1000 records deleted +1000 records inserted +Iteration:49 + 1000 records deleted +1000 records inserted +Iteration:50 + 1000 records deleted +1000 records inserted +Iteration:51 + 1000 records deleted +1000 records inserted +Iteration:52 + 1000 records deleted +1000 records inserted +Iteration:53 + 1000 records deleted +1000 records inserted +Iteration:54 + 1000 records deleted +1000 records inserted +Iteration:55 + 1000 records deleted +1000 records inserted +Iteration:56 + 1000 records deleted +1000 records inserted +Iteration:57 + 1000 records deleted +1000 records inserted +Iteration:58 + 1000 records deleted +1000 records inserted +Iteration:59 + 1000 records deleted +1000 records inserted +Iteration:60 + 1000 records deleted +1000 records inserted +Iteration:61 + 1000 records deleted +1000 records inserted +Iteration:62 + 1000 records deleted +1000 records inserted +Iteration:63 + 1000 records deleted +1000 records inserted +Iteration:64 + 1000 records deleted +1000 records inserted +Iteration:65 + 1000 records deleted +1000 records inserted +Iteration:66 + 1000 records deleted +1000 records inserted +Iteration:67 + 1000 records deleted +1000 records inserted +Iteration:68 + 1000 records deleted +1000 records inserted +Iteration:69 + 1000 records deleted +1000 records inserted +Iteration:70 + 1000 records deleted +1000 records inserted +Iteration:71 + 1000 records deleted +1000 records inserted +Iteration:72 + 1000 records deleted +1000 records inserted +Iteration:73 + 1000 records deleted +1000 records inserted +Iteration:74 + 1000 records deleted +1000 records inserted +Iteration:75 + 1000 records deleted +1000 records inserted +Iteration:76 + 1000 records deleted +1000 records inserted +Iteration:77 + 1000 records deleted +1000 records inserted +Iteration:78 + 1000 records deleted +1000 records inserted +Iteration:79 + 1000 records deleted +1000 records inserted +Iteration:80 + 1000 records deleted +1000 records inserted +Iteration:81 + 1000 records deleted +1000 records inserted +Iteration:82 + 1000 records deleted +1000 records inserted +Iteration:83 + 1000 records deleted +1000 records inserted +Iteration:84 + 1000 records deleted +1000 records inserted +Iteration:85 + 1000 records deleted +1000 records inserted +Iteration:86 + 1000 records deleted +1000 records inserted +Iteration:87 + 1000 records deleted +1000 records inserted +Iteration:88 + 1000 records deleted +1000 records inserted +Iteration:89 + 1000 records deleted +1000 records inserted +Iteration:90 + 1000 records deleted +1000 records inserted +Iteration:91 + 1000 records deleted +1000 records inserted +Iteration:92 + 1000 records deleted +1000 records inserted +Iteration:93 + 1000 records deleted +1000 records inserted +Iteration:94 + 1000 records deleted +1000 records inserted +Iteration:95 + 1000 records deleted +1000 records inserted +Iteration:96 + 1000 records deleted +1000 records inserted +Iteration:97 + 1000 records deleted +1000 records inserted +Iteration:98 + 1000 records deleted +1000 records inserted +Iteration:99 + 1000 records deleted +1000 records inserted diff --git a/test/dbapi/Table/exp.test101 b/test/dbapi/Table/exp.test101 new file mode 100644 index 00000000..442eca9d --- /dev/null +++ b/test/dbapi/Table/exp.test101 @@ -0,0 +1,302 @@ +Table created +4000 records inserted +Iteration:0 + 1000 records deleted +1000 records inserted +Iteration:1 + 1000 records deleted +1000 records inserted +Iteration:2 + 1000 records deleted +1000 records inserted +Iteration:3 + 1000 records deleted +1000 records inserted +Iteration:4 + 1000 records deleted +1000 records inserted +Iteration:5 + 1000 records deleted +1000 records inserted +Iteration:6 + 1000 records deleted +1000 records inserted +Iteration:7 + 1000 records deleted +1000 records inserted +Iteration:8 + 1000 records deleted +1000 records inserted +Iteration:9 + 1000 records deleted +1000 records inserted +Iteration:10 + 1000 records deleted +1000 records inserted +Iteration:11 + 1000 records deleted +1000 records inserted +Iteration:12 + 1000 records deleted +1000 records inserted +Iteration:13 + 1000 records deleted +1000 records inserted +Iteration:14 + 1000 records deleted +1000 records inserted +Iteration:15 + 1000 records deleted +1000 records inserted +Iteration:16 + 1000 records deleted +1000 records inserted +Iteration:17 + 1000 records deleted +1000 records inserted +Iteration:18 + 1000 records deleted +1000 records inserted +Iteration:19 + 1000 records deleted +1000 records inserted +Iteration:20 + 1000 records deleted +1000 records inserted +Iteration:21 + 1000 records deleted +1000 records inserted +Iteration:22 + 1000 records deleted +1000 records inserted +Iteration:23 + 1000 records deleted +1000 records inserted +Iteration:24 + 1000 records deleted +1000 records inserted +Iteration:25 + 1000 records deleted +1000 records inserted +Iteration:26 + 1000 records deleted +1000 records inserted +Iteration:27 + 1000 records deleted +1000 records inserted +Iteration:28 + 1000 records deleted +1000 records inserted +Iteration:29 + 1000 records deleted +1000 records inserted +Iteration:30 + 1000 records deleted +1000 records inserted +Iteration:31 + 1000 records deleted +1000 records inserted +Iteration:32 + 1000 records deleted +1000 records inserted +Iteration:33 + 1000 records deleted +1000 records inserted +Iteration:34 + 1000 records deleted +1000 records inserted +Iteration:35 + 1000 records deleted +1000 records inserted +Iteration:36 + 1000 records deleted +1000 records inserted +Iteration:37 + 1000 records deleted +1000 records inserted +Iteration:38 + 1000 records deleted +1000 records inserted +Iteration:39 + 1000 records deleted +1000 records inserted +Iteration:40 + 1000 records deleted +1000 records inserted +Iteration:41 + 1000 records deleted +1000 records inserted +Iteration:42 + 1000 records deleted +1000 records inserted +Iteration:43 + 1000 records deleted +1000 records inserted +Iteration:44 + 1000 records deleted +1000 records inserted +Iteration:45 + 1000 records deleted +1000 records inserted +Iteration:46 + 1000 records deleted +1000 records inserted +Iteration:47 + 1000 records deleted +1000 records inserted +Iteration:48 + 1000 records deleted +1000 records inserted +Iteration:49 + 1000 records deleted +1000 records inserted +Iteration:50 + 1000 records deleted +1000 records inserted +Iteration:51 + 1000 records deleted +1000 records inserted +Iteration:52 + 1000 records deleted +1000 records inserted +Iteration:53 + 1000 records deleted +1000 records inserted +Iteration:54 + 1000 records deleted +1000 records inserted +Iteration:55 + 1000 records deleted +1000 records inserted +Iteration:56 + 1000 records deleted +1000 records inserted +Iteration:57 + 1000 records deleted +1000 records inserted +Iteration:58 + 1000 records deleted +1000 records inserted +Iteration:59 + 1000 records deleted +1000 records inserted +Iteration:60 + 1000 records deleted +1000 records inserted +Iteration:61 + 1000 records deleted +1000 records inserted +Iteration:62 + 1000 records deleted +1000 records inserted +Iteration:63 + 1000 records deleted +1000 records inserted +Iteration:64 + 1000 records deleted +1000 records inserted +Iteration:65 + 1000 records deleted +1000 records inserted +Iteration:66 + 1000 records deleted +1000 records inserted +Iteration:67 + 1000 records deleted +1000 records inserted +Iteration:68 + 1000 records deleted +1000 records inserted +Iteration:69 + 1000 records deleted +1000 records inserted +Iteration:70 + 1000 records deleted +1000 records inserted +Iteration:71 + 1000 records deleted +1000 records inserted +Iteration:72 + 1000 records deleted +1000 records inserted +Iteration:73 + 1000 records deleted +1000 records inserted +Iteration:74 + 1000 records deleted +1000 records inserted +Iteration:75 + 1000 records deleted +1000 records inserted +Iteration:76 + 1000 records deleted +1000 records inserted +Iteration:77 + 1000 records deleted +1000 records inserted +Iteration:78 + 1000 records deleted +1000 records inserted +Iteration:79 + 1000 records deleted +1000 records inserted +Iteration:80 + 1000 records deleted +1000 records inserted +Iteration:81 + 1000 records deleted +1000 records inserted +Iteration:82 + 1000 records deleted +1000 records inserted +Iteration:83 + 1000 records deleted +1000 records inserted +Iteration:84 + 1000 records deleted +1000 records inserted +Iteration:85 + 1000 records deleted +1000 records inserted +Iteration:86 + 1000 records deleted +1000 records inserted +Iteration:87 + 1000 records deleted +1000 records inserted +Iteration:88 + 1000 records deleted +1000 records inserted +Iteration:89 + 1000 records deleted +1000 records inserted +Iteration:90 + 1000 records deleted +1000 records inserted +Iteration:91 + 1000 records deleted +1000 records inserted +Iteration:92 + 1000 records deleted +1000 records inserted +Iteration:93 + 1000 records deleted +1000 records inserted +Iteration:94 + 1000 records deleted +1000 records inserted +Iteration:95 + 1000 records deleted +1000 records inserted +Iteration:96 + 1000 records deleted +1000 records inserted +Iteration:97 + 1000 records deleted +1000 records inserted +Iteration:98 + 1000 records deleted +1000 records inserted +Iteration:99 + 1000 records deleted +1000 records inserted diff --git a/test/dbapi/Table/exp.test102 b/test/dbapi/Table/exp.test102 new file mode 100644 index 00000000..756dadbe --- /dev/null +++ b/test/dbapi/Table/exp.test102 @@ -0,0 +1,302 @@ +Table created +4000 records inserted +Iteration:0 + 4000 records deleted +4000 records inserted +Iteration:1 + 4000 records deleted +4000 records inserted +Iteration:2 + 4000 records deleted +4000 records inserted +Iteration:3 + 4000 records deleted +4000 records inserted +Iteration:4 + 4000 records deleted +4000 records inserted +Iteration:5 + 4000 records deleted +4000 records inserted +Iteration:6 + 4000 records deleted +4000 records inserted +Iteration:7 + 4000 records deleted +4000 records inserted +Iteration:8 + 4000 records deleted +4000 records inserted +Iteration:9 + 4000 records deleted +4000 records inserted +Iteration:10 + 4000 records deleted +4000 records inserted +Iteration:11 + 4000 records deleted +4000 records inserted +Iteration:12 + 4000 records deleted +4000 records inserted +Iteration:13 + 4000 records deleted +4000 records inserted +Iteration:14 + 4000 records deleted +4000 records inserted +Iteration:15 + 4000 records deleted +4000 records inserted +Iteration:16 + 4000 records deleted +4000 records inserted +Iteration:17 + 4000 records deleted +4000 records inserted +Iteration:18 + 4000 records deleted +4000 records inserted +Iteration:19 + 4000 records deleted +4000 records inserted +Iteration:20 + 4000 records deleted +4000 records inserted +Iteration:21 + 4000 records deleted +4000 records inserted +Iteration:22 + 4000 records deleted +4000 records inserted +Iteration:23 + 4000 records deleted +4000 records inserted +Iteration:24 + 4000 records deleted +4000 records inserted +Iteration:25 + 4000 records deleted +4000 records inserted +Iteration:26 + 4000 records deleted +4000 records inserted +Iteration:27 + 4000 records deleted +4000 records inserted +Iteration:28 + 4000 records deleted +4000 records inserted +Iteration:29 + 4000 records deleted +4000 records inserted +Iteration:30 + 4000 records deleted +4000 records inserted +Iteration:31 + 4000 records deleted +4000 records inserted +Iteration:32 + 4000 records deleted +4000 records inserted +Iteration:33 + 4000 records deleted +4000 records inserted +Iteration:34 + 4000 records deleted +4000 records inserted +Iteration:35 + 4000 records deleted +4000 records inserted +Iteration:36 + 4000 records deleted +4000 records inserted +Iteration:37 + 4000 records deleted +4000 records inserted +Iteration:38 + 4000 records deleted +4000 records inserted +Iteration:39 + 4000 records deleted +4000 records inserted +Iteration:40 + 4000 records deleted +4000 records inserted +Iteration:41 + 4000 records deleted +4000 records inserted +Iteration:42 + 4000 records deleted +4000 records inserted +Iteration:43 + 4000 records deleted +4000 records inserted +Iteration:44 + 4000 records deleted +4000 records inserted +Iteration:45 + 4000 records deleted +4000 records inserted +Iteration:46 + 4000 records deleted +4000 records inserted +Iteration:47 + 4000 records deleted +4000 records inserted +Iteration:48 + 4000 records deleted +4000 records inserted +Iteration:49 + 4000 records deleted +4000 records inserted +Iteration:50 + 4000 records deleted +4000 records inserted +Iteration:51 + 4000 records deleted +4000 records inserted +Iteration:52 + 4000 records deleted +4000 records inserted +Iteration:53 + 4000 records deleted +4000 records inserted +Iteration:54 + 4000 records deleted +4000 records inserted +Iteration:55 + 4000 records deleted +4000 records inserted +Iteration:56 + 4000 records deleted +4000 records inserted +Iteration:57 + 4000 records deleted +4000 records inserted +Iteration:58 + 4000 records deleted +4000 records inserted +Iteration:59 + 4000 records deleted +4000 records inserted +Iteration:60 + 4000 records deleted +4000 records inserted +Iteration:61 + 4000 records deleted +4000 records inserted +Iteration:62 + 4000 records deleted +4000 records inserted +Iteration:63 + 4000 records deleted +4000 records inserted +Iteration:64 + 4000 records deleted +4000 records inserted +Iteration:65 + 4000 records deleted +4000 records inserted +Iteration:66 + 4000 records deleted +4000 records inserted +Iteration:67 + 4000 records deleted +4000 records inserted +Iteration:68 + 4000 records deleted +4000 records inserted +Iteration:69 + 4000 records deleted +4000 records inserted +Iteration:70 + 4000 records deleted +4000 records inserted +Iteration:71 + 4000 records deleted +4000 records inserted +Iteration:72 + 4000 records deleted +4000 records inserted +Iteration:73 + 4000 records deleted +4000 records inserted +Iteration:74 + 4000 records deleted +4000 records inserted +Iteration:75 + 4000 records deleted +4000 records inserted +Iteration:76 + 4000 records deleted +4000 records inserted +Iteration:77 + 4000 records deleted +4000 records inserted +Iteration:78 + 4000 records deleted +4000 records inserted +Iteration:79 + 4000 records deleted +4000 records inserted +Iteration:80 + 4000 records deleted +4000 records inserted +Iteration:81 + 4000 records deleted +4000 records inserted +Iteration:82 + 4000 records deleted +4000 records inserted +Iteration:83 + 4000 records deleted +4000 records inserted +Iteration:84 + 4000 records deleted +4000 records inserted +Iteration:85 + 4000 records deleted +4000 records inserted +Iteration:86 + 4000 records deleted +4000 records inserted +Iteration:87 + 4000 records deleted +4000 records inserted +Iteration:88 + 4000 records deleted +4000 records inserted +Iteration:89 + 4000 records deleted +4000 records inserted +Iteration:90 + 4000 records deleted +4000 records inserted +Iteration:91 + 4000 records deleted +4000 records inserted +Iteration:92 + 4000 records deleted +4000 records inserted +Iteration:93 + 4000 records deleted +4000 records inserted +Iteration:94 + 4000 records deleted +4000 records inserted +Iteration:95 + 4000 records deleted +4000 records inserted +Iteration:96 + 4000 records deleted +4000 records inserted +Iteration:97 + 4000 records deleted +4000 records inserted +Iteration:98 + 4000 records deleted +4000 records inserted +Iteration:99 + 4000 records deleted +4000 records inserted diff --git a/test/dbapi/Table/insertnulltest1.c b/test/dbapi/Table/insertnulltest1.c new file mode 100644 index 00000000..fb10d873 --- /dev/null +++ b/test/dbapi/Table/insertnulltest1.c @@ -0,0 +1,69 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 20); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 10 ; i++) + { + conn.startTransaction(); + id1= i; + if (i%2 == 0) table->markFldNull(2); + rv = table->insertTuple(); + if (rv != OK) break; + if (i%2 == 0) table->clearFldNull(2); + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("Binded Tuple value is %d %d %s \n", id1, id2, name); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest2.c b/test/dbapi/Table/insertnulltest2.c new file mode 100644 index 00000000..34d1b8ed --- /dev/null +++ b/test/dbapi/Table/insertnulltest2.c @@ -0,0 +1,70 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true);//NOT NULL + tabDef.addField("f2", typeInt, 0, NULL, false); + tabDef.addField("f3", typeString, 20);//Bydefault 'NOT NULL' is false + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 5 ; i++) + { + conn.startTransaction(); + id1= i; + if (i%2 == 0) table->markFldNull(3); + rv = table->insertTuple(); + if (rv != OK) break; + if (i%2 == 0) table->clearFldNull(3); + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + table->bindFld("f2", &id2); + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("Binded Tuple value is %d %d %s \n", id1, id2, name); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest3.c b/test/dbapi/Table/insertnulltest3.c new file mode 100644 index 00000000..fe2ce450 --- /dev/null +++ b/test/dbapi/Table/insertnulltest3.c @@ -0,0 +1,67 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true);//NOT NULL + tabDef.addField("f2", typeInt, 0, NULL, false); + tabDef.addField("f3", typeString, 20); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "unchangedvalue"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + //table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 5 ; i++) + { + conn.startTransaction(); + id1= i; + rv = table->insertTuple(); + if (rv != OK) break; + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + table->bindFld("f2", &id2); + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("Binded Tuple value is %d %d %s \n", id1, id2, name); + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest4.c b/test/dbapi/Table/insertnulltest4.c new file mode 100644 index 00000000..7e07b521 --- /dev/null +++ b/test/dbapi/Table/insertnulltest4.c @@ -0,0 +1,77 @@ +/* using markfieldnull without clearFieldNull. + * create table t1 with f1 and f2 field + * without clearFldNull() f2 field will be null always. + * + * Author : Jitendra Lenka. + */ + + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + 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"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + + int icount =0; + for (int i = 0 ; i < 10 ; i++) + { + conn.startTransaction(); + id1= i; + if (i%2 == 0) table->markFldNull(2); + rv = table->insertTuple(); + if (rv != OK) break; + //if (i%2 == 0) table->clearFldNull(2); + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + + printf("Binded Tuple value is %d %d \n", id1, id2); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest5.c b/test/dbapi/Table/insertnulltest5.c new file mode 100644 index 00000000..cf5dd600 --- /dev/null +++ b/test/dbapi/Table/insertnulltest5.c @@ -0,0 +1,70 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true);//NOT NULL + tabDef.addField("f2", typeInt, 0, NULL, false); + tabDef.addField("f3", typeString, 20);//Bydefault 'NOT NULL' is false + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 5 ; i++) + { + conn.startTransaction(); + id1= i; + if (i%2 == 0) table->markFldNull("f3"); + rv = table->insertTuple(); + if (rv != OK) break; + if (i%2 == 0) table->clearFldNull("f3"); + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + table->bindFld("f2", &id2); + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("Binded Tuple value is %d %d %s \n", id1, id2, name); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest6.c b/test/dbapi/Table/insertnulltest6.c new file mode 100644 index 00000000..6bd9c237 --- /dev/null +++ b/test/dbapi/Table/insertnulltest6.c @@ -0,0 +1,73 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true);//NOT NULL + tabDef.addField("f2", typeInt, 0, NULL, false); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1=0, id2 = 5; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + conn.startTransaction(); + rv = table->markFldNull(1); + if (rv != OK) { + printf("test passed\n"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + printf("table dropped\n"); + conn.close(); + return 0; + } + rv = table->insertTuple(); + if(rv==OK) + { + printf("Error\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + table->clearFldNull(1); + conn.commit(); + + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + table->bindFld("f2", &id2); + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + printf("Binded Tuple value is %d %d \n", id1, id2); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest7.c b/test/dbapi/Table/insertnulltest7.c new file mode 100644 index 00000000..3986309a --- /dev/null +++ b/test/dbapi/Table/insertnulltest7.c @@ -0,0 +1,70 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + 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"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + int icount =0; + for (int i = 0 ; i < 10 ; i++) + { + conn.startTransaction(); + id1= i;id2=id2+i; + if (i%2 == 0){ + if ((rv = table->markFldNull(1)) != OK ) { + conn.rollback(); continue; } + if ( (rv = table->markFldNull(2)) != OK) { + conn.rollback(); + continue; + } + } + rv = table->insertTuple(); + if (rv != OK) break; + if (i%2 == 0) {table->clearFldNull(1);table->clearFldNull(2);} + icount++; + conn.commit(); + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) printf("Column 1 is null\n"); + if (table->isFldNull(2)) printf("Column 2 is null\n"); + printf("Binded Tuple value is %d %d \n", id1, id2); + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/insertnulltest8.c b/test/dbapi/Table/insertnulltest8.c new file mode 100644 index 00000000..50efac44 --- /dev/null +++ b/test/dbapi/Table/insertnulltest8.c @@ -0,0 +1,145 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true);//NOT NULL + tabDef.addField("f2", typeInt, 0, NULL, false); + tabDef.addField("f3", typeInt, 0, NULL, false); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1=0, id2 = 5, id3=10; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", &id3); + int icount=0; + for(int i=0;i<6;i++) + { + conn.startTransaction(); + id1=i; + if(i%2==0) + { + if(i!=0) + table->markFldNull(2); + } + else table->markFldNull(3); + rv = table->insertTuple(); + if(rv!=OK) break; + if(i%2==0) table->clearFldNull(2); + else table->clearFldNull(3); + icount++; + conn.commit(); + } + printf("Tuples inserted in 1/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *tuple = NULL; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) + { + printf("Column 1 is null\n"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("Binded Tuple value is %d %d %d\n", id1, id2, id3); + } + rv=table->closeScan(); + + Condition p1; + int val1=4; + p1.setTerm("f1", OpLessThan, &val1); + table->setCondition(&p1); + conn.startTransaction(); + rv=table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 5; + } + while(true) + { + tuple = (char*)table->fetch(); + if (tuple == NULL) { break; } + rv = table->markFldNull("f1"); + if (rv == ErrNullViolation) { + printf("NULL Violation\n"); + continue; + } + rv=table->updateTuple(); + if(rv==OK) + { + table->clearFldNull("f1"); + break; + } + table->clearFldNull("f1"); + } + conn.commit(); + table->closeScan(); + + conn.startTransaction(); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 4; + } + printf("Scan after updation\n"); + printf("********************\n"); + printf("f1 | f2\t| f3\n"); + printf("--------------------------\n"); + + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + if (table->isFldNull(1)) + { + printf("Column 1 is null\n"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + if (table->isFldNull(2)) printf("Column 2 is null\n"); + if (table->isFldNull(3)) printf("Column 3 is null\n"); + printf("%d | %d\t| %d\n", id1, id2, id3); + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/inserttest1.c b/test/dbapi/Table/inserttest1.c new file mode 100644 index 00000000..f016b7a3 --- /dev/null +++ b/test/dbapi/Table/inserttest1.c @@ -0,0 +1,79 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 20); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 10 ; i++) + { + conn.startTransaction(); + id1= i; + rv = table->insertTuple(); + if (rv != OK) break; + icount++; + conn.commit(); + + } + printf("Tuples inserted in 1/txn is %d\n", icount); + icount = 0; + conn.startTransaction(); + for (int i = 20 ; i < 30 ; i++) + { + id1 = i; + rv = table->insertTuple(); + if (rv != OK) break; + icount++; + } + conn.commit(); + printf("Tuples inserted in 10/txn is %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *fld2ptr, *fld3ptr, *tuple; + + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + fld2ptr = (char*)tuple + os::align(sizeof(int)); + fld3ptr = (char*)tuple + (2 * os::align(sizeof(int))); + printf("Tuple value is %d %d %s \n", *((int*)tuple), *((int*)fld2ptr), (char*)fld3ptr ); + printf("Binded Tuple value is %d %d %s \n", id1, id2, name); + + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/inserttest2.c b/test/dbapi/Table/inserttest2.c new file mode 100644 index 00000000..6d63f299 --- /dev/null +++ b/test/dbapi/Table/inserttest2.c @@ -0,0 +1,55 @@ +//Test Case: +//Insert 1 million tuples. There will not be enough db space. +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeInt); + tabDef.addField("f3", typeString, 1016); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } + int id1 = 0, id2 = 5; + char name[20] = "PRAVEEN"; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + table->bindFld("f3", name); + int icount =0; + for (int i = 0 ; i < 1000 ; i++) + { + conn.startTransaction(); + for (int j = 0 ; j < 100 ; j++) { + id1= icount++; + rv = table->insertTuple(); + if (rv != OK) break; + } + conn.commit(); + } + printf("Tuples inserted %d\n", icount); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + if (rv == ErrNoMemory) + { + //insert is expected to fail + printf("insert failed with return values %d\n", rv); + return 0; + } + return 1; +} diff --git a/test/dbapi/Table/inserttest3.c b/test/dbapi/Table/inserttest3.c new file mode 100644 index 00000000..12cffc5a --- /dev/null +++ b/test/dbapi/Table/inserttest3.c @@ -0,0 +1,65 @@ +//TestCase: We need to start new server to test this. +//the default db size set is not enough to test this +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + 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"); conn.close(); return 3; } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return 2; + } + int id1 = 0, id2 = 5; + table->bindFld("f1", &id1); + table->bindFld("f2", &id2); + int icount =0; + for (int i = 0 ; i < 10000 ; i++) + { + conn.startTransaction(); + for (int j = 0 ; j < 100 ; j++) { + id1= icount++; + rv = table->insertTuple(); + if (rv != OK) break; + } + if (rv != OK) break; + conn.commit(); + } + printf("Tuples inserted %d\n", icount); + table->setCondition(NULL); + rv = table->execute(); + if (rv != OK) + { + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + } + void *fld2ptr, *fld3ptr, *tuple; + icount = 0; + while(true) + { + tuple = (char*)table->fetch() ; + if (tuple == NULL) {break;} + icount++; + } + table->closeScan(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + if (icount != 1000000) return 3; + return 0; +} diff --git a/test/dbapi/Table/spaceusedtest.c b/test/dbapi/Table/spaceusedtest.c new file mode 100644 index 00000000..5b45c61a --- /dev/null +++ b/test/dbapi/Table/spaceusedtest.c @@ -0,0 +1,43 @@ +/* create table 't1' with two fields f1 int, f2 int. + * use spaceused() to know the size of the table, + * here the table size will be 16 bytes. + * + * AUTHOR : Jitendra Lenka + */ + +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root","manager"); + if(rv!=OK)return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if(dbMgr == NULL) + { + printf("Auth failed\n"); + return 2; + } + + TableDef tabDef; + tabDef.addField("f1",typeInt,0,NULL,true); + tabDef.addField("f2",typeInt); + + rv = dbMgr->createTable("t1",tabDef); + if(rv!=OK) + { + printf("Table created failed\n"); + conn.close(); + return 0; + } + + + Table *table = dbMgr->openTable("t1"); + long spaceused; + spaceused = table->spaceUsed(); + printf("Total space used=%ld\n",spaceused); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} diff --git a/test/dbapi/Table/test003.ksh b/test/dbapi/Table/test003.ksh new file mode 100755 index 00000000..0c318915 --- /dev/null +++ b/test/dbapi/Table/test003.ksh @@ -0,0 +1,36 @@ +#!/bin/ksh +#Run this test only under csql/test or on this directory. +#Otherwise, it may fail +executable=${PWD}/dbapi/Table/insert +CSQL_CONF=${PWD}/dbapi/Table/csql.conf +REL_PATH=. +if [ -s "$executable" -a -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/dbapi/Table +fi + +export CSQL_CONFIG_FILE=$REL_PATH/csql.conf + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/insert 2> $0.valgr +else + $REL_PATH/insert + if [ $? -ne 0 ] + then + exit 2; + fi +fi + +kill -9 $pid +if [ $? -ne 0 ] +then + exit 3; +fi +ipcrm -M 7117 -M 1771 + +exit 0; diff --git a/test/dbapi/TableDef/Makefile b/test/dbapi/TableDef/Makefile new file mode 100644 index 00000000..a02a1e2d --- /dev/null +++ b/test/dbapi/TableDef/Makefile @@ -0,0 +1,70 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 \ + test002 \ + test003 \ + test004 \ + test005 \ + test006 \ + test007 \ + test008 \ + test009 \ + test010 \ + test011 + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: fieldname1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test002: fieldname2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test003: fieldname3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test004: withoutfieldname.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test005: dupfieldname.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test006: fieldcount1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test007: fieldcount2.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test008: fieldcount3.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test009: fieldcasesensitive.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test010: tablename1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +test011: tuplesize1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/TableDef/csql.conf b/test/dbapi/TableDef/csql.conf new file mode 100644 index 00000000..cec31ed8 --- /dev/null +++ b/test/dbapi/TableDef/csql.conf @@ -0,0 +1,62 @@ +# CSQL System Configuration File + +#####################################Server Section######################## +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined + +# Page size. Each database is logically divided into pages and allocation happens +# in this unit of pages. Increasing this value will reduce frequent allocation of pages. +PAGE_SIZE= 8192 + +#Total number of client process which can connect and work with the +# database concurrently +MAX_PROCS = 100 + +# Maximum size of the system database. +MAX_SYS_DB_SIZE=10485760 + +#Maximum size of the user database file. +MAX_DB_SIZE=335544320 + +#Shared memory key to be used by the system to create and locate system database. +SYS_DB_KEY=7117 + +#Shared memory key to be used by the system to create and locate user database. +USER_DB_KEY=1771 + +#Give full path for the log file where important system actions are stored. +LOG_FILE=/tmp/csql/log/log.out + +#The virtual memory start address at which the shared memory segment +# will be created and attached. +MAP_ADDRESS=400000000 + +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined +#####################################Client Section######################## + +#Mutex timeout interval seconds +MUTEX_TIMEOUT_SECS=0 +MUTEX_TIMEOUT_USECS=5000 +MUTEX_TIMEOUT_RETRIES=10 + +#Lock timeout interval seconds +LOCK_TIMEOUT_SECS=0 +LOCK_TIMEOUT_USECS=5000 +LOCK_TIMEOUT_RETRIES=10 + +#####################################Cache Section######################## + +#Whether to enable caching of tables from target database +CACHE_TABLE=false + +#DSN Name to connect to the target database. +#This should be present in ~/odbc.ini file +DSN=myodbc3 + +#Give full path for the file where all the cached table information is stored +TABLE_CONFIG_FILE=/tmp/csql/csqltable.conf + +#####################################End Section######################## diff --git a/test/dbapi/TableDef/dupfieldname.c b/test/dbapi/TableDef/dupfieldname.c new file mode 100644 index 00000000..92d00356 --- /dev/null +++ b/test/dbapi/TableDef/dupfieldname.c @@ -0,0 +1,29 @@ +//Should not allow duplicate field names in one table +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + //int test=0; + tabDef.addField("f1", typeInt, 0, NULL, true); + rv=(DbRetVal)tabDef.addField("f1", typeInt); + if(rv==0) + { + printf("Test failed with return value %d\n",rv); + return rv; + } + printf("test passed\n"); + dbMgr->createTable("t1", tabDef); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + +//3298:3086821072:TableDef.cxx:40:Field f_1 already Exists +//Table created with field name f_1 only + diff --git a/test/dbapi/TableDef/fieldcasesensitive.c b/test/dbapi/TableDef/fieldcasesensitive.c new file mode 100644 index 00000000..01f068ef --- /dev/null +++ b/test/dbapi/TableDef/fieldcasesensitive.c @@ -0,0 +1,28 @@ +//Create table with fieldname as "EMP" and "emp". it should succeed. +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + tabDef.addField("EMP", typeInt, 0, NULL, true); + rv=(DbRetVal)tabDef.addField("emp", typeInt); + if(rv!=0) + { + printf("Test Failed with return value %d\n",rv); + return rv; + } + + dbMgr->createTable("t1", tabDef); + printf("Table created\n"); + printf("test Passed\n"); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + diff --git a/test/dbapi/TableDef/fieldcount1.c b/test/dbapi/TableDef/fieldcount1.c new file mode 100644 index 00000000..6347795f --- /dev/null +++ b/test/dbapi/TableDef/fieldcount1.c @@ -0,0 +1,23 @@ +//100 times addField f1 and dropField f1. getFldCount() should return 0 +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + for (int i=0;i<100;i++) + { + tabDef.addField("f1", typeInt); + tabDef.dropField("f1"); + } + int fieldcount=tabDef.getFieldCount(); + printf("Number of Fields = %d\n",fieldcount); + printf("Test Passed\n"); + conn.close(); + return 0; +} + diff --git a/test/dbapi/TableDef/fieldcount2.c b/test/dbapi/TableDef/fieldcount2.c new file mode 100644 index 00000000..09b2d7ca --- /dev/null +++ b/test/dbapi/TableDef/fieldcount2.c @@ -0,0 +1,33 @@ +//100 times addField f1 and dropField f1. getFieldCount() should return 0 +//and table creation should fail saying no fields in tabledef +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + for (int i=0;i<100;i++) + { + tabDef.addField("f1", typeInt); + tabDef.dropField("f1"); + } + int fieldcount=tabDef.getFieldCount(); + printf("Number of Fields = %d\n",fieldcount); + rv=dbMgr->createTable("t1", tabDef); + if(rv==OK) + { + printf("Table created without Fields\n"); + printf("Test failed\n"); + dbMgr->dropTable("t1"); + return 3; + } + + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + diff --git a/test/dbapi/TableDef/fieldcount3.c b/test/dbapi/TableDef/fieldcount3.c new file mode 100644 index 00000000..ac78f177 --- /dev/null +++ b/test/dbapi/TableDef/fieldcount3.c @@ -0,0 +1,39 @@ +//Create table with 1024 fields and call getFldCount() +//and check return value is 1024 +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + int test; + TableDef tabDef; + char str[6]="f",field[6]; + for (int i=1;i<=1024;i++) + { + sprintf(field,"%s%d",str,i); + test=tabDef.addField(field, typeInt); + if(test!=0) + { + printf("Field f%d could not be created",i); + return test; + } + } + int fieldcount=tabDef.getFieldCount(); + printf("Number of Fields = %d\n",fieldcount); + rv=dbMgr->createTable("t1", tabDef); + if(rv!=OK) + { + printf("Table creation Failed\n"); + printf("Test failed\n"); + return 3; + } + printf("Table created \n"); + printf("Test passed\n"); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + diff --git a/test/dbapi/TableDef/fieldname1.c b/test/dbapi/TableDef/fieldname1.c new file mode 100644 index 00000000..c9412df5 --- /dev/null +++ b/test/dbapi/TableDef/fieldname1.c @@ -0,0 +1,43 @@ +//Create table with the field name made up of special characters other than +//underscore. it should not be allowed. +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + int i=0; + rv=(DbRetVal)tabDef.addField("f-2", typeInt); + if(rv==OK) i++; + rv=(DbRetVal)tabDef.addField("2f", typeInt); + if(rv==OK) i++; + rv=(DbRetVal)tabDef.addField("f2@", typeInt); + if(rv==OK) i++; + rv=(DbRetVal)tabDef.addField("_f2#", typeInt); + if(rv==OK) i++; + rv=(DbRetVal)tabDef.addField("$f2", typeInt); + if(rv==OK) i++; + rv=(DbRetVal)tabDef.addField("$@*#", typeInt); + if(rv==OK) i++; + + + if(i){printf(" Test Failed \n"); return i;} + + rv=dbMgr->createTable("t1", tabDef); + if(rv==OK) + { + printf("Allowing fieldnames made up of all special characters\n"); + printf("Test failed\n"); + dbMgr->dropTable("t1"); + return 3; + } + + printf("Test Passed\n"); + conn.close(); + return 0; +} +//Table is created and allowing field names with special characters other than underscores also diff --git a/test/dbapi/TableDef/fieldname2.c b/test/dbapi/TableDef/fieldname2.c new file mode 100644 index 00000000..e9eb0f37 --- /dev/null +++ b/test/dbapi/TableDef/fieldname2.c @@ -0,0 +1,28 @@ +//Should not allow field names more than 64 character +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + + tabDef.addField("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklabc", typeInt, 0, NULL, true); + rv=dbMgr->createTable("t1", tabDef); + if(rv==OK) + { + printf("Allowing fieldname more than 64 character\n"); + printf("Test Failed\n"); + dbMgr->dropTable("t1"); + return 3; + } + printf("Test Passed\n"); + conn.close(); + return 0; +} + +//Table is created and allowing fieldnames with more than 64 characters + diff --git a/test/dbapi/TableDef/fieldname3.c b/test/dbapi/TableDef/fieldname3.c new file mode 100644 index 00000000..a0e09ae7 --- /dev/null +++ b/test/dbapi/TableDef/fieldname3.c @@ -0,0 +1,59 @@ +//addField f1, dropField f1 and then addField f1 with notnull flag set, +//table creation should succeed and it should make the f1 field notnull +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + + tabDef.addField("f1", typeInt); + tabDef.dropField("f1"); + tabDef.addField("f1", typeInt, 0, NULL, true); + rv=dbMgr->createTable("t1", tabDef); + if(rv!=OK) + { + printf("Table creation failed\n"); + printf("Test Failed\n"); + dbMgr->dropTable("t1"); + return 3; + } + printf("Table created\n"); + + Table *table = dbMgr->openTable("t1"); + if (table == NULL) + { + printf("Unable to open table\n"); + dbMgr->dropTable("t1"); + conn.close(); + return -1; + } +// int id; +// table->bindFld("f1",&id); + + conn.startTransaction(); + rv=table->insertTuple(); + if(rv==OK) + { + printf("NULL value inserted in NOTNULL field\n"); + printf("Test Failed\n"); + conn.commit(); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + return 4; + } + conn.commit(); + printf("NULL value can not be stored\n"); + printf("Test passed\n"); + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + + diff --git a/test/dbapi/TableDef/tablename1.c b/test/dbapi/TableDef/tablename1.c new file mode 100644 index 00000000..e2f9572b --- /dev/null +++ b/test/dbapi/TableDef/tablename1.c @@ -0,0 +1,27 @@ +//create table with the name made up of special characters other than underscores.It should fail +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + + tabDef.addField("f_1", typeInt, 0, NULL, true); + rv=dbMgr->createTable("t-1",tabDef); + if(rv==OK) + { + printf("Test Failed\n"); + rv=dbMgr->dropTable("t-1"); + return 3; + } + printf("Test Passed\n"); + conn.close(); + return 0; +} + +//Table creating with name made up of any special character + diff --git a/test/dbapi/TableDef/tuplesize1.c b/test/dbapi/TableDef/tuplesize1.c new file mode 100644 index 00000000..e4a964c8 --- /dev/null +++ b/test/dbapi/TableDef/tuplesize1.c @@ -0,0 +1,28 @@ +//addfield f1 int, addField f2 char(10), addField f3 int. +//Check the getTupleSize() return value. It should be 20 +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + + tabDef.addField("f1", typeInt, 0, NULL, true); + tabDef.addField("f2", typeString,10); + tabDef.addField("f3", typeInt); + + dbMgr->createTable("t1", tabDef); + printf("Table created\n"); + size_t sizeofTuple = os::align(tabDef.getTupleSize()); + printf("Size of 1 tuple is %d\n",sizeofTuple); + + dbMgr->dropTable("t1"); + conn.close(); + return 0; +} + + diff --git a/test/dbapi/TableDef/withoutfieldname.c b/test/dbapi/TableDef/withoutfieldname.c new file mode 100644 index 00000000..ace9afb5 --- /dev/null +++ b/test/dbapi/TableDef/withoutfieldname.c @@ -0,0 +1,26 @@ +//create table without fields. it should be failed +#include +int main() +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) return 1; + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return 2;} + + TableDef tabDef; + + rv=dbMgr->createTable("t1", tabDef); + if(rv==OK) + { + printf("Table created without Fields\n"); + printf("Test failed\n"); + dbMgr->dropTable("t1"); + return 3; + } + + printf("Test Passed\n"); + conn.close(); + return 0; +} + diff --git a/test/dbapi/Threads/DMLThreadTest.c b/test/dbapi/Threads/DMLThreadTest.c new file mode 100644 index 00000000..c1f7154b --- /dev/null +++ b/test/dbapi/Threads/DMLThreadTest.c @@ -0,0 +1,379 @@ +//#include +//TestCase: It creates 5 threads and all threads insert ITERATION records simultanesouly. +//after insertion, it checks whether 50000 records are there in the table +//after that, 5 threads select 10K records each simultanesouly. +//verify that 10K records are selected in each thread. +//The test is repeated with no index, hash index and tree index +#include +#define THREADS 5 +#define ITERATION 25000 +void* runInsTest(void *p); +void* runSelTest(void *p); +void* runDelTest(void *p); +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true); +#ifdef VARCHAR + tabDef.addField("f2", typeVarchar, 12); +#else + tabDef.addField("f2", typeString, 12); +#endif + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); +#ifdef HASH + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } +#endif +#ifdef TREE + idxInfo->indType = treeIndex; + //idxInfo->bucketSize = 25; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } +#endif + delete idxInfo; + pthread_t thr[THREADS]; + int message[THREADS]; + int status; + for (int i=0; i openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + table->setCondition(NULL); + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + table->execute(); + int count=0; + void *tuple = NULL; + while ((tuple = (char*) table->fetch())) { + count++; + } + printf("Tuples found: %d\n", count); + table->closeScan(); + conn.commit(); + +#ifdef HASH + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + int icount=0; + for(int i = 0; i< THREADS * ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + valTerm = i; + rv = table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) break; + icount++; + table->closeScan(); + conn.commit(); + //if (i%ITERATION == 0) printf("%d\n", i); + } + printf("Index Tuples found: %d\n", icount); +#endif + + + + dbMgr->closeTable(table); + + for (int i=0; i dropTable("t1"); + + conn.close(); + return 0; +} +void* runInsTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[20] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + int icount =0; + int val = *(int*)message; + int retrycnt=0; + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + id= i; + strcpy(name, "KARAN123"); + ret = table->insertTuple(); + retrycnt=0; + while (ret == ErrLockTimeOut) + { + rv = conn.rollback(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying abort\n"); + rv = conn.rollback(); + } + } + if (retrycnt == 3) { ret = 1; break;} + rv = conn.startTransaction(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying startTransaction\n"); + rv = conn.startTransaction(); + } + } + ret = table->insertTuple(); + retrycnt++; + //ret =1; break; //temp to analyse issue + } + if (ret != 0) { printf("RETURNING EARLY: %d with i:%d\n", ret, i); break;} + icount++; + rv = conn.commit(); + if (rv != OK) { + printf("COMMIT returned %d\n", rv); + os::usleep(500); + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + //if (icount %ITERATION ==0) printf("%d\n", i); + } + char msgBuf[1024]; + sprintf(msgBuf,"Insert: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} +void* runSelTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[1020] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int i; + int icount =0; + int val = *(int*)message; + + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + valTerm = i; + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) break; + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) break; + icount++; + table->closeScan(); + rv = conn.commit(); + if (rv != OK) { + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + } + + char msgBuf[1024]; + sprintf(msgBuf,"Select: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} +void* runDelTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[20] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int i; + int ret; + int retrycnt=0; + int icount =0; + int val = *(int*)message; + + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + id= i; + valTerm = i; + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) { printf("DELETE:execute failed\n"); break;} + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) { printf("DELETE:fetch failed\n");break;} + ret = table->deleteTuple(); + retrycnt=0; + while (ret == ErrLockTimeOut) + { + table->closeScan(); + rv = conn.rollback(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying abort\n"); + rv = conn.rollback(); + } + } + if (retrycnt == 10) { ret = 1; break;} + rv = conn.startTransaction(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying startTransaction\n"); + rv = conn.startTransaction(); + } + } + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) { printf("DELETE:execute failed\n"); break;} + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) { printf("DELETE:fetch failed\n");break;} + ret = table->deleteTuple(); + retrycnt++; + } + if (ret != 0) { printf("RETURNING EARLY: %d with i:%d\n", ret, i); break;} + table->closeScan(); + rv = conn.commit(); + if (rv != OK) { + printf("COMMIT returned %d for record %d\n", rv, i); + if (rv != ErrLockTimeOut) + { + printf("RETURNING EARLY: with i:%d\n", i); + break; + } + + os::usleep(500); + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + icount++; + } + char msgBuf[1024]; + sprintf(msgBuf,"Delete: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} + + diff --git a/test/dbapi/Threads/Makefile b/test/dbapi/Threads/Makefile new file mode 100644 index 00000000..bafcd027 --- /dev/null +++ b/test/dbapi/Threads/Makefile @@ -0,0 +1,58 @@ + +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = noindex hash tree autoinc autoinchash autoinctree noindexvarchar hashvarchar treevarchar + + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +noindex: DMLThreadTest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +hash: DMLThreadTest.c + $(CPlus) -DHASH $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +tree: DMLThreadTest.c + $(CPlus) -DTREE $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +noindexvarchar: DMLThreadTest.c + $(CPlus) -DVARCHAR $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +hashvarchar: DMLThreadTest.c + $(CPlus) -DHASH -DVARCHAR $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +treevarchar: DMLThreadTest.c + $(CPlus) -DTREE -DVARCHAR $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +autoinc: autoincTest.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +autoinchash: autoincTest.c + $(CPlus) -DHASH $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +autoinctree: autoincTest.c + $(CPlus) -DTREE $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/Threads/autoincTest.c b/test/dbapi/Threads/autoincTest.c new file mode 100644 index 00000000..82e9c0ce --- /dev/null +++ b/test/dbapi/Threads/autoincTest.c @@ -0,0 +1,367 @@ +//#include +//TestCase: It creates 5 threads and all threads insert ITERATION records simultanesouly. +//after insertion, it checks whether 50000 records are there in the table +//after that, 5 threads select 10K records each simultanesouly. +//verify that 10K records are selected in each thread. +//The test is repeated with no index, hash index and tree index +#include +#define THREADS 5 +#define ITERATION 25000 +void* runInsTest(void *p); +void* runSelTest(void *p); +void* runDelTest(void *p); +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true, true); + tabDef.addField("f2", typeString, 12); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->isPrimary = true; + idxInfo->isUnique = true; +#ifdef HASH + idxInfo->indType = hashIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } +#endif +#ifdef TREE + idxInfo->indType = treeIndex; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } +#endif + delete idxInfo; + pthread_t thr[THREADS]; + int message[THREADS]; + int status; + for (int i=0; i openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + table->setCondition(NULL); + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + table->execute(); + int count=0; + void *tuple = NULL; + while ((tuple = (char*) table->fetch())) { + count++; + } + printf("Tuples found: %d\n", count); + table->closeScan(); + conn.commit(); + +#ifdef HASH + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + int icount=0; + for(int i = 0; i< THREADS * ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + valTerm = i+1; + rv = table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) break; + icount++; + table->closeScan(); + conn.commit(); + //if (i%ITERATION == 0) printf("%d\n", i); + } + printf("Index Tuples found: %d\n", icount); +#endif + + + + dbMgr->closeTable(table); + + for (int i=0; i dropTable("t1"); + + conn.close(); + return 0; +} +void* runInsTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[20] = "PRABAKARAN"; + //table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + int icount =0; + int val = *(int*)message; + int retrycnt=0; + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + id= i; + strcpy(name, "KARAN123"); + ret = table->insertTuple(); + retrycnt=0; + while (ret == ErrLockTimeOut) + { + rv = conn.rollback(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying abort\n"); + rv = conn.rollback(); + } + } + if (retrycnt == 3) { ret = 1; break;} + rv = conn.startTransaction(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying startTransaction\n"); + rv = conn.startTransaction(); + } + } + ret = table->insertTuple(); + retrycnt++; + //ret =1; break; //temp to analyse issue + } + if (ret != 0) { printf("RETURNING EARLY: %d with i:%d\n", ret, i); break;} + icount++; + rv = conn.commit(); + if (rv != OK) { + printf("COMMIT returned %d\n", rv); + os::usleep(500); + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + //if (icount %ITERATION ==0) printf("%d\n", i); + } + char msgBuf[1024]; + sprintf(msgBuf,"Insert: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} +void* runSelTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[1020] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int i; + int icount =0; + int val = *(int*)message; + + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + valTerm = i; + if (valTerm ==0) valTerm=1; + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) break; + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) break; + icount++; + table->closeScan(); + rv = conn.commit(); + if (rv != OK) { + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + } + + char msgBuf[1024]; + sprintf(msgBuf,"Select: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} +void* runDelTest(void *message) +{ + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return NULL; + } + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return NULL;} + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return NULL; } + int id = 0; + char name[20] = "PRABAKARAN"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int i; + int ret; + int retrycnt=0; + int icount =0; + int val = *(int*)message; + + Condition p1; + int valTerm = 0; + p1.setTerm("f1", OpEquals, &valTerm); + table->setCondition(&p1); + + for(i = val * ITERATION; i< (val *ITERATION) +ITERATION; i++) + { + rv = conn.startTransaction(); + if (rv != OK) while (rv !=OK) rv = conn.startTransaction(); + id= i; + valTerm = i; + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) { printf("DELETE:execute failed\n"); break;} + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) { printf("DELETE:fetch failed\n");break;} + ret = table->deleteTuple(); + retrycnt=0; + while (ret == ErrLockTimeOut) + { + table->closeScan(); + rv = conn.rollback(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying abort\n"); + rv = conn.rollback(); + } + } + if (retrycnt == 10) { ret = 1; break;} + rv = conn.startTransaction(); + if (rv != OK) { + while (rv == ErrLockTimeOut) + { + printf("retrying startTransaction\n"); + rv = conn.startTransaction(); + } + } + rv = table->execute(); + if (rv != OK) { + printf("Execute returned %d\n", rv); + os::usleep(500); + int retry=5; + while (rv == ErrLockTimeOut) { + if (retry == 0) { printf("DELETE:execute failed\n"); break;} + printf("retrying execute\n"); + rv = table->execute(); + retry--; + } + } + tuple = (char*)table->fetch() ; + if (tuple == NULL) { printf("DELETE:fetch failed\n");break;} + ret = table->deleteTuple(); + retrycnt++; + } + if (ret != 0) { printf("RETURNING EARLY: %d with i:%d\n", ret, i); break;} + table->closeScan(); + rv = conn.commit(); + if (rv != OK) { + printf("COMMIT returned %d for record %d\n", rv, i); + if (rv != ErrLockTimeOut) + { + printf("RETURNING EARLY: with i:%d\n", i); + break; + } + + os::usleep(500); + while (rv == ErrLockTimeOut) { + printf("retrying commit\n"); + rv = conn.commit(); + } + } + icount++; + } + char msgBuf[1024]; + sprintf(msgBuf,"Delete: Thread %lu %d: Total rows :%d\n",os::getthrid(), val, icount); + os::write(1,msgBuf,strlen(msgBuf)); + dbMgr->closeTable(table); + rv = conn.close(); + return NULL; +} + + diff --git a/test/dbapi/Threads/test001.ksh b/test/dbapi/Threads/test001.ksh new file mode 100755 index 00000000..88c08286 --- /dev/null +++ b/test/dbapi/Threads/test001.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/noindex 2> $0.valgr +else + $REL_PATH/noindex >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test002.ksh b/test/dbapi/Threads/test002.ksh new file mode 100755 index 00000000..19125ed8 --- /dev/null +++ b/test/dbapi/Threads/test002.ksh @@ -0,0 +1,26 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +rm /tmp/out + +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/hash 2> $0.valgr +else + $REL_PATH/hash >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + #rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test003.ksh b/test/dbapi/Threads/test003.ksh new file mode 100755 index 00000000..c3f2960d --- /dev/null +++ b/test/dbapi/Threads/test003.ksh @@ -0,0 +1,25 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/tree 2> $0.valgr +else + $REL_PATH/tree >/tmp/out +fi +sleep 1 + +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test004.ksh b/test/dbapi/Threads/test004.ksh new file mode 100755 index 00000000..67e1c77d --- /dev/null +++ b/test/dbapi/Threads/test004.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/noindexvarchar 2> $0.valgr +else + $REL_PATH/noindexvarchar >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test005.ksh b/test/dbapi/Threads/test005.ksh new file mode 100755 index 00000000..d45ed4a1 --- /dev/null +++ b/test/dbapi/Threads/test005.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/hashvarchar 2> $0.valgr +else + $REL_PATH/hashvarchar >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test006.ksh b/test/dbapi/Threads/test006.ksh new file mode 100755 index 00000000..d344b3f9 --- /dev/null +++ b/test/dbapi/Threads/test006.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/treevarchar 2> $0.valgr +else + $REL_PATH/treevarchar >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 15 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test007.ksh b/test/dbapi/Threads/test007.ksh new file mode 100755 index 00000000..422ade66 --- /dev/null +++ b/test/dbapi/Threads/test007.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/autoinc 2> $0.valgr +else + $REL_PATH/autoinc >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 10 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test008.ksh b/test/dbapi/Threads/test008.ksh new file mode 100755 index 00000000..dec66a85 --- /dev/null +++ b/test/dbapi/Threads/test008.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/autoinchash 2> $0.valgr +else + $REL_PATH/autoinchash >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 10 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/Threads/test009.ksh b/test/dbapi/Threads/test009.ksh new file mode 100755 index 00000000..85a0789b --- /dev/null +++ b/test/dbapi/Threads/test009.ksh @@ -0,0 +1,24 @@ +#!/bin/ksh +FILE=${PWD}/dbapi/Threads/noindex +REL_PATH=. +if [ -s "$FILE" ] +then + REL_PATH=`pwd`/dbapi/Threads +fi +sleep 1 +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/autoinctree 2> $0.valgr +else + $REL_PATH/autoinctree >/tmp/out +fi +sleep 1 +NO=`grep "Total rows :25000" /tmp/out |wc -l` +if [ $NO -ne 10 ] +then + echo failed with $NO + rm /tmp/out + exit 2 +fi +rm /tmp/out +exit 0 diff --git a/test/dbapi/UserManager/Makefile b/test/dbapi/UserManager/Makefile new file mode 100644 index 00000000..99831b40 --- /dev/null +++ b/test/dbapi/UserManager/Makefile @@ -0,0 +1,42 @@ + +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsql + +TARGETS = \ + test001 + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +test001: usertest1.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f $(TARGETS) + diff --git a/test/dbapi/UserManager/usertest1.c b/test/dbapi/UserManager/usertest1.c new file mode 100644 index 00000000..818ce92f --- /dev/null +++ b/test/dbapi/UserManager/usertest1.c @@ -0,0 +1,47 @@ +#include +int main() +{ + Connection conn; + DbRetVal rv = OK; + //check whether connection open fails for non existing user + rv = conn.open("user1", "passwd"); + if (rv == OK) return 1; + + printf("connection open failed \n"); + + //open with dba to create new user + rv = conn.open("root", "manager"); + if (rv != OK) return 2; + UserManager *uMgr = conn.getUserManager(); + uMgr->createUser("user1", "passwd"); + rv = conn.close(); + if (rv != OK) return 3; + printf("New user created \n"); + //check whether the newly created user name works + rv = conn.open("user1", "passwd"); + if (rv != OK) return 4; + rv = conn.close(); + if (rv != OK) return 5; + printf("New user login worked \n"); + + //check whether the newly created user name fails if + //wrong password is passed + rv = conn.open("user1", "wrongpasswd"); + if (rv == OK) return 6; + + //open with dba to delete the newly created user + rv = conn.open("root", "manager"); + if (rv != OK) return 7; + uMgr = conn.getUserManager(); + uMgr->deleteUser("user1"); + rv = conn.close(); + if (rv != OK) return 8; + printf("New user deleted \n"); + + //check whether it is deleted by connecting with that user + //name and password. It should fail + rv = conn.open("user1", "passwd"); + if (rv == OK) return 9; + + return 0; +} -- 2.11.4.GIT