提交 1294a060 authored 作者: noelgrandin's avatar noelgrandin

Fix bug in varags support in ALIAS's, patch from Nicolas Fortin

上级 fe593d24
......@@ -57,10 +57,10 @@ public class FunctionTable extends Table {
throw DbException.get(
ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1, function.getName());
}
int params = function.getParameterCount();
Expression[] columnListArgs = new Expression[params];
Expression[] args = function.getArgs();
for (int i = 0; i < params; i++) {
int numParams = args.length;
Expression[] columnListArgs = new Expression[numParams];
for (int i = 0; i < numParams; i++) {
args[i] = args[i].optimize(session);
columnListArgs[i] = args[i];
}
......
......@@ -66,6 +66,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb("functions");
testVersion();
testFunctionTable();
testFunctionTableVarArgs();
testArrayParameters();
testDefaultConnection();
testFunctionInSchema();
......@@ -123,6 +124,20 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn.close();
}
private void testFunctionTableVarArgs() throws SQLException {
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
stat.execute("create alias varargs_function_table for \"" + TestFunctions.class.getName()
+ ".varArgsFunctionTable\"");
ResultSet rs = stat.executeQuery("select * from varargs_function_table(1,2,3,5,8,13)");
for (int i : new int[] { 1, 2, 3, 5, 8, 13 }) {
assertTrue(rs.next());
assertEquals(i, rs.getInt(1));
}
assertFalse(rs.next());
conn.close();
}
/**
* This method is called via reflection from the database.
*
......@@ -137,6 +152,23 @@ public class TestFunctions extends TestBase implements AggregateFunction {
return result;
}
/**
* This method is called via reflection from the database.
*
* @return a result set
*/
public static ResultSet varArgsFunctionTable(int... values) throws SQLException {
if (values.length != 6) {
throw new SQLException("Unexpected argument count");
}
SimpleResultSet result = new SimpleResultSet();
result.addColumn("A", Types.INTEGER, 0, 0);
for (int value : values) {
result.addRow(value);
}
return result;
}
private void testNvl2() throws SQLException {
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论