提交 a1fae401 authored 作者: Andrew Brock's avatar Andrew Brock

Create local variable for whether we're in PostgreSQL mode, remove…

Create local variable for whether we're in PostgreSQL mode, remove implementation details from doco, add compiler/IDE hint for falling-through switch statement
上级 4a2eb9f4
......@@ -954,7 +954,7 @@ or the SQL statement <code>SET MODE PostgreSQL</code>.
<ul>
<li>Uses \ for back-references</li>
<li>Will not throw an exception when the <code>flagsString</code> parameter contains a 'g'</li>
<li>Will use Java's <code>String.replaceFirst()</code> method (instead of <code>String.replaceAll()</code>) if the 'g' flag is not present in the <code>flagsString</code> parameter.</li>
<li>In the absence of the 'g' flag in the <code>flagsString</code> parameter, only the first-matched substring will be replaced</li>
</ul>
</li><li>Fixed-width strings are padded with spaces.
</li><li>MONEY data type is treated like NUMERIC(19, 2) data type.
......
......@@ -1370,9 +1370,10 @@ public class Function extends Expression implements FunctionCall {
}
String regexpMode = v3 == null || v3.getString() == null ? "" :
v3.getString();
int flags = makeRegexpFlags(regexpMode, Mode.ModeEnum.PostgreSQL.equals(database.getMode().getEnum()));
boolean isInPostgreSqlMode = Mode.ModeEnum.PostgreSQL.equals(database.getMode().getEnum())
int flags = makeRegexpFlags(regexpMode, isInPostgreSqlMode);
try {
if(Mode.ModeEnum.PostgreSQL.equals(database.getMode().getEnum()) && !regexpMode.contains("g")) {
if(isInPostgreSqlMode && !regexpMode.contains("g")) {
result = ValueString.get(
Pattern.compile(regexp, flags).matcher(v0.getString())
.replaceFirst(replacement),
......@@ -2060,6 +2061,7 @@ public class Function extends Expression implements FunctionCall {
if (ignoreGlobalFlag) {
break;
}
//$FALL-THROUGH$
default:
throw DbException.get(ErrorCode.INVALID_VALUE_2, stringFlags);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论