|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.execute.DDLConstantAction
org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
org.apache.derby.impl.sql.execute.AlterTableConstantAction
class AlterTableConstantAction
This class describes actions that are ALWAYS performed for an ALTER TABLE Statement at Execution time.
Field Summary | |
---|---|
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 long |
estimatedRowCount
|
private static int |
GROUP_FETCH_SIZE
|
private long[] |
indexConglomerateNumbers
|
private FormatableBitSet |
indexedCols
|
private java.lang.String |
indexNameForUpdateStatistics
If statistic is getting updated for just one index, then indexNameForUpdateStatistics will tell the name of the specific index whose statistics need to be updated. |
private ExecIndexRow[] |
indexRows
|
private DataValueDescriptor[] |
lastUniqueKey
|
private LanguageConnectionContext |
lcc
|
private char |
lockGranularity
|
private boolean[] |
needToDropSort
|
private int |
numIndexes
|
private ColumnOrdering[][] |
ordering
|
private boolean |
purge
|
private DataValueDescriptor[] |
rowBuffer
|
private DataValueDescriptor[][] |
rowBufferArray
RUNTIME state of the system is maintained in these objects. |
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 |
Constructor Summary | |
---|---|
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,
java.lang.String indexNameForUpdateStatistics)
Make the AlterAction for an ALTER TABLE statement. |
Method Summary | |
---|---|
private void |
addNewColumnToTable(Activation activation,
LanguageConnectionContext lcc,
DataDictionary dd,
TransactionController tc,
int ix)
Workhorse for adding a new column to a table. |
private void |
cleanUp()
|
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 int |
compareWithPrevKey(int index,
boolean firstRow)
|
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(Activation activation)
routine to process compress table or ALTER TABLE |
private void |
createNewBackingCongloms(java.util.ArrayList newConglomActions,
long[] ixCongNums,
Activation activation,
DataDictionary dd)
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,
LanguageConnectionContext lcc)
Defragment rows in the given table. |
private void |
dropAllColumnDefaults(UUID tableId,
DataDictionary dd)
|
private void |
dropColumnFromTable(Activation activation,
java.lang.String columnName)
Workhorse for dropping a column from a table. |
void |
executeConstantAction(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(Activation activation)
Get info on the indexes on the table being compressed. |
private long |
getColumnMax(Activation activation,
TableDescriptor td,
java.lang.String columnName,
long increment,
long initial)
computes the minimum/maximum value in a column of a table. |
DataValueDescriptor[] |
getNextRowFromRowSource()
Get the next row as an array of column objects. |
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 |
initializeRowBuffers(ExecIndexRow ir)
|
private void |
insertIntoSorter(int index,
RowLocation rl)
|
private void |
modifyColumnConstraint(Activation activation,
java.lang.String colName,
boolean nullability)
Workhorse for modifying column level constraints. |
private void |
modifyColumnDefault(Activation activation,
int ix)
Workhorse for modifying the default value of a column. |
private void |
modifyColumnType(Activation activation,
int ix)
|
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 |
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()
|
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(Activation activation)
|
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 |
updateNewAutoincrementColumn(Activation activation,
java.lang.String columnName,
long initial,
long increment)
Update values in a new autoincrement column being added to a table. |
private void |
updateNewColumnToDefault(Activation activation,
ColumnDescriptor columnDescriptor,
LanguageConnectionContext lcc)
Update a new column with its default. |
private void |
updateStatistics(Activation activation)
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private SchemaDescriptor sd
private java.lang.String tableName
private UUID schemaId
private int tableType
private ColumnInfo[] columnInfo
private ConstraintConstantAction[] constraintActions
private char lockGranularity
private long tableConglomerateId
private boolean compressTable
private int behavior
private boolean sequential
private boolean truncateTable
private boolean purge
private boolean defragment
private boolean truncateEndOfTable
private boolean updateStatistics
private boolean updateStatisticsAll
private java.lang.String indexNameForUpdateStatistics
private DataValueDescriptor[][] rowBufferArray
private DataValueDescriptor[] rowBuffer
private DataValueDescriptor[] lastUniqueKey
private static final int GROUP_FETCH_SIZE
private boolean doneScan
private boolean[] needToDropSort
private boolean[] validRow
private int bulkFetchSize
private int currentCompressRow
private int numIndexes
private int rowCount
private long estimatedRowCount
private long[] indexConglomerateNumbers
private long[] sortIds
private FormatableBitSet indexedCols
private ConglomerateController compressHeapCC
private ExecIndexRow[] indexRows
private ExecRow[] baseRow
private ExecRow currentRow
private GroupFetchScanController compressHeapGSC
private IndexRowGenerator[] compressIRGs
private DataValueDescriptor[][] baseRowArray
private RowLocation[] compressRL
private SortController[] sorters
private int droppedColumnPosition
private ColumnOrdering[][] ordering
private int[][] collation
private TableDescriptor td
private LanguageConnectionContext lcc
private DataDictionary dd
private DependencyManager dm
private TransactionController tc
private Activation activation
Constructor Detail |
---|
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, java.lang.String indexNameForUpdateStatistics)
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.indexNameForUpdateStatistics
- Will name the index whose statistics
will be updatedMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void executeConstantAction(Activation activation) throws StandardException
executeConstantAction
in interface ConstantAction
activation
- The execution environment for this constant action.
StandardException
- Thrown on failureConstantAction.executeConstantAction(org.apache.derby.iapi.sql.Activation)
private void updateStatistics(Activation activation) throws StandardException
activation
- the current activation
StandardException
private void initializeRowBuffers(ExecIndexRow ir)
private int compareWithPrevKey(int index, boolean firstRow) throws StandardException
StandardException
private void truncateEnd(TransactionController tc) throws StandardException
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.
tc
- transaction controller to use to do updates.
StandardException
private void defragmentRows(TransactionController tc, LanguageConnectionContext lcc) throws StandardException
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.
tc
- transaction controller to use to do updates.lcc
- the language connection context
StandardException
private static void setup_indexes(TransactionController tc, TableDescriptor td, int[][] index_col_map, ScanController[] index_scan, ConglomerateController[] index_cc, DataValueDescriptor[][] index_row) throws StandardException
StandardException
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
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,
StandardException
- Standard exception policy.private void purgeRows(TransactionController tc) throws StandardException
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.
tc
- transaction controller to use to do updates.
StandardException
private void addNewColumnToTable(Activation activation, LanguageConnectionContext lcc, DataDictionary dd, TransactionController tc, int ix) throws StandardException
ix
- the index of the column specfication in the ALTER
statement-- currently we allow only one.
StandardException
- thrown on failure.private void dropColumnFromTable(Activation activation, java.lang.String columnName) throws StandardException
activation
- the current activationcolumnName
- the name of the column specfication in the ALTER
statement-- currently we allow only one.
StandardException
- thrown on failure.private void modifyColumnType(Activation activation, int ix) throws StandardException
StandardException
private void modifyColumnConstraint(Activation activation, java.lang.String colName, boolean nullability) throws StandardException
StandardException
private void modifyColumnDefault(Activation activation, int ix) throws StandardException
activation
- activationix
- the index of the column specfication in the ALTER
statement-- currently we allow only one.
StandardException,
- thrown on error.
StandardException
private void compressTable(Activation activation) throws StandardException
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.
StandardException
private void truncateTable(Activation activation) throws StandardException
StandardException
private void updateAllIndexes(long newHeapConglom, DataDictionary dd) throws StandardException
StandardException
- thrown on errorprivate void updateIndex(long newHeapConglom, DataDictionary dd, int index, long[] newIndexCongloms) throws StandardException
StandardException
private void getAffectedIndexes(Activation activation) throws StandardException
StandardException
- Thrown on errorprivate void createNewBackingCongloms(java.util.ArrayList newConglomActions, long[] ixCongNums, Activation activation, DataDictionary dd) throws StandardException
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.
StandardException
private void setUpAllSorts(ExecRow sourceRow, RowLocation rl) throws StandardException
StandardException
- thrown on errorpublic FormatableBitSet getValidColumns()
RowSource
getValidColumns
in interface RowSource
RowSource.getValidColumns()
public DataValueDescriptor[] getNextRowFromRowSource() throws StandardException
RowSource
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().
getNextRowFromRowSource
in interface RowSource
StandardException
- on errorRowSource.getNextRowFromRowSource()
public boolean needsToClone()
RowSource
needsToClone
in interface RowSource
RowSource.needsToClone()
public void closeRowSource()
RowSource
closeRowSource
in interface RowSource
RowSource.closeRowSource()
public boolean needsRowLocation()
RowLocationRetRowSource
needsRowLocation
in interface RowLocationRetRowSource
RowLocationRetRowSource.needsRowLocation()
public void rowLocation(RowLocation rl) throws StandardException
RowLocationRetRowSource
boolean needsRL = rowSource.needsRowLocation(); DataValueDescriptor[] row; while((row = rowSource.getNextRowFromRowSource()) != null) { RowLocation rl = heapConglomerate.insertRow(row); if (needsRL) rowSource.rowLocation(rl); }
rowLocation
in interface RowLocationRetRowSource
StandardException
- on errorRowLocationRetRowSource.rowLocation(org.apache.derby.iapi.types.RowLocation)
private void objectifyStreamingColumns() throws StandardException
StandardException
private void insertIntoSorter(int index, RowLocation rl) throws StandardException
StandardException
private void cleanUp() throws StandardException
StandardException
- Thrown on errorprivate int getSemiRowCount(TransactionController tc) throws StandardException
StandardException
- Thrown on failureprivate void updateNewColumnToDefault(Activation activation, ColumnDescriptor columnDescriptor, LanguageConnectionContext lcc) throws StandardException
columnDescriptor
- catalog descriptor for the columnlcc
- the language connection context
StandardException
- if update to default failsprivate static void executeUpdate(LanguageConnectionContext lcc, java.lang.String updateStmt) throws StandardException
StandardException
private long getColumnMax(Activation activation, TableDescriptor td, java.lang.String columnName, long increment, long initial) throws StandardException
StandardException
private void dropAllColumnDefaults(UUID tableId, DataDictionary dd) throws StandardException
StandardException
private void openBulkFetchScan(long heapConglomNumber) throws StandardException
StandardException
private void closeBulkFetchScan() throws StandardException
StandardException
private void updateNewAutoincrementColumn(Activation activation, java.lang.String columnName, long initial, long increment) throws StandardException
columnName
- autoincrement column name that is being added.initial
- initial value of the autoincrement column.increment
- increment value of the autoincrement column.
StandardException
updateNewColumnToDefault(org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.dictionary.ColumnDescriptor, org.apache.derby.iapi.sql.conn.LanguageConnectionContext)
private boolean validateNotNullConstraint(java.lang.String[] columnNames, boolean[] nullCols, int numRows, LanguageConnectionContext lcc, java.lang.String errorMsg) throws StandardException
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
StandardException
- on errorprivate java.lang.Object[] compressIndexArrays(long[] indexCIDS, IndexRowGenerator[] irgs)
indexCIDS
- array of index conglomerate numbersirgs
- array of index row generaters
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |