Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
849484e9
Unverified
提交
849484e9
authored
7月 29, 2018
作者:
Andrei Tokar
提交者:
GitHub
7月 29, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1334 from h2database/issue#1331
Force SYS_ID.ID index always to be a MVDelegateIndex
上级
a77075e0
0c9a16b0
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
52 行增加
和
0 行删除
+52
-0
Database.java
h2/src/main/org/h2/engine/Database.java
+49
-0
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+3
-0
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
849484e9
...
@@ -8,10 +8,13 @@ package org.h2.engine;
...
@@ -8,10 +8,13 @@ package org.h2.engine;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.BitSet
;
import
java.util.BitSet
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -36,6 +39,7 @@ import org.h2.jdbc.JdbcConnection;
...
@@ -36,6 +39,7 @@ import org.h2.jdbc.JdbcConnection;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceSystem
;
import
org.h2.message.TraceSystem
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.RowFactory
;
import
org.h2.result.RowFactory
;
...
@@ -783,6 +787,7 @@ public class Database implements DataHandler {
...
@@ -783,6 +787,7 @@ public class Database implements DataHandler {
data
.
isHidden
=
true
;
data
.
isHidden
=
true
;
data
.
session
=
systemSession
;
data
.
session
=
systemSession
;
meta
=
mainSchema
.
createTable
(
data
);
meta
=
mainSchema
.
createTable
(
data
);
handleUpgradeIssues
();
IndexColumn
[]
pkCols
=
IndexColumn
.
wrap
(
new
Column
[]
{
columnId
});
IndexColumn
[]
pkCols
=
IndexColumn
.
wrap
(
new
Column
[]
{
columnId
});
starting
=
true
;
starting
=
true
;
metaIdIndex
=
meta
.
addIndex
(
systemSession
,
"SYS_ID"
,
metaIdIndex
=
meta
.
addIndex
(
systemSession
,
"SYS_ID"
,
...
@@ -839,6 +844,50 @@ public class Database implements DataHandler {
...
@@ -839,6 +844,50 @@ public class Database implements DataHandler {
}
}
}
}
private
void
handleUpgradeIssues
()
{
if
(
mvStore
!=
null
&&
!
isReadOnly
())
{
MVStore
store
=
mvStore
.
getStore
();
// Version 1.4.197 erroneously handles index on SYS_ID.ID as secondary
// and does not delegate to scan index as it should.
// This code will try to fix that by converging ROW_ID and ID,
// since they may have got out of sync, and by removing map "index.0",
// which corresponds to a secondary index.
if
(
store
.
hasMap
(
"index.0"
))
{
Index
scanIndex
=
meta
.
getScanIndex
(
systemSession
);
Cursor
curs
=
scanIndex
.
find
(
systemSession
,
null
,
null
);
List
<
Row
>
allMetaRows
=
new
ArrayList
<>();
boolean
needRepair
=
false
;
while
(
curs
.
next
())
{
Row
row
=
curs
.
get
();
allMetaRows
.
add
(
row
);
long
rowId
=
row
.
getKey
();
int
id
=
row
.
getValue
(
0
).
getInt
();
if
(
id
!=
rowId
)
{
needRepair
=
true
;
row
.
setKey
(
id
);
}
}
if
(
needRepair
)
{
Row
[]
array
=
allMetaRows
.
toArray
(
new
Row
[
0
]);
Arrays
.
sort
(
array
,
new
Comparator
<
Row
>()
{
@Override
public
int
compare
(
Row
o1
,
Row
o2
)
{
return
Integer
.
compare
(
o1
.
getValue
(
0
).
getInt
(),
o2
.
getValue
(
0
).
getInt
());
}
});
meta
.
truncate
(
systemSession
);
for
(
Row
row
:
array
)
{
meta
.
addRow
(
systemSession
,
row
);
}
systemSession
.
commit
(
true
);
}
store
.
removeMap
(
"index.0"
);
store
.
commit
();
}
}
}
private
void
startServer
(
String
key
)
{
private
void
startServer
(
String
key
)
{
try
{
try
{
server
=
Server
.
createTcpServer
(
server
=
Server
.
createTcpServer
(
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
849484e9
...
@@ -499,12 +499,15 @@ public class MVTable extends TableBase {
...
@@ -499,12 +499,15 @@ public class MVTable extends TableBase {
int
mainIndexColumn
=
primaryIndex
.
getMainIndexColumn
()
!=
SearchRow
.
ROWID_INDEX
int
mainIndexColumn
=
primaryIndex
.
getMainIndexColumn
()
!=
SearchRow
.
ROWID_INDEX
?
SearchRow
.
ROWID_INDEX
:
getMainIndexColumn
(
indexType
,
cols
);
?
SearchRow
.
ROWID_INDEX
:
getMainIndexColumn
(
indexType
,
cols
);
if
(
database
.
isStarting
())
{
if
(
database
.
isStarting
())
{
// if index does exists as a separate map it can't be a delegate
if
(
transactionStore
.
hasMap
(
"index."
+
indexId
))
{
if
(
transactionStore
.
hasMap
(
"index."
+
indexId
))
{
// we can not reuse primary index
mainIndexColumn
=
SearchRow
.
ROWID_INDEX
;
mainIndexColumn
=
SearchRow
.
ROWID_INDEX
;
}
}
}
else
if
(
primaryIndex
.
getRowCountMax
()
!=
0
)
{
}
else
if
(
primaryIndex
.
getRowCountMax
()
!=
0
)
{
mainIndexColumn
=
SearchRow
.
ROWID_INDEX
;
mainIndexColumn
=
SearchRow
.
ROWID_INDEX
;
}
}
if
(
mainIndexColumn
!=
SearchRow
.
ROWID_INDEX
)
{
if
(
mainIndexColumn
!=
SearchRow
.
ROWID_INDEX
)
{
primaryIndex
.
setMainIndexColumn
(
mainIndexColumn
);
primaryIndex
.
setMainIndexColumn
(
mainIndexColumn
);
index
=
new
MVDelegateIndex
(
this
,
indexId
,
indexName
,
primaryIndex
,
index
=
new
MVDelegateIndex
(
this
,
indexId
,
indexName
,
primaryIndex
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论