提交 87f9a57a authored 作者: Thomas Mueller's avatar Thomas Mueller

Unset parameters were not detected when the query was re-compiled.

上级 9fbe093a
......@@ -8,7 +8,6 @@ package org.h2.command;
import java.sql.SQLException;
import org.h2.expression.Expression;
import org.h2.expression.Parameter;
import org.h2.result.LocalResult;
import org.h2.util.ObjectArray;
......@@ -45,17 +44,20 @@ public class CommandContainer extends Command {
// TODO test with 'always recompile'
prepared.setModificationMetaId(0);
String sql = prepared.getSQL();
ObjectArray oldValues = prepared.getParameters();
ObjectArray oldParams = prepared.getParameters();
Parser parser = new Parser(session);
prepared = parser.parseOnly(sql);
long mod = prepared.getModificationMetaId();
prepared.setModificationMetaId(0);
ObjectArray newParams = prepared.getParameters();
for (int i = 0; i < newParams.size(); i++) {
Value v = ((Expression) oldValues.get(i)).getValue(session);
Parameter old = (Parameter) oldParams.get(i);
if (old.isValueSet()) {
Value v = old.getValue(session);
Parameter p = (Parameter) newParams.get(i);
p.setValue(v);
}
}
prepared.prepare();
prepared.setModificationMetaId(mod);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论