11 char name
[100];//="NIHAR";
12 int select(Table
*table
, ComparisionOp op
)
14 printf("Operator Test for %d\n",op
);
17 p1
.setTerm("f1",op
,&val1
);
18 table
->setCondition(&p1
);
21 while((tuple
=(char*) table
->fetch()))
23 printf("Tuple is %d %s \n",id
,name
);
32 DbRetVal rv
=conn
.open("root","manager");
35 printf("Error during connection %d\n", rv
);
38 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
39 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
41 tabDef
.addField("f1", typeInt
, 0, NULL
, true );
42 tabDef
.addField("f2", typeString
, 100);
43 rv
= dbMgr
->createTable("t1", tabDef
);
44 if (rv
!= OK
) { printf("Table creation failed\n"); return 3; }
45 printf("Table created\n");
47 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
48 strcpy(idxInfo
->tableName
, "t1");
49 idxInfo
->list
.append("f1");
50 idxInfo
->indType
= hashIndex
;
51 rv
= dbMgr
->createIndex("indx1", idxInfo
);
52 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
53 printf("Index created\n");
57 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
58 strcpy(idxInfo
->tableName
, "t1");
59 idxInfo
->list
.append("f1");
60 idxInfo
->indType
= treeIndex
;
61 rv
= dbMgr
->createIndex("indx1", idxInfo
);
62 if (rv
!= OK
) { printf("Index creation failed\n"); return -1; }
63 printf("Index created\n");
66 Table
*table
= dbMgr
->openTable("t1");
67 if (table
== NULL
) { printf("Unable to open table\n"); return 4; }
68 table
->bindFld("f1", &id
);
69 table
->bindFld("f2", name
);
74 rv
=conn
.startTransaction();
75 for(i
= 6; i
< 12; i
++)
77 if (rv
!= OK
) exit(5);
79 sprintf(nam
,"%s%d","NIHAR",i
);
81 ret
= table
->insertTuple();
85 conn
.startTransaction();
86 select(table
, OpEquals
);
89 conn
.startTransaction();
90 select(table
, OpNotEquals
);
93 conn
.startTransaction();
94 select(table
, OpLessThan
);
97 conn
.startTransaction();
98 select( table
, OpLessThanEquals
);
101 conn
.startTransaction();
102 select( table
, OpGreaterThan
);
105 conn
.startTransaction();
106 select( table
, OpGreaterThanEquals
);
109 dbMgr
->closeTable(table
);
110 dbMgr
->dropTable("t1");