提交 116f4c3d authored 作者: Thomas Mueller's avatar Thomas Mueller

The function "regexp_replace" threw the wrong kind of exception if the…

The function "regexp_replace" threw the wrong kind of exception if the replacement string was invalid.
上级 f65cac4f
......@@ -1138,8 +1138,11 @@ public class Function extends Expression implements FunctionCall {
}
case REGEXP_REPLACE: {
String regexp = v1.getString();
String replacement = v2.getString();
try {
result = ValueString.get(v0.getString().replaceAll(regexp, v2.getString()));
result = ValueString.get(v0.getString().replaceAll(regexp, replacement));
} catch (StringIndexOutOfBoundsException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, replacement);
} catch (PatternSyntaxException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, regexp);
}
......
......@@ -4,6 +4,9 @@
-- Initial Developer: H2 Group
--
--- special grammar and test cases ---------------------------------------------------------------------------------------------
call regexp_replace('x', 'x', '\');
> exception
select * from dual where x = x + 1 or x in(2, 0);
> X
> -
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论