Examples of CursorResultSet


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

            throw StandardException.unexpectedUserException(t);
        }

    if (constants.deferred)
    {
      CursorResultSet tempRS = rowHolder.getResultSet();
      try
      {
                ExecRow  deferredRowBuffer = null;

        tempRS.open();
        while ((deferredRowBuffer = tempRS.getNextRow()) != null)
        {
                    int rowNumber = deferredRowBuffer.getColumn( 1).getInt();
                    rs.absolute( rowNumber);
          rs.deleteRow();
        }
      }
            catch (Throwable t)
            {
                throw StandardException.unexpectedUserException(t);
            }
            finally
      {
        sourceResultSet.clearCurrentRow();
        tempRS.close();
      }
    }

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

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

    ExecIndexRow  deferredIndexRow = new IndexRow();

    /* Deferred processing only necessary for unique indexes */
    if (rowHolder != null)
    {
      CursorResultSet rs = rowHolder.getResultSet();
      try
      {
        rs.open();
        while ((deferredRow = rs.getNextRow()) != null)
        {
          if (SanityManager.DEBUG)
          {
            if (!(deferredRow instanceof ExecIndexRow))
            {
              SanityManager.THROWASSERT("deferredRow isn't an instance "+
                "of ExecIndexRow as expected. "+
                "It is an "+deferredRow.getClass().getName());
            }
          }
          insertAndCheckDups((ExecIndexRow)deferredRow);
        }
      }
      finally
      {
        rs.close();

        /*
        ** If row holder was passed in, let the
        ** client of this method clean it up.
        */
 
View Full Code Here

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

        triggerActivator.notifyEvent(TriggerEvents.BEFORE_INSERT,
                        (CursorResultSet)null,
                        rowHolder.getResultSet());
      }

      CursorResultSet rs = rowHolder.getResultSet();
      try
      {
        rs.open();
        while ((deferredRowBuffer = rs.getNextRow()) != null)
        {
          // we have to set the source row so the check constraint
          // sees the correct row.
          sourceResultSet.setCurrentRow(deferredRowBuffer);
          evaluateCheckConstraints();
          rowChanger.insertRow(deferredRowBuffer);
        }
      } finally
      {
        sourceResultSet.clearCurrentRow();
        rs.close();
      }
     
      if (fkChecker != null)
      {
        /*
        ** Second scan to make sure all the foreign key
        ** constraints are ok.  We have to do this after
        ** we have completed the inserts in case of self
        ** referencing constraints.
        */
        rs = rowHolder.getResultSet();
        try
        {
          rs.open();
          while ((deferredRowBuffer = rs.getNextRow()) != null)
          {
            fkChecker.doFKCheck(deferredRowBuffer);
          }
        } finally
        {
          rs.close();
        }
      }

      // fire AFTER trigger
      if (triggerActivator != null)
View Full Code Here

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

                           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 =
          deferredBaseCC.fetch(
                     baseRowLocation, deferredSparseRow.getRowArray(),
                     readBitSet);

        // In case of cascade delete , things like before triggers can delete
        // the rows before the dependent result get a chance to delete
        if(cascadeDelete && !row_exists)
          continue;

        if (SanityManager.DEBUG)
        {
          if (!row_exists)
          {
                          SanityManager.THROWASSERT("could not find row "+baseRowLocation);
          }
        }
 
        rc.deleteRow(deferredBaseRow, baseRowLocation);
        source.markRowAsDeleted();
      }
    } finally
    {
        rs.close();
    }
  }
View Full Code Here

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

      ** Second scan to make sure all the foreign key
      ** constraints are ok.  We have to do this after
      ** we have completed the deletes in case of self referencing
      ** constraints.
      */
      CursorResultSet rs = rowHolder.getResultSet();
      try
      {
        rs.open();
        while ((deferredRLRow = rs.getNextRow()) != null)
        {
          fkChecker.doPKCheck(deferredRLRow, restrictCheckOnly);
        }
      } finally
      {
        rs.close();
      }
    }
  }
