* @exception T_Fail Throws T_Fail on any test failure.
**/
protected boolean t_013(TransactionController tc)
throws StandardException, T_Fail
{
ScanController scan = null;
// SanityManager.DEBUG_SET("LockTrace");
REPORT("Starting t_013");
T_CreateConglomRet create_ret = new T_CreateConglomRet();
// Create the btree so that it only allows 2 rows per page.
createCongloms(tc, 2, true, false, 5, create_ret);
// Open the base table
ConglomerateController base_cc =
tc.openConglomerate(
create_ret.base_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
// Open the secondary index
ConglomerateController index_cc =
tc.openConglomerate(
create_ret.index_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
// Create an index row object for the "delete row"
DataValueDescriptor[] r1 = TemplateRow.newU8Row(2);
T_SecondaryIndexRow index_row1 = new T_SecondaryIndexRow();
RowLocation base_rowloc1 = base_cc.newRowLocationTemplate();
index_row1.init(r1, base_rowloc1, 3);
// Create another index row object for the other inserts.
DataValueDescriptor[] r2 = TemplateRow.newU8Row(2);
T_SecondaryIndexRow index_row2 = new T_SecondaryIndexRow();
RowLocation base_rowloc2 = base_cc.newRowLocationTemplate();
index_row2.init(r2, base_rowloc2, 3);
// Commit the create of the tables so that the following aborts don't
// undo that work.
tc.commit();
// CASE 1:
tc.commit();
// Open the base table
base_cc = tc.openConglomerate(
create_ret.base_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
// Open the secondary index
index_cc = tc.openConglomerate(
create_ret.index_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
((SQLLongint)r1[0]).setValue(1);
// insert row which will be deleted (key = 100, base_rowloc1):
((SQLLongint)r1[1]).setValue(100);
base_cc.insertAndFetchLocation(r1, base_rowloc1);
// Insert the row into the secondary index.
if (index_cc.insert(index_row1.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
// insert enough rows so that the logical undo of the insert will
// need to search the tree. The tree has been set to split after
// 5 rows are on a page, so 10 should be plenty.
for (int i = 0; i < 10; i++)
{
((SQLLongint)r2[1]).setValue(i);
// Insert the row into the base table;remember its location.
base_cc.insertAndFetchLocation(r2, base_rowloc2);
// Insert the row into the secondary index.
if (index_cc.insert(index_row2.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
}
// delete row which was inserted (key = 100, base_rowloc1):
if (!t_delete(tc, create_ret.index_conglomid,
index_row1.getRow(), create_ret.index_template_row))
{
throw T_Fail.testFailMsg(
"t_008: could not delete key.");
}
base_cc.delete(base_rowloc1);
// insert enough rows so that the logical undo of the delete will
// need to search the tree. The tree has been set to split after
// 5 rows are on a page, so 10 should be plenty.
for (int i = 10; i < 20; i++)
{
((SQLLongint)r2[1]).setValue(i);
// Insert the row into the base table;remember its location.
base_cc.insertAndFetchLocation(r2, base_rowloc2);
// Insert the row into the secondary index.
if (index_cc.insert(index_row2.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
}
// insert row which will be deleted (key = 100, base_rowloc1):
((SQLLongint)r1[1]).setValue(100);
base_cc.insertAndFetchLocation(r1, base_rowloc1);
// Insert the row into the secondary index.
if (index_cc.insert(index_row1.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
// insert enough rows so that the logical undo of the update field will
// need to search the tree. The tree has been set to split after
// 5 rows are on a page, so 10 should be plenty.
for (int i = 20; i < 30; i++)
{
((SQLLongint)r2[1]).setValue(i);
// Insert the row into the base table;remember its location.
base_cc.insertAndFetchLocation(r2, base_rowloc2);
// Insert the row into the secondary index.
if (index_cc.insert(index_row2.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
}
// RESOLVE (mikem) - check that the right row is at key 100.
tc.abort();
// index check - there should be no records left.
ScanController empty_scan =
tc.openScan(create_ret.index_conglomid, false,
0,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE,
(FormatableBitSet) null,
null, ScanController.NA,
null,
null, ScanController.NA);
if (empty_scan.next())
throw T_Fail.testFailMsg("t_002: there are still rows in table.");
tc.commit();
REPORT("Ending t_013");