}
// for each related column, stuff system.column
for (int ix = 0; ix < columnInfo.length; ix++)
{
ColumnDescriptorList cdl = new ColumnDescriptorList();
/* If there is a default value, use it, otherwise use null */
// Are we adding a new column or modifying a default?
if (columnInfo[ix].action == ColumnInfo.CREATE)
{
addNewColumnToTable(activation, ix);
}
else if (columnInfo[ix].action ==
ColumnInfo.MODIFY_COLUMN_DEFAULT_RESTART ||
columnInfo[ix].action == ColumnInfo.MODIFY_COLUMN_DEFAULT_INCREMENT)
{
modifyColumnDefault(activation, ix);
}
else if (columnInfo[ix].action ==
ColumnInfo.MODIFY_COLUMN_TYPE)
{
modifyColumnType(activation, ix);
}
else if (columnInfo[ix].action ==
ColumnInfo.MODIFY_COLUMN_CONSTRAINT)
{
modifyColumnConstraint(activation, columnInfo[ix].name, true);
}
else if (columnInfo[ix].action ==
ColumnInfo.MODIFY_COLUMN_CONSTRAINT_NOT_NULL)
{
if (! tableScanned)
{
tableScanned = true;
numRows = getSemiRowCount(tc);
}
// check that the data in the column is not null
String colNames[] = new String[1];
colNames[0] = columnInfo[ix].name;
boolean nullCols[] = new boolean[1];
/* note validateNotNullConstraint returns true if the
* column is nullable
*/
if (validateNotNullConstraint(colNames, nullCols,
numRows, lcc, SQLState.LANG_NULL_DATA_IN_NON_NULL_COLUMN))
{
/* nullable column - modify it to be not null
* This is O.K. at this point since we would have
* thrown an exception if any data was null
*/
modifyColumnConstraint(activation, columnInfo[ix].name, false);
}
}
else if (columnInfo[ix].action == ColumnInfo.DROP)
{
dropColumnFromTable(activation, ix);
}
else if (SanityManager.DEBUG)
{
SanityManager.THROWASSERT(
"Unexpected action in AlterTableConstantAction");
}
}
}
/* Create/Drop any constraints */
if (constraintActions != null)
{
for (int conIndex = 0; conIndex < constraintActions.length; conIndex++)
{
ConstraintConstantAction cca = constraintActions[conIndex];
if (cca instanceof CreateConstraintConstantAction)
{
int constraintType = cca.getConstraintType();
/* Some constraint types require special checking:
* Check - table must be empty, for now
* Primary Key - table cannot already have a primary key
*/
switch (constraintType)
{
case DataDictionary.PRIMARYKEY_CONSTRAINT:
// Check to see if a constraint of the same type already exists
ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
if (cdl.getPrimaryKey() != null)
{
throw StandardException.newException(SQLState.LANG_ADD_PRIMARY_KEY_FAILED1,
td.getQualifiedName());
}
if (! tableScanned)