Examples of CursorResultSet


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

            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

    ExecRow      deferredRow;

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

    ** If it's a deferred update, scan the temporary conglomerate and
    ** insert the rows into the VTI using rowChanger.
    */
    if (constants.deferred)
    {
      CursorResultSet tempRS = rowHolder.getResultSet();
      try
      {
        tempRS.open();
        while ((row = tempRS.getNextRow()) != null)
        {
                    int rowNumber = row.getColumn( rowLocationColumn).getInt();
                    rs.absolute( rowNumber);
          updateVTI(rs, row);
        }
      }
            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

                        (CursorResultSet)null,
                        rowHolder.getResultSet(),
                        (int[])null);
      }

      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);
                    boolean allOk = evaluateCheckConstraints();

                    if (allOk) {
                        rowChanger.insertRow(deferredRowBuffer, false);
                    } else {
                        RowLocation offendingRow =
                            rowChanger.insertRow(deferredRowBuffer, true);
                        deferredChecks =
                            DeferredConstraintsMemory.rememberCheckViolations(
                                lcc,
                                constants.targetUUID,
                                schemaName,
                                tableName,
                                deferredChecks,
                                violatingCheckConstraints,
                                offendingRow,
                                new CheckInfo[1]);
                    }
        }
      } 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(activation, 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 = 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.
          */
                    boolean allOk = true;

          if (triggerInfo != null)
          {
            source.setCurrentRow(deferredTempRow);
                        allOk = evaluateCheckConstraints();
          }

          /*
          ** The last column is a Ref, which contains a
          ** RowLocation.
          */
          DataValueDescriptor rlColumn = deferredTempRow2.getColumn(numberOfBaseColumns + 1);
          RowLocation baseRowLocation =
              (RowLocation) (rlColumn).getObject();

                    if (!allOk) {
                        deferredChecks =
                            DeferredConstraintsMemory.rememberCheckViolations(
                                lcc,
                                constants.targetUUID,
                                constants.getSchemaName(),
                                constants.getTableName(),
                                deferredChecks,
                                violatingCheckConstraints,
                                baseRowLocation,
                                new CheckInfo[1]);
                    }

          /* 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);
        }
      } finally
      {
        source.clearCurrentRow();
        rs.close();
      }
    }
  }
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))
                        {
                            // Argument "1" below: If a PK referenced by an FK
                            // is deferred, require at least one to be present
                            // in the primary table since we have modified the
                            // row's PK, unless postCheck == true, in which the
                            // call to postChecks does the actual checking, and
                            // we need at least one row intact to fulfill the
                            // constraint.
                           riChecker.doRICheck(
                                    activation,
                                    i,
                                    deletedRow,
                                    restrictCheckOnly,
                                    1);
            }
          } 

                    if (restrictCheckOnly) {
                        riChecker.postCheck(i);
                    }
        }
        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(
                                activation,
                                i,
                                insertedRow,
                                restrictCheckOnly,
                                0);        // N/A, not referenced key
            }
                    }
        }
        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

        throws StandardException
    {
        // nothing to do if no rows qualified
        if ( thenRows == null ) { return; }

        CursorResultSet sourceRS = thenRows.getResultSet();
        GeneratedMethod actionGM = ((BaseActivation) activation).getMethod( _actionMethodName );

        //
        // Push the action-specific ConstantAction rather than the Merge statement's
        // ConstantAction. The INSERT/UPDATE/DELETE expects the default ConstantAction
        // to be appropriate to it.
        //
        try {
            activation.pushConstantAction( _thenAction );

            try {
                //
                // Poke the temporary table into the variable which will be pushed as
                // an argument to the INSERT/UPDATE/DELETE action.
                //
                Field   resultSetField = activation.getClass().getField( _resultSetFieldName );
                resultSetField.set( activation, sourceRS );

                Activation  cursorActivation = sourceRS.getActivation();

                //
                // Now execute the generated method which creates an InsertResultSet,
                // UpdateResultSet, or DeleteResultSet.
                //
View Full Code Here

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

          rowHolderId++;
          continue;
        }
                TemporaryRowHolder
                        currentRowHolder = sVector.elementAt(rowHolderId);
        CursorResultSet rs = currentRowHolder.getResultSet();
        rs.open();
        while ((row = rs.getNextRow()) != null)
        {
          rowHolder.insert(row);
        }
        rs.close();
        rowHolderId++;
      }
     
    }
  }
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.