* the left, since it won't match if it is any longer than it.
*/
if (receiver.requiresTypeFromContext())
{
receiver.setType(
new DataTypeDescriptor(
TypeId.getBuiltInTypeId(Types.VARCHAR), true));
//check if this parameter can pick up it's collation from pattern
//or escape clauses in that order. If not, then it will take it's
//collation from the compilation schema.
if (!leftOperand.requiresTypeFromContext()) {
receiver.setCollationInfo(leftOperand.getTypeServices());
} else if (rightOperand != null && !rightOperand.requiresTypeFromContext()) {
receiver.setCollationInfo(rightOperand.getTypeServices());
} else {
receiver.setCollationUsingCompilationSchema();
}
}
/*
* Is there a ? parameter for the PATTERN of LIKE? ie. "column like ?"
*
* Copy from the receiver -- legal if both are parameters,
* both will be max length.
* REMIND: should nullability be copied, or set to true?
*/
if (leftOperand.requiresTypeFromContext())
{
/*
* Set the pattern to the type of the left parameter, if
* the left is a string, otherwise set it to be VARCHAR.
*/
if (receiver.getTypeId().isStringTypeId())
{
leftOperand.setType(receiver.getTypeServices());
}
else
{
leftOperand.setType(
new DataTypeDescriptor(
TypeId.getBuiltInTypeId(Types.VARCHAR), true));
}
//collation of ? operand should be picked up from the context.
//By the time we come here, receiver will have correct collation
//set on it and hence we can rely on it to get correct collation
//for the other ? in LIKE clause
leftOperand.setCollationInfo(receiver.getTypeServices());
}
/*
* Is there a ? parameter for the ESCAPE of LIKE?
* Copy from the receiver -- legal if both are parameters,
* both will be max length. nullability is set to true.
*/
if (rightOperand != null && rightOperand.requiresTypeFromContext())
{
/*
* Set the pattern to the type of the left parameter, if
* the left is a string, otherwise set it to be VARCHAR.
*/
if (receiver.getTypeId().isStringTypeId())
{
rightOperand.setType(receiver.getTypeServices());
}
else
{
rightOperand.setType(
new DataTypeDescriptor(
TypeId.getBuiltInTypeId(Types.VARCHAR), true));
}
//collation of ? operand should be picked up from the context.
//By the time we come here, receiver will have correct collation
//set on it and hence we can rely on it to get correct collation