Search in sources :

Example 21 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_CreateConglomRet method t_014.

/**
 * Test getTableProperties() of BTreeController.
 * <p>
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_014(TransactionController tc) throws StandardException, T_Fail {
    ScanController scan = null;
    // SanityManager.DEBUG_SET("LockTrace");
    REPORT("Starting t_014");
    // create the base table
    DataValueDescriptor[] base_row = TemplateRow.newU8Row(2);
    T_SecondaryIndexRow index_row1 = new T_SecondaryIndexRow();
    long base_conglomid = tc.createConglomerate(// create a heap conglomerate
    "heap", // base table template row
    base_row, // column sort order - not required for heap
    null, // default collation
    null, // default properties
    null, TransactionController.IS_DEFAULT);
    // Open the base table
    ConglomerateController base_cc = tc.openConglomerate(base_conglomid, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    RowLocation base_rowloc1 = base_cc.newRowLocationTemplate();
    index_row1.init(base_row, base_rowloc1, 3);
    // create the secondary index
    Properties properties = createProperties(// no current properties list
    null, // don't allow duplicates
    false, // index on all base row cols + row location
    3, // non-unique index
    2, // maintain parent links
    true, // fake base conglom for now
    base_conglomid, // row loc in last column
    2);
    properties.put(Property.PAGE_SIZE_PARAMETER, "8192");
    properties.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, "99");
    properties.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, "42");
    TransactionManager tm = (TransactionManager) tc;
    // Create a index.
    long conglomid = tc.createConglomerate(// create a heap conglomerate
    "BTREE", // 1 column template.
    index_row1.getRow(), // column sort order - default
    null, // default collation
    null, // default properties
    properties, // not temporary
    TransactionController.IS_DEFAULT);
    // Open the conglomerate.
    ConglomerateController cc = tc.openConglomerate(conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    // verify that input properties were used.
    Properties ret_prop = new Properties();
    ret_prop.put(Property.PAGE_SIZE_PARAMETER, "");
    ret_prop.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, "");
    ret_prop.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, "");
    cc.getTableProperties(ret_prop);
    if (ret_prop.getProperty(Property.PAGE_SIZE_PARAMETER).compareTo("8192") != 0 || ret_prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER).compareTo("0") != 0 || ret_prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER).compareTo("1") != 0) {
        throw T_Fail.testFailMsg("(getTableProperties) Did not get expected table propertes." + "\nGot pageSize = " + ret_prop.getProperty(Property.PAGE_SIZE_PARAMETER) + "\nGot reserved = " + ret_prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER) + "\nGot minimum record size = " + ret_prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER));
    }
    tc.commit();
    REPORT("Ending t_014");
    return (true);
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) TransactionManager(org.apache.derby.iapi.store.access.conglomerate.TransactionManager) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) Properties(java.util.Properties) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 22 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_CreateConglomRet method t_017.

/**
 * Test BTree.openScan(), BtreeScan.init(), BtreeScan.next(),
 * BtreeScan.fetch() with descending indexes.
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_017(TransactionController tc) throws StandardException, T_Fail {
    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_017");
    // create the base table
    long base_conglomid = tc.createConglomerate(// create a heap conglomerate
    "heap", // base table template row
    base_row, // column sort order - not required for heap
    null, // default collation
    null, // default properties
    null, // not temporary
    TransactionController.IS_DEFAULT);
    // 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(// no current properties list
    null, // don't allow duplicates
    false, // 4 columns in index row
    5, // non-unique index
    5, // maintain parent links
    true, // base conglom id
    base_conglomid, // row loc in last column
    4);
    // create the index with all the columns in descending order
    ColumnOrdering[] order = new ColumnOrdering[5];
    // descending
    order[0] = new T_ColumnOrderingImpl(0, false);
    // descending
    order[1] = new T_ColumnOrderingImpl(1, false);
    // descending
    order[2] = new T_ColumnOrderingImpl(2, false);
    // descending
    order[3] = new T_ColumnOrderingImpl(3, false);
    // asccending
    order[4] = new T_ColumnOrderingImpl(4, true);
    long index_conglomid = tc.createConglomerate(// create a btree secondary
    "BTREE", // row template
    index_row.getRow(), // column sort order - default
    order, // default collation
    null, // properties
    properties, // not temporary
    TransactionController.IS_DEFAULT);
    // 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);
        // ")" + template);
        if (index_cc.insert(template.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    index_cc.checkConsistency();
    ((B2IController) index_cc).debugConglomerate();
    ret_val = t_desc_scan_test_cases(tc, index_conglomid, template);
    // 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);
        // ")" + template);
        if (index_cc.insert(template.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
        // now delete the row.
        base_cc.delete(row_loc);
        ScanController delete_scan = tc.openScan(index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, template.getRow(), ScanController.GE, null, template.getRow(), ScanController.GT);
        if (!delete_scan.next()) {
            throw T_Fail.testFailMsg("delete could not find key");
        } else {
            delete_scan.delete();
            if (delete_scan.next())
                throw T_Fail.testFailMsg("delete found more than one key");
        }
        delete_scan.close();
    }
    ret_val = t_desc_scan_test_cases(tc, index_conglomid, template);
    // Close the conglomerate.
    index_cc.close();
    tc.commit();
    REPORT("Ending t_017");
    return (ret_val);
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ColumnOrdering(org.apache.derby.iapi.store.access.ColumnOrdering) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLChar(org.apache.derby.iapi.types.SQLChar) Properties(java.util.Properties) SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLLongint(org.apache.derby.iapi.types.SQLLongint) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 23 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_CreateConglomRet method t_001.

/**
 * Test BTreeController.insert()
 * <p>
 * Just verify that insert code works for a secondary index.  Just call
 * the interface and make sure the row got there.
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_001(TransactionController tc) throws StandardException, T_Fail {
    REPORT("Starting t_001");
    T_CreateConglomRet create_ret = new T_CreateConglomRet();
    createCongloms(tc, 2, false, false, 0, 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);
    if (!(index_cc instanceof B2IController)) {
        throw T_Fail.testFailMsg("openConglomerate returned wrong type");
    }
    if (!index_cc.isKeyed()) {
        throw T_Fail.testFailMsg("btree is not keyed.");
    }
    index_cc.checkConsistency();
    // Create a row and insert into base table, remembering it's location.
    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);
    ((SQLLongint) r1[0]).setValue(2);
    ((SQLLongint) r1[1]).setValue(2);
    // Insert the row into the base table and remember its location.
    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");
    // Make sure we read back the value we wrote from base and index table.
    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);
    // base table check:
    if (!base_cc.fetch(base_rowloc1, r2, (FormatableBitSet) null)) {
        return (FAIL("(t_001) insert into base table failed"));
    }
    if (((SQLLongint) r2[0]).getLong() != 2 || ((SQLLongint) r2[1]).getLong() != 2) {
        return (FAIL("(t_001) insert into base table failed"));
    }
    // index check - there should be only one record:
    ScanController scan = tc.openScan(create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA);
    scan.next();
    scan.fetch(index_row2.getRow());
    // isCurrentPositionDeleted() works.
    if (scan.isCurrentPositionDeleted())
        throw T_Fail.testFailMsg("current row should not be deleted\n");
    if (!scan.doesCurrentPositionQualify())
        throw T_Fail.testFailMsg("current row should still qualify\n");
    scan.delete();
    if (!scan.isCurrentPositionDeleted())
        throw T_Fail.testFailMsg("current row should be deleted\n");
    if (scan.doesCurrentPositionQualify())
        throw T_Fail.testFailMsg("deleted row should not qualify\n");
    // just call the debugging code to make sure it doesn't fail.
    REPORT("Calling scan.tostring(): " + scan);
    if (scan.next() || ((SQLLongint) (index_row2.getRow()[0])).getLong() != 2 || ((SQLLongint) (index_row2.getRow()[1])).getLong() != 2) {
        return (FAIL("(t_001) insert into index failed in base cols"));
    }
    // test the scaninfo interface.
    ScanInfo scan_info = scan.getScanInfo();
    Properties prop = scan_info.getAllScanInfo(null);
    if (Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_PAGES_VISITED))) != 1) {
        throw T_Fail.testFailMsg("(scanInfo) wrong numPagesVisited.  Expected 1, got " + Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_PAGES_VISITED))));
    }
    if (Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_VISITED))) != 1) {
        throw T_Fail.testFailMsg("(scanInfo) wrong numRowsVisited. Expected 1, got " + Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_VISITED))));
    }
    if (Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_QUALIFIED))) != 1) {
        throw T_Fail.testFailMsg("(scanInfo) wrong numRowsQualified. Expected 1, got " + Integer.parseInt(prop.getProperty(MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_QUALIFIED))));
    }
    int compare_result = base_rowloc1.compare(base_rowloc2);
    if (compare_result != 0) {
        return (FAIL("(t_001) insert into index failed in recordhandle.\n" + "\texpected RecordHandle = " + base_rowloc1 + "\n" + "\tgot      RecordHandle = " + base_rowloc2 + "\tcompare result = " + compare_result));
    }
    index_cc.checkConsistency();
    // Close the conglomerates.
    base_cc.close();
    index_cc.close();
    try {
        base_cc.insert(r1);
        return (FAIL("(t_001) insert on closed conglomerate worked"));
    } catch (StandardException e) {
    // e.printStackTrace();
    }
    try {
        if (index_cc.insert(r1) != 0)
            throw T_Fail.testFailMsg("insert failed");
        return (FAIL("(t_001) insert on closed conglomerate worked"));
    } catch (StandardException e) {
    // e.printStackTrace();
    }
    tc.commit();
    REPORT("Ending t_001");
    return true;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ScanInfo(org.apache.derby.iapi.store.access.ScanInfo) Properties(java.util.Properties) SQLLongint(org.apache.derby.iapi.types.SQLLongint) StandardException(org.apache.derby.shared.common.error.StandardException) SQLLongint(org.apache.derby.iapi.types.SQLLongint) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 24 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_CreateConglomRet method t_015.

/**
 * Test latch release during critical time during row level locking.
 * <p>
 * Use trace points to force errors in split at critical points:
 *     leaf_split_abort{1,2,3,4}
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_015(TransactionController tc) throws StandardException, T_Fail {
    ScanController scan = null;
    // SanityManager.DEBUG_SET("LockTrace");
    REPORT("Starting t_015");
    T_CreateConglomRet create_ret = new T_CreateConglomRet();
    // Create the btree so that it only allows 2 rows per page.
    createCongloms(tc, 2, false, false, 2, 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);
    if (!(index_cc instanceof B2IController)) {
        throw T_Fail.testFailMsg("openConglomerate returned wrong type");
    }
    index_cc.checkConsistency();
    // Create a row and insert into base table, remembering it's location.
    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);
    // Commit the create of the tables so that the following aborts don't
    // undo that work.
    tc.commit();
    // Now load up the table with multiple pages of data.
    // 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);
    // now insert enough rows to cause failure
    for (int i = 100; i > 0; i -= 2) {
        ((SQLLongint) r1[0]).setValue(2);
        ((SQLLongint) r1[1]).setValue(i);
        // Insert the row into the base table;remember its location.
        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");
        }
    }
    // Now try simulated lock wait/latch release paths through the code.
    String[] latch_debug_strings = { "B2iRowLocking3_1_lockScanRow1", "B2iRowLocking3_2_lockScanRow1", "BTreeScan_positionAtStartPosition1", // "BTreeScan_reposition1",
    "BTreeScan_fetchNextGroup1" };
    for (int errs = 0; errs < latch_debug_strings.length; errs++) {
        REPORT("Doing latch release tests: " + latch_debug_strings[errs]);
        // latch release path through the code.
        if (SanityManager.DEBUG)
            SanityManager.DEBUG_SET(latch_debug_strings[errs]);
        // Just scan the rows and make sure you see them all, mostly just
        // a test to make sure no errors are thrown by the latch release
        // code paths.
        scan = tc.openScan(create_ret.index_conglomid, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA);
        int row_count = 0;
        while (scan.next()) {
            row_count++;
        }
        scan.close();
        if (row_count != 50)
            throw T_Fail.testFailMsg("wrong scan count = " + row_count);
    }
    tc.abort();
    REPORT("Ending t_015");
    return true;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLLongint(org.apache.derby.iapi.types.SQLLongint) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 25 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_CreateConglomRet method t_019.

/**
 * Test BTree.openScan(), BtreeScan.init(), BtreeScan.next(),
 * BtreeScan.fetch() with alternating ascending and descending coulmn
 * sort order indexes.
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_019(TransactionController tc) throws StandardException, T_Fail {
    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_019");
    // create the base table
    long base_conglomid = tc.createConglomerate(// create a heap conglomerate
    "heap", // base table template row
    base_row, // column sort order - not required for heap
    null, // default collation
    null, // default properties
    null, // not temporary
    TransactionController.IS_DEFAULT);
    // 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(// no current properties list
    null, // don't allow duplicates
    false, // 4 columns in index row
    5, // non-unique index
    5, // maintain parent links
    true, // base conglom id
    base_conglomid, // row loc in last column
    4);
    // create the index with all the columns in descending order
    ColumnOrdering[] order = new ColumnOrdering[5];
    // Descending
    order[0] = new T_ColumnOrderingImpl(0, false);
    // Ascending
    order[1] = new T_ColumnOrderingImpl(1, true);
    // Ascending
    order[2] = new T_ColumnOrderingImpl(2, true);
    // descending
    order[3] = new T_ColumnOrderingImpl(3, false);
    // asccending
    order[4] = new T_ColumnOrderingImpl(4, true);
    long index_conglomid = tc.createConglomerate(// create a btree secondary
    "BTREE", // row template
    index_row.getRow(), // column sort order - default
    order, // default collation
    null, // properties
    properties, // not temporary
    TransactionController.IS_DEFAULT);
    // 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);
        // ")" + template);
        if (index_cc.insert(template.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    index_cc.checkConsistency();
    ((B2IController) index_cc).debugConglomerate();
    ret_val = t_ascdesc1_scan_test_cases(tc, index_conglomid, template);
    // 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);
        // ")" + template);
        if (index_cc.insert(template.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
        // now delete the row.
        base_cc.delete(row_loc);
        ScanController delete_scan = tc.openScan(index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, template.getRow(), ScanController.GE, null, template.getRow(), ScanController.GT);
        if (!delete_scan.next()) {
            throw T_Fail.testFailMsg("delete could not find key");
        } else {
            delete_scan.delete();
            if (delete_scan.next())
                throw T_Fail.testFailMsg("delete found more than one key");
        }
        delete_scan.close();
    }
    ret_val = t_ascdesc1_scan_test_cases(tc, index_conglomid, template);
    // Close the conglomerate.
    index_cc.close();
    tc.commit();
    REPORT("Ending t_019");
    return (ret_val);
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ColumnOrdering(org.apache.derby.iapi.store.access.ColumnOrdering) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLChar(org.apache.derby.iapi.types.SQLChar) Properties(java.util.Properties) SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLLongint(org.apache.derby.iapi.types.SQLLongint) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation)

Aggregations

ScanController (org.apache.derby.iapi.store.access.ScanController)61 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 RowLocation (org.apache.derby.iapi.types.RowLocation)29 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)22 SQLLongint (org.apache.derby.iapi.types.SQLLongint)20 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)9 StandardException (org.apache.derby.shared.common.error.StandardException)9 TransactionController (org.apache.derby.iapi.store.access.TransactionController)8 Properties (java.util.Properties)7 GroupFetchScanController (org.apache.derby.iapi.store.access.GroupFetchScanController)7 SQLChar (org.apache.derby.iapi.types.SQLChar)6 UUID (org.apache.derby.catalog.UUID)5 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)5 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)5 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)4 HashSet (java.util.HashSet)3 Hashtable (java.util.Hashtable)3 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)3