throws StandardException
{
super.bindExpression(fromList, subqueryList, aggregateVector);
//RESOLVELOCALIZE - convert constants to national constants
TypeCompiler leftTC = leftOperand.getTypeCompiler();
TypeCompiler rightTC = rightOperand.getTypeCompiler();
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 = (ValueNode)
getNodeFactory().getNode(
C_NodeTypes.CAST_NODE,
rightOperand,
new DataTypeDescriptor(
rightTypeId,
true,
rightTypeServices.getMaximumWidth()),
getContextManager());
((CastNode) rightOperand).bindCastNodeOnly();
}
else if (! rightTypeId.isStringTypeId() && leftTypeId.isStringTypeId())
{
DataTypeDescriptor leftTypeServices = leftOperand.getTypeServices();
leftOperand = (ValueNode)
getNodeFactory().getNode(
C_NodeTypes.CAST_NODE,
leftOperand,
new DataTypeDescriptor(
leftTypeId,
true,
leftTypeServices.getMaximumWidth()),
getContextManager());
((CastNode) leftOperand).bindCastNodeOnly();
}
/* If we are comparing a char with a national char then
* we need to generate a cast to the appropriate national
* char above the char operand.
*/
else if (! leftTypeId.isNationalStringTypeId() &&
rightTypeId.isNationalStringTypeId())
{
leftOperand = (ValueNode)
getNodeFactory().getNode(
C_NodeTypes.CAST_NODE,
leftOperand,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(leftTC.getMatchingNationalCharTypeName(),
leftTC.getCastToCharWidth(
leftOperand.getTypeServices())),
getContextManager());
((CastNode) leftOperand).bindCastNodeOnly();
}
else if (! rightTypeId.isNationalStringTypeId() &&
leftTypeId.isNationalStringTypeId())
{
rightOperand = (ValueNode)
getNodeFactory().getNode(
C_NodeTypes.CAST_NODE,
rightOperand,
DataTypeDescriptor.getBuiltInDataTypeDescriptor(rightTC.getMatchingNationalCharTypeName(),
rightTC.getCastToCharWidth(
rightOperand.getTypeServices())),
getContextManager());
((CastNode) rightOperand).bindCastNodeOnly();
}