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

pack-priv Class AlterTableConstantAction

extends DDLSingleTableConstantAction
implements RowLocationRetRowSource
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.access.RowLocationRetRowSource, org.apache.derby.iapi.store.access.RowSource
Imports
java.util.ArrayList, .List, .Properties, org.apache.derby.catalog.Dependable, .DependableFinder, .IndexDescriptor, .UUID, org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl, .StatisticsImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.io.FormatableBitSet, .StreamStorable, org.apache.derby.iapi.sql.Activation, .PreparedStatement, .ResultSet, .StatementType, org.apache.derby.iapi.sql.compile.CompilerContext, .Parser, .Visitable, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.depend.DependencyManager, org.apache.derby.iapi.sql.dictionary.CheckConstraintDescriptor, .ColumnDescriptor, .ColumnDescriptorList, .ConglomerateDescriptor, .ConstraintDescriptor, .ConstraintDescriptorList, .DataDescriptorGenerator, .DataDictionary, .DefaultDescriptor, .DependencyDescriptor, .ForeignKeyConstraintDescriptor, .IndexLister, .IndexRowGenerator, .ReferencedKeyConstraintDescriptor, .SPSDescriptor, .SchemaDescriptor, .SequenceDescriptor, .StatisticsDescriptor, .TableDescriptor, .TriggerDescriptor, org.apache.derby.iapi.sql.execute.ConstantAction, .ExecIndexRow, .ExecRow, org.apache.derby.iapi.store.access.ColumnOrdering, .ConglomerateController, .GroupFetchScanController, .Qualifier, .RowLocationRetRowSource, .RowSource, .RowUtil, .ScanController, .SortController, .SortObserver, .TransactionController, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .RowLocation, .TypeId, org.apache.derby.iapi.util.IdUtil, org.apache.derby.impl.sql.compile.ColumnDefinitionNode, .StatementNode, org.apache.derby.shared.common.sanity.SanityManager

This class describes actions that are ALWAYS performed for an ALTER TABLE Statement at Execution time.

Field Summary

Modifier and TypeField and Description
private Activation
private ExecRow[]
private DataValueDescriptor[][]
private int
private int
private int[][]
private ColumnInfo[]
private ConglomerateController
private GroupFetchScanController
private IndexRowGenerator[]
private RowLocation[]
private boolean
private ConstraintConstantAction[]
private int
private ExecRow
private DataDictionary
private boolean
private DependencyManager
private boolean
private int
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
private long[]
private FormatableBitSet
private 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[]
private LanguageConnectionContext
private char
private boolean[]
private int
private ColumnOrdering[][]
private boolean
private static final int
private static final int
private int
private UUID
private SchemaDescriptor
private boolean
private SortController[]
private long[]
private long
private String
private int
private TransactionController
private TableDescriptor
private boolean
private boolean
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[]
Inherited from org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction:
tableId

Constructor Summary

AccessConstructor and Description
pack-priv
AlterTableConstantAction(SchemaDescriptor
descriptor for the table's schema.
sd
,
String
Name of table.
tableName
,
UUID
UUID of table
tableId
,
long
heap conglomerate number of table
tableConglomerateId
,
int
Type of table (e.g., BASE).
tableType
,
ColumnInfo[]
Information on all the columns in the table.
columnInfo
,
ConstraintConstantAction[]
ConstraintConstantAction[] for constraints
constraintActions
,
char
The lock granularity.
lockGranularity
,
boolean
Whether or not this is a compress table
compressTable
,
int
drop behavior for dropping column
behavior
,
boolean
If compress table/drop column, whether or not sequential
sequential
,
boolean
Whether or not this is a truncate table
truncateTable
,
boolean
PURGE during INPLACE COMPRESS?
purge
,
boolean
DEFRAGMENT during INPLACE COMPRESS?
defragment
,
boolean
TRUNCATE END during INPLACE COMPRESS?
truncateEndOfTable
,
boolean
TRUE means we are here to update statistics
updateStatistics
,
boolean
TRUE means we are here to update statistics of all the indexes. False means we are here to update statistics of only one index.
updateStatisticsAll
,
boolean
TRUE means we are here to drop statistics
dropStatistics
,
boolean
TRUE means we are here to drop statistics of all the indexes. False means we are here to drop statistics of only one index.
dropStatisticsAll
,
String
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.
indexNameForStatistics
)

Make the AlterAction for an ALTER TABLE statement.

Method Summary

