1 // Test Case: DB Full test with table and two index(hash and tree)
4 // Note:Each page can hold 4 records.
5 // For 100 iterations, delete and insert 1000 records
6 // Result:In all 100 iterations operations should succeed
12 DbRetVal rv
= conn
.open("root", "manager");
13 if (rv
!= OK
) return 1;
14 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
15 if (dbMgr
== NULL
) { printf("Auth failed\n"); return 2;}
18 tabDef
.addField("f1", typeInt
, 0, NULL
, true);
19 tabDef
.addField("f2", typeInt
, 0, NULL
, true);
20 tabDef
.addField("f3", typeString
, 2000);
21 rv
= dbMgr
->createTable("t1", tabDef
);
22 if (rv
!= OK
) { printf("Table creation failed\n"); conn
.close(); return 3; }
23 printf("Table created\n");
25 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
26 strcpy(idxInfo
->tableName
, "t1");
27 idxInfo
->list
.append("f1");
28 idxInfo
->indType
= hashIndex
;
29 rv
= dbMgr
->createIndex("indx1", idxInfo
);
30 idxInfo
->list
.remove("f1");
31 idxInfo
->list
.append("f2");
32 idxInfo
->indType
= treeIndex
;
33 rv
= dbMgr
->createIndex("indx2", idxInfo
);
35 Table
*table
= dbMgr
->openTable("t1");
38 printf("Unable to open table\n");
39 dbMgr
->dropTable("t1");
44 char name
[20] = "PRAVEEN";
45 table
->bindFld("f1", &id1
);
46 table
->bindFld("f2", &id2
);
47 table
->bindFld("f3", name
);
49 for (i
= 0 ; i
< 4000 ; i
++)
51 conn
.startTransaction();
54 rv
= table
->insertTuple();
58 printf("%d records inserted\n", i
);
59 for (int k
=0; k
<100; k
++) {
60 table
->setCondition(NULL
);
61 rv
= table
->execute();
63 printf("table execute failed rv:%d\n", rv
);
64 dbMgr
->closeTable(table
);
69 for (i
= 0 ; i
< 1000 ; i
++)
71 conn
.startTransaction();
72 tuple
= table
->fetchNoBind();
73 if (tuple
== NULL
) { printf("No more records\n"); break; }
74 rv
= table
->deleteTuple();
75 if (rv
!= OK
) { printf("Delete tuple failed\n"); break;}
79 printf("Iteration:%d \n %d records deleted\n", k
, i
);
81 for (i
= 0 ; i
< 1000 ; i
++)
83 conn
.startTransaction();
86 rv
= table
->insertTuple();
90 printf("%d records inserted\n", i
);
93 dbMgr
->closeTable(table
);
94 dbMgr
->dropTable("t1");