LikeType likeType = (LikeType)context.preptimeObjectAt(TYPE_INDEX);
if (likeType == null)
likeType = this.likeType;
// Get the cached matcher from prepare time.
Matcher matcher = (Matcher) context.preptimeObjectAt(MATCHER_INDEX);
if (matcher == null) {
String right = inputs.get(1).getString();
char esca = '\\';
if (inputs.size() == 3)
{
String escapeString = inputs.get(2).getString();
if (escapeString.length() != 1)
throw new InvalidParameterValueException("Invalid escape character: " + escapeString);
esca = escapeString.charAt(0);
}
// Get the cached matcher from execute time.
matcher = (Matcher) context.exectimeObjectAt(MATCHER_INDEX);
if (matcher == null || !matcher.sameState(right, esca))
{
matcher = Matchers.getMatcher(right, esca, likeType == LikeType.ILIKE);
context.putExectimeObject(MATCHER_INDEX, matcher);
}
}
String left = inputs.get(0).getString();
try
{
output.putBool(matcher.matches(left));
}
catch (InvalidOperationException e)
{
context.warnClient(e);
output.putNull();