提交 6909ba2d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix invokation of overriden function without a schema name

上级 7179b825
......@@ -2707,7 +2707,7 @@ public class Parser {
return orderList;
}
private JavaFunction readJavaFunction(Schema schema, String functionName) {
private JavaFunction readJavaFunction(Schema schema, String functionName, boolean throwIfNotFound) {
FunctionAlias functionAlias = null;
if (schema != null) {
functionAlias = schema.findFunction(functionName);
......@@ -2716,7 +2716,11 @@ public class Parser {
functionName);
}
if (functionAlias == null) {
if (throwIfNotFound) {
throw DbException.get(ErrorCode.FUNCTION_NOT_FOUND_1, functionName);
} else {
return null;
}
}
Expression[] args;
ArrayList<Expression> argList = New.arrayList();
......@@ -2761,7 +2765,14 @@ public class Parser {
private Expression readFunction(Schema schema, String name) {
if (schema != null) {
return readJavaFunction(schema, name);
return readJavaFunction(schema, name, true);
}
boolean allowOverride = database.isAllowBuiltinAliasOverride();
if (allowOverride) {
JavaFunction jf = readJavaFunction(null, name, false);
if (jf != null) {
return jf;
}
}
AggregateType agg = getAggregateType(name);
if (agg != null) {
......@@ -2773,7 +2784,10 @@ public class Parser {
if (aggregate != null) {
return readJavaAggregate(aggregate);
}
return readJavaFunction(null, name);
if (allowOverride) {
throw DbException.get(ErrorCode.FUNCTION_NOT_FOUND_1, name);
}
return readJavaFunction(null, name, true);
}
switch (function.getFunctionType()) {
case Function.CAST: {
......
......@@ -68,6 +68,12 @@ SET BUILTIN_ALIAS_OVERRIDE=1;
CREATE ALIAS TRUNC FOR "java.lang.Math.floor(double)";
> ok
SELECT TRUNC(1.5);
>> 1.0
SELECT TRUNC(-1.5);
>> -2.0
DROP ALIAS TRUNC;
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论