Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2aec7182
提交
2aec7182
authored
1月 20, 2017
作者:
Sergi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/h2database/h2database
上级
60fcd5aa
899022c9
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
71 行增加
和
35 行删除
+71
-35
.gitignore
h2/.gitignore
+1
-0
help.csv
h2/src/docsrc/help/help.csv
+5
-1
Parser.java
h2/src/main/org/h2/command/Parser.java
+7
-7
Comparison.java
h2/src/main/org/h2/expression/Comparison.java
+7
-0
FilePathNioMem.java
h2/src/main/org/h2/store/fs/FilePathNioMem.java
+18
-21
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+20
-0
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+7
-0
testScript.sql
h2/src/test/org/h2/test/testScript.sql
+6
-6
没有找到文件。
h2/.gitignore
浏览文件 @
2aec7182
...
...
@@ -12,3 +12,4 @@ temp
test.out.txt
.idea/
*.log
target/
h2/src/docsrc/help/help.csv
浏览文件 @
2aec7182
...
...
@@ -613,7 +613,8 @@ CREATE SEQUENCE SEQ_ID
CREATE [ CACHED | MEMORY ] [ TEMP | [ GLOBAL | LOCAL ] TEMPORARY ]
TABLE [ IF NOT EXISTS ] name
[ ( { columnDefinition | constraint } [,...] ) ]
[ ENGINE tableEngineName [ WITH tableEngineParamName [,...] ] ]
[ ENGINE tableEngineName ]
[ WITH tableEngineParamName [,...] ]
[ NOT PERSISTENT ] [ TRANSACTIONAL ]
[ AS select ]","
Creates a new table.
...
...
@@ -635,6 +636,9 @@ The ENGINE option is only required when custom table implementations are used.
The table engine class must implement the interface ""org.h2.api.TableEngine"".
Any table engine parameters are passed down in the tableEngineParams field of the CreateTableData object.
Either ENGINE, or WITH (table engine params), or both may be specified. If ENGINE is not specified
in CREATE TABLE, then the engine specified by DEFAULT_TABLE_ENGINE option of database params is used.
Tables with the NOT PERSISTENT modifier are kept fully in memory, and all
rows are lost when the database is closed.
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
2aec7182
...
...
@@ -6126,15 +6126,15 @@ public class Parser {
}
}
else
{
command
.
setTableEngine
(
readUniqueIdentifier
());
if
(
readIf
(
"WITH"
))
{
ArrayList
<
String
>
tableEngineParams
=
New
.
arrayList
();
do
{
tableEngineParams
.
add
(
readUniqueIdentifier
());
}
while
(
readIf
(
","
));
command
.
setTableEngineParams
(
tableEngineParams
);
}
}
}
if
(
readIf
(
"WITH"
))
{
ArrayList
<
String
>
tableEngineParams
=
New
.
arrayList
();
do
{
tableEngineParams
.
add
(
readUniqueIdentifier
());
}
while
(
readIf
(
","
));
command
.
setTableEngineParams
(
tableEngineParams
);
}
// MySQL compatibility
if
(
readIf
(
"AUTO_INCREMENT"
))
{
read
(
"="
);
...
...
h2/src/main/org/h2/expression/Comparison.java
浏览文件 @
2aec7182
...
...
@@ -194,6 +194,13 @@ public class Comparison extends Condition {
return
ValueExpression
.
getNull
();
}
}
int
colType
=
left
.
getType
();
int
constType
=
r
.
getType
();
int
resType
=
Value
.
getHigherOrder
(
colType
,
constType
);
// If not the column values will need to be promoted
// to constant type, but vise versa, then let's do this here once.
if
(
constType
!=
resType
)
right
=
ValueExpression
.
get
(
r
.
convertTo
(
resType
));
}
else
if
(
right
instanceof
Parameter
)
{
((
Parameter
)
right
).
setColumn
(
((
ExpressionColumn
)
left
).
getColumn
());
...
...
h2/src/main/org/h2/store/fs/FilePathNioMem.java
浏览文件 @
2aec7182
...
...
@@ -399,11 +399,13 @@ class FileNioMemData {
private
static
final
int
BLOCK_SIZE
=
1
<<
BLOCK_SIZE_SHIFT
;
private
static
final
int
BLOCK_SIZE_MASK
=
BLOCK_SIZE
-
1
;
private
static
final
CompressLZF
LZF
=
new
CompressLZF
();
private
static
final
byte
[]
BUFFER
=
new
byte
[
BLOCK_SIZE
*
2
];
private
static
final
ByteBuffer
COMPRESSED_EMPTY_BLOCK
;
private
static
final
CompressLaterCache
<
CompressItem
,
CompressItem
>
COMPRESS_LATER
=
private
final
CompressLZF
LZF
=
new
CompressLZF
();
/** the output buffer when compressing */
private
final
byte
[]
compressOutputBuffer
=
new
byte
[
BLOCK_SIZE
*
2
];
private
final
CompressLaterCache
<
CompressItem
,
CompressItem
>
compressLaterCache
=
new
CompressLaterCache
<
CompressItem
,
CompressItem
>(
CACHE_SIZE
);
private
String
name
;
...
...
@@ -417,10 +419,11 @@ class FileNioMemData {
private
int
sharedLockCount
;
static
{
byte
[]
n
=
new
byte
[
BLOCK_SIZE
];
int
len
=
LZF
.
compress
(
n
,
BLOCK_SIZE
,
BUFFER
,
0
);
final
byte
[]
n
=
new
byte
[
BLOCK_SIZE
];
final
byte
[]
output
=
new
byte
[
BLOCK_SIZE
*
2
];
int
len
=
new
CompressLZF
().
compress
(
n
,
BLOCK_SIZE
,
output
,
0
);
COMPRESSED_EMPTY_BLOCK
=
ByteBuffer
.
allocateDirect
(
len
);
COMPRESSED_EMPTY_BLOCK
.
put
(
BUFFER
,
0
,
len
);
COMPRESSED_EMPTY_BLOCK
.
put
(
output
,
0
,
len
);
}
FileNioMemData
(
String
name
,
boolean
compress
)
{
...
...
@@ -530,9 +533,7 @@ class FileNioMemData {
private
void
addToCompressLaterCache
(
int
page
)
{
CompressItem
c
=
new
CompressItem
(
this
,
page
);
synchronized
(
LZF
)
{
COMPRESS_LATER
.
put
(
c
,
c
);
}
compressLaterCache
.
put
(
c
,
c
);
}
private
void
expand
(
int
page
)
{
...
...
@@ -548,10 +549,8 @@ class FileNioMemData {
}
ByteBuffer
out
=
ByteBuffer
.
allocateDirect
(
BLOCK_SIZE
);
if
(
d
!=
COMPRESSED_EMPTY_BLOCK
)
{
synchronized
(
LZF
)
{
d
.
position
(
0
);
CompressLZF
.
expand
(
d
,
out
);
}
d
.
position
(
0
);
CompressLZF
.
expand
(
d
,
out
);
}
list
[
page
]
=
out
;
}
...
...
@@ -568,12 +567,10 @@ class FileNioMemData {
return
;
}
ByteBuffer
d
=
list
[
page
];
synchronized
(
LZF
)
{
int
len
=
LZF
.
compress
(
d
,
0
,
BUFFER
,
0
);
d
=
ByteBuffer
.
allocateDirect
(
len
);
d
.
put
(
BUFFER
,
0
,
len
);
list
[
page
]
=
d
;
}
int
len
=
LZF
.
compress
(
d
,
0
,
compressOutputBuffer
,
0
);
d
=
ByteBuffer
.
allocateDirect
(
len
);
d
.
put
(
compressOutputBuffer
,
0
,
len
);
list
[
page
]
=
d
;
}
/**
...
...
@@ -602,7 +599,7 @@ class FileNioMemData {
*
* @param newLength the new length
*/
void
truncate
(
long
newLength
)
{
synchronized
void
truncate
(
long
newLength
)
{
changeLength
(
newLength
);
long
end
=
MathUtils
.
roundUpLong
(
newLength
,
BLOCK_SIZE
);
if
(
end
!=
newLength
)
{
...
...
@@ -642,7 +639,7 @@ class FileNioMemData {
* @param write true for writing
* @return the new position
*/
long
readWrite
(
long
pos
,
ByteBuffer
b
,
int
off
,
int
len
,
boolean
write
)
{
synchronized
long
readWrite
(
long
pos
,
ByteBuffer
b
,
int
off
,
int
len
,
boolean
write
)
{
long
end
=
pos
+
len
;
if
(
end
>
length
)
{
if
(
write
)
{
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
2aec7182
...
...
@@ -58,6 +58,7 @@ public class TestOptimizations extends TestBase {
testNestedIn
();
testConstantIn1
();
testConstantIn2
();
testConstantTypeConversionToColumnType
();
testNestedInSelectAndLike
();
testNestedInSelect
();
testInSelectJoin
();
...
...
@@ -463,6 +464,25 @@ public class TestOptimizations extends TestBase {
conn
.
close
();
}
private
void
testConstantTypeConversionToColumnType
()
throws
SQLException
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations;IGNORECASE=TRUE"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
executeUpdate
(
"CREATE TABLE test (x int)"
);
ResultSet
resultSet
;
resultSet
=
stat
.
executeQuery
(
"EXPLAIN SELECT x FROM test WHERE x = '5'"
);
assertTrue
(
resultSet
.
next
());
// String constant '5' has been converted to int constant 5 on optimization
assertTrue
(
resultSet
.
getString
(
1
).
endsWith
(
"X = 5"
));
stat
.
execute
(
"drop table test"
);
conn
.
close
();
}
private
void
testNestedInSelect
()
throws
SQLException
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
...
...
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
2aec7182
...
...
@@ -110,6 +110,13 @@ public class TestTableEngines extends TestBase {
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
0
));
assertEquals
(
"param2"
,
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
1
));
stat
.
execute
(
"CREATE TABLE t2(id int, name varchar) WITH \"param1\", \"param2\""
);
assertEquals
(
2
,
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
size
());
assertEquals
(
"param1"
,
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
0
));
assertEquals
(
"param2"
,
EndlessTableEngine
.
createTableData
.
tableEngineParams
.
get
(
1
));
conn
.
close
();
if
(!
config
.
memory
)
{
// Test serialization of table parameters
...
...
h2/src/test/org/h2/test/testScript.sql
浏览文件 @
2aec7182
...
...
@@ -8172,9 +8172,9 @@ select * from s;
>
rows
:
1
select
some
(
y
>
10
),
every
(
y
>
10
),
min
(
y
),
max
(
y
)
from
t
;
>
BOOL_OR
(
Y
>
10
)
BOOL_AND
(
Y
>
1
0
)
MIN
(
Y
)
MAX
(
Y
)
>
---------------
---------------- ------ ------
>
null
null
null
null
>
BOOL_OR
(
Y
>
10
.
0
)
BOOL_AND
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
---------------
-- --
---------------- ------ ------
>
null
null
null
null
>
rows
:
1
insert
into
t
values
(
1000000004
,
4
);
...
...
@@ -8230,9 +8230,9 @@ stddev_pop(distinct y) s_py, stddev_samp(distinct y) s_sy, var_pop(distinct y) v
>
rows
:
1
select
some
(
y
>
10
),
every
(
y
>
10
),
min
(
y
),
max
(
y
)
from
t
;
>
BOOL_OR
(
Y
>
10
)
BOOL_AND
(
Y
>
1
0
)
MIN
(
Y
)
MAX
(
Y
)
>
---------------
---------------- ------ ------
>
TRUE
FALSE
4
.
0
16
.
0
>
BOOL_OR
(
Y
>
10
.
0
)
BOOL_AND
(
Y
>
10
.
0
)
MIN
(
Y
)
MAX
(
Y
)
>
---------------
-- --
---------------- ------ ------
>
TRUE
FALSE
4
.
0
16
.
0
>
rows
:
1
drop
view
s
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论