Top Description Fields Constructors Methods
org.apache.derby.impl.sql.execute

pack-priv Class MergeResultSet

extends NoRowsResultSetImpl
Class Inheritance
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.io.StreamStorable, org.apache.derby.iapi.services.loader.GeneratedMethod, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.execute.ConstantAction, .ExecIndexRow, .ExecRow, .NoPutResultSet, org.apache.derby.iapi.store.access.BackingStoreHashtable, org.apache.derby.iapi.types.DataValueDescriptor, .RowLocation, .SQLRef, org.apache.derby.shared.common.sanity.SanityManager

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

Modifier and TypeField and Description
private MergeConstantAction
private NoPutResultSet
private int
private ExecRow
private long
private BackingStoreHashtable
private TemporaryRowHolderImpl[]
Inherited from org.apache.derby.impl.sql.execute.NoRowsResultSetImpl:
activationbeginExecutionTimebeginTimeendExecutionTimeendTimelcc

Constructor Summary

AccessConstructor and Description
pack-priv
MergeResultSet(NoPutResultSet drivingLeftJoin, Activation activation)

Construct from a driving left join and an Activation.

Method Summary

Modifier and TypeMethod and Description
private void
addSubjectRow(SQLRef
The location of the subject row.
subjectRowID
)

Add another subject row id to the evolving hashtable of affected target rows.

public void
cleanUp()

Implements org.apache.derby.iapi.sql.ResultSet.cleanUp.

Tells the system to clean up on an error.

public void
close()

Implements org.apache.derby.iapi.sql.ResultSet.close.

Clean up resources and call close on data members.

pack-priv boolean
collectAffectedRows()

Loop through the rows in the driving left join.

private void
createSubjectRowIDhashtable()

Create a BackingStoreHashtable to hold the ids of subject rows.

public void
finish()

Overrides org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.finish.

Implements org.apache.derby.iapi.sql.ResultSet.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().

public final long
public void
open()

Implements org.apache.derby.iapi.sql.ResultSet.open.

Needs to be called before the result set will do anything.

pack-priv void
setup()

Overrides org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.setup.

Set up the result set for use.

Inherited from org.apache.derby.impl.sql.execute.NoRowsResultSetImpl:
addWarningcheckRowPositionclearCurrentRowclosedoesCommitevaluateGenerationClausesgetAbsoluteRowgetActivationgetAutoGeneratedKeysResultsetgetBeginExecutionTimestampgetCurrentTimeMillisgetCursorNamegetEndExecutionTimestampgetExecuteTimegetFirstRowgetLastRowgetNextRowgetPreviousRowgetQueryPlanTextgetRelativeRowgetResultDescriptiongetRowNumbergetSubqueryTrackingArraygetTimeSpentgetWarningsisClosedreturnsRowssetAfterLastRowsetBeforeFirstRowtoXML

Field Detail

_constantsback to summary
private MergeConstantAction _constants
_drivingLeftJoinback to summary
private NoPutResultSet _drivingLeftJoin
_numOpensback to summary
private int _numOpens
_rowback to summary
private ExecRow _row
_rowCountback to summary
private long _rowCount
_subjectRowIDsback to summary
private BackingStoreHashtable _subjectRowIDs
_thenRowsback to summary
private TemporaryRowHolderImpl[] _thenRows

Constructor Detail

MergeResultSetback to summary
pack-priv MergeResultSet(NoPutResultSet drivingLeftJoin, Activation activation) throws StandardException

Construct from a driving left join and an Activation.

Method Detail

addSubjectRowback to summary
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:SQLRef

The location of the subject row.

Exceptions
StandardException:
A cardinality exception is thrown if we've already added this subject row.
cleanUpback to summary
public void cleanUp() throws StandardException

Implements org.apache.derby.iapi.sql.ResultSet.cleanUp.

Doc from org.apache.derby.iapi.sql.ResultSet.cleanUp.

Tells the system to clean up on an error.

Exceptions
StandardException:
Thrown on error.
closeback to summary
public void close() throws StandardException

Implements org.apache.derby.iapi.sql.ResultSet.close.

Clean up resources and call close on data members.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.sql.ResultSet.close.

Thrown on error.

collectAffectedRowsback to summary
pack-priv boolean collectAffectedRows() throws StandardException

Loop through the rows in the driving left join.

createSubjectRowIDhashtableback to summary
private void createSubjectRowIDhashtable() throws StandardException

Create a BackingStoreHashtable to hold the ids of subject rows.

finishback to summary
public void finish() throws StandardException

Overrides org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.finish.

Implements org.apache.derby.iapi.sql.ResultSet.finish.

Doc from org.apache.derby.iapi.sql.ResultSet.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(). Will close the result set if it is not already closed.

Exceptions
StandardException:
on error
modifiedRowCountback to summary
public final long modifiedRowCount()

Overrides org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.modifiedRowCount.

Implements org.apache.derby.iapi.sql.ResultSet.modifiedRowCount.

Doc from org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.modifiedRowCount.

Returns zero.

Returns:long

Doc from org.apache.derby.iapi.sql.ResultSet.modifiedRowCount.

The number of rows affect by the statement, so far.

Annotations
@Override
openback to summary
public void open() throws StandardException

Implements org.apache.derby.iapi.sql.ResultSet.open.

Doc from org.apache.derby.iapi.sql.ResultSet.open.

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.

Exceptions
StandardException:
Thrown on failure
setupback to summary
pack-priv void setup() throws StandardException

Overrides org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.setup.

Doc from org.apache.derby.impl.sql.execute.NoRowsResultSetImpl.setup.

Set up the result set for use. Should always be called from open().

Annotations
@Override
Exceptions
StandardException:
thrown on error