Search in sources :

Example 86 with TransactionController

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

the class DropSchemaConstantAction method executeConstantAction.

// INTERFACE METHODS
/**
 *	This is the guts of the Execution-time logic for DROP TABLE.
 *
 *	@see ConstantAction#executeConstantAction
 *
 * @exception StandardException		Thrown on failure
 */
public void executeConstantAction(Activation activation) throws StandardException {
    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    TransactionController tc = lcc.getTransactionExecute();
    /*
		** Inform the data dictionary that we are about to write to it.
		** There are several calls to data dictionary "get" methods here
		** that might be done in "read" mode in the data dictionary, but
		** it seemed safer to do this whole operation in "write" mode.
		**
		** We tell the data dictionary we're done writing at the end of
		** the transaction.
		*/
    dd.startWriting(lcc);
    SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
    sd.drop(lcc, activation);
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 87 with TransactionController

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

the class DropStatisticsConstantAction method executeConstantAction.

public void executeConstantAction(Activation activation) throws StandardException {
    TableDescriptor td;
    ConglomerateDescriptor cd = null;
    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();
    dd.startWriting(lcc);
    if (forTable) {
        td = dd.getTableDescriptor(objectName, sd, tc);
    } else {
        cd = dd.getConglomerateDescriptor(objectName, sd, false);
        td = dd.getTableDescriptor(cd.getTableID());
    }
    /* invalidate all SPS's on the table-- bad plan on SPS, so user drops
		 * statistics and would want SPS's invalidated so that recompile would
		 * give good plans; thats the theory anyways....
		 */
    dm.invalidateFor(td, DependencyManager.DROP_STATISTICS, lcc);
    dd.dropStatisticsDescriptors(td.getUUID(), ((cd != null) ? cd.getUUID() : null), tc);
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DependencyManager(org.apache.derby.iapi.sql.depend.DependencyManager) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 88 with TransactionController

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

the class DropTriggerConstantAction method executeConstantAction.

/**
 *	This is the guts of the Execution-time logic for DROP STATEMENT.
 *
 *	@see ConstantAction#executeConstantAction
 *
 * @exception StandardException		Thrown on failure
 */
public void executeConstantAction(Activation activation) throws StandardException {
    TriggerDescriptor triggerd;
    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    /*
		** Inform the data dictionary that we are about to write to it.
		** There are several calls to data dictionary "get" methods here
		** that might be done in "read" mode in the data dictionary, but
		** it seemed safer to do this whole operation in "write" mode.
		**
		** We tell the data dictionary we're done writing at the end of
		** the transaction.
		*/
    dd.startWriting(lcc);
    TableDescriptor td = dd.getTableDescriptor(tableId);
    if (td == null) {
        throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND_DURING_EXECUTION, tableId.toString());
    }
    TransactionController tc = lcc.getTransactionExecute();
    lockTableForDDL(tc, td.getHeapConglomerateId(), true);
    // get td again in case table shape is changed before lock is acquired
    td = dd.getTableDescriptor(tableId);
    if (td == null) {
        throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND_DURING_EXECUTION, tableId.toString());
    }
    /* 
		** Get the trigger descriptor.  We're responsible for raising
		** the error if it isn't found 
		*/
    triggerd = dd.getTriggerDescriptor(triggerName, sd);
    if (triggerd == null) {
        throw StandardException.newException(SQLState.LANG_OBJECT_NOT_FOUND_DURING_EXECUTION, "TRIGGER", (sd.getSchemaName() + "." + triggerName));
    }
    /* 
	 	** Prepare all dependents to invalidate.  (This is there chance
		** to say that they can't be invalidated.  For example, an open
		** cursor referencing a table/trigger that the user is attempting to
		** drop.) If no one objects, then invalidate any dependent objects.
		*/
    triggerd.drop(lcc);
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor) TriggerDescriptor(org.apache.derby.iapi.sql.dictionary.TriggerDescriptor)

Example 89 with TransactionController

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

the class D_DiagnosticUtil method diag_containerid_to_conglomid.

public static long diag_containerid_to_conglomid(Object module, long containerid) {
    String ret_string = null;
    AccessFactory store_module = null;
    long conglom_id = Long.MIN_VALUE;
    // Find the AccessFactory
    store_module = (AccessFactory) getServiceModule(module, AccessFactory.MODULE);
    if (store_module != null) {
        try {
            TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
            conglom_id = tc.findConglomid(containerid);
        } catch (Throwable t) {
            t.printStackTrace();
        // on error just return the initialized bad value conglom_id
        }
    } else {
    // during access boot this does not exist, assume for now that
    // is why we got here.  RESOLVE - it would be nice if we could
    // actuallly figure that is why we failed.
    /*
            System.out.println(
                "Could not find module for module: " + module);
            */
    }
    return (conglom_id);
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 90 with TransactionController

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

the class D_DiagnosticUtil method diag_conglomid_to_containerid.

public static long diag_conglomid_to_containerid(Object module, long conglomid) {
    String ret_string = null;
    AccessFactory store_module = null;
    long container_id = Long.MIN_VALUE;
    // Find the AccessFactory
    store_module = (AccessFactory) getServiceModule(module, AccessFactory.MODULE);
    if (store_module != null) {
        try {
            TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
            container_id = tc.findContainerid(conglomid);
        } catch (Throwable t) {
            t.printStackTrace();
        // on error just return the initialized bad value conglom_id
        }
    } else {
    // during access boot this does not exist, assume for now that
    // is why we got here.  RESOLVE - it would be nice if we could
    // actuallly figure that is why we failed.
    /*
            System.out.println(
                "Could not find module for module: " + module);
            */
    }
    return (container_id);
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Aggregations

TransactionController (org.apache.derby.iapi.store.access.TransactionController)124 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)47 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)40 StandardException (org.apache.derby.shared.common.error.StandardException)26 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)23 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)20 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)20 UUID (org.apache.derby.catalog.UUID)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)13 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)12 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)12 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)12 Properties (java.util.Properties)11 AccessFactory (org.apache.derby.iapi.store.access.AccessFactory)11 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 XATransactionController (org.apache.derby.iapi.store.access.XATransactionController)9 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)8 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)8 ScanController (org.apache.derby.iapi.store.access.ScanController)8