Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
91926786
提交
91926786
authored
4月 09, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting / javadocs
上级
d95318e6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
28 个修改的文件
包含
348 行增加
和
277 行删除
+348
-277
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-2
SetTypes.java
h2/src/main/org/h2/command/dml/SetTypes.java
+1
-1
Mode.java
h2/src/main/org/h2/engine/Mode.java
+2
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+6
-3
Index.java
h2/src/main/org/h2/index/Index.java
+1
-0
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+1
-1
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+1
-1
FreeSpaceList.java
h2/src/main/org/h2/mvstore/FreeSpaceList.java
+208
-208
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+6
-6
Page.java
h2/src/main/org/h2/mvstore/Page.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+2
-2
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+1
-1
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+72
-14
Table.java
h2/src/main/org/h2/table/Table.java
+1
-0
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+1
-1
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+9
-6
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-1
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+4
-4
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+1
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+7
-7
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+10
-5
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+3
-3
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+2
-2
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
91926786
...
@@ -4718,7 +4718,7 @@ public class Parser {
...
@@ -4718,7 +4718,7 @@ public class Parser {
}
}
throw
DbException
.
getInvalidValueException
(
"BINARY_COLLATION"
,
name
);
throw
DbException
.
getInvalidValueException
(
"BINARY_COLLATION"
,
name
);
}
}
private
RunScriptCommand
parseRunScript
()
{
private
RunScriptCommand
parseRunScript
()
{
RunScriptCommand
command
=
new
RunScriptCommand
(
session
);
RunScriptCommand
command
=
new
RunScriptCommand
(
session
);
read
(
"FROM"
);
read
(
"FROM"
);
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
91926786
...
@@ -1273,8 +1273,8 @@ public class Select extends Query {
...
@@ -1273,8 +1273,8 @@ public class Select extends Query {
return
false
;
return
false
;
}
}
public
SortOrder
prepare
Order
()
{
public
SortOrder
getSort
Order
()
{
return
sort
;
return
sort
;
}
}
}
}
h2/src/main/org/h2/command/dml/SetTypes.java
浏览文件 @
91926786
...
@@ -203,7 +203,7 @@ public class SetTypes {
...
@@ -203,7 +203,7 @@ public class SetTypes {
* The type of a SET BINARY_COLLATION statement.
* The type of a SET BINARY_COLLATION statement.
*/
*/
public
static
final
int
BINARY_COLLATION
=
38
;
public
static
final
int
BINARY_COLLATION
=
38
;
private
static
final
ArrayList
<
String
>
TYPES
=
New
.
arrayList
();
private
static
final
ArrayList
<
String
>
TYPES
=
New
.
arrayList
();
private
SetTypes
()
{
private
SetTypes
()
{
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
91926786
...
@@ -112,12 +112,12 @@ public class Mode {
...
@@ -112,12 +112,12 @@ public class Mode {
* The function LOG() uses base 10 instead of E.
* The function LOG() uses base 10 instead of E.
*/
*/
public
boolean
logIsLogBase10
;
public
boolean
logIsLogBase10
;
/**
/**
* SERIAL and BIGSERIAL columns are not automatically primary keys.
* SERIAL and BIGSERIAL columns are not automatically primary keys.
*/
*/
public
boolean
serialColumnIsNotPK
;
public
boolean
serialColumnIsNotPK
;
/**
/**
* Swap the parameters of the CONVERT function.
* Swap the parameters of the CONVERT function.
*/
*/
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
91926786
...
@@ -242,7 +242,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -242,7 +242,7 @@ public class Function extends Expression implements FunctionCall {
// 2 or 3 arguments
// 2 or 3 arguments
addFunction
(
"LOCATE"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"LOCATE"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
// alias for MSSQLServer
// alias for MSSQLServer
addFunction
(
"CHARINDEX"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"CHARINDEX"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
// same as LOCATE with 2 arguments
// same as LOCATE with 2 arguments
addFunction
(
"POSITION"
,
LOCATE
,
2
,
Value
.
INT
);
addFunction
(
"POSITION"
,
LOCATE
,
2
,
Value
.
INT
);
addFunction
(
"INSTR"
,
INSTR
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"INSTR"
,
INSTR
,
VAR_ARGS
,
Value
.
INT
);
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
91926786
...
@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*
*
* @param masks the search mask
* @param masks the search mask
* @param rowCount the number of rows in the index
* @param rowCount the number of rows in the index
* @param sortOrder the sort order
* @return the estimated cost
* @return the estimated cost
*/
*/
protected
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
SortOrder
sortOrder
)
{
protected
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
SortOrder
sortOrder
)
{
...
@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
break
;
break
;
}
}
}
}
//
If the query ORDER BY clause matches the ordering of this index, it will be cheaper
//
if the ORDER BY clause matches the ordering of this index,
//
than another index, so adjust the cost accordingly.
//
it will be cheaper than another index, so adjust the cost accordingly
if
(
sortOrder
!=
null
)
{
if
(
sortOrder
!=
null
)
{
int
[]
columnIndexes
=
new
int
[
indexColumns
.
length
];
int
[]
columnIndexes
=
new
int
[
indexColumns
.
length
];
int
[]
columnSortTypes
=
new
int
[
indexColumns
.
length
];
int
[]
columnSortTypes
=
new
int
[
indexColumns
.
length
];
...
@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
coveringCount
++;
coveringCount
++;
}
}
if
(
sortOrderMatches
)
{
if
(
sortOrderMatches
)
{
// "coveringCount" makes sure that when we have two or more covering indexes, we choose the one that covers more
// "coveringCount" makes sure that when we have two
// or more covering indexes, we choose the one
// that covers more
cost
-=
coveringCount
;
cost
-=
coveringCount
;
}
}
}
}
...
...
h2/src/main/org/h2/index/Index.java
浏览文件 @
91926786
...
@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
...
@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
* @param session the session
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the estimated cost
* @return the estimated cost
*/
*/
double
getCost
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
);
double
getCost
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
);
...
...
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
91926786
...
@@ -45,7 +45,7 @@ public class Chunk {
...
@@ -45,7 +45,7 @@ public class Chunk {
* The total number of pages in this chunk.
* The total number of pages in this chunk.
*/
*/
int
pageCount
;
int
pageCount
;
/**
/**
* The number of pages still alive.
* The number of pages still alive.
*/
*/
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
91926786
...
@@ -352,7 +352,7 @@ public class DataUtils {
...
@@ -352,7 +352,7 @@ public class DataUtils {
file
,
src
.
remaining
(),
pos
,
e
);
file
,
src
.
remaining
(),
pos
,
e
);
}
}
}
}
/**
/**
* Convert the length to a length code 0..31. 31 means more than 1 MB.
* Convert the length to a length code 0..31. 31 means more than 1 MB.
*
*
...
...
h2/src/main/org/h2/mvstore/FreeSpaceList.java
浏览文件 @
91926786
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
91926786
...
@@ -1176,7 +1176,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1176,7 +1176,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
keyType
=
keyType
;
this
.
keyType
=
keyType
;
return
this
;
return
this
;
}
}
public
DataType
getKeyType
()
{
public
DataType
getKeyType
()
{
return
keyType
;
return
keyType
;
}
}
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
91926786
...
@@ -868,7 +868,7 @@ public class MVStore {
...
@@ -868,7 +868,7 @@ public class MVStore {
}
else
{
}
else
{
meta
.
put
(
"root."
+
m
.
getId
(),
String
.
valueOf
(
Integer
.
MAX_VALUE
));
meta
.
put
(
"root."
+
m
.
getId
(),
String
.
valueOf
(
Integer
.
MAX_VALUE
));
}
}
}
}
Set
<
Chunk
>
removedChunks
=
applyFreedPages
(
storeVersion
,
time
);
Set
<
Chunk
>
removedChunks
=
applyFreedPages
(
storeVersion
,
time
);
ByteBuffer
buff
;
ByteBuffer
buff
;
if
(
writeBuffer
!=
null
)
{
if
(
writeBuffer
!=
null
)
{
...
@@ -947,15 +947,15 @@ public class MVStore {
...
@@ -947,15 +947,15 @@ public class MVStore {
writeFileHeader
();
writeFileHeader
();
shrinkFileIfPossible
(
1
);
shrinkFileIfPossible
(
1
);
}
}
for
(
MVMap
<?,
?>
m
:
changed
)
{
for
(
MVMap
<?,
?>
m
:
changed
)
{
Page
p
=
m
.
getRoot
();
Page
p
=
m
.
getRoot
();
if
(
p
.
getTotalCount
()
>
0
)
{
if
(
p
.
getTotalCount
()
>
0
)
{
p
.
writeEnd
();
p
.
writeEnd
();
}
}
}
}
meta
.
getRoot
().
writeEnd
();
meta
.
getRoot
().
writeEnd
();
// some pages might have been changed in the meantime (in the newest version)
// some pages might have been changed in the meantime (in the newest version)
unsavedPageCount
=
Math
.
max
(
0
,
unsavedPageCount
-
currentUnsavedPageCount
);
unsavedPageCount
=
Math
.
max
(
0
,
unsavedPageCount
-
currentUnsavedPageCount
);
currentStoreVersion
=
-
1
;
currentStoreVersion
=
-
1
;
...
@@ -1297,7 +1297,7 @@ public class MVStore {
...
@@ -1297,7 +1297,7 @@ public class MVStore {
}
}
registerFreePage
(
version
,
c
.
id
,
DataUtils
.
getPageMaxLength
(
pos
),
1
);
registerFreePage
(
version
,
c
.
id
,
DataUtils
.
getPageMaxLength
(
pos
),
1
);
}
}
private
void
registerFreePage
(
long
version
,
int
chunkId
,
long
maxLengthLive
,
int
pageCount
)
{
private
void
registerFreePage
(
long
version
,
int
chunkId
,
long
maxLengthLive
,
int
pageCount
)
{
synchronized
(
freedPages
)
{
synchronized
(
freedPages
)
{
HashMap
<
Integer
,
Chunk
>
freed
=
freedPages
.
get
(
version
);
HashMap
<
Integer
,
Chunk
>
freed
=
freedPages
.
get
(
version
);
...
@@ -1736,7 +1736,7 @@ public class MVStore {
...
@@ -1736,7 +1736,7 @@ public class MVStore {
}
}
store
(
true
);
store
(
true
);
}
}
public
boolean
isReadOnly
()
{
public
boolean
isReadOnly
()
{
return
readOnly
;
return
readOnly
;
}
}
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
91926786
...
@@ -852,7 +852,7 @@ public class Page {
...
@@ -852,7 +852,7 @@ public class Page {
}
}
return
write
(
chunk
,
buff
);
return
write
(
chunk
,
buff
);
}
}
/**
/**
* Unlink the children recursively after all data is written.
* Unlink the children recursively after all data is written.
*/
*/
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
91926786
...
@@ -218,7 +218,7 @@ public class MVPrimaryIndex extends BaseIndex {
...
@@ -218,7 +218,7 @@ public class MVPrimaryIndex extends BaseIndex {
return
new
MVStoreCursor
(
session
,
Collections
.<
Value
>
emptyList
().
iterator
(),
0
);
return
new
MVStoreCursor
(
session
,
Collections
.<
Value
>
emptyList
().
iterator
(),
0
);
}
}
long
key
=
first
?
map
.
firstKey
().
getLong
()
:
map
.
lastKey
().
getLong
();
long
key
=
first
?
map
.
firstKey
().
getLong
()
:
map
.
lastKey
().
getLong
();
MVStoreCursor
cursor
=
new
MVStoreCursor
(
session
,
MVStoreCursor
cursor
=
new
MVStoreCursor
(
session
,
Arrays
.
asList
((
Value
)
ValueLong
.
get
(
key
)).
iterator
(),
key
);
Arrays
.
asList
((
Value
)
ValueLong
.
get
(
key
)).
iterator
(),
key
);
cursor
.
next
();
cursor
.
next
();
return
cursor
;
return
cursor
;
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
91926786
...
@@ -520,7 +520,7 @@ public class MVTable extends TableBase {
...
@@ -520,7 +520,7 @@ public class MVTable extends TableBase {
rowCount
=
0
;
rowCount
=
0
;
changesSinceAnalyze
=
0
;
changesSinceAnalyze
=
0
;
}
}
@Override
@Override
public
void
addRow
(
Session
session
,
Row
row
)
{
public
void
addRow
(
Session
session
,
Row
row
)
{
lastModificationId
=
database
.
getNextModificationDataId
();
lastModificationId
=
database
.
getNextModificationDataId
();
...
@@ -701,7 +701,7 @@ public class MVTable extends TableBase {
...
@@ -701,7 +701,7 @@ public class MVTable extends TableBase {
public
String
toString
()
{
public
String
toString
()
{
return
getSQL
();
return
getSQL
();
}
}
public
boolean
isMVStore
()
{
public
boolean
isMVStore
()
{
return
true
;
return
true
;
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
91926786
...
@@ -147,7 +147,7 @@ public class MVTableEngine implements TableEngine {
...
@@ -147,7 +147,7 @@ public class MVTableEngine implements TableEngine {
public
Store
(
Database
db
,
MVStore
store
)
{
public
Store
(
Database
db
,
MVStore
store
)
{
this
.
db
=
db
;
this
.
db
=
db
;
this
.
store
=
store
;
this
.
store
=
store
;
this
.
transactionStore
=
new
TransactionStore
(
store
,
this
.
transactionStore
=
new
TransactionStore
(
store
,
new
ValueDataType
(
null
,
null
,
null
));
new
ValueDataType
(
null
,
null
,
null
));
}
}
...
...
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
91926786
...
@@ -75,7 +75,7 @@ public class TransactionStore {
...
@@ -75,7 +75,7 @@ public class TransactionStore {
public
TransactionStore
(
MVStore
store
)
{
public
TransactionStore
(
MVStore
store
)
{
this
(
store
,
new
ObjectDataType
());
this
(
store
,
new
ObjectDataType
());
}
}
/**
/**
* Create a new transaction store.
* Create a new transaction store.
*
*
...
@@ -92,7 +92,7 @@ public class TransactionStore {
...
@@ -92,7 +92,7 @@ public class TransactionStore {
ArrayType
valueType
=
new
ArrayType
(
new
DataType
[]{
ArrayType
valueType
=
new
ArrayType
(
new
DataType
[]{
new
ObjectDataType
(),
new
ObjectDataType
(),
keyType
new
ObjectDataType
(),
new
ObjectDataType
(),
keyType
});
});
MVMapConcurrent
.
Builder
<
long
[],
Object
[]>
builder
=
MVMapConcurrent
.
Builder
<
long
[],
Object
[]>
builder
=
new
MVMapConcurrent
.
Builder
<
long
[],
Object
[]>().
new
MVMapConcurrent
.
Builder
<
long
[],
Object
[]>().
valueType
(
valueType
);
valueType
(
valueType
);
// TODO escape other map names, to avoid conflicts
// TODO escape other map names, to avoid conflicts
...
@@ -129,7 +129,7 @@ public class TransactionStore {
...
@@ -129,7 +129,7 @@ public class TransactionStore {
/**
/**
* Get the list of currently open transactions that have pending writes.
* Get the list of currently open transactions that have pending writes.
*
*
* @return the list of transactions
* @return the list of transactions
*/
*/
public
synchronized
List
<
Transaction
>
getOpenTransactions
()
{
public
synchronized
List
<
Transaction
>
getOpenTransactions
()
{
...
@@ -158,8 +158,8 @@ public class TransactionStore {
...
@@ -158,8 +158,8 @@ public class TransactionStore {
int
status
=
Transaction
.
STATUS_OPEN
;
int
status
=
Transaction
.
STATUS_OPEN
;
return
new
Transaction
(
this
,
transactionId
,
status
,
null
,
0
);
return
new
Transaction
(
this
,
transactionId
,
status
,
null
,
0
);
}
}
void
storeTransaction
(
Transaction
t
)
{
private
void
storeTransaction
(
Transaction
t
)
{
long
transactionId
=
t
.
getId
();
long
transactionId
=
t
.
getId
();
if
(
openTransactions
.
containsKey
(
transactionId
))
{
if
(
openTransactions
.
containsKey
(
transactionId
))
{
return
;
return
;
...
@@ -185,10 +185,10 @@ public class TransactionStore {
...
@@ -185,10 +185,10 @@ public class TransactionStore {
openTransactions
.
put
(
t
.
getId
(),
v
);
openTransactions
.
put
(
t
.
getId
(),
v
);
store
.
commit
();
store
.
commit
();
}
}
/**
/**
* Log an entry.
* Log an entry.
*
*
* @param t the transaction
* @param t the transaction
* @param logId the log id
* @param logId the log id
* @param opType the operation type
* @param opType the operation type
...
@@ -345,7 +345,7 @@ public class TransactionStore {
...
@@ -345,7 +345,7 @@ public class TransactionStore {
* The transaction store.
* The transaction store.
*/
*/
final
TransactionStore
store
;
final
TransactionStore
store
;
/**
/**
* The version of the store at the time the transaction was started.
* The version of the store at the time the transaction was started.
*/
*/
...
@@ -454,7 +454,7 @@ public class TransactionStore {
...
@@ -454,7 +454,7 @@ public class TransactionStore {
*/
*/
public
<
K
,
V
>
TransactionMap
<
K
,
V
>
openMap
(
String
name
,
long
readVersion
)
{
public
<
K
,
V
>
TransactionMap
<
K
,
V
>
openMap
(
String
name
,
long
readVersion
)
{
checkOpen
();
checkOpen
();
return
new
TransactionMap
<
K
,
V
>(
this
,
name
,
new
ObjectDataType
(),
return
new
TransactionMap
<
K
,
V
>(
this
,
name
,
new
ObjectDataType
(),
new
ObjectDataType
(),
readVersion
);
new
ObjectDataType
(),
readVersion
);
}
}
...
@@ -569,7 +569,7 @@ public class TransactionStore {
...
@@ -569,7 +569,7 @@ public class TransactionStore {
*/
*/
private
final
MVMap
<
K
,
Object
[]>
mapRead
;
private
final
MVMap
<
K
,
Object
[]>
mapRead
;
TransactionMap
(
Transaction
transaction
,
String
name
,
DataType
keyType
,
TransactionMap
(
Transaction
transaction
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
readVersion
)
{
DataType
valueType
,
long
readVersion
)
{
this
.
transaction
=
transaction
;
this
.
transaction
=
transaction
;
ArrayType
arrayType
=
new
ArrayType
(
new
DataType
[]
{
ArrayType
arrayType
=
new
ArrayType
(
new
DataType
[]
{
...
@@ -811,7 +811,13 @@ public class TransactionStore {
...
@@ -811,7 +811,13 @@ public class TransactionStore {
public
V
getLatest
(
K
key
)
{
public
V
getLatest
(
K
key
)
{
return
get
(
key
,
mapWrite
);
return
get
(
key
,
mapWrite
);
}
}
/**
* Whether the map contains the key.
*
* @param key the key
* @return true if the map contains an entry for this key
*/
public
boolean
containsKey
(
K
key
)
{
public
boolean
containsKey
(
K
key
)
{
return
get
(
key
)
!=
null
;
return
get
(
key
)
!=
null
;
}
}
...
@@ -855,50 +861,102 @@ public class TransactionStore {
...
@@ -855,50 +861,102 @@ public class TransactionStore {
}
}
}
}
/**
* Rename the map.
*
* @param newMapName the new map name
*/
public
void
renameMap
(
String
newMapName
)
{
public
void
renameMap
(
String
newMapName
)
{
// TODO rename maps transactionally
// TODO rename maps transactionally
mapWrite
.
renameMap
(
newMapName
);
mapWrite
.
renameMap
(
newMapName
);
}
}
/**
* Check whether this map is closed.
*
* @return true if closed
*/
public
boolean
isClosed
()
{
public
boolean
isClosed
()
{
return
mapWrite
.
isClosed
();
return
mapWrite
.
isClosed
();
}
}
/**
* Remove the map.
*/
public
void
removeMap
()
{
public
void
removeMap
()
{
// TODO remove in a transaction
// TODO remove in a transaction
mapWrite
.
removeMap
();
mapWrite
.
removeMap
();
}
}
/**
* Clear the map.
*/
public
void
clear
()
{
public
void
clear
()
{
// TODO truncate transactionally
// TODO truncate transactionally
mapWrite
.
clear
();
mapWrite
.
clear
();
}
}
/**
* Get the first key.
*
* @return the first key, or null if empty
*/
public
K
firstKey
()
{
public
K
firstKey
()
{
// TODO transactional firstKey
// TODO transactional firstKey
return
mapRead
.
firstKey
();
return
mapRead
.
firstKey
();
}
}
/**
* Get the last key.
*
* @return the last key, or null if empty
*/
public
K
lastKey
()
{
public
K
lastKey
()
{
// TODO transactional lastKey
// TODO transactional lastKey
return
mapRead
.
lastKey
();
return
mapRead
.
lastKey
();
}
}
/**
* Iterate over all keys.
*
* @param from the first key to return
* @return the iterator
*/
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
// TODO transactional keyIterator
// TODO transactional keyIterator
return
mapRead
.
keyIterator
(
from
);
return
mapRead
.
keyIterator
(
from
);
}
}
/**
* Get the smallest key that is larger or equal to this key.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
ceilingKey
(
K
key
)
{
public
K
ceilingKey
(
K
key
)
{
// TODO transactional ceilingKey
// TODO transactional ceilingKey
return
mapRead
.
ceilingKey
(
key
);
return
mapRead
.
ceilingKey
(
key
);
}
}
/**
* Get the smallest key that is larger than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
higherKey
(
K
key
)
{
public
K
higherKey
(
K
key
)
{
// TODO transactional higherKey
// TODO transactional higherKey
return
mapRead
.
higherKey
(
key
);
return
mapRead
.
higherKey
(
key
);
}
}
/**
* Get the largest key that is smaller than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
lowerKey
(
K
key
)
{
public
K
lowerKey
(
K
key
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
return
mapRead
.
lowerKey
(
key
);
return
mapRead
.
lowerKey
(
key
);
...
@@ -909,7 +967,7 @@ public class TransactionStore {
...
@@ -909,7 +967,7 @@ public class TransactionStore {
}
}
}
}
/**
/**
* A data type that contains an array of objects with the specified data
* A data type that contains an array of objects with the specified data
* types.
* types.
...
@@ -970,8 +1028,8 @@ public class TransactionStore {
...
@@ -970,8 +1028,8 @@ public class TransactionStore {
array
[
i
]
=
t
.
read
(
buff
);
array
[
i
]
=
t
.
read
(
buff
);
}
}
return
array
;
return
array
;
}
}
}
}
}
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
91926786
...
@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
* @param session the session
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the plan item
* @return the plan item
*/
*/
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
)
{
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
)
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
91926786
...
@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
}
}
SortOrder
sortOrder
=
null
;
SortOrder
sortOrder
=
null
;
if
(
select
!=
null
)
{
if
(
select
!=
null
)
{
sortOrder
=
select
.
prepare
Order
();
sortOrder
=
select
.
getSort
Order
();
}
}
item
=
table
.
getBestPlanItem
(
s
,
masks
,
sortOrder
);
item
=
table
.
getBestPlanItem
(
s
,
masks
,
sortOrder
);
// The more index conditions, the earlier the table.
// The more index conditions, the earlier the table.
...
...
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
91926786
...
@@ -35,15 +35,17 @@ public class CompareMode {
...
@@ -35,15 +35,17 @@ public class CompareMode {
public
static
final
String
ICU4J
=
"ICU4J_"
;
public
static
final
String
ICU4J
=
"ICU4J_"
;
/**
/**
* This constant means that the BINARY columns are sorted as if the bytes were signed.
* This constant means that the BINARY columns are sorted as if the bytes
* were signed.
*/
*/
public
static
final
String
SIGNED
=
"SIGNED"
;
public
static
final
String
SIGNED
=
"SIGNED"
;
/**
/**
* This constant means that the BINARY columns are sorted as if the bytes were unsigned.
* This constant means that the BINARY columns are sorted as if the bytes
* were unsigned.
*/
*/
public
static
final
String
UNSIGNED
=
"UNSIGNED"
;
public
static
final
String
UNSIGNED
=
"UNSIGNED"
;
private
static
CompareMode
lastUsed
;
private
static
CompareMode
lastUsed
;
private
static
final
boolean
CAN_USE_ICU4J
;
private
static
final
boolean
CAN_USE_ICU4J
;
...
@@ -78,12 +80,13 @@ public class CompareMode {
...
@@ -78,12 +80,13 @@ public class CompareMode {
*
*
* @param name the collation name or null
* @param name the collation name or null
* @param strength the collation strength
* @param strength the collation strength
* @param binaryUnsigned whether to compare binaries as unsigned
* @return the compare mode
* @return the compare mode
*/
*/
public
static
synchronized
CompareMode
getInstance
(
String
name
,
int
strength
,
boolean
binaryUnsigned
)
{
public
static
synchronized
CompareMode
getInstance
(
String
name
,
int
strength
,
boolean
binaryUnsigned
)
{
if
(
lastUsed
!=
null
)
{
if
(
lastUsed
!=
null
)
{
if
(
StringUtils
.
equals
(
lastUsed
.
name
,
name
)
&&
if
(
StringUtils
.
equals
(
lastUsed
.
name
,
name
)
&&
lastUsed
.
strength
==
strength
&&
lastUsed
.
strength
==
strength
&&
lastUsed
.
binaryUnsigned
==
binaryUnsigned
)
{
lastUsed
.
binaryUnsigned
==
binaryUnsigned
)
{
return
lastUsed
;
return
lastUsed
;
}
}
...
@@ -220,7 +223,7 @@ public class CompareMode {
...
@@ -220,7 +223,7 @@ public class CompareMode {
public
int
getStrength
()
{
public
int
getStrength
()
{
return
strength
;
return
strength
;
}
}
public
boolean
isBinaryUnsigned
()
{
public
boolean
isBinaryUnsigned
()
{
return
binaryUnsigned
;
return
binaryUnsigned
;
}
}
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
91926786
...
@@ -606,7 +606,7 @@ public abstract class TestBase {
...
@@ -606,7 +606,7 @@ public abstract class TestBase {
fail
(
"Expected: "
+
df
.
format
(
expected
)
+
" actual: "
+
df
.
format
(
actual
));
fail
(
"Expected: "
+
df
.
format
(
expected
)
+
" actual: "
+
df
.
format
(
actual
));
}
}
}
}
/**
/**
* Check if two values are equal, and if not throw an exception.
* Check if two values are equal, and if not throw an exception.
*
*
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
91926786
...
@@ -836,7 +836,7 @@ public class TestCases extends TestBase {
...
@@ -836,7 +836,7 @@ public class TestCases extends TestBase {
Connection
conn
=
getConnection
(
"cases"
);
Connection
conn
=
getConnection
(
"cases"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
;
ResultSet
rs
;
// test the default (SIGNED)
// test the default (SIGNED)
stat
.
execute
(
"create table bin( x binary(1) );"
);
stat
.
execute
(
"create table bin( x binary(1) );"
);
stat
.
execute
(
"insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');"
);
stat
.
execute
(
"insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');"
);
...
@@ -849,7 +849,7 @@ public class TestCases extends TestBase {
...
@@ -849,7 +849,7 @@ public class TestCases extends TestBase {
assertEquals
(
"09"
,
rs
.
getString
(
1
));
assertEquals
(
"09"
,
rs
.
getString
(
1
));
rs
.
next
();
rs
.
next
();
assertEquals
(
"0a"
,
rs
.
getString
(
1
));
assertEquals
(
"0a"
,
rs
.
getString
(
1
));
// test UNSIGNED mode
// test UNSIGNED mode
stat
.
execute
(
"drop table bin"
);
stat
.
execute
(
"drop table bin"
);
stat
.
execute
(
"SET BINARY_COLLATION UNSIGNED"
);
stat
.
execute
(
"SET BINARY_COLLATION UNSIGNED"
);
...
@@ -864,10 +864,10 @@ public class TestCases extends TestBase {
...
@@ -864,10 +864,10 @@ public class TestCases extends TestBase {
assertEquals
(
"99"
,
rs
.
getString
(
1
));
assertEquals
(
"99"
,
rs
.
getString
(
1
));
rs
.
next
();
rs
.
next
();
assertEquals
(
"aa"
,
rs
.
getString
(
1
));
assertEquals
(
"aa"
,
rs
.
getString
(
1
));
conn
.
close
();
conn
.
close
();
}
}
private
void
testPersistentSettings
()
throws
SQLException
{
private
void
testPersistentSettings
()
throws
SQLException
{
deleteDb
(
"cases"
);
deleteDb
(
"cases"
);
Connection
conn
=
getConnection
(
"cases"
);
Connection
conn
=
getConnection
(
"cases"
);
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
91926786
...
@@ -303,7 +303,7 @@ public class TestCompatibility extends TestBase {
...
@@ -303,7 +303,7 @@ public class TestCompatibility extends TestBase {
assertEquals
(
"John, Doe"
,
rs
.
getString
(
1
));
assertEquals
(
"John, Doe"
,
rs
.
getString
(
1
));
rs
.
close
();
rs
.
close
();
prep
.
close
();
prep
.
close
();
// CONVERT has it's parameters the other way around from the default mode
// CONVERT has it's parameters the other way around from the default mode
rs
=
stat
.
executeQuery
(
"SELECT CONVERT(INT, '10')"
);
rs
=
stat
.
executeQuery
(
"SELECT CONVERT(INT, '10')"
);
rs
.
next
();
rs
.
next
();
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
91926786
...
@@ -882,11 +882,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -882,11 +882,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
deleteDb
(
"functions"
);
deleteDb
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Connection
conn
=
getConnection
(
"functions"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE(1.234, 2) FROM dual"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE(1.234, 2) FROM dual"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
1.23d
,
rs
.
getDouble
(
1
));
assertEquals
(
1.23d
,
rs
.
getDouble
(
1
));
rs
=
stat
.
executeQuery
(
"SELECT CURRENT_TIMESTAMP(), TRUNCATE(CURRENT_TIMESTAMP()) FROM dual"
);
rs
=
stat
.
executeQuery
(
"SELECT CURRENT_TIMESTAMP(), TRUNCATE(CURRENT_TIMESTAMP()) FROM dual"
);
rs
.
next
();
rs
.
next
();
Calendar
c
=
Calendar
.
getInstance
();
Calendar
c
=
Calendar
.
getInstance
();
...
@@ -897,14 +897,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -897,14 +897,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
c
.
set
(
Calendar
.
MILLISECOND
,
0
);
java
.
util
.
Date
nowDate
=
c
.
getTime
();
java
.
util
.
Date
nowDate
=
c
.
getTime
();
assertEquals
(
nowDate
,
rs
.
getTimestamp
(
2
));
assertEquals
(
nowDate
,
rs
.
getTimestamp
(
2
));
try
{
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad', 1) FROM dual"
);
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad', 1) FROM dual"
);
fail
(
"expected exception"
);
fail
(
"expected exception"
);
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
// expected
// expected
}
}
// check for passing wrong data type
// check for passing wrong data type
try
{
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad') FROM dual"
);
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE('bad') FROM dual"
);
...
@@ -912,7 +912,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -912,7 +912,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
// expected
// expected
}
}
// check for too many parameters
// check for too many parameters
try
{
try
{
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE(1,2,3) FROM dual"
);
rs
=
stat
.
executeQuery
(
"SELECT TRUNCATE(1,2,3) FROM dual"
);
...
@@ -920,10 +920,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -920,10 +920,10 @@ public class TestFunctions extends TestBase implements AggregateFunction {
}
catch
(
SQLException
ex
)
{
}
catch
(
SQLException
ex
)
{
// expected
// expected
}
}
conn
.
close
();
conn
.
close
();
}
}
private
void
assertCallResult
(
String
expected
,
Statement
stat
,
String
sql
)
throws
SQLException
{
private
void
assertCallResult
(
String
expected
,
Statement
stat
,
String
sql
)
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"CALL "
+
sql
);
ResultSet
rs
=
stat
.
executeQuery
(
"CALL "
+
sql
);
rs
.
next
();
rs
.
next
();
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
91926786
...
@@ -783,12 +783,15 @@ public class TestOptimizations extends TestBase {
...
@@ -783,12 +783,15 @@ public class TestOptimizations extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
/** Where there are multiple indices, and we have an ORDER BY, select the index that already has the required ordering. */
/**
* Where there are multiple indices, and we have an ORDER BY, select the
* index that already has the required ordering.
*/
private
void
testOrderedIndexes
()
throws
SQLException
{
private
void
testOrderedIndexes
()
throws
SQLException
{
deleteDb
(
"optimizations"
);
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR, PRIMARY KEY(K1,K2))"
);
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR, PRIMARY KEY(K1,K2))"
);
stat
.
execute
(
"CREATE INDEX my_index ON my_table(K1,VAL);"
);
stat
.
execute
(
"CREATE INDEX my_index ON my_table(K1,VAL);"
);
ResultSet
rs
=
stat
.
executeQuery
(
"EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,VAL"
);
ResultSet
rs
=
stat
.
executeQuery
(
"EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,VAL"
);
...
@@ -796,15 +799,17 @@ public class TestOptimizations extends TestBase {
...
@@ -796,15 +799,17 @@ public class TestOptimizations extends TestBase {
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.MY_INDEX: K1 = 7 */"
);
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.MY_INDEX: K1 = 7 */"
);
stat
.
execute
(
"DROP TABLE my_table"
);
stat
.
execute
(
"DROP TABLE my_table"
);
// where we have two covering indexes, make sure we choose the one that covers more
// where we have two covering indexes, make sure
// we choose the one that covers more
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)"
);
stat
.
execute
(
"CREATE INDEX my_index1 ON my_table(K1,K2);"
);
stat
.
execute
(
"CREATE INDEX my_index1 ON my_table(K1,K2);"
);
stat
.
execute
(
"CREATE INDEX my_index2 ON my_table(K1,K2,VAL);"
);
stat
.
execute
(
"CREATE INDEX my_index2 ON my_table(K1,K2,VAL);"
);
rs
=
stat
.
executeQuery
(
"EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,K2,VAL"
);
rs
=
stat
.
executeQuery
(
"EXPLAIN PLAN FOR SELECT * FROM my_table WHERE K1=7 ORDER BY K1,K2,VAL"
);
rs
.
next
();
rs
.
next
();
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.MY_INDEX2: K1 = 7 */"
);
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.MY_INDEX2: K1 = 7 */"
);
conn
.
close
();
conn
.
close
();
}
}
}
}
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
91926786
...
@@ -79,9 +79,9 @@ public class TestMVStore extends TestBase {
...
@@ -79,9 +79,9 @@ public class TestMVStore extends TestBase {
testIterate
();
testIterate
();
testCloseTwice
();
testCloseTwice
();
testSimple
();
testSimple
();
// longer running tests
// longer running tests
testLargerThan2G
();
testLargerThan2G
();
}
}
...
@@ -1360,7 +1360,7 @@ public class TestMVStore extends TestBase {
...
@@ -1360,7 +1360,7 @@ public class TestMVStore extends TestBase {
}
}
s
.
close
();
s
.
close
();
}
}
private
void
testLargerThan2G
()
throws
IOException
{
private
void
testLargerThan2G
()
throws
IOException
{
if
(!
config
.
big
)
{
if
(!
config
.
big
)
{
return
;
return
;
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
91926786
...
@@ -42,7 +42,7 @@ public class TestMVTableEngine extends TestBase {
...
@@ -42,7 +42,7 @@ public class TestMVTableEngine extends TestBase {
testLocking
();
testLocking
();
testSimple
();
testSimple
();
}
}
private
void
testSpeed
()
throws
Exception
{
private
void
testSpeed
()
throws
Exception
{
String
dbName
;
String
dbName
;
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
...
@@ -56,7 +56,7 @@ public class TestMVTableEngine extends TestBase {
...
@@ -56,7 +56,7 @@ public class TestMVTableEngine extends TestBase {
// System.out.println(prof.getTop(10));
// System.out.println(prof.getTop(10));
}
}
}
}
private
void
testSpeed
(
String
dbName
)
throws
Exception
{
private
void
testSpeed
(
String
dbName
)
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
Connection
conn
;
Connection
conn
;
...
...
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
91926786
...
@@ -78,7 +78,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -78,7 +78,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
testFuzzOperations
();
testFuzzOperations
();
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore"
);
}
}
private
void
testDropTempTable
()
throws
SQLException
{
private
void
testDropTempTable
()
throws
SQLException
{
deleteDb
(
"pageStoreDropTemp"
);
deleteDb
(
"pageStoreDropTemp"
);
Connection
c1
=
getConnection
(
"pageStoreDropTemp"
);
Connection
c1
=
getConnection
(
"pageStoreDropTemp"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论