Search in sources :

Example 26 with SQLChar

use of org.apache.derby.iapi.types.SQLChar 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)

Example 27 with SQLChar

use of org.apache.derby.iapi.types.SQLChar in project derby by apache.

the class T_CreateConglomRet method createCongloms.

/**
 * Utility routine to create base table for tests.
 * <p>
 * A little utility routine to create base tables for tests.  Just
 * here to make tests a little more readable.  It currently just
 * creates a heap table with "num_cols" SQLLongint columns.
 *
 * @param num_cols the number of columns in the base table.
 *
 * @exception  StandardException  Standard exception policy.
 */
void createCongloms(TransactionController tc, int num_cols, boolean unique, boolean varying_first_col, int max_btreerows_per_page, T_CreateConglomRet ret_val) throws StandardException {
    T_SecondaryIndexRow index_row = new T_SecondaryIndexRow();
    DataValueDescriptor[] base_row = TemplateRow.newU8Row(num_cols);
    if (varying_first_col) {
        SQLChar string_col = new SQLChar();
        base_row[0] = string_col;
    }
    long base_conglomid = 0;
    // create the base table
    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
    RowLocation base_rowloc = base_cc.newRowLocationTemplate();
    index_row.init(base_row, base_rowloc, num_cols + 1);
    // 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
    num_cols + 1, // non-unique index
    (unique ? num_cols : num_cols + 1), // maintain parent links
    true, // base conglomid
    base_conglomid, // row loc in last column
    num_cols);
    if (max_btreerows_per_page > 1) {
        if (BTree.PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER != null) {
            properties.put(BTree.PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER, String.valueOf(max_btreerows_per_page));
        }
    }
    long index_conglomid = tc.createConglomerate(// create a btree secondary
    "BTREE", // index row template
    index_row.getRow(), // column sort order - default
    null, // default collation
    null, // properties
    properties, // not temporary
    TransactionController.IS_DEFAULT);
    // return values to caller
    ret_val.base_conglomid = base_conglomid;
    ret_val.index_conglomid = index_conglomid;
    // RESOLVE (mikem - 04/29/98 - why is following line commented out?
    // ret_val.base_template_row  = TemplateRow.newU8Row(num_cols);
    ret_val.index_template_row = index_row.getRow();
    return;
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) Properties(java.util.Properties) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 28 with SQLChar

use of org.apache.derby.iapi.types.SQLChar in project derby by apache.

the class T_RawStoreFactory method P055.

