Class TemporaryRowHolderResultSet

    • Constructor Detail

      • TemporaryRowHolderResultSet

        public TemporaryRowHolderResultSet​(TransactionController tc,
                                           ExecRow[] rowArray,
                                           ResultDescription resultDescription,
                                           boolean isVirtualMemHeap,
                                           TemporaryRowHolderImpl holder)
        Constructor
        Parameters:
        tc - the xact controller
        rowArray - the row array
        resultDescription - value returned by getResultDescription()
      • TemporaryRowHolderResultSet

        public TemporaryRowHolderResultSet​(TransactionController tc,
                                           ExecRow[] rowArray,
                                           ResultDescription resultDescription,
                                           boolean isVirtualMemHeap,
                                           boolean isAppendable,
                                           long positionIndexConglomId,
                                           TemporaryRowHolderImpl holder)
        Constructor
        Parameters:
        tc - the xact controller
        rowArray - the row array
        resultDescription - value returned by getResultDescription()
        isAppendable - true,if we can insert rows after this result is created
        positionIndexConglomId - conglomId of the index which has order rows are inserted and their row location
    • Method Detail

      • reset

        public void reset​(ExecRow[] rowArray)
        Reset the exec row array and reinitialize
        Parameters:
        rowArray - the row array
      • reStartScan

        public void reStartScan​(long currentConglomId,
                                long pconglomId)
                         throws StandardException
        postion scan to start from after where we stopped earlier
        Throws:
        StandardException
      • supersetofAllColumns

        private static int[] supersetofAllColumns​(int[] columnsArray1,
                                                  int[] columnsArray2)
      • shrinkArray

        private static int[] shrinkArray​(int[] columnsArrary)
      • justTheRequiredColumnsPositions

        private static int[] justTheRequiredColumnsPositions​(int[] columnsArrary)
      • getNewRSOnCurrentRow

        public static TemporaryRowHolderResultSet getNewRSOnCurrentRow​(TriggerDescriptor triggerd,
                                                                       Activation activation,
                                                                       CursorResultSet rs,
                                                                       int[] colsReadFromTable)
                                                                throws StandardException
        Whip up a new Temp ResultSet that has a single row. This row will either have all the columns from the current row of the passed resultset or a subset of the columns from the passed resulset. It all depends on what columns are needed by the passed trigger and what columns exist in the resulset. The Temp resulset should only have the columns required by the trigger.
        Parameters:
        triggerd - We are building Temp resultset for this trigger
        activation - the activation
        rs - the result set
        colsReadFromTable - The passed resultset is composed of these columns. We will create a temp resultset which will have either all these columns or only a subset of these columns. It all depends on what columns are needed by the trigger. If this param is null, then that means that all the columns from the trigger table have been read into the passed resultset.
        Returns:
        a single row result set
        Throws:
        StandardException - on error
      • markAsTopResultSet

        public void markAsTopResultSet()
        Mark the ResultSet as the topmost one in the ResultSet tree. Useful for closing down the ResultSet on an error.
        Specified by:
        markAsTopResultSet in interface NoPutResultSet
      • getPointOfAttachment

        public int getPointOfAttachment()
        Return the point of attachment for this subquery. (Only meaningful for Any and Once ResultSets, which can and will only be at the top of a ResultSet for a subquery.)
        Specified by:
        getPointOfAttachment in interface NoPutResultSet
        Returns:
        int Point of attachment (result set number) for this subquery. (-1 if not a subquery - also Sanity violation)
      • getScanIsolationLevel

        public int getScanIsolationLevel()
        Return the isolation level of the scan in the result set. Only expected to be called for those ResultSets that contain a scan.
        Specified by:
        getScanIsolationLevel in interface NoPutResultSet
        Returns:
        The isolation level of the scan (in TransactionController constants).
      • setTargetResultSet

        public void setTargetResultSet​(TargetResultSet trs)
        Notify a NPRS that it is the source for the specified TargetResultSet. This is useful when doing bulk insert.
        Specified by:
        setTargetResultSet in interface NoPutResultSet
        Parameters:
        trs - The TargetResultSet.
      • setNeedsRowLocation

        public void setNeedsRowLocation​(boolean needsRowLocation)
        Set whether or not the NPRS need the row location when acting as a row source. (The target result set determines this.)
        Specified by:
        setNeedsRowLocation in interface NoPutResultSet
      • getEstimatedRowCount

        public double getEstimatedRowCount()
        Get the estimated row count from this result set.
        Specified by:
        getEstimatedRowCount in interface NoPutResultSet
        Returns:
        The estimated row count (as a double) from this result set.
      • resultSetNumber

        public int resultSetNumber()
        Get the number of this ResultSet, which is guaranteed to be unique within a statement.
        Specified by:
        resultSetNumber in interface NoPutResultSet
      • setCurrentRow

        public void setCurrentRow​(ExecRow row)
        Set the current row to the row passed in.
        Specified by:
        setCurrentRow in interface NoPutResultSet
        Parameters:
        row - the new current row
      • clearCurrentRow

        public void clearCurrentRow()
        Clear the current row
        Specified by:
        clearCurrentRow in interface ResultSet
      • getRowLocation

        public RowLocation getRowLocation()
        Returns the row location of the current base table row of the cursor. If this cursor's row is composed of multiple base tables' rows, i.e. due to a join, then a null is returned. For a temporary row holder, we always return null.
        Specified by:
        getRowLocation in interface CursorResultSet
        Returns:
        the row location of the current cursor row.
      • returnsRows

        public boolean returnsRows()
        Returns TRUE if the statement returns rows (i.e. is a SELECT or FETCH statement), FALSE if it returns no rows.
        Specified by:
        returnsRows in interface ResultSet
        Returns:
        TRUE if the statement returns rows, FALSE if not.
      • modifiedRowCount

        public long modifiedRowCount()
        Description copied from interface: ResultSet
        Returns the number of rows affected by the statement. Only valid of returnsRows() returns false. For other DML statements, it returns the number of rows modified by the statement. For statements that do not affect rows (like DDL statements), it returns zero.
        Specified by:
        modifiedRowCount in interface ResultSet
        Returns:
        The number of rows affect by the statement, so far.
      • getResultDescription

        public ResultDescription getResultDescription()
        Returns a ResultDescription object, which describes the results of the statement this ResultSet is in. This will *not* be a description of this particular ResultSet, if this is not the outermost ResultSet.
        Specified by:
        getResultDescription in interface ResultSet
        Returns:
        A ResultDescription describing the results of the statement.
      • getAbsoluteRow

        public ExecRow getAbsoluteRow​(int row)
                               throws StandardException
        Returns the row at the absolute position from the query, and returns NULL when there is no such position. (Negative position means from the end of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position). NOTE: An exception will be thrown on 0.
        Specified by:
        getAbsoluteRow in interface ResultSet
        Parameters:
        row - The position.
        Returns:
        The row at the absolute position, or NULL if no such position.
        Throws:
        StandardException - Thrown on failure
        See Also:
        Row
      • getRelativeRow

        public ExecRow getRelativeRow​(int row)
                               throws StandardException
        Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position. (Negative position means toward the beginning of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position). NOTE: 0 is valid. NOTE: An exception is thrown if the cursor is not currently positioned on a row.
        Specified by:
        getRelativeRow in interface ResultSet
        Parameters:
        row - The position.
        Returns:
        The row at the relative position, or NULL if no such position.
        Throws:
        StandardException - Thrown on failure
        See Also:
        Row
      • getPreviousRow

        public ExecRow getPreviousRow()
                               throws StandardException
        Returns the previous row from the query, and returns NULL when there are no more previous rows.
        Specified by:
        getPreviousRow in interface ResultSet
        Returns:
        The previous row, or NULL if no more previous rows.
        Throws:
        StandardException - Thrown on failure
        See Also:
        Row
      • checkRowPosition

        public boolean checkRowPosition​(int isType)
        Determine if the cursor is before the first row in the result set.
        Specified by:
        checkRowPosition in interface ResultSet
        Returns:
        true if before the first row, false otherwise. Returns false when the result set contains no rows.
      • getRowNumber

        public int getRowNumber()
        Returns the row number of the current row. Row numbers start from 1 and go to 'n'. Corresponds to row numbering used to position current row in the result set (as per JDBC).
        Specified by:
        getRowNumber in interface ResultSet
        Returns:
        the row number, or 0 if not on a row
      • isClosed

        public boolean isClosed()
        Find out if the ResultSet is closed or not. Will report true for result sets that do not return rows.
        Specified by:
        isClosed in interface ResultSet
        Returns:
        true if the ResultSet has been closed.
      • finish

        public void finish()
                    throws StandardException
        Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open(). Will close the result set if it is not already closed.
        Specified by:
        finish in interface ResultSet
        Throws:
        StandardException - on error
      • getExecuteTime

        public long getExecuteTime()
        Get the execution time in milliseconds.
        Specified by:
        getExecuteTime in interface ResultSet
        Returns:
        long The execution time in milliseconds.
      • getBeginExecutionTimestamp

        public java.sql.Timestamp getBeginExecutionTimestamp()
        Get the Timestamp for the beginning of execution.
        Specified by:
        getBeginExecutionTimestamp in interface ResultSet
        Returns:
        Timestamp The Timestamp for the beginning of execution.
      • getEndExecutionTimestamp

        public java.sql.Timestamp getEndExecutionTimestamp()
        Get the Timestamp for the end of execution.
        Specified by:
        getEndExecutionTimestamp in interface ResultSet
        Returns:
        Timestamp The Timestamp for the end of execution.
      • getTimeSpent

        public long getTimeSpent​(int type)
        Return the total amount of time spent in this ResultSet
        Specified by:
        getTimeSpent in interface ResultSet
        Parameters:
        type - CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
        Returns:
        long The total amount of time spent (in milliseconds).
      • getSubqueryTrackingArray

        public NoPutResultSet[] getSubqueryTrackingArray​(int numSubqueries)
        Get the subquery ResultSet tracking array from the top ResultSet. (Used for tracking open subqueries when closing down on an error.)
        Specified by:
        getSubqueryTrackingArray in interface ResultSet
        Parameters:
        numSubqueries - The size of the array (For allocation on demand.)
        Returns:
        NoPutResultSet[] Array of NoPutResultSets for subqueries.
      • getCursorName

        public java.lang.String getCursorName()
        Returns the name of the cursor, if this is cursor statement of some type (declare, open, fetch, positioned update, positioned delete, close).
        Specified by:
        getCursorName in interface ResultSet
        Returns:
        A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.
      • getNextRowFromRowSource

        public DataValueDescriptor[] getNextRowFromRowSource()
                                                      throws StandardException
        Get the next row as an array of column objects. The column objects can be a JBMS Storable or any Serializable/Externalizable/Formattable/Streaming type.
        A return of null indicates that the complete set of rows has been read.

        A null column can be specified by leaving the object null, or indicated by returning a non-null getValidColumns. On streaming columns, it can be indicated by returning a non-null get FieldStates.

        If RowSource.needToClone() is true then the returned row (the DataValueDescriptor[]) is guaranteed not to be modified by drainer of the RowSource (except that the input stream will be read, of course) and drainer will keep no reference to it before making the subsequent nextRow call. So it is safe to return the same DataValueDescriptor[] in subsequent nextRow calls if that is desirable for performance reasons.

        If RowSource.needToClone() is false then the returned row (the DataValueDescriptor[]) may be be modified by drainer of the RowSource, and the drainer may keep a reference to it after making the subsequent nextRow call. In this case the client should severe all references to the row after returning it from getNextRowFromRowSource().

        Specified by:
        getNextRowFromRowSource in interface RowSource
        Throws:
        StandardException - Standard Derby Error Policy
      • needsToClone

        public boolean needsToClone()
        Does the caller of getNextRowFromRowSource() need to clone the row in order to keep a reference to the row past the getNextRowFromRowSource() call which returned the row. This call must always return the same for all rows in a RowSource (ie. the caller will call this once per scan from a RowSource and assume the behavior is true for all rows in the RowSource).
        Specified by:
        needsToClone in interface RowSource
      • getValidColumns

        public FormatableBitSet getValidColumns()
        getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call. If getValidColumns returns null, the number of columns is given by the DataValueDescriptor.length where DataValueDescriptor[] is returned by the preceeding getNextRowFromRowSource() call. Column N maps to DataValueDescriptor[N], where column numbers start at zero. If getValidColumns return a non null validColumns FormatableBitSet the number of columns is given by the number of bits set in validColumns. Column N is not in the partial row if validColumns.get(N) returns false. Column N is in the partial row if validColumns.get(N) returns true. If column N is in the partial row then it maps to DataValueDescriptor[M] where M is the count of calls to validColumns.get(i) that return true where i < N. If DataValueDescriptor.length is greater than the number of columns indicated by validColumns the extra entries are ignored.
        Specified by:
        getValidColumns in interface RowSource
      • closeRowSource

        public void closeRowSource()
        closeRowSource tells the RowSource that it will no longer need to return any rows and it can release any resource it may have. Subsequent call to any method on the RowSource will result in undefined behavior. A closed rowSource can be closed again.
        Specified by:
        closeRowSource in interface RowSource
      • setHasDeferrableChecks

        public void setHasDeferrableChecks()
        Description copied from interface: NoPutResultSet
        Set that we are acting on behalf of an insert result set that has deferrable check constraints
        Specified by:
        setHasDeferrableChecks in interface NoPutResultSet
      • rowLocation

        public void rowLocation​(RowLocation rl)
                         throws StandardException
        rowLocation is a callback for the drainer of the row source to return the rowLocation of the current row, i.e, the row that is being returned by getNextRowFromRowSource. This interface is for the purpose of loading a base table with index. In that case, the indices can be built at the same time the base table is laid down once the row location of the base row is known. This is an example pseudo code on how this call is expected to be used:
                        boolean needsRL = rowSource.needsRowLocation();
                        DataValueDescriptor[] row;
                        while((row = rowSource.getNextRowFromRowSource()) != null)
                        {
                                RowLocation rl = heapConglomerate.insertRow(row);
                                if (needsRL)
                                        rowSource.rowLocation(rl);
                        }
                        

        NeedsRowLocation and rowLocation will ONLY be called by a drainer of the row source which CAN return a row location. Drainer of row source which cannot return rowLocation will guarentee to not call either callbacks. Conversely, if NeedsRowLocation is called and it returns true, then for every row return by getNextRowFromRowSource, a rowLocation callback must also be issued with the row location of the row. Implementor of both the source and the drain of the row source must be aware of this protocol.
        The RowLocation object is own by the caller of rowLocation, in other words, the drainer of the RowSource. This is so that we don't need to new a row location for every row. If the Row Source wants to keep the row location, it needs to clone it (RowLocation is a ClonableObject).
        Specified by:
        rowLocation in interface RowLocationRetRowSource
        Throws:
        StandardException - on error
      • isForUpdate

        public boolean isForUpdate()
        Is this ResultSet or it's source result set for update This method will be overriden in the inherited Classes if it is true
        Specified by:
        isForUpdate in interface NoPutResultSet
        Returns:
        Whether or not the result set is for update.
      • clone

        public java.lang.Object clone()
        Shallow clone this result set. Used in trigger reference. beetle 4373.
        Overrides:
        clone in class java.lang.Object
      • addWarning

        public void addWarning​(java.sql.SQLWarning w)
        Description copied from interface: ResultSet
        Add a warning to this result set.
        Specified by:
        addWarning in interface ResultSet
        Parameters:
        w - the warning to add
      • getWarnings

        public java.sql.SQLWarning getWarnings()
        Description copied from interface: ResultSet
        Return the set of warnings generated during the execution of this result set. The warnings are cleared once this call returns.
        Specified by:
        getWarnings in interface ResultSet
      • getActivation

        public final Activation getActivation()
        Return the Activation for this result set.
        Specified by:
        getActivation in interface ResultSet
        Returns:
        activation
      • toXML

        public org.w3c.dom.Element toXML​(org.w3c.dom.Element parentNode,
                                         java.lang.String tag)
                                  throws java.lang.Exception
        Description copied from interface: ResultSet

        Produce an xml image of this ResultSet and its descendant ResultSets. Appends an element to the parentNode and returns the appended element.

        Specified by:
        toXML in interface ResultSet
        Parameters:
        parentNode - Node to put content into.
        tag - Element tag for content
        Returns:
        the content as an element with the given tag name
        Throws:
        java.lang.Exception