use of org.apache.derby.iapi.sql.depend.ProviderInfo in project derby by apache.
the class BasicDependencyManager method getPersistentProviderInfos.
/**
* @see DependencyManager#getPersistentProviderInfos
*
* @exception StandardException Thrown on error
*/
public ProviderInfo[] getPersistentProviderInfos(ProviderList pl) throws StandardException {
Enumeration e = pl.elements();
int numProviders = 0;
ProviderInfo[] retval;
/*
** We make 2 passes - the first to count the number of persistent
** providers and the second to populate the array of ProviderInfos.
*/
while (e != null && e.hasMoreElements()) {
Provider prov = (Provider) e.nextElement();
if (prov.isPersistent()) {
numProviders++;
}
}
e = pl.elements();
retval = new ProviderInfo[numProviders];
int piCtr = 0;
while (e != null && e.hasMoreElements()) {
Provider prov = (Provider) e.nextElement();
if (prov.isPersistent()) {
retval[piCtr++] = new BasicProviderInfo(prov.getObjectID(), prov.getDependableFinder(), prov.getObjectName());
}
}
return retval;
}
use of org.apache.derby.iapi.sql.depend.ProviderInfo 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);
}
}
}
use of org.apache.derby.iapi.sql.depend.ProviderInfo in project derby by apache.
the class CreateViewNode method bindViewDefinition.
/**
* Bind the query expression for a view definition.
*
* @param dataDictionary The DataDictionary to use to look up
* columns, tables, etc.
*
* @return Array of providers that this view depends on.
*
* @exception StandardException Thrown on error
*/
private ProviderInfo[] bindViewDefinition(DataDictionary dataDictionary, CompilerContext compilerContext, LanguageConnectionContext lcc, OptimizerFactory optimizerFactory, ResultSetNode queryExpr, ContextManager cm) throws StandardException {
FromList fromList = new FromList(optimizerFactory.doJoinOrderOptimization(), cm);
ProviderList prevAPL = compilerContext.getCurrentAuxiliaryProviderList();
ProviderList apl = new ProviderList();
try {
compilerContext.setCurrentAuxiliaryProviderList(apl);
compilerContext.pushCurrentPrivType(Authorizer.SELECT_PRIV);
/* Bind the tables in the queryExpression */
queryExpr = queryExpr.bindNonVTITables(dataDictionary, fromList);
queryExpr = queryExpr.bindVTITables(fromList);
/* Bind the expressions under the resultSet */
queryExpr.bindExpressions(fromList);
// cannot define views on temporary tables
if (queryExpr instanceof SelectNode) {
// If attempting to reference a SESSION schema table (temporary or permanent) in the view, throw an exception
if (queryExpr.referencesSessionSchema())
throw StandardException.newException(SQLState.LANG_OPERATION_NOT_ALLOWED_ON_SESSION_SCHEMA_TABLES);
}
// bind the query expression
queryExpr.bindResultColumns(fromList);
// rejects any untyped nulls in the RCL
// e.g.: CREATE VIEW v1 AS VALUES NULL
queryExpr.bindUntypedNullsToResultColumns(null);
} finally {
compilerContext.popCurrentPrivType();
compilerContext.setCurrentAuxiliaryProviderList(prevAPL);
}
DependencyManager dm = dataDictionary.getDependencyManager();
ProviderInfo[] provInfo = dm.getPersistentProviderInfos(apl);
// need to clear the column info in case the same table descriptor
// is reused, eg., in multiple target only view definition
dm.clearColumnInfoInProviders(apl);
/* Verify that all underlying ResultSets reclaimed their FromList */
if (SanityManager.DEBUG) {
SanityManager.ASSERT(fromList.size() == 0, "fromList.size() is expected to be 0, not " + fromList.size() + " on return from RS.bindExpressions()");
}
return provInfo;
}
Aggregations