/**
 *        Test rollback of partial row update.
 *        Create a long row with 10 columns on 2 pages (5 columns on each page).
 *        Update the 1st column on the 2nd page (the 6th column) which causes the
 *        last column (10th column) to move off the page. Then abort and make sure
 *        that all the original columns are there and correct.
 *
 *        NOTE: stored length is twice string length + 2
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P055(long segment) throws StandardException, T_Fail {
    if (!testRollback)
        return;
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment, 4096);
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    int colSize = 90;
    T_RawStoreRow r0 = new T_RawStoreRow(10);
    r0.setColumn(0, colSize, REC_001);
    r0.setColumn(1, colSize, REC_002);
    r0.setColumn(2, colSize, REC_003);
    r0.setColumn(3, colSize, REC_004);
    r0.setColumn(4, colSize, REC_005);
    r0.setColumn(5, colSize, REC_009);
    r0.setColumn(6, colSize, REC_010);
    r0.setColumn(7, colSize, REC_011);
    r0.setColumn(8, colSize, REC_012);
    r0.setColumn(9, colSize, REC_013);
    int insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_OVERFLOW;
    RecordHandle rh0 = null;
    try {
        rh0 = t_util.t_insertAtSlot(page, 0, r0, (byte) insertFlag);
    } catch (StandardException se) {
        throw T_Fail.testFailMsg("insert of long row failed.");
    }
    if (rh0 == null)
        throw T_Fail.testFailMsg("insert of first long row failed.");
    else {
        REPORT("about to check fetch...");
        DataValueDescriptor column = new SQLChar();
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 0, column, false, REC_001, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 1, column, false, REC_002, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 2, column, false, REC_003, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 3, column, false, REC_004, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 4, column, false, REC_005, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 5, column, false, REC_009, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 6, column, false, REC_010, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 7, column, false, REC_011, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 8, column, false, REC_012, colSize);
        t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 9, column, false, REC_013, colSize);
    }
    t_util.t_commit(t);
    // update col 5 (the 6th column, the first column on the 2nd overflow page), which causes
    // the last column (col 9, the 10th column) to move off the page.
    c = t_util.t_openContainer(t, segment, cid, true);
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    T_RawStoreRow updateRow = new T_RawStoreRow(10);
    for (int i = 0; i < 10; i++) updateRow.setColumn(i, (String) null);
    updateRow.setColumn(5, colSize * 2, REC_009);
    FormatableBitSet colList = new FormatableBitSet(10);
    colList.set(5);
    page.updateAtSlot(0, updateRow.getRow(), colList);
    REPORT("about to check fetch after update ...");
    DataValueDescriptor column = new SQLChar();
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 0, column, false, REC_001, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 1, column, false, REC_002, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 2, column, false, REC_003, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 3, column, false, REC_004, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 4, column, false, REC_005, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 5, column, false, REC_009, colSize * 2);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 6, column, false, REC_010, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 7, column, false, REC_011, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 8, column, false, REC_012, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 9, column, false, REC_013, colSize);
    page.unlatch();
    t_util.t_abort(t);
    REPORT("about to check fetch after abort ...");
    c = t_util.t_openContainer(t, segment, cid, false);
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 0, column, false, REC_001, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 1, column, false, REC_002, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 2, column, false, REC_003, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 3, column, false, REC_004, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 4, column, false, REC_005, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 5, column, false, REC_009, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 6, column, false, REC_010, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 7, column, false, REC_011, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 8, column, false, REC_012, colSize);
    t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, 9, column, false, REC_013, colSize);
    page.unlatch();
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t_util.t_commit(t);
    t.close();
    PASS("P055: segment = " + segment);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) SQLChar(org.apache.derby.iapi.types.SQLChar) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Example 29 with SQLChar

use of org.apache.derby.iapi.types.SQLChar in project derby by apache.

the class T_RawStoreFactory method P009.

/**
 *		P009
 *
 *		this test exercises repeated shrinking and expanding of fields using updateFieldBySlot
 *
 *		we will insert as many rows as possible into the page. Then set some of the columns to null,
 *		That should not create more space on the page for inserts, because the extra space become
 *		reservedspace for the row.  So, the next insert should fail.
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P009(long segment) throws StandardException, T_Fail {
    int slot = 0;
    int i = 0;
    int j = 0;
    String field = REC_001;
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment);
    // Get the first page & check the record counts are zero
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    // Create a 13-column row
    T_RawStoreRow row = new T_RawStoreRow(13);
    row.setColumn(0, (String) null);
    row.setColumn(1, REC_001);
    row.setColumn(2, REC_002);
    row.setColumn(3, REC_003);
    row.setColumn(4, REC_004);
    row.setColumn(5, REC_005);
    row.setColumn(6, REC_006);
    row.setColumn(7, REC_007);
    row.setColumn(8, (String) null);
    row.setColumn(9, (String) null);
    row.setColumn(10, REC_007);
    row.setColumn(11, (String) null);
    row.setColumn(12, REC_006);
    // insert the row into the page until the page is full
    int numRows = 0;
    slot = page.FIRST_SLOT_NUMBER;
    while (page.spaceForInsert(row.getRow(), (FormatableBitSet) null, 100)) {
        t_util.t_insert(page, row);
        numRows++;
    }
    REPORT(numRows + " rows inserted ");
    // update all the fields in the even number rows to null
    // set all the fields in the odd number rows to REC_001
    // null
    DataValueDescriptor col = new SQLChar();
    for (i = page.FIRST_SLOT_NUMBER; i < (page.FIRST_SLOT_NUMBER + 2); i++) {
        for (slot = i; slot <= (numRows - 1); slot += 2) {
            for (j = 0; j <= 12; j++) {
                if (page.updateFieldAtSlot(slot, j, col, null) == null) {
                    throw T_Fail.testFailMsg("Failed to update field " + j + ", in row " + slot);
                }
            }
        }
        col = new SQLChar(REC_001);
    }
    // fetch all the fields, and see if they are correct
    DataValueDescriptor storedColumn = new SQLChar();
    field = null;
    for (i = page.FIRST_SLOT_NUMBER; i < (page.FIRST_SLOT_NUMBER + 2); i++) {
        for (slot = i; slot <= (numRows - 1); slot += 2) {
            for (j = 0; j <= 12; j++) {
                t_util.t_checkFetchColFromSlot(page, slot, j, storedColumn, false, field);
            }
        }
        field = REC_001;
    }
    // Now if we try to insert the old row again, there should still be no room
    if (page.spaceForInsert())
        throw T_Fail.testFailMsg("Did not get no room for record on page error");
    // update the first and last field of every row to REC_006
    col = new SQLChar(REC_006);
    for (slot = page.FIRST_SLOT_NUMBER; slot <= (numRows - 1); slot++) {
        if (page.updateFieldAtSlot(slot, 0, col, null) == null || page.updateFieldAtSlot(slot, 12, col, null) == null) {
            throw T_Fail.testFailMsg("Failed to update fields to REC_006 in row " + slot);
        }
    }
    // update field 5 and 6 of every row to REC_007
    col = new SQLChar(REC_007);
    for (slot = page.FIRST_SLOT_NUMBER; slot <= (numRows - 1); slot++) {
        if (page.updateFieldAtSlot(slot, 5, col, null) == null || page.updateFieldAtSlot(slot, 6, col, null) == null) {
            throw T_Fail.testFailMsg("Failed to update fields to REC_007 in row " + slot);
        }
    }
    // fetch all the fields again, and see if they are correct
    for (i = page.FIRST_SLOT_NUMBER; i < (page.FIRST_SLOT_NUMBER + 2); i++) {
        for (slot = i; slot <= (numRows - 1); slot += 2) {
            for (j = 0; j <= 12; j++) {
                switch(j) {
                    case 0:
                    case 12:
                        field = REC_006;
                        break;
                    case 5:
                    case 6:
                        field = REC_007;
                        break;
                    default:
                        if ((slot % 2) == 0)
                            field = null;
                        else
                            field = REC_001;
                        break;
                }
                t_util.t_checkFetchColFromSlot(page, slot, j, storedColumn, false, field);
            }
        }
    }
    // We now try to insert the old row one last time, there should still be no room
    if (page.spaceForInsert())
        throw T_Fail.testFailMsg("Did not get no room for record on page error");
    // now we want to increase row 0 and column 5 one byte at a time, until the page is full
    // but, every 5 increases we will reduce the field size by one byte
    field = REC_007;
    i = 0;
    String field_pre = null;
    while (true) {
        if ((i % 5) != 0) {
            field_pre = field;
            field += REC_008;
        } else {
            field = field_pre;
        }
        if (((i % 10) == 3) || ((i % 10) == 7)) {
            page.unlatch();
            page = null;
            factory.idle();
            page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        }
        col = new SQLChar(field);
        try {
            page.updateFieldAtSlot(0, 5, col, null);
        } catch (StandardException se) {
            // now we have filled the page
            if (i < 809) {
                throw T_Fail.testFailMsg("should be able to update Row 0 Column 5 809 times" + ", but only updated " + i + " times.  Note: you maybe getting this error if your page format has changed.");
            } else {
                REPORT("Row 0 Column 5 was updated " + i + " times.");
            }
            break;
        }
        i++;
    }
    // The page is completely full at this point.
    // update Row 1 Column 1 from REC_001 to REC_002.  They are the same length
    page.unlatch();
    page = null;
    factory.idle();
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    col = new SQLChar(REC_002);
    if (page.updateFieldAtSlot(1, 1, col, null) == null) {
        throw T_Fail.testFailMsg("update Row 1 and Column 1 to same length data failed.");
    }
    REPORT("updated col1 in row 1 to same length");
    // now expand update Row 1 Column 1 by one byte.  This should fail.
    page.unlatch();
    page = null;
    factory.idle();
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    field = REC_002 + REC_008;
    col = new SQLChar(field);
    try {
        page.updateFieldAtSlot(1, 1, col, null);
        throw T_Fail.testFailMsg("update Row 1 and Column 1 to longer length should have failed.");
    } catch (StandardException se) {
        ;
    }
    // clean up
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t_util.t_commit(t);
    t.close();
    PASS("P009: segment " + segment);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Example 30 with SQLChar

use of org.apache.derby.iapi.types.SQLChar in project derby by apache.

the class T_RawStoreFactory method P032.

/**
 *		Insert 60-column long rows into 1K pages, each column is less than a page.
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P032(long segment) throws StandardException, T_Fail {
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment, 4096);
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    int insertFlag = Page.INSERT_INITIAL;
    insertFlag |= Page.INSERT_OVERFLOW;
    T_RawStoreRow r0 = new T_RawStoreRow(60);
    for (int i = 0; i < 60; i++) {
        r0.setColumn(i, 1200, REC_001);
    }
    RecordHandle rh0 = null;
    try {
        rh0 = t_util.t_insertAtSlot(page, 0, r0, (byte) insertFlag);
    } catch (StandardException se) {
        throw T_Fail.testFailMsg("insert of first long row failed.");
    }
    if (rh0 == null)
        throw T_Fail.testFailMsg("insert of a 60-column (300 bytes per column) row failed.");
    else {
        REPORT("about to check fetch the first long row inserted...");
        DataValueDescriptor column = new SQLChar();
        for (int i = 0; i < 60; i++) {
            t_util.t_checkFetchColFromSlot(page, page.FIRST_SLOT_NUMBER, i, column, false, REC_001, 1200);
        }
    }
    // create a new row with 60 columns, and each column has REC_001 = "McLaren"
    for (int i = 0; i < 60; i++) {
        r0.setColumn(i, REC_001);
    }
    RecordHandle rh1 = null;
    try {
        rh1 = t_util.t_insertAtSlot(page, 1, r0, (byte) insertFlag);
    } catch (StandardException se) {
        throw T_Fail.testFailMsg("insert of second long row failed.");
    }
    if (rh1 == null) {
        throw T_Fail.testFailMsg("insert of a 60-column (~10 bytes per column) row failed.");
    } else {
        REPORT("about to check fetch the second long row inserted ...");
        DataValueDescriptor column = new SQLChar();
        for (int i = 0; i < 60; i++) {
            t_util.t_checkFetchColFromSlot(page, 1, i, column, false, REC_001);
        }
    }
    page.unlatch();
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t_util.t_commit(t);
    t.close();
    PASS("P032: segment = " + segment);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Aggregations

SQLChar (org.apache.derby.iapi.types.SQLChar)60 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)42 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)22 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)21 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)18 UUID (org.apache.derby.catalog.UUID)15 SQLLongint (org.apache.derby.iapi.types.SQLLongint)13 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)12 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)12 RowLocation (org.apache.derby.iapi.types.RowLocation)10 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)9 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)8 StandardException (org.apache.derby.shared.common.error.StandardException)8 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)7 UserType (org.apache.derby.iapi.types.UserType)7 ScanController (org.apache.derby.iapi.store.access.ScanController)6 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)4 LinkedList (java.util.LinkedList)3