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

--no commit message

--no commit message
上级 b3f0513a
......@@ -20,13 +20,20 @@ import org.h2.table.Table;
*/
public class AlterTableSet extends SchemaCommand {
/**
* Enable the referential integrity.
*/
public static final int REFERENTIAL_INTEGRITY_TRUE = 0;
/**
* Disable the referential integrity.
*/
public static final int REFERENTIAL_INTEGRITY_FALSE = 1;
private String tableName;
private final int type;
private boolean checkExisting;
public static final int REFERENTIAL_INTEGRITY_TRUE = 4;
public static final int REFERENTIAL_INTEGRITY_FALSE = 5;
public AlterTableSet(Session session, Schema schema, int type) {
super(session, schema);
this.type = type;
......
......@@ -135,6 +135,12 @@ public class BackupCommand extends Prepared {
return true;
}
/**
* Fix the file name, replacing backslash with slash.
*
* @param f the file name
* @return the corrected file name
*/
public static String correctFileName(String f) {
f = f.replace('\\', '/');
if (f.startsWith("/")) {
......
......@@ -32,6 +32,12 @@ public class ExecuteProcedure extends Prepared {
this.procedure = procedure;
}
/**
* Set the expression at the given index.
*
* @param index the index (0 based)
* @param expr the expression
*/
public void setExpression(int index, Expression expr) throws SQLException {
expressions.add(index, expr);
}
......
......@@ -181,7 +181,7 @@ public abstract class Query extends Prepared {
return true;
}
public final boolean sameResultAsLast(Session session, Value[] params, Value[] lastParams, long lastEvaluated)
private boolean sameResultAsLast(Session session, Value[] params, Value[] lastParams, long lastEvaluated)
throws SQLException {
Database db = session.getDatabase();
for (int i = 0; i < params.length; i++) {
......@@ -320,10 +320,17 @@ public abstract class Query extends Prepared {
}
}
public SortOrder prepareOrder(ObjectArray expressions, ObjectArray orderList) throws SQLException {
/**
* Create a {@link SortOrder} object given the list of {@link SelectOrderBy} objects.
* The expression list is extended if necessary.
*
* @param orderList a list of {@link SelectOrderBy} elements
* @param expressionCount the number of columns in the query
* @return the {@link SortOrder} object
*/
public SortOrder prepareOrder(ObjectArray orderList, int expressionCount) throws SQLException {
int[] index = new int[orderList.size()];
int[] sortType = new int[orderList.size()];
int originalLength = expressions.size();
for (int i = 0; i < orderList.size(); i++) {
SelectOrderBy o = (SelectOrderBy) orderList.get(i);
int idx;
......@@ -343,7 +350,7 @@ public abstract class Query extends Prepared {
idx = -idx;
}
idx -= 1;
if (idx < 0 || idx >= originalLength) {
if (idx < 0 || idx >= expressionCount) {
throw Message.getSQLException(ErrorCode.ORDER_BY_NOT_IN_RESULT, "" + (idx + 1));
}
}
......@@ -388,6 +395,12 @@ public abstract class Query extends Prepared {
return visitor.getMaxDataModificationId();
}
/**
* Visit all expressions and subqueries in this query using the visitor pattern.
*
* @param expressionVisitorType the visitor type
* @return true if no component returned false
*/
public final boolean isEverything(int expressionVisitorType) {
ExpressionVisitor visitor = ExpressionVisitor.get(expressionVisitorType);
return isEverything(visitor);
......
......@@ -80,6 +80,12 @@ public class Select extends Query {
super(session);
}
/**
* Add a table to the query.
*
* @param filter the table to add
* @param isTop if the table can be the first table in the query plan
*/
public void addTableFilter(TableFilter filter, boolean isTop) {
// TODO compatibility: it seems oracle doesn't check on
// duplicate aliases; do other databases check it?
......@@ -119,6 +125,11 @@ public class Select extends Query {
orderList = order;
}
/**
* Add a condition to the list of conditions.
*
* @param cond the condition to add
*/
public void addCondition(Expression cond) {
if (condition == null) {
condition = cond;
......@@ -658,7 +669,7 @@ public class Select extends Query {
throw Message.getInternalError("not initialized");
}
if (orderList != null) {
sort = prepareOrder(expressions, orderList);
sort = prepareOrder(orderList, expressions.size());
orderList = null;
}
for (int i = 0; i < expressions.size(); i++) {
......
......@@ -216,11 +216,11 @@ public class SelectUnion extends Query {
}
if (orderList != null) {
initOrder(expressions, null, orderList, getColumnCount(), true);
sort = prepareOrder(expressions, orderList);
sort = prepareOrder(orderList, expressions.size());
orderList = null;
}
}
public double getCost() {
return left.getCost() + right.getCost();
}
......
......@@ -105,7 +105,7 @@ public class LZFInputStream extends InputStream {
return read == 0 ? -1 : read;
}
public int readBlock(byte[] b, int off, int len) throws IOException {
private int readBlock(byte[] b, int off, int len) throws IOException {
fillBuffer();
if (pos >= bufferLength) {
return -1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论