Class AlterTableConstantAction
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.DDLConstantAction
-
- org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
-
- org.apache.derby.impl.sql.execute.AlterTableConstantAction
-
- All Implemented Interfaces:
ConstantAction
,RowLocationRetRowSource
,RowSource
class AlterTableConstantAction extends DDLSingleTableConstantAction implements RowLocationRetRowSource
This class describes actions that are ALWAYS performed for an ALTER TABLE Statement at Execution time.
-
-
Field Summary
Fields Modifier and Type Field Description private Activation
activation
private ExecRow[]
baseRow
private DataValueDescriptor[][]
baseRowArray
private int
behavior
private int
bulkFetchSize
private int[][]
collation
private ColumnInfo[]
columnInfo
private ConglomerateController
compressHeapCC
private GroupFetchScanController
compressHeapGSC
private IndexRowGenerator[]
compressIRGs
private RowLocation[]
compressRL
private boolean
compressTable
private ConstraintConstantAction[]
constraintActions
private int
currentCompressRow
private ExecRow
currentRow
private DataDictionary
dd
private boolean
defragment
private DependencyManager
dm
private boolean
doneScan
private int
droppedColumnPosition
private boolean
dropStatistics
dropStatistics will indicate that we are here for dropping the statistics.private boolean
dropStatisticsAll
The flag dropStatisticsAll will tell if we are going to drop the statistics of all indexes or just one index on a table.private long
estimatedRowCount
private long[]
indexConglomerateNumbers
private FormatableBitSet
indexedCols
private java.lang.String
indexNameForStatistics
If statistic is getting updated/dropped for just one index, then indexNameForStatistics will tell the name of the specific index whose statistics need to be updated/dropped.private ExecIndexRow[]
indexRows
private LanguageConnectionContext
lcc
private char
lockGranularity
private boolean[]
needToDropSort
private int
numIndexes
private ColumnOrdering[][]
ordering
private boolean
purge
private static int
RANGE_BOTTOM
private static int
RANGE_TOP
private int
rowCount
private UUID
schemaId
private SchemaDescriptor
sd
private boolean
sequential
private SortController[]
sorters
private long[]
sortIds
private long
tableConglomerateId
private java.lang.String
tableName
private int
tableType
private TransactionController
tc
private TableDescriptor
td
private boolean
truncateEndOfTable
private boolean
truncateTable
private boolean
updateStatistics
updateStatistics will indicate that we are here for updating the statistics.private boolean
updateStatisticsAll
The flag updateStatisticsAll will tell if we are going to update the statistics of all indexes or just one index on a table.private boolean[]
validRow
-
Fields inherited from class org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
tableId
-
Fields inherited from interface org.apache.derby.iapi.sql.execute.ConstantAction
WHEN_MATCHED_THEN_DELETE, WHEN_MATCHED_THEN_UPDATE, WHEN_NOT_MATCHED_THEN_INSERT
-
-
Constructor Summary
Constructors Constructor Description AlterTableConstantAction(SchemaDescriptor sd, java.lang.String tableName, UUID tableId, long tableConglomerateId, int tableType, ColumnInfo[] columnInfo, ConstraintConstantAction[] constraintActions, char lockGranularity, boolean compressTable, int behavior, boolean sequential, boolean truncateTable, boolean purge, boolean defragment, boolean truncateEndOfTable, boolean updateStatistics, boolean updateStatisticsAll, boolean dropStatistics, boolean dropStatisticsAll, java.lang.String indexNameForStatistics)
Make the AlterAction for an ALTER TABLE statement.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addNewColumnToTable(int ix)
Workhorse for adding a new column to a table.private void
cleanUp()
private void
clearState()
Clear the state of this constant action.private void
closeBulkFetchScan()
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.private boolean
columnDroppedAndTriggerDependencies(TriggerDescriptor trd, UUID spsUUID, boolean isWhenClause, boolean cascade, java.lang.String columnName)
private java.lang.Object[]
compressIndexArrays(long[] indexCIDS, IndexRowGenerator[] irgs)
Get rid of duplicates from a set of index conglomerate numbers and index descriptors.private void
compressTable()
routine to process compress table or ALTER TABLEDROP COLUMN ; private void
createNewBackingCongloms(java.util.ArrayList<ConstantAction> newConglomActions, long[] ixCongNums)
Iterate through the received list of CreateIndexConstantActions and execute each one, It's possible that one or more of the constant actions in the list has been rendered "unneeded" by the time we get here (because the index that the constant action was going to create is no longer needed), so we have to check for that.private void
defragmentRows(TransactionController tc)
Defragment rows in the given table.private void
dropColumnFromTable(java.lang.String columnName)
Workhorse for dropping a column from a table.private void
dropStatistics()
Drop statistics of either all the indexes on the table or only one specific index depending on what user has requested.void
executeConstantAction(Activation activation)
Run this constant action.private void
executeConstantActionBody(Activation activation)
This is the guts of the Execution-time logic for ALTER TABLE.private static void
executeUpdate(LanguageConnectionContext lcc, java.lang.String updateStmt)
private static void
fixIndex(DataValueDescriptor[] base_row, DataValueDescriptor[] index_row, RowLocation old_row_loc, RowLocation new_row_loc, ConglomerateController index_cc, ScanController index_scan, int[] index_col_map)
Delete old index row and insert new index row in input index.private void
getAffectedIndexes()
Get info on the indexes on the table being compressed.private long
getColumnMax(TableDescriptor td, java.lang.String columnName, long increment)
computes the minimum/maximum value in a column of a table.DataValueDescriptor[]
getNextRowFromRowSource()
Get the next row as an array of column objects.private long
getRangeBound(DataTypeDescriptor dtd, int topOrBottom)
Get the ran max or min range bound for an autoincrement column.private int
getSemiRowCount(TransactionController tc)
Return the "semi" row count of a table.FormatableBitSet
getValidColumns()
getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call.private void
insertIntoSorter(int index, RowLocation rl)
private void
modifyColumnConstraint(java.lang.String colName, boolean nullability)
Workhorse for modifying column level constraints.private void
modifyColumnDefault(int ix)
Workhorse for modifying the default value of a column.private void
modifyColumnType(int ix)
private void
modifyIdentityState(int ix)
Change an identity from ALWAYS to BY DEFAULT (or vice versa)boolean
needsRowLocation()
needsRowLocation returns true iff this the row source expects the drainer of the row source to call rowLocation after getting a row from getNextRowFromRowSource.boolean
needsRowLocationForDeferredCheckConstraints()
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.private void
objectifyStreamingColumns()
void
offendingRowLocation(RowLocation rl, long containdId)
private void
openBulkFetchScan(long heapConglomNumber)
private void
purgeRows(TransactionController tc)
Purge committed deleted rows from conglomerate.void
rowLocation(RowLocation rl)
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.private static void
setup_indexes(TransactionController tc, TableDescriptor td, int[][] index_col_map, ScanController[] index_scan, ConglomerateController[] index_cc, DataValueDescriptor[][] index_row)
private void
setUpAllSorts(ExecRow sourceRow, RowLocation rl)
Set up to update all of the indexes on a table when doing a bulk insert on an empty table.java.lang.String
toString()
private void
truncateEnd(TransactionController tc)
Truncate end of conglomerate.private void
truncateTable()
private void
updateAllIndexes(long newHeapConglom, DataDictionary dd)
Update all of the indexes on a table when doing a bulk insert on an empty table.private void
updateIndex(long newHeapConglom, DataDictionary dd, int index, long[] newIndexCongloms)
private void
updateNewColumnToDefault(ColumnDescriptor columnDescriptor)
Update a new column with its default.private void
updateStatistics()
Update statistics of either all the indexes on the table or only one specific index depending on what user has requested.private boolean
validateNotNullConstraint(java.lang.String[] columnNames, boolean[] nullCols, int numRows, LanguageConnectionContext lcc, java.lang.String errorMsg)
Make sure that the columns are non null If any column is nullable, check that the data is null.-
Methods inherited from class org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
dropConglomerate, dropConglomerate, dropConstraint, dropConstraint, dropConstraint, executeConglomReplacement, getConglomReplacementAction, recreateUniqueConstraintBackingIndexAsUniqueWhenNotNull
-
Methods inherited from class org.apache.derby.impl.sql.execute.DDLConstantAction
addColumnDependencies, adjustUDTDependencies, adjustUDTDependencies, constructToString, getAndCheckSchemaDescriptor, getSchemaDescriptorForCreate, lockTableForDDL, storeConstraintDependenciesOnPrivileges, storeViewTriggerDependenciesOnPrivileges
-
-
-
-
Field Detail
-
RANGE_TOP
private static final int RANGE_TOP
- See Also:
- Constant Field Values
-
RANGE_BOTTOM
private static final int RANGE_BOTTOM
- See Also:
- Constant Field Values
-
sd
private SchemaDescriptor sd
-
tableName
private java.lang.String tableName
-
schemaId
private UUID schemaId
-
tableType
private int tableType
-
columnInfo
private ColumnInfo[] columnInfo
-
constraintActions
private ConstraintConstantAction[] constraintActions
-
lockGranularity
private char lockGranularity
-
tableConglomerateId
private long tableConglomerateId
-
compressTable
private boolean compressTable
-
behavior
private int behavior
-
sequential
private boolean sequential
-
truncateTable
private boolean truncateTable
-
purge
private boolean purge
-
defragment
private boolean defragment
-
truncateEndOfTable
private boolean truncateEndOfTable
-
updateStatistics
private boolean updateStatistics
updateStatistics will indicate that we are here for updating the statistics. It could be statistics of just one index or all the indexes on a given table.
-
updateStatisticsAll
private boolean updateStatisticsAll
The flag updateStatisticsAll will tell if we are going to update the statistics of all indexes or just one index on a table.
-
dropStatistics
private boolean dropStatistics
dropStatistics will indicate that we are here for dropping the statistics. It could be statistics of just one index or all the indexes on a given table.
-
dropStatisticsAll
private boolean dropStatisticsAll
The flag dropStatisticsAll will tell if we are going to drop the statistics of all indexes or just one index on a table.
-
indexNameForStatistics
private java.lang.String indexNameForStatistics
If statistic is getting updated/dropped for just one index, then indexNameForStatistics will tell the name of the specific index whose statistics need to be updated/dropped.
-
doneScan
private boolean doneScan
-
needToDropSort
private boolean[] needToDropSort
-
validRow
private boolean[] validRow
-
bulkFetchSize
private int bulkFetchSize
-
currentCompressRow
private int currentCompressRow
-
numIndexes
private int numIndexes
-
rowCount
private int rowCount
-
estimatedRowCount
private long estimatedRowCount
-
indexConglomerateNumbers
private long[] indexConglomerateNumbers
-
sortIds
private long[] sortIds
-
indexedCols
private FormatableBitSet indexedCols
-
compressHeapCC
private ConglomerateController compressHeapCC
-
indexRows
private ExecIndexRow[] indexRows
-
baseRow
private ExecRow[] baseRow
-
currentRow
private ExecRow currentRow
-
compressHeapGSC
private GroupFetchScanController compressHeapGSC
-
compressIRGs
private IndexRowGenerator[] compressIRGs
-
baseRowArray
private DataValueDescriptor[][] baseRowArray
-
compressRL
private RowLocation[] compressRL
-
sorters
private SortController[] sorters
-
droppedColumnPosition
private int droppedColumnPosition
-
ordering
private ColumnOrdering[][] ordering
-
collation
private int[][] collation
-
td
private TableDescriptor td
-
lcc
private LanguageConnectionContext lcc
-
dd
private DataDictionary dd
-
dm
private DependencyManager dm
-
tc
private TransactionController tc
-
activation
private Activation activation
-
-
Constructor Detail
-
AlterTableConstantAction
AlterTableConstantAction(SchemaDescriptor sd, java.lang.String tableName, UUID tableId, long tableConglomerateId, int tableType, ColumnInfo[] columnInfo, ConstraintConstantAction[] constraintActions, char lockGranularity, boolean compressTable, int behavior, boolean sequential, boolean truncateTable, boolean purge, boolean defragment, boolean truncateEndOfTable, boolean updateStatistics, boolean updateStatisticsAll, boolean dropStatistics, boolean dropStatisticsAll, java.lang.String indexNameForStatistics)
Make the AlterAction for an ALTER TABLE statement.- Parameters:
sd
- descriptor for the table's schema.tableName
- Name of table.tableId
- UUID of tabletableConglomerateId
- heap conglomerate number of tabletableType
- Type of table (e.g., BASE).columnInfo
- Information on all the columns in the table.constraintActions
- ConstraintConstantAction[] for constraintslockGranularity
- The lock granularity.compressTable
- Whether or not this is a compress tablebehavior
- drop behavior for dropping columnsequential
- If compress table/drop column, whether or not sequentialtruncateTable
- Whether or not this is a truncate tablepurge
- PURGE during INPLACE COMPRESS?defragment
- DEFRAGMENT during INPLACE COMPRESS?truncateEndOfTable
- TRUNCATE END during INPLACE COMPRESS?updateStatistics
- TRUE means we are here to update statisticsupdateStatisticsAll
- TRUE means we are here to update statistics of all the indexes. False means we are here to update statistics of only one index.dropStatistics
- TRUE means we are here to drop statisticsdropStatisticsAll
- TRUE means we are here to drop statistics of all the indexes. False means we are here to drop statistics of only one index.indexNameForStatistics
- Will name the index whose statistics will be updated/dropped. This param is looked at only if updateStatisticsAll/dropStatisticsAll is set to false and updateStatistics/dropStatistics is set to true.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
executeConstantAction
public void executeConstantAction(Activation activation) throws StandardException
Run this constant action.- Specified by:
executeConstantAction
in interfaceConstantAction
- Parameters:
activation
- the activation in which to run the action- Throws:
StandardException
- if an error happens during execution of the action
-
executeConstantActionBody
private void executeConstantActionBody(Activation activation) throws StandardException
This is the guts of the Execution-time logic for ALTER TABLE.- Throws:
StandardException
- Thrown on failure- See Also:
ConstantAction.executeConstantAction(org.apache.derby.iapi.sql.Activation)
-
clearState
private void clearState()
Clear the state of this constant action.
-
dropStatistics
private void dropStatistics() throws StandardException
Drop statistics of either all the indexes on the table or only one specific index depending on what user has requested.- Throws:
StandardException
-
updateStatistics
private void updateStatistics() throws StandardException
Update statistics of either all the indexes on the table or only one specific index depending on what user has requested.- Throws:
StandardException
-
truncateEnd
private void truncateEnd(TransactionController tc) throws StandardException
Truncate end of conglomerate.Returns the contiguous free space at the end of the table back to the operating system. Takes care of space allocation bit maps, and OS call to return the actual space.
- Parameters:
tc
- transaction controller to use to do updates.- Throws:
StandardException
-
defragmentRows
private void defragmentRows(TransactionController tc) throws StandardException
Defragment rows in the given table.Scans the rows at the end of a table and moves them to free spots towards the beginning of the table. In the same transaction all associated indexes are updated to reflect the new location of the base table row.
After a defragment pass, if was possible, there will be a set of empty pages at the end of the table which can be returned to the operating system by calling truncateEnd(). The allocation bit maps will be set so that new inserts will tend to go to empty and half filled pages starting from the front of the conglomerate.
- Parameters:
tc
- transaction controller to use to do updates.- Throws:
StandardException
-
setup_indexes
private static void setup_indexes(TransactionController tc, TableDescriptor td, int[][] index_col_map, ScanController[] index_scan, ConglomerateController[] index_cc, DataValueDescriptor[][] index_row) throws StandardException
- Throws:
StandardException
-
fixIndex
private static void fixIndex(DataValueDescriptor[] base_row, DataValueDescriptor[] index_row, RowLocation old_row_loc, RowLocation new_row_loc, ConglomerateController index_cc, ScanController index_scan, int[] index_col_map) throws StandardException
Delete old index row and insert new index row in input index.- Parameters:
base_row
- all columns of base rowindex_row
- an index row template, filled in by this routineold_row_loc
- old location of base row, used to delete indexnew_row_loc
- new location of base row, used to update indexindex_cc
- index conglomerate to insert new rowindex_scan
- index scan to delete old entryindex_col_map
- description of mapping of index row to base row,- Throws:
StandardException
- Standard exception policy.
-
purgeRows
private void purgeRows(TransactionController tc) throws StandardException
Purge committed deleted rows from conglomerate.Scans the table and purges any committed deleted rows from the table. If all rows on a page are purged then page is also reclaimed.
- Parameters:
tc
- transaction controller to use to do updates.- Throws:
StandardException
-
addNewColumnToTable
private void addNewColumnToTable(int ix) throws StandardException
Workhorse for adding a new column to a table.- Parameters:
ix
- the index of the column specfication in the ALTER statement-- currently we allow only one.- Throws:
StandardException
- thrown on failure.
-
dropColumnFromTable
private void dropColumnFromTable(java.lang.String columnName) throws StandardException
Workhorse for dropping a column from a table. This routine drops a column from a table, taking care to properly handle the various related schema objects. The syntax which gets you here is: ALTER TABLE tbl DROP [COLUMN] col [CASCADE|RESTRICT] The keyword COLUMN is optional, and if you don't specify CASCADE or RESTRICT, the default is CASCADE (the default is chosen in the parser, not here). If you specify RESTRICT, then the column drop should be rejected if it would cause a dependent schema object to become invalid. If you specify CASCADE, then the column drop should additionally drop other schema objects which have become invalid. You may not drop the last (only) column in a table. Schema objects of interest include: - views - triggers - constraints - check constraints - primary key constraints - foreign key constraints - unique key constraints - not null constraints - privileges - indexes - default values Dropping a column may also change the column position numbers of other columns in the table, which may require fixup of schema objects (such as triggers and column privileges) which refer to columns by column position number. Indexes are a bit interesting. The official SQL spec doesn't talk about indexes; they are considered to be an imlementation-specific performance optimization. The current Derby behavior is that: - CASCADE/RESTRICT doesn't matter for indexes - when a column is dropped, it is removed from any indexes which contain it. - if that column was the only column in the index, the entire index is dropped.- Parameters:
columnName
- the name of the column specfication in the ALTER statement-- currently we allow only one.- Throws:
StandardException
- thrown on failure.
-
columnDroppedAndTriggerDependencies
private boolean columnDroppedAndTriggerDependencies(TriggerDescriptor trd, UUID spsUUID, boolean isWhenClause, boolean cascade, java.lang.String columnName) throws StandardException
- Throws:
StandardException
-
modifyColumnType
private void modifyColumnType(int ix) throws StandardException
- Throws:
StandardException
-
modifyColumnConstraint
private void modifyColumnConstraint(java.lang.String colName, boolean nullability) throws StandardException
Workhorse for modifying column level constraints. Right now it is restricted to modifying a null constraint to a not null constraint.- Throws:
StandardException
-
modifyColumnDefault
private void modifyColumnDefault(int ix) throws StandardException
Workhorse for modifying the default value of a column.- Parameters:
ix
- the index of the column specfication in the ALTER statement-- currently we allow only one.- Throws:
StandardException
-
getRangeBound
private long getRangeBound(DataTypeDescriptor dtd, int topOrBottom) throws StandardException
Get the ran max or min range bound for an autoincrement column.- Parameters:
dtd
- The type of the autoincrement column.topOrBottom
- RANGE_TOP or RANGE_BOTTOM- Returns:
- the top or bottom of the range
- Throws:
StandardException
-
modifyIdentityState
private void modifyIdentityState(int ix) throws StandardException
Change an identity from ALWAYS to BY DEFAULT (or vice versa)- Parameters:
ix
- the index of the column specfication in the ALTER statement-- currently we allow only one.- Throws:
StandardException
-
compressTable
private void compressTable() throws StandardException
routine to process compress table or ALTER TABLEDROP COLUMN ; Uses class level variable "compressTable" to determine if processing compress table or drop column: if (!compressTable) must be drop column.
Handles rebuilding of base conglomerate and all necessary indexes.
- Throws:
StandardException
-
truncateTable
private void truncateTable() throws StandardException
- Throws:
StandardException
-
updateAllIndexes
private void updateAllIndexes(long newHeapConglom, DataDictionary dd) throws StandardException
Update all of the indexes on a table when doing a bulk insert on an empty table.- Throws:
StandardException
- thrown on error
-
updateIndex
private void updateIndex(long newHeapConglom, DataDictionary dd, int index, long[] newIndexCongloms) throws StandardException
- Throws:
StandardException
-
getAffectedIndexes
private void getAffectedIndexes() throws StandardException
Get info on the indexes on the table being compressed.- Throws:
StandardException
- Thrown on error
-
createNewBackingCongloms
private void createNewBackingCongloms(java.util.ArrayList<ConstantAction> newConglomActions, long[] ixCongNums) throws StandardException
Iterate through the received list of CreateIndexConstantActions and execute each one, It's possible that one or more of the constant actions in the list has been rendered "unneeded" by the time we get here (because the index that the constant action was going to create is no longer needed), so we have to check for that.- Parameters:
newConglomActions
- Potentially empty list of constant actions to execute, if still neededixCongNums
- Optional array of conglomerate numbers; if non-null then any entries in the array which correspond to a dropped physical conglomerate (as determined from the list of constant actions) will be updated to have the conglomerate number of the newly-created physical conglomerate.- Throws:
StandardException
-
setUpAllSorts
private void setUpAllSorts(ExecRow sourceRow, RowLocation rl) throws StandardException
Set up to update all of the indexes on a table when doing a bulk insert on an empty table.- Throws:
StandardException
- thrown on error
-
getValidColumns
public FormatableBitSet getValidColumns()
Description copied from interface:RowSource
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 interfaceRowSource
- See Also:
RowSource.getValidColumns()
-
getNextRowFromRowSource
public DataValueDescriptor[] getNextRowFromRowSource() throws StandardException
Description copied from interface:RowSource
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 interfaceRowSource
- Throws:
StandardException
- on error- See Also:
RowSource.getNextRowFromRowSource()
-
needsToClone
public boolean needsToClone()
Description copied from interface:RowSource
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 interfaceRowSource
- See Also:
RowSource.needsToClone()
-
closeRowSource
public void closeRowSource()
Description copied from interface:RowSource
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 interfaceRowSource
- See Also:
RowSource.closeRowSource()
-
needsRowLocation
public boolean needsRowLocation()
Description copied from interface:RowLocationRetRowSource
needsRowLocation returns true iff this the row source expects the drainer of the row source to call rowLocation after getting a row from getNextRowFromRowSource.- Specified by:
needsRowLocation
in interfaceRowLocationRetRowSource
- Returns:
- true iff this row source expects some row location to be returned
- See Also:
RowLocationRetRowSource.needsRowLocation()
-
needsRowLocationForDeferredCheckConstraints
public boolean needsRowLocationForDeferredCheckConstraints()
- Specified by:
needsRowLocationForDeferredCheckConstraints
in interfaceRowLocationRetRowSource
-
rowLocation
public void rowLocation(RowLocation rl) throws StandardException
Description copied from interface:RowLocationRetRowSource
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 guarantee 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 interfaceRowLocationRetRowSource
- Throws:
StandardException
- on error- See Also:
RowLocationRetRowSource.rowLocation(org.apache.derby.iapi.types.RowLocation)
-
objectifyStreamingColumns
private void objectifyStreamingColumns() throws StandardException
- Throws:
StandardException
-
insertIntoSorter
private void insertIntoSorter(int index, RowLocation rl) throws StandardException
- Throws:
StandardException
-
cleanUp
private void cleanUp() throws StandardException
- Throws:
StandardException
- Thrown on error
-
getSemiRowCount
private int getSemiRowCount(TransactionController tc) throws StandardException
Return the "semi" row count of a table. We are only interested in whether the table has 0, 1 or > 1 rows.- Returns:
- Number of rows (0, 1 or > 1) in table.
- Throws:
StandardException
- Thrown on failure
-
updateNewColumnToDefault
private void updateNewColumnToDefault(ColumnDescriptor columnDescriptor) throws StandardException
Update a new column with its default. We could do the scan ourself here, but instead we get a nested connection and issue the appropriate update statement.- Parameters:
columnDescriptor
- catalog descriptor for the column- Throws:
StandardException
- if update to default fails
-
executeUpdate
private static void executeUpdate(LanguageConnectionContext lcc, java.lang.String updateStmt) throws StandardException
- Throws:
StandardException
-
getColumnMax
private long getColumnMax(TableDescriptor td, java.lang.String columnName, long increment) throws StandardException
computes the minimum/maximum value in a column of a table.- Throws:
StandardException
-
openBulkFetchScan
private void openBulkFetchScan(long heapConglomNumber) throws StandardException
- Throws:
StandardException
-
closeBulkFetchScan
private void closeBulkFetchScan() throws StandardException
- Throws:
StandardException
-
validateNotNullConstraint
private boolean validateNotNullConstraint(java.lang.String[] columnNames, boolean[] nullCols, int numRows, LanguageConnectionContext lcc, java.lang.String errorMsg) throws StandardException
Make sure that the columns are non null If any column is nullable, check that the data is null.- Parameters:
columnNames
- names of columns to be checkednullCols
- true if corresponding column is nullablenumRows
- number of rows in the tablelcc
- language contexterrorMsg
- error message to use for exception- Returns:
- true if any nullable columns found (nullable columns must have all non null data or exception is thrown
- Throws:
StandardException
- on error
-
compressIndexArrays
private java.lang.Object[] compressIndexArrays(long[] indexCIDS, IndexRowGenerator[] irgs)
Get rid of duplicates from a set of index conglomerate numbers and index descriptors.- Parameters:
indexCIDS
- array of index conglomerate numbersirgs
- array of index row generaters- Returns:
- value: If no duplicates, returns NULL; otherwise, a size-3 array of objects, first element is an array of duplicates' indexes in the input arrays; second element is the compact indexCIDs; third element is the compact irgs.
-
offendingRowLocation
public void offendingRowLocation(RowLocation rl, long containdId) throws StandardException
- Specified by:
offendingRowLocation
in interfaceRowLocationRetRowSource
- Throws:
StandardException
-
-