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

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


        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

            // 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

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

      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

    long        bindTime = 0;
    long        optimizeTime = 0;
    long        generateTime = 0;
    Timestamp      beginTimestamp = null;
    Timestamp      endTimestamp = null;
    StatementContext  statementContext = null;

    // verify it isn't already prepared...
    // if it is, and is valid, simply return that tree.
    // if it is invalid, we will recompile now.
    if (preparedStmt != null) {
View Full Code Here

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

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

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

     */
  public void checkCancellationFlag()
        throws
            StandardException
  {
        StatementContext localStatementContext = getLanguageConnectionContext().getStatementContext();           
        if (localStatementContext == null) {
            return;
        }

        if (localStatementContext.isCancelled()) {
            throw StandardException.newException(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT);
        }
    }
View Full Code Here

   * @exception StandardException thrown on error
   */
  void setup() throws StandardException {
    isOpen = true;

        StatementContext sc = lcc.getStatementContext();
        sc.setTopResultSet(this, subqueryTrackingArray);

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

    {
      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

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.