提交 6ac4d3c8 authored 作者: andrei's avatar andrei

IndexCursor inList

上级 e0619d3a
...@@ -148,6 +148,9 @@ public class IndexCursor implements Cursor { ...@@ -148,6 +148,9 @@ public class IndexCursor implements Cursor {
} }
} }
} }
if (inColumn != null) {
start = table.getTemplateRow();
}
} }
/** /**
...@@ -326,7 +329,6 @@ public class IndexCursor implements Cursor { ...@@ -326,7 +329,6 @@ public class IndexCursor implements Cursor {
while (inResult.next()) { while (inResult.next()) {
Value v = inResult.currentRow()[0]; Value v = inResult.currentRow()[0];
if (v != ValueNull.INSTANCE) { if (v != ValueNull.INSTANCE) {
v = inColumn.convert(v);
if (inResultTested == null) { if (inResultTested == null) {
inResultTested = new HashSet<>(); inResultTested = new HashSet<>();
} }
...@@ -342,9 +344,6 @@ public class IndexCursor implements Cursor { ...@@ -342,9 +344,6 @@ public class IndexCursor implements Cursor {
private void find(Value v) { private void find(Value v) {
v = inColumn.convert(v); v = inColumn.convert(v);
int id = inColumn.getColumnId(); int id = inColumn.getColumnId();
if (start == null) {
start = table.getTemplateRow();
}
start.setValue(id, v); start.setValue(id, v);
cursor = index.find(tableFilter, start, start); cursor = index.find(tableFilter, start, start);
} }
......
...@@ -10,6 +10,7 @@ import java.sql.PreparedStatement; ...@@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
...@@ -107,33 +108,37 @@ public class TestFuzzOptimizations extends TestBase { ...@@ -107,33 +108,37 @@ public class TestFuzzOptimizations extends TestBase {
ArrayList<String> params = New.arrayList(); ArrayList<String> params = New.arrayList();
String condition = getRandomCondition(random, params, columns, String condition = getRandomCondition(random, params, columns,
compares, values); compares, values);
// System.out.println(condition + " " + params); String message = "seed: " + seed + " " + condition;
PreparedStatement prep0 = conn.prepareStatement( executeAndCompare(condition, params, message);
"select * from test0 where " + condition
+ " order by 1, 2, 3");
PreparedStatement prep1 = conn.prepareStatement(
"select * from test1 where " + condition
+ " order by 1, 2, 3");
for (int j = 0; j < params.size(); j++) {
prep0.setString(j + 1, params.get(j));
prep1.setString(j + 1, params.get(j));
}
ResultSet rs0 = prep0.executeQuery();
ResultSet rs1 = prep1.executeQuery();
assertEquals("seed: " + seed + " " + condition, rs0, rs1);
if (params.size() > 0) { if (params.size() > 0) {
for (int j = 0; j < params.size(); j++) { for (int j = 0; j < params.size(); j++) {
String value = values[random.nextInt(values.length - 2)]; String value = values[random.nextInt(values.length - 2)];
params.set(j, value); params.set(j, value);
prep0.setString(j + 1, value);
prep1.setString(j + 1, value);
} }
assertEquals("seed: " + seed + " " + condition, rs0, rs1); executeAndCompare(condition, params, message);
} }
} }
executeAndCompare("a >=0 and b in(?, 2) and a in(1, ?, null)", Arrays.asList("10", "2"),
"seed=-6191135606105920350L");
db.execute("drop table test0, test1"); db.execute("drop table test0, test1");
} }
private void executeAndCompare(String condition, List<String> params, String message) throws SQLException {
PreparedStatement prep0 = conn.prepareStatement(
"select * from test0 where " + condition
+ " order by 1, 2, 3");
PreparedStatement prep1 = conn.prepareStatement(
"select * from test1 where " + condition
+ " order by 1, 2, 3");
for (int j = 0; j < params.size(); j++) {
prep0.setString(j + 1, params.get(j));
prep1.setString(j + 1, params.get(j));
}
ResultSet rs0 = prep0.executeQuery();
ResultSet rs1 = prep1.executeQuery();
assertEquals(message, rs0, rs1);
}
private String getRandomCondition(Random random, ArrayList<String> params, private String getRandomCondition(Random random, ArrayList<String> params,
String[] columns, String[] compares, String[] values) { String[] columns, String[] compares, String[] values) {
int comp = 1 + random.nextInt(4); int comp = 1 + random.nextInt(4);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论