protected DataTypeDescriptor concatenationOperatorNode(ConcatenationOperatorNode node)
throws StandardException {
ValueNode leftOperand = node.getLeftOperand();
ValueNode rightOperand = node.getRightOperand();
DataTypeDescriptor leftType = leftOperand.getType();
DataTypeDescriptor rightType = rightOperand.getType();
if ((leftType != null) &&
!leftType.getTypeId().isStringTypeId()) {
leftType = new DataTypeDescriptor(TypeId.VARCHAR_ID,
leftType.isNullable(),
leftType.getMaximumWidth());
leftOperand = (ValueNode)node.getNodeFactory()
.getNode(NodeTypes.CAST_NODE,
leftOperand, leftType,
node.getParserContext());
node.setLeftOperand(leftOperand);
}
else if (isParameterOrUntypedNull(leftOperand)) {
leftType = new DataTypeDescriptor(TypeId.VARCHAR_ID, true);
leftOperand.setType(leftType);
}
if ((rightType != null) &&
!rightType.getTypeId().isStringTypeId()) {
rightType = new DataTypeDescriptor(TypeId.VARCHAR_ID,
rightType.isNullable(),
rightType.getMaximumWidth());
rightOperand = (ValueNode)node.getNodeFactory()
.getNode(NodeTypes.CAST_NODE,
rightOperand, rightType,
node.getParserContext());
node.setRightOperand(rightOperand);
}
else if (isParameterOrUntypedNull(rightOperand)) {
rightType = new DataTypeDescriptor(TypeId.VARCHAR_ID, true);
rightOperand.setType(rightType);
}
if ((leftType == null) || (rightType == null))
return null;
return new DataTypeDescriptor(TypeId.VARCHAR_ID,
leftType.isNullable() || rightType.isNullable(),
leftType.getMaximumWidth() + rightType.getMaximumWidth(),
CharacterTypeAttributes.mergeCollations(leftType.getCharacterAttributes(), rightType.getCharacterAttributes()));
}