提交 fec189c4 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: unique indexes that were created later on did not work correctly if…

MVStore: unique indexes that were created later on did not work correctly if there were over 5000 rows in the table.
上级 2653329f
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>MVStore: creating secondary indexes on large tables
<ul><li>MVStore: unique indexes that were created later on did not work correctly
if there were over 5000 rows in the table.
</li><li>MVStore: creating secondary indexes on large tables
results in missing rows in the index.
</li><li>Metadata: the password of linked tables is now only visible for admin users.
</li><li>For Windows, database URLs of the form "jdbc:h2:/test" where considered
......
......@@ -123,11 +123,11 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
Value v = s.value;
if (indexType.isUnique()) {
ValueArray unique = (ValueArray) v;
Value[] array = unique.getList();
Value[] array = ((ValueArray) v).getList();
// don't change the original value
array = Arrays.copyOf(array, array.length);
unique = ValueArray.get(unique.getList());
unique.getList()[keyColumns - 1] = ValueLong.get(Long.MIN_VALUE);
array[keyColumns - 1] = ValueLong.get(Long.MIN_VALUE);
ValueArray unique = ValueArray.get(array);
ValueArray key = (ValueArray) dataMap.getLatestCeilingKey(unique);
if (key != null) {
SearchRow r2 = getRow(key.getList());
......
......@@ -49,6 +49,7 @@ public class TestMVTableEngine extends TestBase {
@Override
public void test() throws Exception {
testUniqueIndex();
testSecondaryIndex();
testGarbageCollectionForLOB();
testSpatial();
......@@ -77,6 +78,22 @@ public class TestMVTableEngine extends TestBase {
testSimple();
}
private void testUniqueIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test as select x, 0 from system_range(1, 5000)");
stat.execute("create unique index on test(x)");
ResultSet rs = stat.executeQuery("select * from test where x=1");
assertTrue(rs.next());
assertFalse(rs.next());
conn.close();
}
private void testSecondaryIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论