提交 c6adedd3 authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation.

上级 37dddac6
...@@ -11,6 +11,7 @@ import java.sql.ResultSetMetaData; ...@@ -11,6 +11,7 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
...@@ -301,6 +302,7 @@ public abstract class Expression { ...@@ -301,6 +302,7 @@ public abstract class Expression {
/** /**
* If this expression consists of column expressions it should return them. * If this expression consists of column expressions it should return them.
* *
* @param session the session
* @return array of expression columns if applicable, null otherwise * @return array of expression columns if applicable, null otherwise
*/ */
public Expression[] getExpressionColumns(Session session) { public Expression[] getExpressionColumns(Session session) {
...@@ -332,9 +334,9 @@ public abstract class Expression { ...@@ -332,9 +334,9 @@ public abstract class Expression {
* @param session the session * @param session the session
* @param rs the result set * @param rs the result set
* @return an array of expression columns * @return an array of expression columns
* @throws SQLException
*/ */
public static Expression[] getExpressionColumns(Session session, ResultSet rs) throws SQLException { public static Expression[] getExpressionColumns(Session session, ResultSet rs) {
try {
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
int columnCount = meta.getColumnCount(); int columnCount = meta.getColumnCount();
Expression[] expressions = new Expression[columnCount]; Expression[] expressions = new Expression[columnCount];
...@@ -350,6 +352,9 @@ public abstract class Expression { ...@@ -350,6 +352,9 @@ public abstract class Expression {
expressions[i] = expr; expressions[i] = expr;
} }
return expressions; return expressions;
} catch (SQLException e) {
throw DbException.convert(e);
}
} }
} }
...@@ -6,13 +6,11 @@ ...@@ -6,13 +6,11 @@
*/ */
package org.h2.expression; package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.FunctionAlias; import org.h2.engine.FunctionAlias;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
...@@ -161,11 +159,7 @@ public class JavaFunction extends Expression implements FunctionCall { ...@@ -161,11 +159,7 @@ public class JavaFunction extends Expression implements FunctionCall {
switch (getType()) { switch (getType()) {
case Value.RESULT_SET: case Value.RESULT_SET:
ValueResultSet rs = getValueForColumnList(session, getArgs()); ValueResultSet rs = getValueForColumnList(session, getArgs());
try {
return getExpressionColumns(session, rs.getResultSet()); return getExpressionColumns(session, rs.getResultSet());
} catch (SQLException e) {
throw DbException.convert(e);
}
case Value.ARRAY: case Value.ARRAY:
return getExpressionColumns(session, (ValueArray) getValue(session)); return getExpressionColumns(session, (ValueArray) getValue(session));
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
package org.h2.expression; package org.h2.expression;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.engine.Database; import org.h2.engine.Database;
...@@ -150,10 +149,7 @@ public class TableFunction extends Function { ...@@ -150,10 +149,7 @@ public class TableFunction extends Function {
} }
public Expression[] getExpressionColumns(Session session) { public Expression[] getExpressionColumns(Session session) {
try {
return getExpressionColumns(session, getTable(session, getArgs(), true, false).getResultSet()); return getExpressionColumns(session, getTable(session, getArgs(), true, false).getResultSet());
} catch (SQLException e) {
throw DbException.convert(e);
}
} }
} }
...@@ -100,12 +100,21 @@ public class TestCallableStatement extends TestBase { ...@@ -100,12 +100,21 @@ public class TestCallableStatement extends TestBase {
} }
} }
public static ResultSet testCall(Connection connect, int a, String b, Timestamp c) throws SQLException { /**
* This method is called via reflection from the database.
*
* @param conn the connection
* @param a the value a
* @param b the value b
* @param c the value c
* @return a result set
*/
public static ResultSet testCall(Connection conn, int a, String b, Timestamp c) throws SQLException {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("A", Types.INTEGER, 0, 0); rs.addColumn("A", Types.INTEGER, 0, 0);
rs.addColumn("B", Types.VARCHAR, 0, 0); rs.addColumn("B", Types.VARCHAR, 0, 0);
rs.addColumn("C", Types.TIMESTAMP, 0, 0); rs.addColumn("C", Types.TIMESTAMP, 0, 0);
if ("jdbc:columnlist:connection".equals(connect.getMetaData().getURL())) { if ("jdbc:columnlist:connection".equals(conn.getMetaData().getURL())) {
return rs; return rs;
} }
rs.addRow(a * 2, b.toUpperCase(), new Timestamp(c.getTime() + 1)); rs.addRow(a * 2, b.toUpperCase(), new Timestamp(c.getTime() + 1));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论