4 char name
[196] = "PRABAKARAN";
5 int select(Table
*table
, ComparisionOp op
)
7 printf("Operator test for %d\n", op
);
10 p1
.setTerm("f1", op
, &val1
);
11 table
->setCondition(&p1
);
14 while ((tuple
= (char*) table
->fetch())) {
15 printf("tuple value is ");
16 AllDataType::printVal(&id
, typeTime
,0);
17 printf(" %s \n", name
);
27 DbRetVal rv
= conn
.open("root", "manager");
30 printf("Error during connection %d\n", rv
);
33 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
34 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
36 tabDef
.addField("f1", typeTime
, 0, NULL
, true);
37 tabDef
.addField("f2", typeString
, 196);
38 rv
= dbMgr
->createTable("t1", tabDef
);
39 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
40 printf("Table created\n");
42 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
43 strcpy(idxInfo
->tableName
, "t1");
44 idxInfo
->list
.append("f1");
45 idxInfo
->indType
= hashIndex
;
46 idxInfo
->isUnique
= true;
47 idxInfo
->isPrimary
= true;
48 rv
= dbMgr
->createIndex("indx1", idxInfo
);
49 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
51 printf("Index created\n");
54 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
55 strcpy(idxInfo
->tableName
, "t1");
56 idxInfo
->list
.append("f1");
57 idxInfo
->indType
= treeIndex
;
58 rv
= dbMgr
->createIndex("indx1", idxInfo
);
59 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
61 printf("Index created\n");
64 Table
*table
= dbMgr
->openTable("t1");
65 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
66 table
->bindFld("f1", &id
);
67 table
->bindFld("f2", name
);
71 rv
=conn
.startTransaction();
72 for(i
= 10; i
< 15; i
++)
74 if (rv
!= OK
) exit(5);
75 for (int j
=29 ; j
<34; j
++) {
77 strcpy(name
, "PRABAKARAN0123456750590");
78 ret
= table
->insertTuple();
84 conn
.startTransaction();
85 select(table
, OpEquals
);
88 conn
.startTransaction();
89 select(table
, OpNotEquals
);
92 conn
.startTransaction();
93 select(table
, OpLessThan
);
96 conn
.startTransaction();
97 select( table
, OpLessThanEquals
);
100 conn
.startTransaction();
101 select( table
, OpGreaterThan
);
104 conn
.startTransaction();
105 select( table
, OpGreaterThanEquals
);
109 dbMgr
->closeTable(table
);
110 dbMgr
->dropTable("t1");