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 4000 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
);
36 Table
*table
= dbMgr
->openTable("t1");
39 printf("Unable to open table\n");
40 dbMgr
->dropTable("t1");
45 char name
[20] = "PRAVEEN";
46 table
->bindFld("f1", &id1
);
47 table
->bindFld("f2", &id2
);
48 table
->bindFld("f3", name
);
50 for (i
= 0 ; i
< 4000 ; i
++)
52 conn
.startTransaction();
55 rv
= table
->insertTuple();
59 printf("%d records inserted\n", i
);
61 for (int k
=0; k
<100; k
++) {
62 table
->setCondition(NULL
);
63 rv
= table
->execute();
65 printf("table execute failed rv:%d\n", rv
);
66 dbMgr
->closeTable(table
);
71 conn
.startTransaction();
72 for (i
= 0 ; i
< 4000 ; i
++)
74 tuple
= table
->fetchNoBind();
75 if (tuple
== NULL
) { printf("No more records\n"); break; }
76 rv
= table
->deleteTuple();
77 if (rv
!= OK
) { printf("Delete tuple failed\n"); break;}
78 if (i
%50 == 0) { conn
.commit(); conn
.startTransaction(); }
82 printf("Iteration:%d \n %d records deleted\n", k
, i
);
84 conn
.startTransaction();
85 for (i
= 0 ; i
< 4000 ; i
++)
89 rv
= table
->insertTuple();
91 if (i
%50 == 0) { conn
.commit(); conn
.startTransaction(); }
94 printf("%d records inserted\n", i
);
97 dbMgr
->closeTable(table
);
98 dbMgr
->dropTable("t1");