use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class RAMTransaction method addColumnToConglomerate.
/**
************************************************************************
* Public Methods of TransactionController interface:
**************************************************************************
*/
/**
* Add a column to a conglomerate. The conglomerate must not be open in
* the current transaction. This also means that there must not be any
* active scans on it.
*
* The column can only be added at the spot just after the current set of
* columns.
*
* The template_column must be nullable.
*
* After this call has been made, all fetches of this column from rows that
* existed in the table prior to this call will return "null".
*
* @param conglomId The identifier of the conglomerate to drop.
* @param column_id The column number to add this column at.
* @param template_column An instance of the column to be added to table.
* @param collation_id collation id of the added column.
*
* @exception StandardException Only some types of conglomerates can support
* adding a column, for instance "heap" conglomerates support adding a
* column while "btree" conglomerates do not. If the column can not be
* added an exception will be thrown.
*/
public void addColumnToConglomerate(long conglomId, int column_id, Storable template_column, int collation_id) throws StandardException {
boolean is_temporary = (conglomId < 0);
Conglomerate conglom = findConglomerate(conglomId);
if (conglom == null) {
throw StandardException.newException(SQLState.AM_NO_SUCH_CONGLOMERATE_DROP, conglomId);
}
// Get exclusive lock on the table being altered.
ConglomerateController cc = conglom.open(this, rawtran, false, OPENMODE_FORUPDATE, MODE_TABLE, accessmanager.table_level_policy[TransactionController.ISOLATION_SERIALIZABLE], (StaticCompiledOpenConglomInfo) null, (DynamicCompiledOpenConglomInfo) null);
conglom.addColumn(this, column_id, template_column, collation_id);
// live in the conglomerate cache.
if (!is_temporary) {
alterTableCallMade = true;
}
cc.close();
return;
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class RAMTransaction method openConglomerate.
private ConglomerateController openConglomerate(Conglomerate conglom, boolean hold, int open_mode, int lock_level, int isolation_level, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException {
if (SanityManager.DEBUG) {
if ((open_mode & ~(ContainerHandle.MODE_UNLOGGED | ContainerHandle.MODE_CREATE_UNLOGGED | ContainerHandle.MODE_FORUPDATE | ContainerHandle.MODE_READONLY | ContainerHandle.MODE_TRUNCATE_ON_COMMIT | ContainerHandle.MODE_DROP_ON_COMMIT | ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY | ContainerHandle.MODE_LOCK_NOWAIT | ContainerHandle.MODE_LOCK_ROW_NOWAIT | ContainerHandle.MODE_TRUNCATE_ON_ROLLBACK | ContainerHandle.MODE_FLUSH_ON_COMMIT | ContainerHandle.MODE_NO_ACTIONS_ON_COMMIT | ContainerHandle.MODE_TEMP_IS_KEPT | ContainerHandle.MODE_USE_UPDATE_LOCKS | ContainerHandle.MODE_SECONDARY_LOCKED | ContainerHandle.MODE_BASEROW_INSERT_LOCKED)) != 0) {
SanityManager.THROWASSERT("Bad open mode to openConglomerate:" + Integer.toHexString(open_mode));
}
SanityManager.ASSERT(conglom != null);
if (lock_level != MODE_RECORD && lock_level != MODE_TABLE) {
SanityManager.THROWASSERT("Bad lock level to openConglomerate:" + lock_level);
}
}
// Get a conglomerate controller.
ConglomerateController cc = conglom.open(this, rawtran, hold, open_mode, determine_lock_level(lock_level), determine_locking_policy(lock_level, isolation_level), static_info, dynamic_info);
// Keep track of it so we can release on close.
conglomerateControllers.add(cc);
return cc;
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class D_DiagnosticUtil method diag_conglomid.
/**
* Given a Database name and conglomid, return diagnositic string.
* <p>
* Return a string with diagnostic information about a particular
* conglomerate, can be called for any type of conglomerate (some types
* may not return any info though).
* <p>
* Can be called from ij to find out info about conglomid 19 in database
* 'msgdb' by using the following syntax:
*
* values
* com.ibm.db2j.protocol.BasicServices.Diagnostic.T_Diagnosticable::
* diag_conglomid('msgdb', 19);
* maximumdisplaywidth 9000;
*
* CREATE FUNCTION DIAG_CONGLOMID(DBNAME VARCHAR(128), CONGLOMID INT)
* RETURNS VARCHAR(32000) RETURNS NULL ON NULL INPUT
* EXTERNAL NAME
* 'org.apache.derby.impl.store.raw.data.D_DiagnosticUtil.diag_conglomid'
* LANGUAGE JAVA PARAMETER STYLE JAVA;
*
* values DIAG_CONGLOMID('msgdb', 19);
* com.ibm.db2j.protocol.BasicServices.Diagnostic.T_Diagnosticable::
* diag_conglomid_print('msgdb', 19);
*
* RESOLVE - An interface that takes a table name would be nice.
*
* @param db_name name of the database
* @param conglomid conglomerate id of the conglomerate to debug
*
* @exception StandardException Standard exception policy.
*/
public static String diag_conglomid(String db_name, long conglomid) throws StandardException {
String ret_string = null;
AccessFactory store_module = null;
store_module = (AccessFactory) getModuleFromDbName(db_name);
if (store_module != null) {
TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
ConglomerateController open_table = tc.openConglomerate(conglomid, false, 0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
open_table.debugConglomerate();
Diagnosticable diag_obj = DiagnosticUtil.findDiagnostic(open_table);
ret_string = diag_obj.diag();
open_table.close();
} else {
System.out.println("Could not find module for database: " + db_name);
}
return (ret_string);
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class TableScanResultSet method close.
/**
* If the result set has been opened,
* close the open scan.
* @exception StandardException on error
*/
public void close() throws StandardException {
beginTime = getCurrentTimeMillis();
if (isOpen) {
/*
** If scan tracing is turned on, print information about this
** TableScanResultSet when it is closed.
*/
if (SanityManager.DEBUG) {
if (SanityManager.DEBUG_ON("ScanTrace")) {
// traceClose();
}
}
// we don't want to keep around a pointer to the
// row ... so it can be thrown away.
// REVISIT: does this need to be in a finally
// block, to ensure that it is executed?
clearCurrentRow();
;
if (scanController != null) {
// This is where we get the positioner info for inner tables
if (runTimeStatisticsOn) {
// This is where we get the scan properties for a subquery
scanProperties = getScanProperties();
startPositionString = printStartPosition();
stopPositionString = printStopPosition();
}
scanController.close();
// should not access after close
scanController = null;
// it in the first place (DERBY-4585).
if (forUpdate && isKeyed) {
activation.clearIndexScanInfo();
}
}
scanControllerOpened = false;
startPosition = null;
stopPosition = null;
super.close();
if (indexCols != null) {
ConglomerateController borrowedBaseCC = activation.getHeapConglomerateController();
if (borrowedBaseCC != null) {
borrowedBaseCC.close();
activation.clearHeapConglomerateController();
}
}
if (past2FutureTbl != null) {
past2FutureTbl.close();
past2FutureTbl = null;
}
} else if (SanityManager.DEBUG)
SanityManager.DEBUG("CloseRepeatInfo", "Close of TableScanResultSet repeated");
closeTime += getElapsedMillis(beginTime);
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class T_ConsistencyChecker method openIndexCC.
/* Open the index conglomerate for update */
private ConglomerateController openIndexCC() throws StandardException {
ConglomerateController indexCC;
indexCC = tc.openConglomerate(id.getConglomerateNumber(), false, // forUpdate
TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
return indexCC;
}
Aggregations