Modifier and TypeMethod and Description
private void
addNewColumnToTable(int
the index of the column specfication in the ALTER statement-- currently we allow only one.
ix
)

Workhorse for adding a new column to a table.

private void
private void
clearState()

Clear the state of this constant action.

private void
public void
closeRowSource()

Implements org.apache.derby.iapi.store.access.RowSource.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, String columnName)

private Object[]

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.
compressIndexArrays
(long[]
array of index conglomerate numbers
indexCIDS
,
IndexRowGenerator[]
array of index row generaters
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 TABLE <t> DROP COLUMN <c>;

Uses class level variable "compressTable" to determine if processing compress table or drop column: if (!compressTable) must be drop column.

private void
createNewBackingCongloms(ArrayList<ConstantAction>
Potentially empty list of constant actions to execute, if still needed
newConglomActions
,
long[]
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.
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
transaction controller to use to do updates.
tc
)

Defragment rows in the given table.

private void
dropColumnFromTable(String
the name of the column specfication in the ALTER statement-- currently we allow only one.
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.

public void
executeConstantAction(Activation
the activation in which to run the action
activation
)

Implements org.apache.derby.iapi.sql.execute.ConstantAction.executeConstantAction.

Run this constant action.

private void
executeConstantActionBody(Activation activation)

This is the guts of the Execution-time logic for ALTER TABLE.

private static void
private static void
fixIndex(DataValueDescriptor[]
all columns of base row
base_row
,
DataValueDescriptor[]
an index row template, filled in by this routine
index_row
,
RowLocation
old location of base row, used to delete index
old_row_loc
,
RowLocation
new location of base row, used to update index
new_row_loc
,
ConglomerateController
index conglomerate to insert new row
index_cc
,
ScanController
index scan to delete old entry
index_scan
,
int[]
description of mapping of index row to base row,
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, String columnName, long increment)

computes the minimum/maximum value in a column of a table.

public DataValueDescriptor[]
getNextRowFromRowSource()

Implements org.apache.derby.iapi.store.access.RowSource.getNextRowFromRowSource.

Get the next row as an array of column objects.

private long

Returns:

the top or bottom of the range
getRangeBound
(DataTypeDescriptor
The type of the autoincrement column.
dtd
,
int
RANGE_TOP or RANGE_BOTTOM
topOrBottom
)

Get the ran max or min range bound for an autoincrement column.

private int

Returns:

Number of rows (0, 1 or > 1) in table.
getSemiRowCount
(TransactionController tc)

Return the "semi" row count of a table.

public FormatableBitSet
getValidColumns()

Implements org.apache.derby.iapi.store.access.RowSource.getValidColumns.

getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call.

private void
private void
modifyColumnConstraint(String colName, boolean nullability)

Workhorse for modifying column level constraints.

private void
modifyColumnDefault(int
the index of the column specfication in the ALTER statement-- currently we allow only one.
ix
)

Workhorse for modifying the default value of a column.

private void
private void
modifyIdentityState(int
the index of the column specfication in the ALTER statement-- currently we allow only one.
ix
)

Change an identity from ALWAYS to BY DEFAULT (or vice versa)

public boolean
needsRowLocation()

Implements org.apache.derby.iapi.store.access.RowLocationRetRowSource.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.

public boolean
public boolean
needsToClone()

Implements org.apache.derby.iapi.store.access.RowSource.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
public void
private void
openBulkFetchScan(long heapConglomNumber)

private void
purgeRows(TransactionController
transaction controller to use to do updates.
tc
)

Purge committed deleted rows from conglomerate.

public void
rowLocation(RowLocation rl)

Implements org.apache.derby.iapi.store.access.RowLocationRetRowSource.rowLocation.

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.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
truncateEnd(TransactionController
transaction controller to use to do updates.
tc
)

Truncate end of conglomerate.

private void
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
catalog descriptor for the column
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

Returns:

true if any nullable columns found (nullable columns must have all non null data or exception is thrown
validateNotNullConstraint
(String[]
names of columns to be checked
columnNames
,
boolean[]
true if corresponding column is nullable
nullCols
,
int
number of rows in the table
numRows
,
LanguageConnectionContext
language context
lcc
,
String
error message to use for exception
errorMsg
)

Make sure that the columns are non null If any column is nullable, check that the data is null.

Inherited from org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction:
dropConglomeratedropConglomeratedropConstraintdropConstraintdropConstraintexecuteConglomReplacementgetConglomReplacementActionrecreateUniqueConstraintBackingIndexAsUniqueWhenNotNull