use of org.apache.derby.iapi.sql.depend.Provider in project derby by apache.
the class DDLConstantAction method addColumnDependencies.
/**
* Add dependencies of a column on providers. These can arise if a generated column depends
* on a user created function.
*/
protected void addColumnDependencies(LanguageConnectionContext lcc, DataDictionary dd, TableDescriptor td, ColumnInfo ci) throws StandardException {
ProviderInfo[] providers = ci.providers;
if (providers != null) {
DependencyManager dm = dd.getDependencyManager();
ContextManager cm = lcc.getContextManager();
int providerCount = providers.length;
ColumnDescriptor cd = td.getColumnDescriptor(ci.name);
DefaultDescriptor defDesc = cd.getDefaultDescriptor(dd);
for (int px = 0; px < providerCount; px++) {
ProviderInfo pi = providers[px];
DependableFinder finder = pi.getDependableFinder();
UUID providerID = pi.getObjectId();
Provider provider = (Provider) finder.getDependable(dd, providerID);
dm.addDependency(defDesc, provider, cm);
}
// end loop through providers
}
}
use of org.apache.derby.iapi.sql.depend.Provider in project derby by apache.
the class BasicDependencyManager method getDependencyDescriptorList.
/**
* Turn a list of DependencyDescriptors into a list of Dependencies.
*
* @param storedList The List of DependencyDescriptors representing
* stored dependencies.
* @param providerForList The provider if this list is being created
* for a list of dependents. Null otherwise.
*
* @return List The converted List
*
* @exception StandardException thrown if something goes wrong
*/
private List<Dependency> getDependencyDescriptorList(List<DependencyDescriptor> storedList, Provider providerForList) throws StandardException {
List<Dependency> retval = new ArrayList<Dependency>();
if (!storedList.isEmpty()) {
/* For each DependencyDescriptor, we need to instantiate
* object descriptors of the appropriate type for both
* the dependent and provider, create a Dependency with
* that Dependent and Provider and substitute the Dependency
* back into the same place in the List
* so that the call gets an enumerations of Dependencys.
*/
for (DependencyDescriptor depDesc : storedList) {
Dependent tempD;
Provider tempP;
DependableFinder finder = depDesc.getDependentFinder();
tempD = (Dependent) finder.getDependable(dd, depDesc.getUUID());
if (providerForList != null) {
// Use the provider being passed in.
tempP = providerForList;
// Sanity check the object identifiers match.
if (SanityManager.DEBUG) {
if (!tempP.getObjectID().equals(depDesc.getProviderID())) {
SanityManager.THROWASSERT("mismatch providers");
}
}
} else {
finder = depDesc.getProviderFinder();
tempP = (Provider) finder.getDependable(dd, depDesc.getProviderID());
}
retval.add(new BasicDependency(tempD, tempP));
}
}
return retval;
}
use of org.apache.derby.iapi.sql.depend.Provider in project derby by apache.
the class BasicDependencyManager method getProviders.
/**
* Returns a list of all providers that this dependent has (even invalid
* ones). Includes all dependency types.
*
* @param d the dependent
* @return A list of providers (possibly empty).
* @throws StandardException thrown if something goes wrong
*/
private List<Provider> getProviders(Dependent d) throws StandardException {
List<Provider> provs = new ArrayList<Provider>();
synchronized (this) {
List deps = (List) dependents.get(d.getObjectID());
if (deps != null) {
Iterator depsIter = deps.iterator();
while (depsIter.hasNext()) {
provs.add(((Dependency) depsIter.next()).getProvider());
}
}
}
// into consideration as well.
if (d.isPersistent()) {
List<Dependency> storedList = getDependencyDescriptorList(dd.getDependentsDescriptorList(d.getObjectID().toString()), (Provider) null);
Iterator<Dependency> depIter = storedList.iterator();
while (depIter.hasNext()) {
provs.add((depIter.next()).getProvider());
}
}
return provs;
}
use of org.apache.derby.iapi.sql.depend.Provider 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.Provider 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