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

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


    if (sourceDrained)
    {
      return null;
    }

    ExecRow    sourceRow = null;
    ExecRow    result = null;

    sourceRow = source.getNextRowCore();

    if (sourceRow != null)
    {
View Full Code Here


   * @exception StandardException thrown on failure.
   */
  public ExecRow doBaseRowProjection(ExecRow sourceRow)
    throws StandardException
  {
    final ExecRow result;
    if (source instanceof ProjectRestrictResultSet) {
      ProjectRestrictResultSet prs = (ProjectRestrictResultSet) source;
      result = prs.doBaseRowProjection(sourceRow);
    } else {
      result = sourceRow.getNewNullRow();
      result.setRowArray(sourceRow.getRowArray());
    }
    return doProjection(result);
  }
View Full Code Here

  void deleteDeferredRows() throws StandardException
  {
   
    DataValueDescriptor    rlColumn;
     RowLocation  baseRowLocation;
    ExecRow    deferredRLRow = null;

    deferredBaseCC = tc.openCompiledConglomerate(false,
                           tc.OPENMODE_FORUPDATE|tc.OPENMODE_SECONDARY_LOCKED,
                           lockMode,
                           TransactionController.ISOLATION_SERIALIZABLE,
                           constants.heapSCOCI,
                           heapDCOCI);
     
    CursorResultSet rs = rowHolder.getResultSet();
    try
    {
      /*
      ** We need to do a fetch doing a partial row
      ** read.  We need to shift our 1-based bit
      ** set to a zero based bit set like the store
      ** expects.
      */
      FormatableBitSet readBitSet = RowUtil.shift(baseRowReadList, 1);

      rs.open();
      while ((deferredRLRow = rs.getNextRow()) != null)
      {
        rlColumn = deferredRLRow.getColumn(rlColumnNumber);
        baseRowLocation =
          (RowLocation) (rlColumn).getObject();
 
        /* Get the base row at the given RowLocation */
        boolean row_exists =
View Full Code Here

  // make sure foreign key constraints are not violated
    void runFkChecker(boolean restrictCheckOnly) throws StandardException
  {

    ExecRow    deferredRLRow = null;
    if (fkChecker != null)
    {
      /*
      ** Second scan to make sure all the foreign key
      ** constraints are ok.  We have to do this after
View Full Code Here

  private ScanController loadSorter()
    throws StandardException
  {
    SortController       sorter;
    long           sortId;
    ExecRow         sourceRow;
    ExecRow         inputRow;
    int            inputRowCountEstimate = (int) optimizerEstimatedRowCount;
    boolean          inOrder = isInSortedOrder;

    tc = getTransactionController();

    ColumnOrdering[] currentOrdering = order;

    /*
    ** Do we have any distinct aggregates?  If so, we'll need
    ** a separate sort.  We use all of the sorting columns and
    ** drop the aggregation on the distinct column.  Then
    ** we'll feed this into the sorter again w/o the distinct
    ** column in the ordering list.
    */
    if (aggInfoList.hasDistinct())
    {
      hasDistinctAggregate = true;
     
      GenericAggregator[] aggsNoDistinct = getSortAggregators(aggInfoList, true,
            activation.getLanguageConnectionContext(), source);
      SortObserver sortObserver = new AggregateSortObserver(true, aggsNoDistinct, aggregates,
                                  sortTemplateRow);

      sortId = tc.createSort((Properties)null,
          sortTemplateRow.getRowArray(),
          order,
          sortObserver,
          false,      // not in order
          inputRowCountEstimate,        // est rows, -1 means no idea 
          maxRowSize    // est rowsize
          );
      sorter = tc.openSort(sortId);
      distinctAggSortId = sortId;
      dropDistinctAggSort = true;
       
      while ((sourceRow = source.getNextRowCore())!=null)
      {
        sorter.insert(sourceRow.getRowArray());
        rowsInput++;
      }

      /*
      ** End the sort and open up the result set
      */
      source.close();
      sortProperties = sorter.getSortInfo().getAllSortInfo(sortProperties);
      sorter.completedInserts();

      scanController =
                tc.openSortScan(sortId, activation.getResultSetHoldability());
     
      /*
      ** Aggs are initialized and input rows
      ** are in order.  All we have to do is
      ** another sort to remove (merge) the
      ** duplicates in the distinct column
      */ 
      inOrder = true;
      inputRowCountEstimate = rowsInput;
 
      /*
      ** Drop the last column from the ordering.  The
      ** last column is the distinct column.  Don't
      ** pay any attention to the fact that the ordering
      ** object's name happens to correspond to a techo
      ** band from the 80's.
      **
      ** If there aren't any ordering columns other
      ** than the distinct (i.e. for scalar distincts)
      ** just skip the 2nd sort altogether -- we'll
      ** do the aggregate merge ourselves rather than
      ** force a 2nd sort.
      */
      if (order.length == 1)
      {
        return scanController;
      }

      ColumnOrdering[] newOrder = new ColumnOrdering[order.length - 1];
      System.arraycopy(order, 0, newOrder, 0, order.length - 1);
      currentOrdering = newOrder;
    }

    SortObserver sortObserver = new AggregateSortObserver(true, aggregates, aggregates,
                                sortTemplateRow);

    sortId = tc.createSort((Properties)null,
            sortTemplateRow.getRowArray(),
            currentOrdering,
            sortObserver,
            inOrder,
            inputRowCountEstimate, // est rows
             maxRowSize      // est rowsize
            );
    sorter = tc.openSort(sortId);
    genericSortId = sortId;
    dropGenericSort = true;
 
    /* The sorter is responsible for doing the cloning */
    while ((inputRow = getNextRowFromRS()) != null)
    {
      sorter.insert(inputRow.getRowArray());
    }
    source.close();
    sortProperties = sorter.getSortInfo().getAllSortInfo(sortProperties);
    sorter.completedInserts();

View Full Code Here

   * Get a row from the input result set. 
   */ 
  private ExecIndexRow getRowFromResultSet()
    throws StandardException
  {
    ExecRow          sourceRow;
    ExecIndexRow      inputRow = null

    if ((sourceRow = source.getNextRowCore()) != null)
    {
      rowsInput++;
View Full Code Here

  public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)
    throws StandardException
  {
    DataTypeDescriptor    dtd;
    ExecRow            row;
    DataValueDescriptor    col;
    String          name = null;
    UUID          uuid = null
    UUID          suuid = null;      // schema 
    UUID          tuuid = null;      // referenced table 
    UUID          actionSPSID = null;    // action sps uuid string
    UUID          whenSPSID = null;    // when clause sps uuid string
    Timestamp        createTime = null;
    String          event = null;
    String          time = null;
    String          type = null;
    String          enabled = null;
    String          triggerDefinition = null;
    String          oldReferencingName = null;
    String          newReferencingName = null;
    ReferencedColumns rcd = null;
    boolean          referencingOld = false;
    boolean          referencingNew = false;

    if (td != null)
    {
      TriggerDescriptor triggerDescriptor = (TriggerDescriptor)td;
      name = triggerDescriptor.getName();
      uuid = triggerDescriptor.getUUID();
      suuid = triggerDescriptor.getSchemaDescriptor().getUUID();
      createTime = triggerDescriptor.getCreationTimestamp();
      // for now we are assuming that a trigger can only listen to a single event
      event = triggerDescriptor.listensForEvent(TriggerDescriptor.TRIGGER_EVENT_UPDATE) ? "U" :
          triggerDescriptor.listensForEvent(TriggerDescriptor.TRIGGER_EVENT_DELETE) ? "D" : "I";
      time = triggerDescriptor.isBeforeTrigger() ? "B" : "A";
      type = triggerDescriptor.isRowTrigger() ? "R" : "S";
      enabled = triggerDescriptor.isEnabled() ? "E" : "D";
      tuuid = triggerDescriptor.getTableDescriptor().getUUID();
      int[] refCols = triggerDescriptor.getReferencedCols();
      rcd = (refCols != null) ? new
        ReferencedColumnsDescriptorImpl(refCols) : null;

      actionSPSID =  triggerDescriptor.getActionId();
      whenSPSID =  triggerDescriptor.getWhenClauseId();
      triggerDefinition = triggerDescriptor.getTriggerDefinition();
      referencingOld = triggerDescriptor.getReferencingOld();
      referencingNew = triggerDescriptor.getReferencingNew();
      oldReferencingName = triggerDescriptor.getOldReferencingName();
      newReferencingName = triggerDescriptor.getNewReferencingName();
    }

    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSTRIGGERS_COLUMN_COUNT);

    /* 1st column is TRIGGERID */
    row.setColumn(1, new SQLChar((uuid == null) ? null : uuid.toString()));

    /* 2nd column is TRIGGERNAME */
    row.setColumn(2, new SQLVarchar(name));

    /* 3rd column is SCHEMAID */
    row.setColumn(3, new SQLChar((suuid == null) ? null : suuid.toString()));

    /* 4th column is CREATIONTIMESTAMP */
    row.setColumn(4, dvf.getDataValue(createTime));

    /* 5th column is EVENT */
    row.setColumn(5, new SQLChar(event));

    /* 6th column is FIRINGTIME */
    row.setColumn(6, new SQLChar(time));

    /* 7th column is TYPE */
    row.setColumn(7, new SQLChar(type));

    /* 8th column is STATE */
    row.setColumn(8, new SQLChar(enabled));

    /* 9th column is TABLEID */
    row.setColumn(9, new SQLChar((tuuid == null) ? null : tuuid.toString()));

    /* 10th column is WHENSTMTID */
    row.setColumn(10, new SQLChar((whenSPSID == null) ? null : whenSPSID.toString()));

    /* 11th column is ACTIONSTMTID */
    row.setColumn(11, new SQLChar((actionSPSID == null) ? null : actionSPSID.toString()));

    /* 12th column is REFERENCEDCOLUMNS
     *  (user type org.apache.derby.catalog.ReferencedColumns)
     */
    row.setColumn(12, dvf.getDataValue(rcd));

    /* 13th column is TRIGGERDEFINITION */
    row.setColumn(13, dvf.getLongvarcharDataValue(triggerDefinition));

    /* 14th column is REFERENCINGOLD */
    row.setColumn(14, dvf.getDataValue(referencingOld));

    /* 15th column is REFERENCINGNEW */
    row.setColumn(15, dvf.getDataValue(referencingNew));

    /* 16th column is OLDREFERENCINGNAME */
    row.setColumn(16, new SQLVarchar(oldReferencingName));

    /* 17th column is NEWREFERENCINGNAME */
    row.setColumn(17, new SQLVarchar(newReferencingName));

    return row;
  }
View Full Code Here

    String statName = null, colMap = null, statType = null;
    Timestamp updateTime = null;
    int columnCount = 0;
    Statistics statisticsObject = null;
    boolean validStat = false;
    ExecRow row = getExecutionFactory().getValueRow(SYSSTATISTICS_COLUMN_COUNT);
   
    if (td != null)
    {
      StatisticsDescriptor statDesc = (StatisticsDescriptor)td;
      myID = statDesc.getUUID().toString();
      tableID = statDesc.getTableUUID().toString();
      referenceID = statDesc.getReferenceID().toString();
      updateTime = statDesc.getUpdateTimestamp();
      statType = statDesc.getStatType();
        validStat = statDesc.isValid();
      statisticsObject = statDesc.getStatistic();
      columnCount = statDesc.getColumnCount();
    }

    row.setColumn(1, new SQLChar(myID));
    row.setColumn(2, new SQLChar(referenceID));
    row.setColumn(3, new SQLChar(tableID));
    row.setColumn(4, new SQLTimestamp(updateTime));
    row.setColumn(5, new SQLChar(statType));
      row.setColumn(6, dvf.getDataValue(validStat));
    row.setColumn(7, dvf.getDataValue(columnCount));
    row.setColumn(8, dvf.getDataValue(statisticsObject));
    return row;
  }
View Full Code Here

   *        StandardException ScalarSubqueryCardinalityViolation
   *            Thrown if scalar subquery returns more than 1 row.
   */
  public ExecRow  getNextRowCore() throws StandardException
  {
      ExecRow candidateRow = null;
    ExecRow secondRow = null;
      ExecRow result = null;

    beginTime = getCurrentTimeMillis();
    // This is an ASSERT and not a real error because this is never
    // outermost in the tree and so a next call when closed will not occur.
    if (SanityManager.DEBUG)
View Full Code Here

      if (past2FutureTbl.size() < maxCapacity)
        past2FutureTbl.put(updatedRL, updatedRL);
      else
      {
        tableScan.skipFutureRowHolder = true;
        ExecRow rlRow = new ValueRow(1);

        for (;;)
        {
          ExecRow aRow = tableScan.getNextRowCore();
          if (aRow == null)
          {
            tableScan.sourceDrained = true;
            tableScan.past2FutureTbl = null// de-reference for garbage coll.
            break;
          }
          RowLocation rowLoc = (RowLocation) aRow.getColumn(aRow.nColumns());

          if (updatedRL.equals(rowLoc))  //this row we are updating jumped forward
          {
            saveLastCusorKey(tableScan, aRow);
            break// don't need to worry about adding this row to hash any more
View Full Code Here

TOP

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

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.