Package org.apache.derby.iapi.sql.execute

Examples of org.apache.derby.iapi.sql.execute.ExecPreparedStatement


                    //the call to java procedure because that activation
                    //is still being used.
                    a.reset();
                // Only invalidate statements if we performed DDL.
                if (dataDictionaryInWriteMode()) {
                    ExecPreparedStatement ps = a.getPreparedStatement();
                    if (ps != null) {
                        ps.makeInvalid(DependencyManager.ROLLBACK, this);
                    }
                }
            } else {
                //We are dealing with commit here.
                if (resultsetReturnsRows){
View Full Code Here


     * in this query.
     * @return true if the row counts should be checked, false otherwise
     */
  protected boolean shouldWeCheckRowCounts() throws StandardException
  {
        final ExecPreparedStatement ps = getPreparedStatement();

    /*
    ** Check the row count only every N executions.  OK to check this
    ** without synchronization, since the value of this number is not
    ** critical.  The value of N is determined by the property
    ** derby.language.stalePlanCheckInterval.
    */
        int executionCount = ps.incrementExecutionCount();

    /*
    ** Always check row counts the first time, to establish the
    ** row counts for each result set.  After that, don't check
    ** if the execution count is below the minimum row count check
    ** interval.  This saves us from checking a database property
    ** when we don't have to (checking involves querying the store,
    ** which can be expensive).
    */

    if (executionCount == 1)
    {
            return true;
    }
    else if (executionCount <
                Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL)
    {
            return false;
    }
    else
    {
            int stalePlanCheckInterval = ps.getStalePlanCheckInterval();

      /*
      ** Only query the database property once.  We can tell because
      ** the minimum value of the property is greater than zero.
      */
      if (stalePlanCheckInterval == 0)
      {
        TransactionController tc = getTransactionController();

        stalePlanCheckInterval =
            PropertyUtil.getServiceInt(
              tc,
              Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
              Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
              Integer.MAX_VALUE,
              Property.DEFAULT_LANGUAGE_STALE_PLAN_CHECK_INTERVAL
              );

                ps.setStalePlanCheckInterval(stalePlanCheckInterval);
      }

            return (executionCount % stalePlanCheckInterval) == 1;

    }
View Full Code Here

     * @throws StandardException
     */
  protected void checkPositionedStatement(String cursorName, String psName)
    throws StandardException {

    ExecPreparedStatement ps = getPreparedStatement();
    if (ps == null)
      return;
     
    CursorActivation cursorActivation = lcc.lookupCursorActivation(cursorName);

    if (cursorActivation != null)
    {
      // check we are compiled against the correct cursor
      if (!psName.equals(cursorActivation.getPreparedStatement().getObjectName())) {

        // our prepared statement is now invalid since there
        // exists another cursor with the same name but a different
        // statement.
        ps.makeInvalid(DependencyManager.CHANGED_CURSOR, lcc);
      }
    }
  }
View Full Code Here

                                    Activation a,
                                    int savedUUIDIdx)
                            throws StandardException
    {
        if ( !isNull() && (value == false) ) {
            final ExecPreparedStatement ps = a.getPreparedStatement();
            final UUID constrId = (UUID)ps.getSavedObject(savedUUIDIdx);
            final LanguageConnectionContext lcc =
                a.getLanguageConnectionContext();
            final boolean isDeferred = lcc.isEffectivelyDeferred(
                   lcc.getCurrentSQLSessionContext(a), constrId);
View Full Code Here

  {
    super(a, resultSetNumber, optimizerEstimatedRowCount, optimizerEstimatedCost);
    source = s;
    originalSource = s;

        ExecPreparedStatement ps = a.getPreparedStatement();
        ExecutionFactory ef = a.getExecutionFactory();

        rowTemplate = ef.getIndexableRow(
                ((ExecRowBuilder) ps.getSavedObject(ra)).build(ef));

    aggInfoList = (AggregatorInfoList) ps.getSavedObject(aggregateItem);
    aggregates = getSortAggregators(aggInfoList, false,
        a.getLanguageConnectionContext(), s);
  }
View Full Code Here

    this.scanIsolationLevel = scanIsolationLevel;
    this.isDerbyStyleTableFunction = isDerbyStyleTableFunction;
        this.vtiSchema = vtiSchema;
        this.vtiName = vtiName;

        ExecPreparedStatement ps = activation.getPreparedStatement();

        this.allocatedRow = ((ExecRowBuilder) ps.getSavedObject(row))
                .build(activation.getExecutionFactory());

        this.returnType = returnTypeNumber == -1 ? null :
            (TypeDescriptor)
            activation.getPreparedStatement().getSavedObject(returnTypeNumber);
View Full Code Here

        // The prepared statement and the activation may already be available
        // if the trigger has been fired before in the same statement. (Only
        // happens with row triggers that are triggered by a statement that
        // touched multiple rows.) The WHEN clause and the trigger action have
        // their own prepared statement and activation. Fetch the correct set.
        ExecPreparedStatement ps = isWhen ? whenPS : actionPS;
        Activation spsActivation = isWhen
                ? spsWhenActivation : spsActionActivation;

    while (true) {
      /*
      ** Only grab the ps the 1st time through.  This
      ** way a row trigger doesn't do any unnecessary
      ** setup work.
      */
      if (ps == null || recompile)
      {
                // The SPS activation will set its parent activation from
                // the statement context. Reset it to the original parent
                // activation first so that it doesn't use the activation of
                // the previously executed SPS as parent. DERBY-6348.
                lcc.getStatementContext().setActivation(activation);

        /*
        ** We need to clone the prepared statement so we don't
        ** wind up marking that ps that is tied to sps as finished
        ** during the course of execution.
        */
        ps = sps.getPreparedStatement();
        ps = ps.getClone();
        // it should be valid since we've just prepared for it
        ps.setValid();
        spsActivation = ps.getActivation(lcc, false);

        /*
        ** Normally, we want getSource() for an sps invocation
        ** to be EXEC STATEMENT xxx, but in this case, since
        ** we are executing the SPS in our own fashion, we want
        ** the text to be the trigger action.  So set it accordingly.
        */
        ps.setSource(sps.getText());
        ps.setSPSAction();

                // Cache the prepared statement and activation in case the
                // trigger fires multiple times.
                if (isWhen) {
                    whenPS = ps;
                    spsWhenActivation = spsActivation;
                } else {
                    actionPS = ps;
                    spsActionActivation = spsActivation;
                }
      }

      // save the active statement context for exception handling purpose
      StatementContext active_sc = lcc.getStatementContext();
     
      /*
      ** Execute the activation.  If we have an error, we
      ** are going to go to some extra work to pop off
      ** our statement context.  This is because we are
      ** a nested statement (we have 2 activations), but
      ** we aren't a nested connection, so we have to
      ** pop off our statementcontext to get error handling 
      ** to work correctly.  This is normally a no-no, but
      ** we are an unusual case.
      */
      try
      {
                // This is a substatement; for now, we do not set any timeout
                // for it. We might change this behaviour later, by linking
                // timeout to its parent statement's timeout settings.
        ResultSet rs = ps.executeSubStatement
          (activation, spsActivation, false, 0L);

                if (isWhen)
                {
                    // This is a WHEN clause. Expect a single BOOLEAN value
View Full Code Here

        this.restriction = restriction;
        this.source = source;
        this.rownumber = 0;

        ExecPreparedStatement ps = activation.getPreparedStatement();

        this.allocatedRow = ((ExecRowBuilder) ps.getSavedObject(rowAllocator))
                .build(activation.getExecutionFactory());

        if (erdNumber != -1) {
            this.referencedColumns =
                (FormatableBitSet) ps.getSavedObject(erdNumber);
        }

        recordConstructorTime();
    }
View Full Code Here

    String          uuidStr = null
    String          suuidStr = null// schema 
    String          compUuidStr = null// compilation schema 
    String          text = null;
    String          usingText = null;
    ExecPreparedStatement  preparedStatement = null;
    String          typeStr = null;
    boolean          valid = true;
    Timestamp        time = null;
    boolean          initiallyCompilable = true;
View Full Code Here

    String            suuidStr;  // schema
    String            typeStr;
    char            type;
    boolean            valid;
    Timestamp          time = null;
    ExecPreparedStatement    preparedStatement = null;
    boolean            initiallyCompilable;
    DataDescriptorGenerator    ddg = dd.getDataDescriptorGenerator();

    if (SanityManager.DEBUG)
    {
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.execute.ExecPreparedStatement

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.