use of org.apache.derby.impl.sql.execute.ColumnInfo in project derby by apache.
the class CreateTableNode method makeConstantAction.
/**
* Create the Constant information that will drive the guts of Execution.
*
* @exception StandardException Thrown on failure
*/
@Override
public ConstantAction makeConstantAction() throws StandardException {
TableElementList coldefs = tableElementList;
// for each column, stuff system.column
ColumnInfo[] colInfos = new ColumnInfo[coldefs.countNumberOfColumns()];
int numConstraints = coldefs.genColumnInfos(colInfos);
/* If we've seen a constraint, then build a constraint list */
CreateConstraintConstantAction[] conActions = null;
SchemaDescriptor sd = getSchemaDescriptor(tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE, true);
if (numConstraints > 0) {
conActions = new CreateConstraintConstantAction[numConstraints];
coldefs.genConstraintActions(true, conActions, getRelativeName(), sd, getDataDictionary());
}
// if the any of columns are "long" and user has not specified a
// page size, set the pagesize to 32k.
// Also in case where the approximate sum of the column sizes is
// greater than the bump threshold , bump the pagesize to 32k
boolean table_has_long_column = false;
int approxLength = 0;
for (int i = 0; i < colInfos.length; i++) {
DataTypeDescriptor dts = colInfos[i].getDataType();
if (dts.getTypeId().isLongConcatableTypeId()) {
table_has_long_column = true;
break;
}
approxLength += dts.getTypeId().getApproximateLengthInBytes(dts);
}
if (table_has_long_column || (approxLength > Property.TBL_PAGE_SIZE_BUMP_THRESHOLD)) {
if (((properties == null) || (properties.get(Property.PAGE_SIZE_PARAMETER) == null)) && (PropertyUtil.getServiceProperty(getLanguageConnectionContext().getTransactionCompile(), Property.PAGE_SIZE_PARAMETER) == null)) {
if (properties == null)
properties = new Properties();
properties.put(Property.PAGE_SIZE_PARAMETER, Property.PAGE_SIZE_DEFAULT_LONG);
}
}
return (getGenericConstantActionFactory().getCreateTableConstantAction(sd.getSchemaName(), getRelativeName(), tableType, colInfos, conActions, properties, lockGranularity, onCommitDeleteRows, onRollbackDeleteRows));
}
use of org.apache.derby.impl.sql.execute.ColumnInfo in project derby by apache.
the class CreateViewNode method genColumnInfos.
/**
* Fill in the ColumnInfo[] for this create view.
*
* @param colInfos The ColumnInfo[] to be filled in.
*/
private void genColumnInfos(ColumnInfo[] colInfos) {
ResultColumnList rcl = queryExpression.getResultColumns();
for (int index = 0; index < colInfos.length; index++) {
ResultColumn rc = rcl.elementAt(index);
// range.
if (SanityManager.DEBUG) {
if (rc.isGenerated())
SanityManager.THROWASSERT("Encountered generated column in expected visible range at rcl[" + index + "]");
}
// RESOLVEAUTOINCREMENT
colInfos[index] = new ColumnInfo(rc.getName(), rc.getType(), null, null, null, null, null, ColumnInfo.CREATE, 0, 0, false, 0);
}
}
use of org.apache.derby.impl.sql.execute.ColumnInfo in project derby by apache.
the class TableElementList method genColumnInfos.
/**
* Fill in the ColumnInfo[] for this table element list.
*
* @param colInfos The ColumnInfo[] to be filled in.
*
* @return int The number of constraints in the create table.
*/
int genColumnInfos(ColumnInfo[] colInfos) throws StandardException {
int numConstraints = 0;
int size = size();
for (int index = 0; index < size; index++) {
if (elementAt(index).getElementType() == TableElementNode.AT_DROP_COLUMN) {
String columnName = elementAt(index).getName();
colInfos[index] = new ColumnInfo(columnName, td.getColumnDescriptor(columnName).getType(), null, null, null, null, null, ColumnInfo.DROP, 0, 0, false, 0);
break;
}
if (!(elementAt(index) instanceof ColumnDefinitionNode)) {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(elementAt(index) instanceof ConstraintDefinitionNode, "elementAt(index) expected to be instanceof " + "ConstraintDefinitionNode");
}
/* Remember how many constraints we've seen */
numConstraints++;
continue;
}
ColumnDefinitionNode coldef = (ColumnDefinitionNode) elementAt(index);
//
// Generated columns may depend on functions mentioned in their
// generation clauses.
//
ProviderList apl = null;
ProviderInfo[] providerInfos = null;
if (coldef.hasGenerationClause()) {
apl = coldef.getGenerationClauseNode().getAuxiliaryProviderList();
}
if (apl != null && apl.size() > 0) {
DependencyManager dm = getDataDictionary().getDependencyManager();
providerInfos = dm.getPersistentProviderInfos(apl);
}
colInfos[index - numConstraints] = new ColumnInfo(coldef.getColumnName(), coldef.getType(), coldef.getDefaultValue(), coldef.getDefaultInfo(), providerInfos, (UUID) null, coldef.getOldDefaultUUID(), coldef.getAction(), (coldef.isAutoincrementColumn() ? coldef.getAutoincrementStart() : 0), (coldef.isAutoincrementColumn() ? coldef.getAutoincrementIncrement() : 0), (coldef.isAutoincrementColumn() ? coldef.getAutoincrementCycle() : false), (coldef.isAutoincrementColumn() ? coldef.getAutoinc_create_or_modify_Start_Increment() : -1));
/* Remember how many constraints that we've seen */
if (coldef.hasConstraint()) {
numConstraints++;
}
}
return numConstraints;
}
Aggregations