Class MergeResultSet
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
-
- org.apache.derby.impl.sql.execute.MergeResultSet
-
- All Implemented Interfaces:
ResultSet
class MergeResultSet extends NoRowsResultSetImpl
INSERT/UPDATE/DELETE a target table based on how it outer joins with a driving table. For a description of how Derby processes the MERGE statement, see the header comment on MergeNode.
-
-
Field Summary
Fields Modifier and Type Field Description private MergeConstantAction
_constants
private NoPutResultSet
_drivingLeftJoin
private int
_numOpens
private ExecRow
_row
private long
_rowCount
private BackingStoreHashtable
_subjectRowIDs
private TemporaryRowHolderImpl[]
_thenRows
-
Fields inherited from class org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
activation, beginExecutionTime, beginTime, endExecutionTime, endTime, lcc
-
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
-
-
Constructor Summary
Constructors Constructor Description MergeResultSet(NoPutResultSet drivingLeftJoin, Activation activation)
Construct from a driving left join and an Activation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addSubjectRow(SQLRef subjectRowID)
Add another subject row id to the evolving hashtable of affected target rows.void
cleanUp()
Tells the system to clean up on an error.void
close()
Clean up resources and call close on data members.(package private) boolean
collectAffectedRows()
Loop through the rows in the driving left join.private void
createSubjectRowIDhashtable()
Create a BackingStoreHashtable to hold the ids of subject rows.void
finish()
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().long
modifiedRowCount()
Returns zero.void
open()
Needs to be called before the result set will do anything.(package private) void
setup()
Set up the result set for use.-
Methods inherited from class org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
addWarning, checkRowPosition, clearCurrentRow, close, doesCommit, evaluateGenerationClauses, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCurrentTimeMillis, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getQueryPlanText, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getTimeSpent, getWarnings, isClosed, returnsRows, setAfterLastRow, setBeforeFirstRow, toXML
-
-
-
-
Field Detail
-
_drivingLeftJoin
private NoPutResultSet _drivingLeftJoin
-
_constants
private MergeConstantAction _constants
-
_row
private ExecRow _row
-
_rowCount
private long _rowCount
-
_thenRows
private TemporaryRowHolderImpl[] _thenRows
-
_subjectRowIDs
private BackingStoreHashtable _subjectRowIDs
-
_numOpens
private int _numOpens
-
-
Constructor Detail
-
MergeResultSet
MergeResultSet(NoPutResultSet drivingLeftJoin, Activation activation) throws StandardException
Construct from a driving left join and an Activation.- Throws:
StandardException
-
-
Method Detail
-
modifiedRowCount
public final long modifiedRowCount()
Description copied from class:NoRowsResultSetImpl
Returns zero.- Specified by:
modifiedRowCount
in interfaceResultSet
- Overrides:
modifiedRowCount
in classNoRowsResultSetImpl
- Returns:
- The number of rows affect by the statement, so far.
-
open
public void open() throws StandardException
Description copied from interface:ResultSet
Needs to be called before the result set will do anything. Need to call before getNextRow(), or for a result set that doesn't return rows, this is the call that will cause all the work to be done.- Throws:
StandardException
- Thrown on failure
-
setup
void setup() throws StandardException
Description copied from class:NoRowsResultSetImpl
Set up the result set for use. Should always be called fromopen()
.- Overrides:
setup
in classNoRowsResultSetImpl
- Throws:
StandardException
- thrown on error
-
close
public void close() throws StandardException
Clean up resources and call close on data members.- Throws:
StandardException
- Thrown on error.
-
cleanUp
public void cleanUp() throws StandardException
Description copied from interface:ResultSet
Tells the system to clean up on an error.- Throws:
StandardException
- Thrown on error.
-
finish
public void finish() throws StandardException
Description copied from interface:ResultSet
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 interfaceResultSet
- Overrides:
finish
in classNoRowsResultSetImpl
- Throws:
StandardException
- on error
-
collectAffectedRows
boolean collectAffectedRows() throws StandardException
Loop through the rows in the driving left join.
- Throws:
StandardException
-
addSubjectRow
private void addSubjectRow(SQLRef subjectRowID) throws StandardException
Add another subject row id to the evolving hashtable of affected target rows. The concept of a subject row is defined by the 2011 SQL Standard, part 2, section 14.12 (merge statement), general rule 6. A row in the target table is a subject row if it joins to the source table on the main search condition and if the joined row satisfies the matching refinement condition for some WHEN MATCHED clause. A row in the target table may only be a subject row once. That is, a given target row may only qualify for UPDATE or DELETE processing once. If it qualifies for more than one UPDATE or DELETE action, then the Standard requires us to raise a cardinality violation.
- Parameters:
subjectRowID
- The location of the subject row.- Throws:
StandardException
- A cardinality exception is thrown if we've already added this subject row.
-
createSubjectRowIDhashtable
private void createSubjectRowIDhashtable() throws StandardException
Create a BackingStoreHashtable to hold the ids of subject rows.
- Throws:
StandardException
-
-