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