Search in sources :

Example 6 with Provider

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
    }
}
Also used : DependableFinder(org.apache.derby.catalog.DependableFinder) ProviderInfo(org.apache.derby.iapi.sql.depend.ProviderInfo) ContextManager(org.apache.derby.iapi.services.context.ContextManager) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) DependencyManager(org.apache.derby.iapi.sql.depend.DependencyManager) DefaultDescriptor(org.apache.derby.iapi.sql.dictionary.DefaultDescriptor) UUID(org.apache.derby.catalog.UUID) Provider(org.apache.derby.iapi.sql.depend.Provider)

Example 7 with Provider

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;
}
Also used : DependableFinder(org.apache.derby.catalog.DependableFinder) DependencyDescriptor(org.apache.derby.iapi.sql.dictionary.DependencyDescriptor) ArrayList(java.util.ArrayList) Dependency(org.apache.derby.iapi.sql.depend.Dependency) Dependent(org.apache.derby.iapi.sql.depend.Dependent) Provider(org.apache.derby.iapi.sql.depend.Provider)

Example 8 with Provider

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;
}
Also used : ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ProviderList(org.apache.derby.iapi.sql.depend.ProviderList) Dependency(org.apache.derby.iapi.sql.depend.Dependency) Provider(org.apache.derby.iapi.sql.depend.Provider)

Example 9 with Provider

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;
}
Also used : Enumeration(java.util.Enumeration) ProviderInfo(org.apache.derby.iapi.sql.depend.ProviderInfo) Provider(org.apache.derby.iapi.sql.depend.Provider)

Example 10 with Provider

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);
        }
    }
}
Also used : ProviderInfo(org.apache.derby.iapi.sql.depend.ProviderInfo) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) DependencyManager(org.apache.derby.iapi.sql.depend.DependencyManager) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor) ViewDescriptor(org.apache.derby.iapi.sql.dictionary.ViewDescriptor) Provider(org.apache.derby.iapi.sql.depend.Provider)

Aggregations

Provider (org.apache.derby.iapi.sql.depend.Provider)10 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)5 ProviderInfo (org.apache.derby.iapi.sql.depend.ProviderInfo)5 ArrayList (java.util.ArrayList)4 UUID (org.apache.derby.catalog.UUID)4 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)4 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)4 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)3 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)3 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)3 TransactionController (org.apache.derby.iapi.store.access.TransactionController)3 Iterator (java.util.Iterator)2 List (java.util.List)2 ListIterator (java.util.ListIterator)2 DependableFinder (org.apache.derby.catalog.DependableFinder)2 Dependency (org.apache.derby.iapi.sql.depend.Dependency)2 ProviderList (org.apache.derby.iapi.sql.depend.ProviderList)2 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)2 ViewDescriptor (org.apache.derby.iapi.sql.dictionary.ViewDescriptor)2 Enumeration (java.util.Enumeration)1