提交 375e5e52 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 378: when using views, the wrong values were bound to a parameter in some cases.

上级 b1c17566
......@@ -274,7 +274,7 @@ public class ViewIndex extends BaseIndex {
}
indexColumnCount++;
paramIndex.add(i);
if ((mask & IndexCondition.RANGE) == IndexCondition.RANGE) {
if (Integer.bitCount(mask) > 1) {
// two parameters for range queries: >= x AND <= y
paramIndex.add(i);
}
......@@ -289,17 +289,16 @@ public class ViewIndex extends BaseIndex {
Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.EQUAL_NULL_SAFE);
i++;
} else {
if ((mask & IndexCondition.START) == IndexCondition.START) {
Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL);
i++;
}
if ((mask & IndexCondition.END) == IndexCondition.END) {
Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL);
i++;
}
}
if ((mask & IndexCondition.START) == IndexCondition.START) {
Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL);
i++;
}
if ((mask & IndexCondition.END) == IndexCondition.END) {
Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.SMALLER_EQUAL);
i++;
}
}
columns = new Column[columnList.size()];
......
......@@ -38,6 +38,7 @@ public class TestCases extends TestBase {
}
public void test() throws Exception {
testViewParameters();
testLargeKeys();
testExtraSemicolonInDatabaseURL();
testGroupSubquery();
......@@ -98,6 +99,21 @@ public class TestCases extends TestBase {
deleteDb("cases");
}
private void testViewParameters() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
stat.execute(
"create view test as select 0 value, 'x' name from dual");
PreparedStatement prep = conn.prepareStatement(
"select 1 from test where name=? and value=? and value<=?");
prep.setString(1, "x");
prep.setInt(2, 0);
prep.setInt(3, 1);
prep.executeQuery();
conn.close();
}
private void testLargeKeys() throws SQLException {
if (config.memory) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论