提交 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 { ...@@ -274,7 +274,7 @@ public class ViewIndex extends BaseIndex {
} }
indexColumnCount++; indexColumnCount++;
paramIndex.add(i); paramIndex.add(i);
if ((mask & IndexCondition.RANGE) == IndexCondition.RANGE) { if (Integer.bitCount(mask) > 1) {
// two parameters for range queries: >= x AND <= y // two parameters for range queries: >= x AND <= y
paramIndex.add(i); paramIndex.add(i);
} }
...@@ -289,7 +289,7 @@ public class ViewIndex extends BaseIndex { ...@@ -289,7 +289,7 @@ public class ViewIndex extends BaseIndex {
Parameter param = new Parameter(firstIndexParam + i); Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.EQUAL_NULL_SAFE); q.addGlobalCondition(param, idx, Comparison.EQUAL_NULL_SAFE);
i++; i++;
} else { }
if ((mask & IndexCondition.START) == IndexCondition.START) { if ((mask & IndexCondition.START) == IndexCondition.START) {
Parameter param = new Parameter(firstIndexParam + i); Parameter param = new Parameter(firstIndexParam + i);
q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL); q.addGlobalCondition(param, idx, Comparison.BIGGER_EQUAL);
...@@ -301,7 +301,6 @@ public class ViewIndex extends BaseIndex { ...@@ -301,7 +301,6 @@ public class ViewIndex extends BaseIndex {
i++; i++;
} }
} }
}
columns = new Column[columnList.size()]; columns = new Column[columnList.size()];
columnList.toArray(columns); columnList.toArray(columns);
......
...@@ -38,6 +38,7 @@ public class TestCases extends TestBase { ...@@ -38,6 +38,7 @@ public class TestCases extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testViewParameters();
testLargeKeys(); testLargeKeys();
testExtraSemicolonInDatabaseURL(); testExtraSemicolonInDatabaseURL();
testGroupSubquery(); testGroupSubquery();
...@@ -98,6 +99,21 @@ public class TestCases extends TestBase { ...@@ -98,6 +99,21 @@ public class TestCases extends TestBase {
deleteDb("cases"); 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 { private void testLargeKeys() throws SQLException {
if (config.memory) { if (config.memory) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论