1 //Testing AND operator with all comparision operator on int data type.
2 //Five tuples are inserted and then selected by setting predicates
9 DbRetVal rv
= conn
.open("root", "manager");
10 if (rv
!= OK
) return 1;
11 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
12 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
14 if ( createTable(dbMgr
) != 0 ) { conn
.close(); return 3; }
16 if (createIndex(dbMgr
, "f1", "idx1") != 0) {dbMgr
->dropTable("t1");
21 #ifdef WITHF1TREEINDEX
22 if (createIndex(dbMgr
, "f1", "idx1", true) != 0) {dbMgr
->dropTable("t1");
29 if (createIndex(dbMgr
, "f2", "idx2") != 0) {dbMgr
->dropTable("t1");
36 #ifdef WITHF2TREEINDEX
37 if (createIndex(dbMgr
, "f2", "idx2", true) != 0) {dbMgr
->dropTable("t1");
43 int inscount
= insertTuple(dbMgr
, conn
);
44 //check the inscount and return error
46 Table
*table
= dbMgr
->openTable("t1");
49 printf("Unable to open table\n");
54 Condition p1
,p2
,p3
,p4
,p5
;
55 int val1
= 2, val2
= 3, val3
= 4;
56 p1
.setTerm("f1", OpEquals
, &val3
);
57 p2
.setTerm("f2", OpGreaterThan
, &val2
);
58 p3
.setTerm("f2", OpEquals
, &val3
);
59 p4
.setTerm("f1", OpLessThan
, &val3
);
60 p5
.setTerm("f1", OpGreaterThan
, &val1
);
64 cond1
.setTerm(p1
.getPredicate(), OpAnd
, p2
.getPredicate());
65 table
->setCondition(&cond1
);
66 printf("Predicate: f1 ==4 AND f2 >3 \n");
67 conn
.startTransaction();
72 cond2
.setTerm(p1
.getPredicate(), OpAnd
, p3
.getPredicate());
73 table
->setCondition(&cond2
);
74 printf("Predicate: f1 ==4 AND f2 ==4 \n");
75 conn
.startTransaction();
80 cond3
.setTerm(p4
.getPredicate(), OpAnd
, p5
.getPredicate());
81 table
->setCondition(&cond3
);
82 printf("Predicate: f1 <4 AND f1 >2 \n");
83 conn
.startTransaction();
89 cond4
.setTerm(p4
.getPredicate(), OpAnd
, p2
.getPredicate());
90 table
->setCondition(&cond4
);
91 printf("Predicate: f1 <4 AND f2 >3 \n");
92 conn
.startTransaction();
96 dbMgr
->closeTable(table
);
97 dbMgr
->dropTable("t1");