📄 t_accessfactory.java
字号:
REPORT("(scanExample) fiddled rows present and accounted for"); REPORT("(scanExample) testing expected delete errors"); // Open 4th scan on conglomerate and test "expected" error returns // from replace, partial column replace, delete. ScanController scan4 = tc.openScan( conglomid, false, // don't hold TransactionController.OPENMODE_FORUPDATE, // for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. // Iterate with the second scan find the "22" row, delete it and // then test that operations on that deleted entry FAIL as expected. while (scan4.next()) { scan4.fetch(row.getRowArray()); if (!scan4.doesCurrentPositionQualify()) { throw T_Fail.testFailMsg("(scanExample doesCurrentPositionQualify() errors) Expected requalify of current row to succeed"); } if (((SQLInteger) row.getCol(0)).getInt() == 22) { if (!scan4.delete()) { throw T_Fail.testFailMsg("(scanExample delete errors) Delete failed."); } break; } } if (scan4.doesCurrentPositionQualify()) { throw T_Fail.testFailMsg("(scanExample doesCurrentPositionQualify() errors) Expected qualify of deleted row to FAIL"); } DataValueDescriptor[] update_row = new DataValueDescriptor[1]; FormatableBitSet update_desc = new FormatableBitSet(1); update_desc.set(0); if (scan4.replace(update_row, update_desc)) { throw T_Fail.testFailMsg("(scanExample delete errors) Expected partial column replace to FAIL"); } if (scan4.replace(row.getRowArray(), (FormatableBitSet) null)) { throw T_Fail.testFailMsg("(scanExample after changes) Expected replace to FAIL"); } if (scan4.delete()) { throw T_Fail.testFailMsg("(scanExample after changes) Expected delete to FAIL"); } scan4.close(); if ((tc.countOpens(TransactionController.OPEN_TOTAL) > 0) || (tc.countOpens(TransactionController.OPEN_CONGLOMERATE) > 0) || (tc.countOpens(TransactionController.OPEN_SCAN) > 0) || (tc.countOpens(TransactionController.OPEN_CREATED_SORTS) > 0) || (tc.countOpens(TransactionController.OPEN_SORT) > 0)) { System.out.println("OPENED:\n" + tc.debugOpened()); return(FAIL("unexpected open count.")); } REPORT("(scanExample) completed"); return true; } protected boolean dropTest(TransactionController tc) throws StandardException, T_Fail { ConglomerateController cc; REPORT("(dropTest) starting"); // Test of drop conglomerate with abort by doing the following: // create table // commit // drop table // make sure table is not still there. // abort // make sure table is still there. // Create a heap conglomerate. long orig_conglomid = tc.createConglomerate( "heap", // create a heap conglomerate new T_AccessRow(1).getRowArray(), // 1 SQLInteger() column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary tc.commit(); tc.dropConglomerate(orig_conglomid); // Try and Open it - it should fail. try { cc = tc.openConglomerate( orig_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); throw T_Fail.testFailMsg("Open conglom on deleted conglom worked."); } catch (StandardException e) { if (!e.getMessageId().equals( SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST)) { throw e; } // normal path through the test - conglomerate does not exist, // ignore the expected error } // Try and Open a random non-existant conglomerate - it should fail. try { cc = tc.openConglomerate( 42424242, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); throw T_Fail.testFailMsg("Open conglom on deleted conglom worked."); } catch (StandardException e) { if (!e.getMessageId().equals( SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST)) { throw e; } // normal path through the test - conglomerate does not exist, // ignore the expected error } // Try and delete it again - it should fail. try { tc.dropConglomerate(orig_conglomid); throw T_Fail.testFailMsg("Delete conglom on deleted conglom worked."); } catch (StandardException e) { // normal path through the test, ignore the expected error } // cursory test to make sure conglom directory is not screwed up. // Create a heap conglomerate. long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate new T_AccessRow(1).getRowArray(), // 1 SQLInteger() column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); tc.abort(); // the original conglomerate should be still around after the abort. cc = tc.openConglomerate( orig_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); cc.close(); return true; } /** * Test the access level getTableProperties() call. * <p> * * @return true if the test succeeded. * * @param tc The transaction controller to use in the test. * * @exception StandardException Standard exception policy. * @exception T_Fail Unexpected behaviour from the API **/ protected boolean getTableProperties( TransactionController tc) throws StandardException, T_Fail { int key_value; Properties prop = new Properties(); prop.put(Property.PAGE_SIZE_PARAMETER, "8192"); prop.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, "99"); prop.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, "42"); prop.put(RawStoreFactory.CONTAINER_INITIAL_PAGES, "22"); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(1); long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, // column sort order not required for heap prop, // default properties TransactionController.IS_DEFAULT); // not temporary // 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 = tc.getUserCreateConglomPropList(); cc.getTableProperties(ret_prop); if (ret_prop.getProperty(Property.PAGE_SIZE_PARAMETER). compareTo("8192") != 0 || ret_prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER). compareTo("99") != 0 || ret_prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER). compareTo("42") != 0 || ret_prop.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES). compareTo("22") != 0) { throw T_Fail.testFailMsg( "(getTableProperties) Did not get expected table propertes(1)." + "\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) + "\nGot initial pages = " + ret_prop.getProperty( RawStoreFactory.CONTAINER_INITIAL_PAGES)); } ret_prop = cc.getInternalTablePropertySet(null); if (ret_prop.getProperty(Property.PAGE_SIZE_PARAMETER). compareTo("8192") != 0 || ret_prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER). compareTo("99") != 0 || ret_prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER). compareTo("42") != 0 || ret_prop.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES). compareTo("22") != 0) { throw T_Fail.testFailMsg( "(getTableProperties) Did not get expected table propertes(2)." + "\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) + "\nGot initial pages = " + ret_prop.getProperty( RawStoreFactory.CONTAINER_INITIAL_PAGES)); } ret_prop = new Properties(); ret_prop = cc.getInternalTablePropertySet(ret_prop); if (ret_prop.getProperty(Property.PAGE_SIZE_PARAMETER). compareTo("8192") != 0 || ret_prop.getProperty(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER). compareTo("99") != 0 || ret_prop.getProperty(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER). compareTo("42") != 0 || ret_prop.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES). compareTo("22") != 0) { throw T_Fail.testFailMsg( "(getTableProperties) Did not get expected table propertes(3)." + "\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) + "\nGot initial pages = " + ret_prop.getProperty( RawStoreFactory.CONTAINER_INITIAL_PAGES)); } return(true); } /** * Test the access level alter table interface for adding columns. * <p> * * @return true if the test succeeded. * * @param tc The transaction controller to use in the test. * * @exception StandardException Standard exception policy. * @exception T_Fail Unexpected behaviour from the API **/ protected boolean alterTable( TransactionController tc) throws StandardException, T_Fail { int key_value; REPORT("(alterTable) starting"); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(1); long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // Open the conglomerate. ConglomerateController cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // Create a 1 column row. int column = 1. T_AccessRow r1 = new T_AccessRow(1); SQLInteger c1 = new SQLInteger(1); r1.setCol(0, c1); // Get a location template RowLocation rowloc1 = cc.newRowLocationTemplate(); // Insert the row and remember its location. cc.insertAndFetchLocation(r1.getRowArray(), rowloc1); // create another 1 column row. int column = 2. // Get a location template r1.setCol(0, new SQLInteger(2)); RowLocation rowloc2 = cc.newRowLocationTemplate(); // Insert the row and remember its location. cc.insertAndFetchLocation(r1.getRowArray(), rowloc2); // At this point the table looks like: // col1 // ---- // 1 // 2 // RESOLVE - currently the store can't catch the following error: /* // Test that we can't alter while it is open. try { tc.addColumnToConglomerate(conglomid, 1, c1); throw T_Fail.testFailMsg( "(alterTable) Allowed alter table while table was open."); } catch (StandardException t) { // expected error continue the test.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -