Search in sources :

Example 81 with DataDictionary

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);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) RoleGrantDescriptor(org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)

Example 82 with DataDictionary

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;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) UserDefinedTypeIdImpl(org.apache.derby.catalog.types.UserDefinedTypeIdImpl) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 83 with DataDictionary

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;
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 84 with DataDictionary

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();
    }
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 85 with DataDictionary

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);
        }
    }
}
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

DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)102 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)57 TransactionController (org.apache.derby.iapi.store.access.TransactionController)40 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)33 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)23 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)22 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)17 StandardException (org.apache.derby.shared.common.error.StandardException)16 UUID (org.apache.derby.catalog.UUID)15 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)15 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)13 CompilerContext (org.apache.derby.iapi.sql.compile.CompilerContext)10 AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)9 RoleGrantDescriptor (org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)8 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)7 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)7 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)7 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)6 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)6 Iterator (java.util.Iterator)5