Package org.apache.derby.iapi.sql.conn

Examples of org.apache.derby.iapi.sql.conn.StatementContext


    *
   * @exception StandardException thrown on failure
   */
  private void doRollback(boolean xa, boolean requestedByUser) throws StandardException
  {
    StatementContext statementContext = getStatementContext();
    if (requestedByUser &&
      (statementContext != null) &&
      statementContext.inUse() &&
      statementContext.isAtomic())
    {
      throw StandardException.newException(SQLState.LANG_NO_ROLLBACK_IN_NESTED_CONNECTION);
    }

    // Log rollback to error log, if appropriate
View Full Code Here


      cc.resetContext();
    }

    cc.setInUse(true);

    StatementContext sc = getStatementContext();
    if (sc.getSystemCode())
      cc.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);

    /*
     * Set the compilation schema when its UUID is available.
     * i.e.:  Schema may not have been physically created yet, so
View Full Code Here

    int          parentStatementDepth = statementDepth;
    boolean        inTrigger = false;
    boolean        parentIsAtomic = false;

    // by default, assume we are going to use the outermost statement context
    StatementContext  statementContext = statementContexts[0];

    /*
    ** If we haven't allocated any statement contexts yet, allocate
    ** the outermost stmt context now and push it.
    */

    if (statementContext == null)
    {
      statementContext = statementContexts[0] = new GenericStatementContext(this);
      statementContext.
        setSQLSessionContext(getTopLevelSQLSessionContext());
    }
    else if (statementDepth > 0)
    {
      StatementContext  parentStatementContext;
      /*
      ** We also cache a 2nd statement context, though we still
      ** push and pop it. Note, new contexts are automatically pushed.
      */
      if (statementDepth == 1)
      {
        statementContext = statementContexts[1];

        if (statementContext == null)
          statementContext = statementContexts[1] = new GenericStatementContext(this);
        else
          statementContext.pushMe();

        parentStatementContext = statementContexts[0];
      }
      else
      {
        parentStatementContext = getStatementContext();
        statementContext = new GenericStatementContext(this);
      }

      statementContext.setSQLSessionContext(
        parentStatementContext.getSQLSessionContext());

      inTrigger = parentStatementContext.inTrigger() || (outermostTrigger == parentStatementDepth);
      parentIsAtomic = parentStatementContext.isAtomic();
      statementContext.setSQLAllowed(parentStatementContext.getSQLAllowed(), false);
      if (parentStatementContext.getSystemCode())
        statementContext.setSystemCode();
    } else {
      statementContext.
        setSQLSessionContext(getTopLevelSQLSessionContext());
    }
View Full Code Here

  /**
   * @see LanguageConnectionContext#setIsolationLevel
   */
  public void setIsolationLevel(int isolationLevel) throws StandardException
  {
    StatementContext stmtCtxt = getStatementContext();
    if (stmtCtxt!= null && stmtCtxt.inTrigger())
      throw StandardException.newException(SQLState.LANG_NO_XACT_IN_TRIGGER, getTriggerExecutionContext().toString());

    // find if there are any held cursors from previous isolation level.
    // if yes, then throw an exception that isolation change not allowed until
    // the held cursors are closed.
View Full Code Here

  /**
   * Return the current SQL session context based on statement context
   */
  private SQLSessionContext getCurrentSQLSessionContext() {
    StatementContext ctx = getStatementContext();
    SQLSessionContext curr;

    if (ctx == null || !ctx.inUse()) {
      curr = getTopLevelSQLSessionContext();
    } else {
      // We are inside a nested connection in a procedure of
      // function.
      curr = ctx.getSQLSessionContext();

      if (SanityManager.DEBUG) {
        SanityManager.ASSERT(
          curr != null,
          "SQL session context should never be empty here");
View Full Code Here

    // Inherit current default schema. The initial value of the
    // default schema is implementation defined. In Derby we
    // inherit it when we invoke stored procedures and functions.
    sc.setDefaultSchema(getDefaultSchema(a));

    StatementContext stmctx = getStatementContext();

    // Since the statement is an invocation (iff push=true), it will now be
    // associated with the pushed SQLSessionContext (and no longer just
    // share that of its caller (or top).  The statement contexts of nested
    // connection statements will inherit statement context so the SQL
    // session context is available through it when nested statements are
    // compiled (and executed, for the most part).  However, for dynamic
    // result sets, the relevant statement context (originating result set)
    // is no longer available for execution time references to the SQL
    // session context, so we rely on the activation of the caller for
    // accessing it, cf. e.g. overload variants of
    // getDefaultSchema/setDefaultSchema.  If such nested connections
    // themselves turn out to be invocations, they in turn get a new
    // SQLSessionContext associated with them etc.
    stmctx.setSQLSessionContext(sc);
  }
View Full Code Here

     * LanguageConnectionContext.
     */
    beginTime = getCurrentTimeMillis();
    beginExecutionTime = beginTime;

    StatementContext sc = lcc.getStatementContext();
    sc.setTopResultSet(this, (NoPutResultSet[]) null);

    // Pick up any materialized subqueries
    subqueryTrackingArray = sc.getSubqueryTrackingArray();
  }
View Full Code Here

        if (runTimeStatsOn) {
            if (! isTopResultSet) {
                 // This is simply for RunTimeStats.  We first need to get the
                 // subquery tracking array via the StatementContext
                StatementContext sc = activation.getLanguageConnectionContext().
                    getStatementContext();
                subqueryTrackingArray = sc.getSubqueryTrackingArray();
            }

            nextTime += getElapsedMillis(beginTime);
        }
        return result;
View Full Code Here

    // when I'm not holding a lock on a prepared statement to avoid
    // deadlock.
    lcc.closeUnusedActivations();

    Activation parentAct = null;
    StatementContext stmctx = lcc.getStatementContext();

    if (stmctx != null) {
      // If not null, parentAct represents one of 1) the activation of a
      // calling statement and this activation corresponds to a statement
      // inside a stored procedure or function, and 2) the activation of
      // a statement that performs a substatement, e.g. trigger body
      // execution.
      parentAct = stmctx.getActivation();
    }

    ac.setParentActivation(parentAct);

    return ac;
View Full Code Here

      // method of the GenericTriggerExecutor class, and at that time
      // the SPS action will be recompiled correctly.
                rePrepare(lccToUse);
      }

      StatementContext statementContext = lccToUse.pushStatementContext(
        isAtomic, updateMode==CursorNode.READ_ONLY, getSource(), pvs, rollbackParentContext, timeoutMillis);

      statementContext.setActivation(activation);

      if (needsSavepoint())
      {
        /* Mark this position in the log so that a statement
        * rollback will undo any changes.
        */
        statementContext.setSavePoint();
        needToClearSavePoint = true;
      }

      if (executionConstants != null)
      {
        lccToUse.validateStmtExecution(executionConstants);
      }

      ResultSet resultSet = null;
      try {
 
        resultSet = activation.execute();

        resultSet.open();
      } catch (StandardException se) {
        /* Cann't handle recompiling SPS action recompile here */
        if (!se.getMessageId().equals(SQLState.LANG_STATEMENT_NEEDS_RECOMPILE)
             || spsAction)
          throw se;
        statementContext.cleanupOnError(se);
        continue recompileOutOfDatePlan;

      }


      if (needToClearSavePoint)
      {
        /* We're done with our updates */
        statementContext.clearSavePoint();
      }

      lccToUse.popStatementContext(statementContext, null);         

      if (activation.isSingleExecution() && resultSet.isClosed())
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.conn.StatementContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.