Class DMLWriteGeneratedColumnsResultSet
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
-
- org.apache.derby.impl.sql.execute.DMLWriteResultSet
-
- org.apache.derby.impl.sql.execute.DMLWriteGeneratedColumnsResultSet
-
- All Implemented Interfaces:
ResultSet
- Direct Known Subclasses:
InsertResultSet
,UpdateResultSet
public abstract class DMLWriteGeneratedColumnsResultSet extends DMLWriteResultSet
-
-
Field Summary
Fields Modifier and Type Field Description protected DataValueDescriptor[]
aiCache
keeps track of autoincrement values that are generated by getSetAutoincrementValues.protected int[]
autoGeneratedKeysColumnIndexes
protected ResultSet
autoGeneratedKeysResultSet
protected TemporaryRowHolderImpl
autoGeneratedKeysRowsHolder
protected boolean
autoincrementGenerated
If set to true, implies that Derby has generated autoincrement values for this (rep)resultset.protected java.lang.String
identitySequenceUUIDString
protected long
identityVal
protected boolean
setIdentity
protected NoPutResultSet
sourceResultSet
-
Fields inherited from class org.apache.derby.impl.sql.execute.DMLWriteResultSet
baseRowReadMap, cachedDestinations, constantAction, heapDCOCI, indexDCOCIs, resultDescription, rowCount, streamStorableHeapColIds
-
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 DMLWriteGeneratedColumnsResultSet(Activation activation)
ConstructorDMLWriteGeneratedColumnsResultSet(Activation activation, ConstantAction constantAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
firstExecuteSpecialHandlingAutoGen(boolean firstExecute, RowChanger rowChanger, UUID targetUUID)
private int[]
generatedColumnPositionsArray(UUID targetUUID)
If user didn't provide columns list for auto-generated columns, then only include columns with auto-generated values in the resultset.ResultSet
getAutoGeneratedKeysResultset()
ResultSet for rows inserted into the table (contains auto-generated keys columns only)protected ExecRow
getCompactRow(ExecRow inputRow, int[] columnIndexes)
Take the input row and return a new compact ExecRow using the column positions provided in columnIndexes.NumberDataValue
getSetAutoincrementValue(int columnPosition, long increment)
getSetAutoincrementValue will get the autoincrement value of the columnPosition specified for the target table.void
saveAIcacheInformation(java.lang.String schemaName, java.lang.String tableName, java.lang.String[] columnNames)
private int[]
uniqueColumnPositionArray(int[] columnIndexes, UUID targetUUID)
Remove duplicate columns from the array.private boolean
verifyAutoGenColumn(ColumnDescriptor cd)
Check that the received ColumnDescriptor corresponds to a column for which it is possible to fetch auto-generated keys.private void
verifyAutoGeneratedColumnsIndexes(int[] columnIndexes, UUID targetUUID)
Verify that the auto-generated columns list (by position) has valid column positions for the table.private void
verifyAutoGeneratedColumnsNames(java.lang.String[] columnNames, UUID targetUUID)
Verify that the auto-generated columns list (by name) has valid column names for the table.protected void
verifyAutoGeneratedRScolumnsList(UUID targetUUID)
-
Methods inherited from class org.apache.derby.impl.sql.execute.DMLWriteResultSet
decodeLockMode, getIndexNameFromCID, getNextRowCore, getResultDescription, makeDeferredSparseRow, modifiedRowCount, normalizeRow, rememberConstraint
-
Methods inherited from class org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
addWarning, checkRowPosition, clearCurrentRow, close, doesCommit, evaluateGenerationClauses, finish, getAbsoluteRow, getActivation, getBeginExecutionTimestamp, getCurrentTimeMillis, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getQueryPlanText, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTimeSpent, getWarnings, isClosed, returnsRows, setAfterLastRow, setBeforeFirstRow, setup, toXML
-
-
-
-
Field Detail
-
aiCache
protected DataValueDescriptor[] aiCache
keeps track of autoincrement values that are generated by getSetAutoincrementValues.
-
identitySequenceUUIDString
protected java.lang.String identitySequenceUUIDString
-
sourceResultSet
protected NoPutResultSet sourceResultSet
-
autoGeneratedKeysResultSet
protected ResultSet autoGeneratedKeysResultSet
-
autoGeneratedKeysRowsHolder
protected TemporaryRowHolderImpl autoGeneratedKeysRowsHolder
-
autoGeneratedKeysColumnIndexes
protected int[] autoGeneratedKeysColumnIndexes
-
autoincrementGenerated
protected boolean autoincrementGenerated
If set to true, implies that Derby has generated autoincrement values for this (rep)resultset. During refresh for example, the autoincrement values are not generated but sent from the source to target or vice-versa.
-
identityVal
protected long identityVal
-
setIdentity
protected boolean setIdentity
-
-
Constructor Detail
-
DMLWriteGeneratedColumnsResultSet
DMLWriteGeneratedColumnsResultSet(Activation activation) throws StandardException
Constructor- Parameters:
activation
- an activation- Throws:
StandardException
- on error
-
DMLWriteGeneratedColumnsResultSet
DMLWriteGeneratedColumnsResultSet(Activation activation, ConstantAction constantAction) throws StandardException
- Throws:
StandardException
-
-
Method Detail
-
getSetAutoincrementValue
public NumberDataValue getSetAutoincrementValue(int columnPosition, long increment) throws StandardException
getSetAutoincrementValue will get the autoincrement value of the columnPosition specified for the target table. If increment is non-zero we will also update the autoincrement value.- Parameters:
columnPosition
- position of the column in the table (1-based)increment
- amount of increment.- Throws:
StandardException
- if anything goes wrong.
-
saveAIcacheInformation
public void saveAIcacheInformation(java.lang.String schemaName, java.lang.String tableName, java.lang.String[] columnNames) throws StandardException
- Throws:
StandardException
-
verifyAutoGeneratedRScolumnsList
protected void verifyAutoGeneratedRScolumnsList(UUID targetUUID) throws StandardException
- Throws:
StandardException
-
verifyAutoGeneratedColumnsIndexes
private void verifyAutoGeneratedColumnsIndexes(int[] columnIndexes, UUID targetUUID) throws StandardException
Verify that the auto-generated columns list (by position) has valid column positions for the table.- Throws:
StandardException
-
verifyAutoGeneratedColumnsNames
private void verifyAutoGeneratedColumnsNames(java.lang.String[] columnNames, UUID targetUUID) throws StandardException
Verify that the auto-generated columns list (by name) has valid column names for the table. If all the column names are valid, convert column names array to corresponding column positions array Save that column positions array in activation. We do this to simplify the rest of the logic(it only has to deal with column positions here after).- Throws:
StandardException
- Thrown on error if invalid column name in the list.
-
verifyAutoGenColumn
private boolean verifyAutoGenColumn(ColumnDescriptor cd)
Check that the received ColumnDescriptor corresponds to a column for which it is possible to fetch auto-generated keys.
-
firstExecuteSpecialHandlingAutoGen
protected void firstExecuteSpecialHandlingAutoGen(boolean firstExecute, RowChanger rowChanger, UUID targetUUID) throws StandardException
- Throws:
StandardException
-
generatedColumnPositionsArray
private int[] generatedColumnPositionsArray(UUID targetUUID) throws StandardException
If user didn't provide columns list for auto-generated columns, then only include columns with auto-generated values in the resultset. Those columns would be ones with default value defined.- Throws:
StandardException
-
uniqueColumnPositionArray
private int[] uniqueColumnPositionArray(int[] columnIndexes, UUID targetUUID) throws StandardException
Remove duplicate columns from the array. Then use this array to generate a sub-set of insert resultset to be returned for JDBC3.0 getGeneratedKeys() call.- Throws:
StandardException
-
getCompactRow
protected ExecRow getCompactRow(ExecRow inputRow, int[] columnIndexes) throws StandardException
Take the input row and return a new compact ExecRow using the column positions provided in columnIndexes. Copies references, no cloning.- Throws:
StandardException
-
getAutoGeneratedKeysResultset
public ResultSet getAutoGeneratedKeysResultset()
Description copied from interface:ResultSet
ResultSet for rows inserted into the table (contains auto-generated keys columns only)- Specified by:
getAutoGeneratedKeysResultset
in interfaceResultSet
- Overrides:
getAutoGeneratedKeysResultset
in classNoRowsResultSetImpl
- Returns:
- NoPutResultSet NoPutResultSets for rows inserted into the table.
- See Also:
ResultSet.getAutoGeneratedKeysResultset()
-
-