T_SecondaryIndexRow index_row = new T_SecondaryIndexRow();
// base row template - last column is just to make row long so that
// multiple pages are spanned.
DataValueDescriptor[] base_row = TemplateRow.newU8Row(4);
base_row[3] = new SQLChar();
String string_1500char = new String();
for (int i = 0; i < 300; i++)
string_1500char += "mikem";
boolean ret_val = true;
long value = -1;
long col1[] = { 1, 3, 4, 4, 4, 5, 5, 5, 6, 7, 9};
long col2[] = { 1, 1, 2, 4, 6, 2, 4, 6, 1, 1, 1};
long col3[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};
// set of deleted rows to make scans more interesting
long d_col1[] ={ 0, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8, 10, 11, 12};
long d_col2[] ={ 1, 1, 2, 3, 5, 0, 3, 5, 0, 0, 1, 42, 42, 1};
long d_col3[] ={91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104};
REPORT("Starting t_003");
// create the base table
long base_conglomid =
tc.createConglomerate(
"heap", // create a heap conglomerate
base_row, // base table template row
null, //column sort order - not required for heap
null, // default properties
TransactionController.IS_DEFAULT); // not temporary
// Open the base table
ConglomerateController base_cc =
tc.openConglomerate(
base_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
// initialize the secondary index row - pointing it at base row
index_row.init(base_row, base_cc.newRowLocationTemplate(), 5);
Properties properties =
createProperties(
null, // no current properties list
false, // don't allow duplicates
5, // 4 columns in index row
5, // non-unique index
true, // maintain parent links
base_conglomid, // base conglom id
4); // row loc in last column
long index_conglomid =
tc.createConglomerate(
"BTREE", // create a btree secondary
index_row.getRow(), // row template
null, //column sort order - default
properties, // properties
TransactionController.IS_DEFAULT); // not temporary
// Open the conglomerate.
ConglomerateController index_cc =
tc.openConglomerate(
index_conglomid,
false,
TransactionController.OPENMODE_FORUPDATE,
TransactionController.MODE_RECORD,
TransactionController.ISOLATION_SERIALIZABLE);
// Create a row.
T_SecondaryIndexRow template = new T_SecondaryIndexRow();
RowLocation row_loc = base_cc.newRowLocationTemplate();
template.init(base_row, row_loc, 5);
// insert them in reverse order just to make sure btree is sorting them
for (int i = col1.length - 1; i >= 0; i--)
{
((SQLLongint)(template.getRow()[0])).setValue(col1[i]);
((SQLLongint)(template.getRow()[1])).setValue(col2[i]);
((SQLLongint)(template.getRow()[2])).setValue(col3[i]);
base_row[3] = new SQLChar(string_1500char);
base_cc.insertAndFetchLocation(base_row, row_loc);
// Insert the row.
// System.out.println("Adding record (" + -(i - (col1.length -1)) +
// ")" + template);
if (index_cc.insert(template.getRow()) != 0)
throw T_Fail.testFailMsg("insert failed");
}
index_cc.checkConsistency();
((B2IController)index_cc).debugConglomerate();
ret_val = t_003_scan_test_cases(tc, index_conglomid, template);
// insert and delete some interesting rows, deleted space management
// may or may not clean these up.
for (int i = d_col1.length - 1; i >= 0; i--)
{
((SQLLongint)(template.getRow()[0])).setValue(d_col1[i]);
((SQLLongint)(template.getRow()[1])).setValue(d_col2[i]);
((SQLLongint)(template.getRow()[2])).setValue(d_col3[i]);
base_row[3] = new SQLChar(string_1500char);
base_cc.insertAndFetchLocation(base_row, row_loc);
// Insert the row.
// System.out.println("Adding record (" + -(i - (col1.length -1)) +