View Full Code Here

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

      return null;
    }

    try
    {
      CursorResultSet brs = beforeResultSet;
      /* We should really shallow clone the result set, because it could be used
       * at multiple places independently in trigger action.  This is a bug found
       * during the fix of beetle 4373.
       */
      if (brs instanceof TemporaryRowHolderResultSet)
        brs = (CursorResultSet) ((TemporaryRowHolderResultSet) brs).clone();
      else if (brs instanceof TableScanResultSet)
        brs = (CursorResultSet) ((TableScanResultSet) brs).clone();
      brs.open();
      java.sql.ResultSet rs = cc.getResultSet(brs);
      resultSetVector.addElement(rs);
      return rs;
    } catch (StandardException se)
    {
View Full Code Here

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

    {
      /* We should really shallow clone the result set, because it could be used
       * at multiple places independently in trigger action.  This is a bug found
       * during the fix of beetle 4373.
       */
      CursorResultSet ars = afterResultSet;
      if (ars instanceof TemporaryRowHolderResultSet)
        ars = (CursorResultSet) ((TemporaryRowHolderResultSet) ars).clone();
      else if (ars instanceof TableScanResultSet)
        ars = (CursorResultSet) ((TableScanResultSet) ars).clone();
      ars.open();
      java.sql.ResultSet rs = cc.getResultSet(ars);
      resultSetVector.addElement(rs);
      return rs;
    } catch (StandardException se)
    {
View Full Code Here

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

    ** are referenced. 
    */
    if (deferred && updatingReferencedKey)
    {
      ExecRow  deletedRow;
      CursorResultSet deletedRows;

      /*
      ** For each referenced key that was modified
      */
      for (int i = 0; i < fkInfoArray.length; i++)
      {
        if (fkInfoArray[i].type == FKInfo.FOREIGN_KEY)
        {
          continue;
        }

        deletedRows = deletedRowHolder.getResultSet();
        try
        {
          /*
          ** For each delete row
          */ 
          deletedRows.open();
          while ((deletedRow = deletedRows.getNextRow()) != null)
          {
            if (!foundRow(deletedRow,
                    fkInfoArray[i].colArray,
                    insertedRowHolder))
            {
              riChecker.doRICheck(i, deletedRow, restrictCheckOnly);
            }
          } 
        }
        finally
        {
          deletedRows.close();
        }
      }
    }

    /*
    ** For a deferred update, make sure that there
    ** aren't any foreign keys that were added that
     ** aren't referenced. 
    */
    if (deferred && updatingForeignKey)
    {
      ExecRow  insertedRow;
      CursorResultSet insertedRows;

      /*
      ** For each foreign key that was modified
      */
      for (int i = 0; i < fkInfoArray.length; i++)
      {
        if (fkInfoArray[i].type == FKInfo.REFERENCED_KEY)
        {
          continue;
        }

        insertedRows = insertedRowHolder.getResultSet();
        try
        {
          /*
          ** For each inserted row
          */ 
          insertedRows.open();
          while ((insertedRow = insertedRows.getNextRow()) != null)
          {
            if (!foundRow(insertedRow,
                    fkInfoArray[i].colArray,
                    deletedRowHolder))
            {
              riChecker.doRICheck(i, insertedRow, restrictCheckOnly);
            }
          } 
        }
        finally
        {
          insertedRows.close();
        }
      }
    }

  }
View Full Code Here

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

    boolean        foundMatch = false;
    Object[]       checkRowArray = checkRow.getRowArray();
    DataValueDescriptor  checkCol;
    DataValueDescriptor  scanCol;

    CursorResultSet rs = rowHolder.getResultSet();
    try
   
      /*
      ** For each inserted row
      */ 
      rs.open();
      while ((scanRow = rs.getNextRow()) != null)
      {
        Object[] scanRowArray = scanRow.getRowArray();
        int i;
        for (i = 0; i < colsToCheck.length; i++)
        {
          checkCol = (DataValueDescriptor)checkRowArray[colsToCheck[i]-1];
          scanCol = (DataValueDescriptor)scanRowArray[colsToCheck[i]-1];

          BooleanDataValue result = checkCol.equals(
                      scanCol,
                      checkCol); // result
          if (!result.getBoolean())
          {
            break;
          }
        }
        if (i == colsToCheck.length)
        {
          foundMatch = true;
          break;
       
      }
    }
    finally
    {
      rs.close();
    }
    return foundMatch;
  }
View Full Code Here

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

                    lockMode,
                    TransactionController.ISOLATION_SERIALIZABLE,
                    constants.heapSCOCI,
                    heapDCOCI);
     
      CursorResultSet rs = insertedRowHolder.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);
        ExecRow deferredTempRow2;

        rs.open();
        while ((deferredTempRow2 = rs.getNextRow()) != null)
        {
          /*
          ** Check the constraint now if we have triggers.
          ** Otherwise we evaluated them as we read the
          ** rows in from the source.
          */
          if (triggerInfo != null)
          {
            source.setCurrentRow(deferredTempRow);
            evaluateCheckConstraints(checkGM, activation);
          }

          /*
          ** The last column is a Ref, which contains a
          ** RowLocation.
          */
          DataValueDescriptor rlColumn = deferredTempRow2.getColumn(numberOfBaseColumns + 1);
          RowLocation baseRowLocation =
              (RowLocation) (rlColumn).getObject();
 
          /* Get the base row at the given RowLocation */
          boolean row_exists =
            deferredBaseCC.fetch(
              baseRowLocation, deferredSparseRow.getRowArray(),
              readBitSet);

          if (SanityManager.DEBUG)
          {
            SanityManager.ASSERT(row_exists, "did not find base row in deferred update");
          }
 
          /*
          ** Copy the columns from the temp row to the base row.
          ** The base row has fewer columns than the temp row,
          ** because it doesn't contain the row location.
          */
          RowUtil.copyRefColumns(newBaseRow,
                      deferredTempRow2,
                      numberOfBaseColumns);

          rowChanger.updateRow(deferredBaseRow,
                    newBaseRow,
                    baseRowLocation);
          source.updateRow(newBaseRow);
        }
      } finally
      {
        source.clearCurrentRow();
        rs.close();
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.