use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class TriggerDescriptor method drop.
public void drop(LanguageConnectionContext lcc) throws StandardException {
DataDictionary dd = getDataDictionary();
DependencyManager dm = getDataDictionary().getDependencyManager();
TransactionController tc = lcc.getTransactionExecute();
dm.invalidateFor(this, DependencyManager.DROP_TRIGGER, lcc);
// Drop the trigger
dd.dropTriggerDescriptor(this, tc);
// Clear the dependencies for the trigger
dm.clearDependencies(lcc, this);
// Drop the spses
SPSDescriptor spsd = dd.getSPSDescriptor(this.getActionId());
// there shouldn't be any dependencies, but in case
// there are, lets clear them
dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
dm.clearDependencies(lcc, spsd);
dd.dropSPSDescriptor(spsd, tc);
if (getWhenClauseId() != null) {
spsd = dd.getSPSDescriptor(getWhenClauseId());
dm.invalidateFor(spsd, DependencyManager.DROP_TRIGGER, lcc);
dm.clearDependencies(lcc, spsd);
dd.dropSPSDescriptor(spsd, tc);
}
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class ConstraintDescriptor method drop.
/**
* Drop the constraint. Clears dependencies, drops
* the backing index and removes the constraint
* from the list on the table descriptor. Does NOT
* do an dm.invalidateFor()
*
* @return If the backing conglomerate for this constraint
* was a) dropped and b) shared by other constraints/indexes,
* then this method will return a ConglomerateDescriptor that
* describes what a new backing conglomerate must look like
* to stay "sharable" across the remaining constraints/indexes.
* It is then up to the caller to create a corresponding
* conglomerate. We don't create the conglomerate here
* because depending on who called us, it might not make
* sense to create it--ex. if we get here because of a DROP
* TABLE, the DropTable action doesn't need to create a
* new backing conglomerate since the table (and all of
* its constraints/indexes) are going to disappear anyway.
*/
public ConglomerateDescriptor drop(LanguageConnectionContext lcc, boolean clearDependencies) throws StandardException {
DataDictionary dd = getDataDictionary();
TransactionController tc = lcc.getTransactionExecute();
if (clearDependencies) {
DependencyManager dm = dd.getDependencyManager();
dm.clearDependencies(lcc, this);
}
/* Drop the constraint.
* NOTE: This must occur before dropping any backing index, since
* a user is not allowed to drop a backing index without dropping
* the constraint.
*/
dd.dropConstraintDescriptor(this, tc);
/* Drop the index, if there's one for this constraint.
* NOTE: There will always be an indexAction. We don't
* force the constraint to exist at bind time, so we always
* generate one.
*/
ConglomerateDescriptor newBackingConglomCD = null;
if (hasBackingIndex()) {
// it may have duplicates, and we drop a backing index
// Bug 4307
// We need to get the conglomerate descriptors from the
// dd in case we dropped other constraints in a cascade operation.
ConglomerateDescriptor[] conglomDescs = dd.getConglomerateDescriptors(getConglomerateId());
// information since they point to the same physical index.
for (ConglomerateDescriptor cd : conglomDescs) {
if (cd.isConstraint()) {
newBackingConglomCD = cd.drop(lcc, table);
break;
}
}
}
table.removeConstraintDescriptor(this);
return newBackingConglomCD;
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class EmbedConnection method checkUserIsNotARole.
/**
* If applicable, check that we don't connect with a user name
* that equals a role.
*
* @exception SQLException Will throw if the current authorization
* id in {@code lcc} (which is already normalized to
* case normal form - CNF) equals an existing role name
* (which is also stored in CNF).
*/
private void checkUserIsNotARole() throws SQLException {
TransactionResourceImpl tr = getTR();
try {
tr.startTransaction();
LanguageConnectionContext lcc = tr.getLcc();
String username = lcc.getSessionUserId();
DataDictionary dd = lcc.getDataDictionary();
// introduced in 10.4):
if (lcc.usesSqlAuthorization() && dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_4, null)) {
TransactionController tc = lcc.getTransactionExecute();
String failedString = MessageService.getTextMessage(MessageId.AUTH_INVALID);
if (dd.getRoleDefinitionDescriptor(username) != null) {
throw newSQLException(SQLState.NET_CONNECT_AUTH_FAILED, failedString);
}
}
tr.rollback();
InterruptStatus.restoreIntrFlagIfSeen(lcc);
} catch (StandardException e) {
try {
tr.rollback();
} catch (StandardException ee) {
}
throw handleException(e);
}
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class BasicDatabase method getAllDatabaseProperties.
/**
* Get the set of database properties from the set stored
* on disk outside of service.properties.
*/
protected Properties getAllDatabaseProperties() throws StandardException {
TransactionController tc = af.getTransaction(getContextService().getCurrentContextManager());
Properties dbProps = tc.getProperties();
tc.commit();
tc.destroy();
return dbProps;
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class BasicDatabase method makeDatabaseID.
protected UUID makeDatabaseID(boolean create, Properties startParams) throws StandardException {
TransactionController tc = af.getTransaction(getContextService().getCurrentContextManager());
String upgradeID = null;
UUID databaseID;
if ((databaseID = (UUID) tc.getProperty(DataDictionary.DATABASE_ID)) == null) {
// no property defined in the Transaction set
// this could be an upgrade, see if it's stored in the service set
UUIDFactory uuidFactory = getMonitor().getUUIDFactory();
upgradeID = startParams.getProperty(DataDictionary.DATABASE_ID);
if (upgradeID == null) {
// just create one
databaseID = uuidFactory.createUUID();
} else {
databaseID = uuidFactory.recreateUUID(upgradeID);
}
tc.setProperty(DataDictionary.DATABASE_ID, databaseID, true);
}
// property set.
if (upgradeID != null)
startParams.remove(DataDictionary.DATABASE_ID);
tc.commit();
tc.destroy();
return databaseID;
}
Aggregations