|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> sql >> [ execute overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.sql.execute
Class AlterTableConstantAction

java.lang.Objectorg.apache.derby.impl.sql.execute.GenericConstantAction
org.apache.derby.impl.sql.execute.DDLConstantAction
org.apache.derby.impl.sql.execute.DDLSingleTableConstantAction
org.apache.derby.impl.sql.execute.AlterTableConstantAction
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.execute.ConstantAction, org.apache.derby.iapi.store.access.RowLocationRetRowSource, org.apache.derby.iapi.store.access.RowSource
- class AlterTableConstantAction
- extends DDLSingleTableConstantAction
- implements org.apache.derby.iapi.store.access.RowLocationRetRowSource
- extends DDLSingleTableConstantAction
This class describes actions that are ALWAYS performed for an ALTER TABLE Statement at Execution time.
| Fields inherited from interface org.apache.derby.iapi.sql.execute.ConstantAction |
RUNTIMESTATISTICS, STATISTICSTIMING |
| Constructor Summary | |
(package private) |
AlterTableConstantAction(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor sd,
java.lang.String tableName,
org.apache.derby.catalog.UUID tableId,
long tableConglomerateId,
int tableType,
ColumnInfo[] columnInfo,
ConstraintConstantAction[] constraintActions,
char lockGranularity,
boolean compressTable,
int behavior,
boolean sequential,
boolean truncateTable)
Make the AlterAction for an ALTER TABLE statement. |
| Method Summary | |
private void |
addNewColumnToTable(org.apache.derby.iapi.sql.Activation activation,
int ix)
Workhorse for adding a new column to a table. |
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 java.lang.Object[] |
compressIndexArrays(long[] indexCIDS,
org.apache.derby.iapi.sql.dictionary.IndexRowGenerator[] irgs)
Get rid of duplicates from a set of index conglomerate numbers and index descriptors. |
private void |
compressTable(org.apache.derby.iapi.sql.Activation activation)
|
private void |
dropAllColumnDefaults(org.apache.derby.catalog.UUID tableId,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
|
private void |
dropColumnFromTable(org.apache.derby.iapi.sql.Activation activation,
int ix)
Workhorse for dropping a column from a table. |
void |
execGuts(org.apache.derby.iapi.sql.Activation activation)
Wrapper for this DDL action. |
void |
executeConstantAction(org.apache.derby.iapi.sql.Activation activation)
This is the guts of the Execution-time logic for ALTER TABLE. |
private static void |
executeUpdate(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc,
java.lang.String updateStmt)
|
private void |
getAffectedIndexes(org.apache.derby.iapi.sql.Activation activation)
Get info on the indexes on the table being compress. |
private long |
getColumnMax(org.apache.derby.iapi.sql.Activation activation,
org.apache.derby.iapi.sql.dictionary.TableDescriptor td,
java.lang.String columnName,
long increment,
long initial)
computes the minimum/maximum value in a column of a table. |
org.apache.derby.iapi.types.DataValueDescriptor[] |
getNextRowFromRowSource()
Get the next row as an array of column objects. |
private int |
getSemiRowCount(org.apache.derby.iapi.store.access.TransactionController tc)
Return the "semi" row count of a table. |
org.apache.derby.iapi.services.io.FormatableBitSet |
getValidColumns()
getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call. |
private void |
insertIntoSorter(int index,
org.apache.derby.iapi.types.RowLocation rl)
|
boolean |
modifiesTableId(org.apache.derby.catalog.UUID tableId)
Does this constant action modify the passed in table uuid? By modify we mean add or drop things tied to this table (e.g. |
private void |
modifyColumnConstraint(org.apache.derby.iapi.sql.Activation activation,
java.lang.String colName,
boolean nullability)
Workhorse for modifying column level constraints. |
private void |
modifyColumnDefault(org.apache.derby.iapi.sql.Activation activation,
int ix)
Workhorse for modifying the default value of a column. |
private void |
modifyColumnType(org.apache.derby.iapi.sql.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)
|
void |
rowLocation(org.apache.derby.iapi.types.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 void |
setUpAllSorts(org.apache.derby.iapi.sql.execute.ExecRow sourceRow,
org.apache.derby.iapi.types.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()
Convert this Object to a human-readable String. |
private void |
truncateTable(org.apache.derby.iapi.sql.Activation activation)
|
private void |
updateAllIndexes(long newHeapConglom,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
Update all of the indexes on a table when doing a bulk insert on an empty table. |
private void |
updateIndex(long newHeapConglom,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd,
int index,
long[] newIndexCongloms)
|
private void |
updateNewAutoincrementColumn(org.apache.derby.iapi.sql.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(org.apache.derby.iapi.sql.Activation activation,
java.lang.String columnName,
java.lang.String defaultText,
org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc)
Update a new column with its default. |
private boolean |
validateNotNullConstraint(java.lang.String[] columnNames,
boolean[] nullCols,
int numRows,
org.apache.derby.iapi.sql.conn.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.DDLConstantAction |
constructToString, getAndCheckSchemaDescriptor, getSchemaDescriptorForCreate, lockTableForDDL, readExternal, upToDate, writeExternal |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
sd
protected org.apache.derby.iapi.sql.dictionary.SchemaDescriptor sd
tableName
protected java.lang.String tableName
schemaId
protected org.apache.derby.catalog.UUID schemaId
tableType
protected int tableType
tableConglomerateId
protected long tableConglomerateId
columnInfo
protected ColumnInfo[] columnInfo
constraintActions
protected ConstraintConstantAction[] constraintActions
lockGranularity
protected char lockGranularity
compressTable
private boolean compressTable
sequential
private boolean sequential
behavior
private int behavior
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 org.apache.derby.iapi.services.io.FormatableBitSet indexedCols
compressHeapCC
private org.apache.derby.iapi.store.access.ConglomerateController compressHeapCC
indexRows
private org.apache.derby.iapi.sql.execute.ExecIndexRow[] indexRows
baseRow
private org.apache.derby.iapi.sql.execute.ExecRow[] baseRow
currentRow
private org.apache.derby.iapi.sql.execute.ExecRow currentRow
compressHeapGSC
private org.apache.derby.iapi.store.access.GroupFetchScanController compressHeapGSC
compressIRGs
private org.apache.derby.iapi.sql.dictionary.IndexRowGenerator[] compressIRGs
baseRowArray
private org.apache.derby.iapi.types.DataValueDescriptor[][] baseRowArray
compressRL
private org.apache.derby.iapi.types.RowLocation[] compressRL
sorters
private org.apache.derby.iapi.store.access.SortController[] sorters
columnPosition
private int columnPosition
ordering
private org.apache.derby.iapi.store.access.ColumnOrdering[][] ordering
td
private org.apache.derby.iapi.sql.dictionary.TableDescriptor td
truncateTable
private boolean truncateTable
lcc
private org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc
dd
private org.apache.derby.iapi.sql.dictionary.DataDictionary dd
dm
private org.apache.derby.iapi.sql.depend.DependencyManager dm
tc
private org.apache.derby.iapi.store.access.TransactionController tc
activation
private org.apache.derby.iapi.sql.Activation activation
tableId
protected org.apache.derby.catalog.UUID tableId
| Constructor Detail |
AlterTableConstantAction
AlterTableConstantAction(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor sd, java.lang.String tableName, org.apache.derby.catalog.UUID tableId, long tableConglomerateId, int tableType, ColumnInfo[] columnInfo, ConstraintConstantAction[] constraintActions, char lockGranularity, boolean compressTable, int behavior, boolean sequential, boolean truncateTable)
- Make the AlterAction for an ALTER TABLE statement.
| Method Detail |
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
executeConstantAction
public void executeConstantAction(org.apache.derby.iapi.sql.Activation activation) throws org.apache.derby.iapi.error.StandardException
- This is the guts of the Execution-time logic for ALTER TABLE.
- Specified by:
executeConstantActionin interfaceorg.apache.derby.iapi.sql.execute.ConstantAction
execGuts
public void execGuts(org.apache.derby.iapi.sql.Activation activation) throws org.apache.derby.iapi.error.StandardException
- Wrapper for this DDL action. Factored out so that our child,
RepAlterTableConstantAction
could enjoy the benefits of the startWriting() method above.
addNewColumnToTable
private void addNewColumnToTable(org.apache.derby.iapi.sql.Activation activation, int ix) throws org.apache.derby.iapi.error.StandardException
- Workhorse for adding a new column to a table.
dropColumnFromTable
private void dropColumnFromTable(org.apache.derby.iapi.sql.Activation activation, int ix) throws org.apache.derby.iapi.error.StandardException
- Workhorse for dropping a column from a table.
modifyColumnType
private void modifyColumnType(org.apache.derby.iapi.sql.Activation activation, int ix) throws org.apache.derby.iapi.error.StandardException
modifyColumnConstraint
private void modifyColumnConstraint(org.apache.derby.iapi.sql.Activation activation, java.lang.String colName, boolean nullability) throws org.apache.derby.iapi.error.StandardException
- Workhorse for modifying column level constraints.
Right now it is restricted to modifying a null constraint to a not null
constraint.
modifyColumnDefault
private void modifyColumnDefault(org.apache.derby.iapi.sql.Activation activation, int ix) throws org.apache.derby.iapi.error.StandardException
- Workhorse for modifying the default value of a column.
compressTable
private void compressTable(org.apache.derby.iapi.sql.Activation activation) throws org.apache.derby.iapi.error.StandardException
truncateTable
private void truncateTable(org.apache.derby.iapi.sql.Activation activation) throws org.apache.derby.iapi.error.StandardException
updateAllIndexes
private void updateAllIndexes(long newHeapConglom,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd)
throws org.apache.derby.iapi.error.StandardException
- Update all of the indexes on a table when doing a bulk insert
on an empty table.
updateIndex
private void updateIndex(long newHeapConglom,
org.apache.derby.iapi.sql.dictionary.DataDictionary dd,
int index,
long[] newIndexCongloms)
throws org.apache.derby.iapi.error.StandardException
getAffectedIndexes
private void getAffectedIndexes(org.apache.derby.iapi.sql.Activation activation) throws org.apache.derby.iapi.error.StandardException
- Get info on the indexes on the table being compress.
setUpAllSorts
private void setUpAllSorts(org.apache.derby.iapi.sql.execute.ExecRow sourceRow, org.apache.derby.iapi.types.RowLocation rl) throws org.apache.derby.iapi.error.StandardException
- Set up to update all of the indexes on a table when doing a bulk insert
on an empty table.
getValidColumns
public org.apache.derby.iapi.services.io.FormatableBitSet getValidColumns()
- Description copied from interface:
org.apache.derby.iapi.store.access.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:
getValidColumnsin interfaceorg.apache.derby.iapi.store.access.RowSource
getNextRowFromRowSource
public org.apache.derby.iapi.types.DataValueDescriptor[] getNextRowFromRowSource() throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.store.access.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:
getNextRowFromRowSourcein interfaceorg.apache.derby.iapi.store.access.RowSource
needsToClone
public boolean needsToClone()
- Description copied from interface:
org.apache.derby.iapi.store.access.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:
needsToClonein interfaceorg.apache.derby.iapi.store.access.RowSource
closeRowSource
public void closeRowSource()
- Description copied from interface:
org.apache.derby.iapi.store.access.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:
closeRowSourcein interfaceorg.apache.derby.iapi.store.access.RowSource
needsRowLocation
public boolean needsRowLocation()
- Description copied from interface:
org.apache.derby.iapi.store.access.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:
needsRowLocationin interfaceorg.apache.derby.iapi.store.access.RowLocationRetRowSource
rowLocation
public void rowLocation(org.apache.derby.iapi.types.RowLocation rl) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.store.access.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 guarentee 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:
rowLocationin interfaceorg.apache.derby.iapi.store.access.RowLocationRetRowSource
objectifyStreamingColumns
private void objectifyStreamingColumns()
throws org.apache.derby.iapi.error.StandardException
insertIntoSorter
private void insertIntoSorter(int index,
org.apache.derby.iapi.types.RowLocation rl)
throws org.apache.derby.iapi.error.StandardException
cleanUp
public void cleanUp()
throws org.apache.derby.iapi.error.StandardException
getSemiRowCount
private int getSemiRowCount(org.apache.derby.iapi.store.access.TransactionController tc) throws org.apache.derby.iapi.error.StandardException
- Return the "semi" row count of a table. We are only interested in
whether the table has 0, 1 or > 1 rows.
updateNewColumnToDefault
private void updateNewColumnToDefault(org.apache.derby.iapi.sql.Activation activation, java.lang.String columnName, java.lang.String defaultText, org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc) throws org.apache.derby.iapi.error.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.
executeUpdate
private static void executeUpdate(org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc, java.lang.String updateStmt) throws org.apache.derby.iapi.error.StandardException
getColumnMax
private long getColumnMax(org.apache.derby.iapi.sql.Activation activation, org.apache.derby.iapi.sql.dictionary.TableDescriptor td, java.lang.String columnName, long increment, long initial) throws org.apache.derby.iapi.error.StandardException
- computes the minimum/maximum value in a column of a table.
dropAllColumnDefaults
private void dropAllColumnDefaults(org.apache.derby.catalog.UUID tableId, org.apache.derby.iapi.sql.dictionary.DataDictionary dd) throws org.apache.derby.iapi.error.StandardException
openBulkFetchScan
private void openBulkFetchScan(long heapConglomNumber)
throws org.apache.derby.iapi.error.StandardException
closeBulkFetchScan
private void closeBulkFetchScan()
throws org.apache.derby.iapi.error.StandardException
updateNewAutoincrementColumn
private void updateNewAutoincrementColumn(org.apache.derby.iapi.sql.Activation activation, java.lang.String columnName, long initial, long increment) throws org.apache.derby.iapi.error.StandardException
- Update values in a new autoincrement column being added to a table.
This is similar to updateNewColumnToDefault whereby we issue an
update statement using a nested connection. The UPDATE statement
uses a static method in ConnectionInfo (which is not documented)
which returns the next value to be inserted into the autoincrement
column.
validateNotNullConstraint
private boolean validateNotNullConstraint(java.lang.String[] columnNames, boolean[] nullCols, int numRows, org.apache.derby.iapi.sql.conn.LanguageConnectionContext lcc, java.lang.String errorMsg) throws org.apache.derby.iapi.error.StandardException
- Make sure that the columns are non null
If any column is nullable, check that the data is null.
compressIndexArrays
private java.lang.Object[] compressIndexArrays(long[] indexCIDS, org.apache.derby.iapi.sql.dictionary.IndexRowGenerator[] irgs)
- Get rid of duplicates from a set of index conglomerate numbers and
index descriptors.
modifiesTableId
public boolean modifiesTableId(org.apache.derby.catalog.UUID tableId)
- Does this constant action modify the passed in table
uuid? By modify we mean add or drop things tied to
this table (e.g. index, trigger, constraint). Things
like views or spses that reference this table don't
count.
- Specified by:
modifiesTableIdin interfaceorg.apache.derby.iapi.sql.execute.ConstantAction- Overrides:
modifiesTableIdin classDDLConstantAction
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> sql >> [ execute overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC