use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.
the class SystemColumnImpl method getJavaColumn.
/**
* Create a system column for a java column.
*
* @param name
* Name of the column.
* @param javaClassName
* @param nullability
* Nullability of the column.
* @return Object representing the column.
*/
static SystemColumn getJavaColumn(String name, String javaClassName, boolean nullability) throws StandardException {
TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName);
DataTypeDescriptor dtd = new DataTypeDescriptor(typeId, nullability);
return new SystemColumnImpl(name, dtd);
}
use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.
the class AggregateNode method getNewAggregatorResultColumn.
/**
* Get the result column that has a new aggregator.
* This aggregator will be fed into the sorter.
*
* @param dd the data dictionary
*
* @return the result column. WARNING: it still needs to be bound
*
* @exception StandardException on error
*/
ResultColumn getNewAggregatorResultColumn(DataDictionary dd) throws StandardException {
String className = aggregatorClassName.toString();
DataTypeDescriptor compType = DataTypeDescriptor.getSQLDataTypeDescriptor(className);
/*
** Create a null of the right type. The proper aggregators
** are created dynamically by the SortObservers
*/
ConstantNode nullNode = getNullNode(compType);
nullNode.bindExpression(// from
null, // subquery
null, // aggregate
null);
/*
** Create a result column with this new node below
** it.
*/
return new ResultColumn(aggregateName, nullNode, getContextManager());
}
use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.
the class BinaryComparisonOperatorNode method bindExpression.
/**
* Bind this comparison operator. All that has to be done for binding
* a comparison operator is to bind the operands, check the compatibility
* of the types, and set the result type to SQLBoolean.
*
* @param fromList The query's FROM list
* @param subqueryList The subquery list being built as we find SubqueryNodes
* @param aggregates The aggregate list being built as we find AggregateNodes
*
* @return The new top of the expression tree.
*
* @exception StandardException Thrown on error
*/
@Override
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException {
super.bindExpression(fromList, subqueryList, aggregates);
TypeId leftTypeId = leftOperand.getTypeId();
TypeId rightTypeId = rightOperand.getTypeId();
/*
* If we are comparing a non-string with a string type, then we
* must prevent the non-string value from being used to probe into
* an index on a string column. This is because the string types
* are all of low precedence, so the comparison rules of the non-string
* value are used, so it may not find values in a string index because
* it will be in the wrong order. So, cast the string value to its
* own type. This is easier than casting it to the non-string type,
* because we would have to figure out the right length to cast it to.
*/
if (!leftTypeId.isStringTypeId() && rightTypeId.isStringTypeId()) {
DataTypeDescriptor rightTypeServices = rightOperand.getTypeServices();
rightOperand = new CastNode(rightOperand, new DataTypeDescriptor(rightTypeId, true, rightTypeServices.getMaximumWidth()), getContextManager());
((CastNode) rightOperand).bindCastNodeOnly();
} else if (!rightTypeId.isStringTypeId() && leftTypeId.isStringTypeId()) {
DataTypeDescriptor leftTypeServices = leftOperand.getTypeServices();
leftOperand = new CastNode(leftOperand, new DataTypeDescriptor(leftTypeId, true, leftTypeServices.getMaximumWidth()), getContextManager());
((CastNode) leftOperand).bindCastNodeOnly();
}
/* Test type compatability and set type info for this node */
bindComparisonOperator();
return this;
}
use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.
the class BinaryListOperatorNode method bindComparisonOperator.
/**
* Test the type compatability of the operands and set the type info
* for this node. This method is useful both during binding and
* when we generate nodes within the language module outside of the parser.
*
* @exception StandardException Thrown on error
*/
void bindComparisonOperator() throws StandardException {
boolean nullableResult;
/* Can the types be compared to each other? */
rightOperandList.comparable(leftOperand);
/*
** Set the result type of this comparison operator based on the
** operands. The result type is always SQLBoolean - the only question
** is whether it is nullable or not. If either the leftOperand or
** any of the elements in the rightOperandList is
** nullable, the result of the comparison must be nullable, too, so
** we can represent the unknown truth value.
*/
nullableResult = leftOperand.getTypeServices().isNullable() || rightOperandList.isNullable();
setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, nullableResult));
}
use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.
the class CreateIndexNode method makeConstantAction.
/**
* Create the Constant information that will drive the guts of Execution.
*
* @exception StandardException Thrown on failure
*/
@Override
public ConstantAction makeConstantAction() throws StandardException {
SchemaDescriptor sd = getSchemaDescriptor();
int columnCount = columnNames.length;
int approxLength = 0;
// so we do not have to consider key columns of long types
for (int i = 0; i < columnCount; i++) {
ColumnDescriptor columnDescriptor = td.getColumnDescriptor(columnNames[i]);
DataTypeDescriptor dts = columnDescriptor.getType();
approxLength += dts.getTypeId().getApproximateLengthInBytes(dts);
}
if (approxLength > Property.IDX_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().getCreateIndexConstantAction(// not for CREATE TABLE
false, unique, // it's not a UniqueWithDuplicateNulls Index
false, // it's not a constraint, so its checking
false, // initiallyDeferred: N/A
false, // constraintType: N/A
-1, indexType, sd.getSchemaName(), indexName.getTableName(), tableName.getTableName(), td.getUUID(), columnNames, isAscending, false, null, properties);
}
Aggregations