Search in sources :

Example 11 with Activation

use of org.apache.derby.iapi.sql.Activation in project derby by apache.

the class GenericResultSetFactory method getDeleteCascadeResultSet.

/**
 *		@see ResultSetFactory#getDeleteCascadeResultSet
 *		@exception StandardException thrown on error
 */
public ResultSet getDeleteCascadeResultSet(NoPutResultSet source, int constantActionItem, ResultSet[] dependentResultSets, String resultSetId) throws StandardException {
    Activation activation = source.getActivation();
    getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);
    return new DeleteCascadeResultSet(source, activation, constantActionItem, dependentResultSets, resultSetId);
}
Also used : Activation(org.apache.derby.iapi.sql.Activation)

Example 12 with Activation

use of org.apache.derby.iapi.sql.Activation in project derby by apache.

the class GenericResultSetFactory method getDeleteResultSet.

/**
 *		@see ResultSetFactory#getDeleteResultSet
 *		@exception StandardException thrown on error
 */
public ResultSet getDeleteResultSet(NoPutResultSet source) throws StandardException {
    Activation activation = source.getActivation();
    getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);
    return new DeleteResultSet(source, activation);
}
Also used : Activation(org.apache.derby.iapi.sql.Activation)

Example 13 with Activation

use of org.apache.derby.iapi.sql.Activation in project derby by apache.

the class GenericLanguageConnectionContext method resetSchemaUsages.

/**
 * @see LanguageConnectionContext#resetSchemaUsages(Activation activation,
 *      String schemaName)
 */
public void resetSchemaUsages(Activation activation, String schemaName) throws StandardException {
    Activation parent = activation.getParentActivation();
    SchemaDescriptor defaultSchema = getInitialDefaultSchemaDescriptor();
    // walk SQL session context chain
    while (parent != null) {
        SQLSessionContext ssc = parent.getSQLSessionContextForChildren();
        SchemaDescriptor s = ssc.getDefaultSchema();
        if (SanityManager.DEBUG) {
            SanityManager.ASSERT(s != null, "s should not be empty here");
        }
        if (schemaName.equals(s.getSchemaName())) {
            ssc.setDefaultSchema(defaultSchema);
        }
        parent = parent.getParentActivation();
    }
    // finally top level
    SQLSessionContext top = getTopLevelSQLSessionContext();
    SchemaDescriptor sd = top.getDefaultSchema();
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(sd != null, "sd should not be empty here");
    }
    if (schemaName.equals(sd.getSchemaName())) {
        top.setDefaultSchema(defaultSchema);
    }
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) Activation(org.apache.derby.iapi.sql.Activation) CursorActivation(org.apache.derby.iapi.sql.execute.CursorActivation) SQLSessionContext(org.apache.derby.iapi.sql.conn.SQLSessionContext)

Example 14 with Activation

use of org.apache.derby.iapi.sql.Activation in project derby by apache.

the class GenericLanguageConnectionContext method verifyNoOpenResultSets.

/**
 * Verify that there are no activations with open result sets
 * on the specified prepared statement.
 *
 * @param pStmt     The prepared Statement
 * @param provider  The object precipitating a possible invalidation
 * @param action    The action causing the possible invalidation
 *
 * @return Nothing.
 *
 * @exception StandardException thrown on failure
 */
public boolean verifyNoOpenResultSets(PreparedStatement pStmt, Provider provider, int action) throws StandardException {
    /*
        ** It is not a problem to create an index when there is an open
        ** result set, since it doesn't invalidate the access path that was
        ** chosen for the result set.
        */
    boolean seenOpenResultSets = false;
    // in this list, thus invalidating the Enumeration
    for (int i = acts.size() - 1; i >= 0; i--) {
        Activation a = acts.get(i);
        if (!a.isInUse()) {
            continue;
        }
        /* for this prepared statement */
        if (pStmt == a.getPreparedStatement()) {
            ResultSet rs = a.getResultSet();
            /* is there an open result set? */
            if (rs != null && !rs.isClosed()) {
                if (!rs.returnsRows())
                    continue;
                seenOpenResultSets = true;
                break;
            }
        }
    }
    if (!seenOpenResultSets)
        return false;
    // There may be open ResultSet's that are yet to be garbage collected
    // let's try and force these out rather than throw an error
    System.gc();
    System.runFinalization();
    // in this list, thus invalidating the Enumeration
    for (int i = acts.size() - 1; i >= 0; i--) {
        Activation a = acts.get(i);
        if (!a.isInUse()) {
            continue;
        }
        /* for this prepared statement */
        if (pStmt == a.getPreparedStatement()) {
            ResultSet rs = a.getResultSet();
            /* is there an open result set? */
            if (rs != null && !rs.isClosed()) {
                if ((provider != null) && rs.returnsRows()) {
                    DependencyManager dmgr = getDataDictionary().getDependencyManager();
                    throw StandardException.newException(SQLState.LANG_CANT_INVALIDATE_OPEN_RESULT_SET, dmgr.getActionString(action), provider.getObjectName());
                }
                return true;
            }
        }
    }
    return false;
}
Also used : ResultSet(org.apache.derby.iapi.sql.ResultSet) DependencyManager(org.apache.derby.iapi.sql.depend.DependencyManager) Activation(org.apache.derby.iapi.sql.Activation) CursorActivation(org.apache.derby.iapi.sql.execute.CursorActivation)

Example 15 with Activation

use of org.apache.derby.iapi.sql.Activation in project derby by apache.

the class GenericResultSetFactory method getDeleteCascadeUpdateResultSet.

/**
 *		@see ResultSetFactory#getDeleteCascadeUpdateResultSet
 *		@exception StandardException thrown on error
 */
public ResultSet getDeleteCascadeUpdateResultSet(NoPutResultSet source, GeneratedMethod generationClauses, GeneratedMethod checkGM, int constantActionItem, int rsdItem) throws StandardException {
    Activation activation = source.getActivation();
    getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);
    return new UpdateResultSet(source, generationClauses, checkGM, activation, constantActionItem, rsdItem);
}
Also used : Activation(org.apache.derby.iapi.sql.Activation)

Aggregations

Activation (org.apache.derby.iapi.sql.Activation)25 CursorActivation (org.apache.derby.iapi.sql.execute.CursorActivation)10 ResultSet (org.apache.derby.iapi.sql.ResultSet)8 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)5 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)3 StandardException (org.apache.derby.shared.common.error.StandardException)3 SQLWarning (java.sql.SQLWarning)2 ResultDescription (org.apache.derby.iapi.sql.ResultDescription)2 SQLSessionContext (org.apache.derby.iapi.sql.conn.SQLSessionContext)2 CursorResultSet (org.apache.derby.iapi.sql.execute.CursorResultSet)2 ExecCursorTableReference (org.apache.derby.iapi.sql.execute.ExecCursorTableReference)2 ExecPreparedStatement (org.apache.derby.iapi.sql.execute.ExecPreparedStatement)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 GeneratedClass (org.apache.derby.iapi.services.loader.GeneratedClass)1 GeneratedMethod (org.apache.derby.iapi.services.loader.GeneratedMethod)1 PreparedStatement (org.apache.derby.iapi.sql.PreparedStatement)1 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)1 IndexRowGenerator (org.apache.derby.iapi.sql.dictionary.IndexRowGenerator)1