use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.
the class ContainedRoles method next.
/**
* @see java.sql.ResultSet#next
*/
public boolean next() throws SQLException {
try {
// activation.
if (!initialized) {
initialized = true;
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
DataDictionary dd = lcc.getDataDictionary();
RoleGrantDescriptor rdDef = dd.getRoleDefinitionDescriptor(role);
if (rdDef != null) {
lcc.beginNestedTransaction(true);
try {
int mode = dd.startReading(lcc);
try {
rci = dd.createRoleClosureIterator(lcc.getLastActivation().getTransactionController(), role, !inverse);
} finally {
dd.doneReading(mode, lcc);
}
} finally {
// make sure we commit; otherwise, we will end up with
// mismatch nested level in the language connection
// context.
lcc.commitNestedTransaction();
}
}
}
return rci != null && ((nextRole = rci.next()) != null);
} catch (StandardException e) {
throw PublicAPI.wrapStandardException(e);
}
}
use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.
the class QueryTreeNode method getUDTDesc.
/**
* Get the AliasDescriptor of a UDT
*/
public AliasDescriptor getUDTDesc(DataTypeDescriptor dtd) throws StandardException {
UserDefinedTypeIdImpl userTypeID = (UserDefinedTypeIdImpl) dtd.getTypeId().getBaseTypeId();
DataDictionary dd = getDataDictionary();
SchemaDescriptor typeSchema = getSchemaDescriptor(userTypeID.getSchemaName());
char udtNameSpace = AliasInfo.ALIAS_NAME_SPACE_UDT_AS_CHAR;
String unqualifiedTypeName = userTypeID.getUnqualifiedName();
AliasDescriptor ad = dd.getAliasDescriptor(typeSchema.getUUID().toString(), unqualifiedTypeName, udtNameSpace);
return ad;
}
use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.
the class StatementNode method lockTableForCompilation.
/* We need to get some kind of table lock (IX here) at the beginning of
* compilation of DMLModStatementNode and DDLStatementNode, to prevent the
* interference of insert/update/delete/DDL compilation and DDL execution,
* see beetle 3976, 4343, and $WS/language/SolutionsToConcurrencyIssues.txt
*/
protected TableDescriptor lockTableForCompilation(TableDescriptor td) throws StandardException {
DataDictionary dd = getDataDictionary();
/* we need to lock only if the data dictionary is in DDL cache mode
*/
if (dd.getCacheMode() == DataDictionary.DDL_MODE) {
ConglomerateController heapCC;
TransactionController tc = getLanguageConnectionContext().getTransactionCompile();
heapCC = tc.openConglomerate(td.getHeapConglomerateId(), false, TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_FOR_LOCK_ONLY, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
heapCC.close();
/*
** Need to get TableDescriptor again after getting the lock, in
** case for example, a concurrent add column thread commits
** while we are binding.
*/
String tableName = td.getName();
td = getTableDescriptor(td.getName(), getSchemaDescriptor(td.getSchemaName()));
if (td == null) {
throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
}
}
return td;
}
use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.
the class ResultColumnList method newRowLocationTemplate.
/**
* Create a row location template of the right type for the source
* conglomerate.
*/
private RowLocation newRowLocationTemplate() throws StandardException {
LanguageConnectionContext lcc = getLanguageConnectionContext();
DataDictionary dd = lcc.getDataDictionary();
int isolationLevel = (dd.getCacheMode() == DataDictionary.DDL_MODE) ? TransactionController.ISOLATION_READ_COMMITTED : TransactionController.ISOLATION_NOLOCK;
ConglomerateController cc = lcc.getTransactionCompile().openConglomerate(conglomerateId, false, 0, TransactionController.MODE_RECORD, isolationLevel);
try {
return cc.newRowLocationTemplate();
} finally {
cc.close();
}
}
use of org.apache.derby.iapi.sql.dictionary.DataDictionary in project derby by apache.
the class TablePrivilegesNode method bindPrivilegesForView.
/**
* Retrieve all the underlying stored dependencies such as table(s),
* view(s) and routine(s) descriptors which the view depends on.
* This information is then passed to the runtime to determine if
* the privilege is grantable to the grantees by this grantor at
* execution time.
*
* Go through the providers regardless who the grantor is since
* the statement cache may be in effect.
*
* @param td the TableDescriptor to check
*
* @exception StandardException standard error policy.
*/
private void bindPrivilegesForView(TableDescriptor td) throws StandardException {
LanguageConnectionContext lcc = getLanguageConnectionContext();
DataDictionary dd = lcc.getDataDictionary();
ViewDescriptor vd = dd.getViewDescriptor(td);
DependencyManager dm = dd.getDependencyManager();
ProviderInfo[] pis = dm.getPersistentProviderInfos(vd);
this.descriptorList = new ArrayList<Provider>();
int siz = pis.length;
for (int i = 0; i < siz; i++) {
Provider provider = (Provider) pis[i].getDependableFinder().getDependable(dd, pis[i].getObjectId());
if (provider instanceof TableDescriptor || provider instanceof ViewDescriptor || provider instanceof AliasDescriptor) {
descriptorList.add(provider);
}
}
}
Aggregations