提交 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 { ...@@ -1138,8 +1138,11 @@ public class Function extends Expression implements FunctionCall {
} }
case REGEXP_REPLACE: { case REGEXP_REPLACE: {
String regexp = v1.getString(); String regexp = v1.getString();
String replacement = v2.getString();
try { 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) { } catch (PatternSyntaxException e) {
throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, regexp); throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, e, regexp);
} }
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- special grammar and test cases ---------------------------------------------------------------------------------------------
call regexp_replace('x', 'x', '\');
> exception
select * from dual where x = x + 1 or x in(2, 0); select * from dual where x = x + 1 or x in(2, 0);
> X > X
> - > -
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论