commenting failing queries
[csql.git] / test / dbapi / Predicate / notandpredicate1.c
blobb606268be970cdb7d40ad62e23fa90c041ffb739
1 //Testing NOT with AND operator with all comparision operator on int data type.
2 //Five tuples are inserted and then selected by setting predicates
3 //with AND operator with NOT operator
5 #include "common.h"
6 int main()
8 Connection conn;
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; }
15 #ifdef WITHF1INDEX
16 if (createIndex(dbMgr, "f1", "idx1") != 0) {dbMgr->dropTable("t1");
17 conn.close();
18 return 4;
20 #endif
22 #ifdef WITHF2INDEX
23 if (createIndex(dbMgr, "f2", "idx2") != 0) {dbMgr->dropTable("t1");
24 conn.close();
25 return 4;
27 #endif
29 int inscount = insertTuple(dbMgr, conn);
30 //check the inscount and return error
32 Table *table = dbMgr->openTable("t1");
33 if (table == NULL)
35 printf("Unable to open table\n");
36 return 0;
40 Condition p1,p2,p3,p4,p5;
41 int val1 = 2, val2 = 3, val3 = 4;
42 p1.setTerm("f1", OpEquals, &val3);
43 p2.setTerm("f2", OpGreaterThan, &val2);
44 p3.setTerm("f2", OpEquals, &val3);
45 p4.setTerm("f1", OpLessThan, &val3);
46 p5.setTerm("f1", OpGreaterThan, &val1);
49 Condition cond1, cond1a;
50 cond1.setTerm(p1.getPredicate(), OpAnd, p2.getPredicate());
51 cond1a.setTerm(cond1.getPredicate(), OpNot);
52 table->setCondition(&cond1a);
53 printf("Predicate: NOT(f1 ==4 AND f2 >3) \n");
54 conn.startTransaction();
55 execAndPrint(table);
56 conn.commit();
58 Condition cond2, cond2a;
59 cond2.setTerm(p1.getPredicate(), OpAnd, p3.getPredicate());
60 cond2a.setTerm(cond2.getPredicate(), OpNot);
61 table->setCondition(&cond2a);
62 printf("Predicate: NOT( f1 ==4 AND f2 ==4) \n");
63 conn.startTransaction();
64 execAndPrint(table);
65 conn.commit();
67 Condition cond3, cond3a;
68 cond3.setTerm(p4.getPredicate(), OpAnd, p5.getPredicate());
69 cond3a.setTerm(cond3.getPredicate(), OpNot);
70 table->setCondition(&cond3a);
71 printf("Predicate: NOT( f1 <4 AND f2 >2) \n");
72 conn.startTransaction();
73 execAndPrint(table);
74 conn.commit();
77 Condition cond4, cond4a;
78 cond4.setTerm(p4.getPredicate(), OpAnd, p2.getPredicate());
79 cond4a.setTerm(cond4.getPredicate(), OpNot);
80 table->setCondition(&cond4a);
81 printf("Predicate: NOT( f1 <4 AND f2 >3) \n");
82 conn.startTransaction();
83 execAndPrint(table);
84 conn.commit();
86 Condition cond5, cond5a;
87 cond5.setTerm(p2.getPredicate(), OpNot);
88 cond5a.setTerm(p4.getPredicate(), OpAnd, cond5.getPredicate());
89 table->setCondition(&cond5a);
90 printf("Predicate: ( f1 <4 AND (NOT(f2 >3)) \n");
91 conn.startTransaction();
92 execAndPrint(table);
94 conn.commit();
95 dbMgr->closeTable(table);
96 dbMgr->dropTable("t1");
97 conn.close();
98 return 0;