⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_accessfactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }        */        // Test that we can't add data to columns that don't exist        // Currently we only error check in debug code.          // RESOLVE - should this be a runtime error?        if (SanityManager.DEBUG)        {            try            {                T_AccessRow two_column_row = new T_AccessRow(2);                SQLInteger col1        = new SQLInteger(3);                SQLInteger col2        = new SQLInteger(3);                cc.insert(two_column_row.getRowArray());                throw T_Fail.testFailMsg(                    "(alterTable) Allowed insert of bad row.");            }            catch (StandardException t)            {                // expected error continue the test.            }        }        // Test that we can't fetch data columns that don't exist        // Currently we only error check for this in sanity code.        // RESOLVE - (mikem) should we check for this in released runtime?        if (SanityManager.DEBUG)        {            try            {                T_AccessRow two_column_row = new T_AccessRow(2);                if (!cc.fetch(                        rowloc1, two_column_row.getRowArray(), (FormatableBitSet) null))                {                    throw T_Fail.testFailMsg(                        "(alterTable) Allowed fetch of bad row, bad ret val.");                }                throw T_Fail.testFailMsg(                    "(alterTable) Allowed fetch of bad row.");            }            catch (StandardException t)            {                // expected error continue the test.            }        }        // Test that we can't fetch data columns that don't exist        // Currently we only error check for this in sanity code.        // RESOLVE - (mikem) should we check for this in released runtime?        if (SanityManager.DEBUG)        {            try            {                DataValueDescriptor[] third_column_row =                     new DataValueDescriptor[3];                third_column_row[2]         = new SQLInteger(3);                FormatableBitSet   fetch_desc        = new FormatableBitSet(3);                fetch_desc.set(2);                if (!cc.fetch(                        rowloc1, third_column_row, fetch_desc))                {                    throw T_Fail.testFailMsg(                        "(alterTable) Allowed fetch of bad row, bad ret val.");                }                throw T_Fail.testFailMsg(                    "(alterTable) Allowed fetch of bad row.");            }            catch (StandardException t)            {                // expected error continue the test.            }        }        // Test that we can't replace data columns that don't exist        // Currently we only error check for this in sanity code.        // RESOLVE - (mikem) should we check for this in released runtime?        if (SanityManager.DEBUG)        {            try            {                T_AccessRow two_column_row = new T_AccessRow(2);                SQLInteger col1        = new SQLInteger(3);                SQLInteger col2        = new SQLInteger(3);                cc.replace(rowloc1, two_column_row.getRowArray(), null);                throw T_Fail.testFailMsg(                    "(alterTable) Allowed replace of bad row.");            }            catch (StandardException t)            {                // expected error continue the test.            }        }        // Test that we can't replace data columns that don't exist        if (SanityManager.DEBUG)        {            try            {                DataValueDescriptor[] second_column_row  =                     new DataValueDescriptor[2];                second_column_row[1]        = new SQLInteger(3);                FormatableBitSet   update_desc        = new FormatableBitSet(2);                update_desc.set(1);                cc.replace(rowloc1, second_column_row, update_desc);                throw T_Fail.testFailMsg(                    "(alterTable) Allowed partial row update of bad column.");            }            catch (StandardException t)            {                // expected error continue the test.            }        }		// Make sure commitNoSync gets executed sometimes.        tc.commitNoSync(TransactionController.RELEASE_LOCKS);        // now alter the conglomerate, add another int column        tc.addColumnToConglomerate(conglomid, 1, c1);        // Open the table after the close done by commit.		cc = tc.openConglomerate(                conglomid,                 false,                TransactionController.OPENMODE_FORUPDATE,                 TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);        T_AccessRow two_column_row = new T_AccessRow(2);        SQLInteger col1        = new SQLInteger(3);        SQLInteger col2        = new SQLInteger(3);        // fetch the rows and make sure you get null's in new fields.        if (!cc.fetch(                rowloc1, two_column_row.getRowArray(), (FormatableBitSet) null))        {			throw T_Fail.testFailMsg(                "(alterTable) Row not there.");        }        if ((((SQLInteger)two_column_row.getCol(0)).getInt() != 1) ||            (!two_column_row.getCol(1).isNull()))        {			throw T_Fail.testFailMsg(                "(alterTable) Bad column value after alter.");        }        if (!cc.fetch(                rowloc2, two_column_row.getRowArray(), (FormatableBitSet) null))        {			throw T_Fail.testFailMsg(                "(alterTable) Row not there.");        }        if ((((SQLInteger)two_column_row.getCol(0)).getInt() != 2) ||            (!two_column_row.getCol(1).isNull()))        {			throw T_Fail.testFailMsg(                "(alterTable) Bad column value after alter.");        }        // make sure insert of 2 column row works.        two_column_row = new T_AccessRow(2);        two_column_row.setCol(0, new SQLInteger(3));        two_column_row.setCol(1, new SQLInteger(300));        cc.insert(two_column_row.getRowArray());        // At this point the table looks like:        // col1 col2        // ---- ----        // 1    NA        // 2    NA        // 3    300        		ScanController scan = 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.        while (scan.next())        {            scan.fetch(two_column_row.getRowArray());            key_value = ((SQLInteger)two_column_row.getCol(0)).getInt();            switch(key_value)            {                case 1:                {                    // Set non-existent column value to 100                    if (!two_column_row.getCol(1).isNull())                    {                        throw T_Fail.testFailMsg(                            "(alterTable) Bad column value after alter.");                    }                    // test that replace field works on alter added column                    // make result row be: (1, 100)                    two_column_row.setCol(1, new SQLInteger(100));                    scan.replace(two_column_row.getRowArray(), (FormatableBitSet) null);                    break;                }                case 2:                {                    if (!two_column_row.getCol(1).isNull())                    {                        throw T_Fail.testFailMsg(                            "(alterTable) Bad column value after alter.");                    }                    // test that replace row works on alter added column row.                    // make result row be: (2, 200)                    two_column_row.setCol(1, new SQLInteger(200));                    scan.replace(two_column_row.getRowArray(), (FormatableBitSet) null);                    break;                }                case 3:                {                    break;                }                default:                {                    throw T_Fail.testFailMsg(                        "(alterTable) bad row value found in table.");                }            }        }        // reposition the scan		scan.reopenScan(			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.        while (scan.next())        {            scan.fetch(two_column_row.getRowArray());            key_value = ((SQLInteger) two_column_row.getCol(0)).getInt();            switch(key_value)            {                case 1:                case 2:                case 3:                {                    int second_col_val =                         ((SQLInteger) two_column_row.getCol(1)).getInt();                    if (second_col_val != (key_value * 100))                    {                        throw T_Fail.testFailMsg(                            "(alterTable) Bad column value after alter." +                            "expected: (" +                                 key_value + ", " + key_value * 100 + ")\n" +                            "got     : (" +                                key_value + ", " + second_col_val  + ")\n");                    }                    break;                }                default:                {                    throw T_Fail.testFailMsg(                        "(alterTable) bad row value found in table.");                }            }        }        scan.close();        tc.commit();		REPORT("(alterTable) completed");		        return true;	}    /**     * Test the access level ScanInfo interface.     * <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 scanInfo(    TransactionController tc)		throws StandardException, T_Fail	{        int key_value;		REPORT("(scanInfo) starting");		// Create a heap conglomerate.        T_AccessRow template_row = new T_AccessRow(2);		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(2);		SQLInteger c1 = new SQLInteger(1);		SQLInteger c2 = new SQLInteger(100);		r1.setCol(0, c1);		r1.setCol(1, c2);		// Get a location template		RowLocation rowloc1 = cc.newRowLocationTemplate();		// Insert the row and remember its location.		cc.insertAndFetchLocation(r1.getRowArray(), rowloc1);        // create another 2 column row. int column = 2.		// Get a location template        r1.setCol(0, new SQLInteger(2));        r1.setCol(1, new SQLInteger(200));		RowLocation rowloc2 = cc.newRowLocationTemplate();		// Insert the row and remember its location.		cc.insertAndFetchLocation(r1.getRowArray(), rowloc2);        cc.delete(rowloc2);        if (tc.isPristine() || tc.isIdle())        {            throw T_Fail.testFailMsg(                "(scanInfo) bad xact state after update xact.");        }        tc.commit();		ScanController scan = tc.openScan(			conglomid,			false,	// don't hold            0,    // for read            TransactionController.MODE_TABLE,            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.        if (!scan.isTableLocked())        {            throw T_Fail.testFailMsg(                "(scanInfo) table should be table locked.");        }        while (scan.next())        {            scan.fetch(r1.getRowArray());        }        ScanInfo   scan_info = scan.getScanInfo();        Properties prop      = scan_info.getAllScanInfo(null);        if (!tc.isPristine() || tc.isIdle())        {            throw T_Fail.testFailMsg(                "(scanInfo) bad xact state after update xact.");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -