Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a7d663ef
提交
a7d663ef
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various system properties have been replaced with database level settings.
上级
8967ca57
显示空白字符变更
内嵌
并排
正在显示
32 个修改的文件
包含
260 行增加
和
279 行删除
+260
-279
Parser.java
h2/src/main/org/h2/command/Parser.java
+7
-7
Prepared.java
h2/src/main/org/h2/command/Prepared.java
+1
-2
Select.java
h2/src/main/org/h2/command/dml/Select.java
+4
-4
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+1
-1
DbSettings.java
h2/src/main/org/h2/constant/DbSettings.java
+128
-2
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+7
-173
Constants.java
h2/src/main/org/h2/engine/Constants.java
+11
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+17
-15
UndoLog.java
h2/src/main/org/h2/engine/UndoLog.java
+3
-3
Comparison.java
h2/src/main/org/h2/expression/Comparison.java
+1
-1
ConditionAndOr.java
h2/src/main/org/h2/expression/ConditionAndOr.java
+2
-2
ConditionIn.java
h2/src/main/org/h2/expression/ConditionIn.java
+1
-2
ConditionInSelect.java
h2/src/main/org/h2/expression/ConditionInSelect.java
+1
-2
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+1
-2
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+4
-6
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+8
-6
PageBtreeNode.java
h2/src/main/org/h2/index/PageBtreeNode.java
+8
-5
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+9
-6
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+3
-2
ResultDiskBuffer.java
h2/src/main/org/h2/result/ResultDiskBuffer.java
+1
-1
RowList.java
h2/src/main/org/h2/result/RowList.java
+1
-2
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+4
-4
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+4
-4
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+4
-4
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-2
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+1
-1
DirectInsert.java
h2/src/test/org/h2/samples/DirectInsert.java
+12
-9
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+7
-2
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+3
-1
TestNestedJoins.java
h2/src/test/org/h2/test/synth/TestNestedJoins.java
+2
-3
TestOuterJoins.java
h2/src/test/org/h2/test/synth/TestOuterJoins.java
+1
-2
TestCompress.java
h2/src/test/org/h2/test/unit/TestCompress.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
a7d663ef
...
@@ -76,7 +76,6 @@ import org.h2.command.dml.SetTypes;
...
@@ -76,7 +76,6 @@ import org.h2.command.dml.SetTypes;
import
org.h2.command.dml.TransactionCommand
;
import
org.h2.command.dml.TransactionCommand
;
import
org.h2.command.dml.Update
;
import
org.h2.command.dml.Update
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.ConstraintReferential
;
import
org.h2.constraint.ConstraintReferential
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
...
@@ -970,7 +969,7 @@ public class Parser {
...
@@ -970,7 +969,7 @@ public class Parser {
table
=
TableView
.
createTempView
(
s
,
session
.
getUser
(),
alias
,
query
,
currentSelect
);
table
=
TableView
.
createTempView
(
s
,
session
.
getUser
(),
alias
,
query
,
currentSelect
);
}
else
{
}
else
{
TableFilter
top
;
TableFilter
top
;
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
database
.
getSettings
().
nestedJoins
)
{
String
joinTable
=
Constants
.
PREFIX_JOIN
+
parseIndex
;
String
joinTable
=
Constants
.
PREFIX_JOIN
+
parseIndex
;
top
=
new
TableFilter
(
session
,
getDualTable
(
true
),
joinTable
,
rightsChecked
,
currentSelect
);
top
=
new
TableFilter
(
session
,
getDualTable
(
true
),
joinTable
,
rightsChecked
,
currentSelect
);
TableFilter
n
=
readTableFilter
(
false
);
TableFilter
n
=
readTableFilter
(
false
);
...
@@ -1234,6 +1233,7 @@ public class Parser {
...
@@ -1234,6 +1233,7 @@ public class Parser {
private
TableFilter
readJoin
(
TableFilter
top
,
Select
command
,
boolean
fromOuter
)
{
private
TableFilter
readJoin
(
TableFilter
top
,
Select
command
,
boolean
fromOuter
)
{
TableFilter
last
=
top
;
TableFilter
last
=
top
;
boolean
nestedJoins
=
database
.
getSettings
().
nestedJoins
;
while
(
true
)
{
while
(
true
)
{
if
(
readIf
(
"RIGHT"
))
{
if
(
readIf
(
"RIGHT"
))
{
readIf
(
"OUTER"
);
readIf
(
"OUTER"
);
...
@@ -1245,7 +1245,7 @@ public class Parser {
...
@@ -1245,7 +1245,7 @@ public class Parser {
if
(
readIf
(
"ON"
))
{
if
(
readIf
(
"ON"
))
{
on
=
readExpression
();
on
=
readExpression
();
}
}
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
nestedJoins
)
{
String
joinTable
=
Constants
.
PREFIX_JOIN
+
parseIndex
;
String
joinTable
=
Constants
.
PREFIX_JOIN
+
parseIndex
;
TableFilter
nt
=
new
TableFilter
(
session
,
getDualTable
(
true
),
joinTable
,
rightsChecked
,
currentSelect
);
TableFilter
nt
=
new
TableFilter
(
session
,
getDualTable
(
true
),
joinTable
,
rightsChecked
,
currentSelect
);
nt
.
addJoin
(
top
,
false
,
true
,
null
);
nt
.
addJoin
(
top
,
false
,
true
,
null
);
...
@@ -1276,7 +1276,7 @@ public class Parser {
...
@@ -1276,7 +1276,7 @@ public class Parser {
if
(
readIf
(
"ON"
))
{
if
(
readIf
(
"ON"
))
{
on
=
readExpression
();
on
=
readExpression
();
}
}
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
nestedJoins
)
{
top
.
addJoin
(
join
,
false
,
false
,
on
);
top
.
addJoin
(
join
,
false
,
false
,
on
);
}
else
{
}
else
{
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
...
@@ -1289,7 +1289,7 @@ public class Parser {
...
@@ -1289,7 +1289,7 @@ public class Parser {
if
(
readIf
(
"ON"
))
{
if
(
readIf
(
"ON"
))
{
on
=
readExpression
();
on
=
readExpression
();
}
}
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
nestedJoins
)
{
top
.
addJoin
(
join
,
false
,
false
,
on
);
top
.
addJoin
(
join
,
false
,
false
,
on
);
}
else
{
}
else
{
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
...
@@ -1298,7 +1298,7 @@ public class Parser {
...
@@ -1298,7 +1298,7 @@ public class Parser {
}
else
if
(
readIf
(
"CROSS"
))
{
}
else
if
(
readIf
(
"CROSS"
))
{
read
(
"JOIN"
);
read
(
"JOIN"
);
TableFilter
join
=
readTableFilter
(
fromOuter
);
TableFilter
join
=
readTableFilter
(
fromOuter
);
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
nestedJoins
)
{
top
.
addJoin
(
join
,
false
,
false
,
null
);
top
.
addJoin
(
join
,
false
,
false
,
null
);
}
else
{
}
else
{
top
.
addJoin
(
join
,
fromOuter
,
false
,
null
);
top
.
addJoin
(
join
,
fromOuter
,
false
,
null
);
...
@@ -1331,7 +1331,7 @@ public class Parser {
...
@@ -1331,7 +1331,7 @@ public class Parser {
}
}
}
}
}
}
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
nestedJoins
)
{
top
.
addJoin
(
join
,
false
,
false
,
on
);
top
.
addJoin
(
join
,
false
,
false
,
on
);
}
else
{
}
else
{
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
top
.
addJoin
(
join
,
fromOuter
,
false
,
on
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Prepared.java
浏览文件 @
a7d663ef
...
@@ -8,7 +8,6 @@ package org.h2.command;
...
@@ -8,7 +8,6 @@ package org.h2.command;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
...
@@ -110,7 +109,7 @@ public abstract class Prepared {
...
@@ -110,7 +109,7 @@ public abstract class Prepared {
}
}
// parser: currently, compiling every create/drop/... twice
// parser: currently, compiling every create/drop/... twice
// because needRecompile return true even for the first execution
// because needRecompile return true even for the first execution
return
SysProperties
.
RECOMPILE_ALWAYS
||
prepareAlways
||
modificationMetaId
<
db
.
getModificationMetaId
()
;
return
prepareAlways
||
modificationMetaId
<
db
.
getModificationMetaId
()
||
db
.
getSettings
().
recompileAlways
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
a7d663ef
...
@@ -548,7 +548,7 @@ public class Select extends Query {
...
@@ -548,7 +548,7 @@ public class Select extends Query {
}
}
int
columnCount
=
expressions
.
size
();
int
columnCount
=
expressions
.
size
();
LocalResult
result
=
null
;
LocalResult
result
=
null
;
if
(
!
SysProperties
.
optimizeInsertFromSelect
||
target
==
null
)
{
if
(
target
==
null
||
!
session
.
getDatabase
().
getSettings
().
optimizeInsertFromSelect
)
{
result
=
createLocalResult
(
result
);
result
=
createLocalResult
(
result
);
}
}
if
(
sort
!=
null
&&
(!
sortUsingIndex
||
distinct
))
{
if
(
sort
!=
null
&&
(!
sortUsingIndex
||
distinct
))
{
...
@@ -795,7 +795,7 @@ public class Select extends Query {
...
@@ -795,7 +795,7 @@ public class Select extends Query {
}
}
}
}
cost
=
preparePlan
();
cost
=
preparePlan
();
if
(
SysProperties
.
OPTIMIZE_DISTINCT
&&
d
istinct
&&
!
isGroupQuery
&&
filters
.
size
()
==
1
&&
expressions
.
size
()
==
1
&&
condition
==
null
)
{
if
(
distinct
&&
session
.
getDatabase
().
getSettings
().
optimizeD
istinct
&&
!
isGroupQuery
&&
filters
.
size
()
==
1
&&
expressions
.
size
()
==
1
&&
condition
==
null
)
{
Expression
expr
=
expressions
.
get
(
0
);
Expression
expr
=
expressions
.
get
(
0
);
expr
=
expr
.
getNonAliasExpression
();
expr
=
expr
.
getNonAliasExpression
();
if
(
expr
instanceof
ExpressionColumn
)
{
if
(
expr
instanceof
ExpressionColumn
)
{
...
@@ -910,7 +910,7 @@ public class Select extends Query {
...
@@ -910,7 +910,7 @@ public class Select extends Query {
Expression
on
=
f
.
getJoinCondition
();
Expression
on
=
f
.
getJoinCondition
();
if
(
on
!=
null
)
{
if
(
on
!=
null
)
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE_VISITOR
))
{
if
(!
on
.
isEverything
(
ExpressionVisitor
.
EVALUATABLE_VISITOR
))
{
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
session
.
getDatabase
().
getSettings
().
nestedJoins
)
{
// need to check that all added are bound to a table
// need to check that all added are bound to a table
on
=
on
.
optimize
(
session
);
on
=
on
.
optimize
(
session
);
if
(!
f
.
isJoinOuter
()
&&
!
f
.
isJoinOuterIndirect
())
{
if
(!
f
.
isJoinOuter
()
&&
!
f
.
isJoinOuterIndirect
())
{
...
@@ -1177,7 +1177,7 @@ public class Select extends Query {
...
@@ -1177,7 +1177,7 @@ public class Select extends Query {
break
;
break
;
}
}
case
ExpressionVisitor
.
EVALUATABLE
:
{
case
ExpressionVisitor
.
EVALUATABLE
:
{
if
(!
SysProperties
.
OPTIMIZE_EVALUATABLE_SUBQUERIES
)
{
if
(!
session
.
getDatabase
().
getSettings
().
optimizeEvaluatableSubqueries
)
{
return
false
;
return
false
;
}
}
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
a7d663ef
...
@@ -126,7 +126,7 @@ public class SelectUnion extends Query {
...
@@ -126,7 +126,7 @@ public class SelectUnion extends Query {
}
}
limitExpr
=
ValueExpression
.
get
(
ValueInt
.
get
(
maxrows
));
limitExpr
=
ValueExpression
.
get
(
ValueInt
.
get
(
maxrows
));
}
}
if
(
SysProperties
.
optimizeInsertFromSelect
)
{
if
(
session
.
getDatabase
().
getSettings
()
.
optimizeInsertFromSelect
)
{
if
(
unionType
==
UNION_ALL
&&
target
!=
null
)
{
if
(
unionType
==
UNION_ALL
&&
target
!=
null
)
{
if
(
sort
==
null
&&
!
distinct
&&
maxrows
==
0
&&
offsetExpr
==
null
&&
limitExpr
==
null
)
{
if
(
sort
==
null
&&
!
distinct
&&
maxrows
==
0
&&
offsetExpr
==
null
&&
limitExpr
==
null
)
{
left
.
query
(
0
,
target
);
left
.
query
(
0
,
target
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constant/DbSettings.java
浏览文件 @
a7d663ef
...
@@ -103,18 +103,46 @@ public class DbSettings extends SettingsBase {
...
@@ -103,18 +103,46 @@ public class DbSettings extends SettingsBase {
public
final
boolean
functionsInSchema
=
get
(
"FUNCTIONS_IN_SCHEMA"
,
false
);
public
final
boolean
functionsInSchema
=
get
(
"FUNCTIONS_IN_SCHEMA"
,
false
);
/**
/**
*
System property <code>h2.largeResultBufferSize
</code> (default: 4096).<br />
*
Database setting <code>LARGE_RESULT_BUFFER_SIZE
</code> (default: 4096).<br />
* Buffer size for large result sets. Set this value to 0 to disable the
* Buffer size for large result sets. Set this value to 0 to disable the
* buffer.
* buffer.
*/
*/
public
final
int
largeResultBufferSize
=
get
(
"LARGE_RESULT_BUFFER_SIZE"
,
4
*
1024
);
public
final
int
largeResultBufferSize
=
get
(
"LARGE_RESULT_BUFFER_SIZE"
,
4
*
1024
);
/**
/**
*
System property <code>h2.largeTransactions
</code> (default: false).<br />
*
Database setting <code>LARGE_TRANSACTIONS
</code> (default: false).<br />
* Support very large transactions
* Support very large transactions
*/
*/
public
final
boolean
largeTransactions
=
get
(
"LARGE_TRANSACTIONS"
,
false
);
public
final
boolean
largeTransactions
=
get
(
"LARGE_TRANSACTIONS"
,
false
);
/**
* Database setting <code>MAX_COMPACT_COUNT</code>
* (default: Integer.MAX_VALUE).<br />
* The maximum number of pages to move when closing a database.
*/
public
final
int
maxCompactCount
=
get
(
"MAX_COMPACT_COUNT"
,
Integer
.
MAX_VALUE
);
/**
* Database setting <code>MAX_COMPACT_TIME</code> (default: 200).<br />
* The maximum time in milliseconds used to compact a database when closing.
*/
public
final
int
maxCompactTime
=
get
(
"MAX_COMPACT_TIME"
,
200
);
/**
* Database setting <code>MAX_MEMORY_ROWS_DISTINCT</code> (default:
* Integer.MAX_VALUE).<br />
* The maximum number of rows kept in-memory for SELECT DISTINCT queries. If
* more than this number of rows are in a result set, a temporary table is
* used.
*/
public
final
int
maxMemoryRowsDistinct
=
get
(
"MAX_MEMORY_ROWS_DISTINCT"
,
Integer
.
MAX_VALUE
);
/**
* Database setting <code>h2.nestedJoins</code> (default: false).<br />
* Whether nested joins should be supported.
*/
public
final
boolean
nestedJoins
=
get
(
"NESTED_JOINS"
,
false
);
/**
/**
* Database setting <code>QUERY_CACHE_SIZE</code> (default: 0).<br />
* Database setting <code>QUERY_CACHE_SIZE</code> (default: 0).<br />
* The size of the query cache. Each session has it's own cache with the
* The size of the query cache. Each session has it's own cache with the
...
@@ -133,6 +161,104 @@ public class DbSettings extends SettingsBase {
...
@@ -133,6 +161,104 @@ public class DbSettings extends SettingsBase {
*/
*/
public
int
maxQueryTimeout
=
get
(
"MAX_QUERY_TIMEOUT"
,
0
);
public
int
maxQueryTimeout
=
get
(
"MAX_QUERY_TIMEOUT"
,
0
);
/**
* Database setting <code>OPTIMIZE_INSERT_FROM_SELECT</code>
* (default: false).<br />
* Insert into table from query directly bypassing temporary disk storage.
* This also applies to create table as select.
*/
public
final
boolean
optimizeInsertFromSelect
=
get
(
"OPTIMIZE_INSERT_FROM_SELECT"
,
false
);
/**
* Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br />
* Improve the performance of simple DISTINCT queries if an index is
* available for the given column. The optimization is used if:
* <ul>
* <li>The select is a single column query without condition </li>
* <li>The query contains only one table, and no group by </li>
* <li>There is only one table involved </li>
* <li>There is an ascending index on the column </li>
* <li>The selectivity of the column is below 20 </li>
* </ul>
*/
public
final
boolean
optimizeDistinct
=
get
(
"OPTIMIZE_DISTINCT"
,
true
);
/**
* Database setting <code>OPTIMIZE_UPDATE</code> (default: true).<br />
* Speed up inserts, updates, and deletes by not reading all rows from a
* page unless necessary.
*/
public
final
boolean
optimizeUpdate
=
get
(
"OPTIMIZE_UPDATE"
,
true
);
/**
* Database setting <code>OPTIMIZE_EVALUATABLE_SUBQUERIES</code> (default:
* true).<br />
* Optimize subqueries that are not dependent on the outer query.
*/
public
final
boolean
optimizeEvaluatableSubqueries
=
get
(
"OPTIMIZE_EVALUATABLE_SUBQUERIES"
,
true
);
/**
* Database setting <code>OPTIMIZE_IN_LIST</code> (default: true).<br />
* Optimize IN(...) and IN(SELECT ...) comparisons. This includes
* optimization for SELECT, DELETE, and UPDATE.
*/
public
final
boolean
optimizeInList
=
get
(
"OPTIMIZE_IN_LIST"
,
true
);
/**
* Database setting <code>OPTIMIZE_IS_NULL</code> (default: false).<br />
* Use an index for condition of the form columnName IS NULL.
*/
public
final
boolean
optimizeIsNull
=
get
(
"OPTIMIZE_IS_NULL"
,
true
);
/**
* Database setting <code>OPTIMIZE_OR</code> (default: false).<br />
* Convert (C=? OR C=?) to (C IN(?, ?)).
*/
public
final
boolean
optimizeOr
=
get
(
"OPTIMIZE_OR"
,
false
);
/**
* Database setting <code>OPTIMIZE_SUBQUERY_CACHE</code> (default: true).<br />
* Cache subquery results.
*/
public
final
boolean
optimizeSubqueryCache
=
get
(
"OPTIMIZE_SUBQUERY_CACHE"
,
true
);
/**
* Database setting <code>OPTIMIZE_TWO_EQUALS</code> (default: true).<br />
* Optimize expressions of the form A=B AND B=1. In this case, AND A=1 is
* added so an index on A can be used.
*/
public
final
boolean
optimizeTwoEquals
=
get
(
"OPTIMIZE_TWO_EQUALS"
,
true
);
/**
* Database setting <code>PAGE_STORE_TRIM</code> (default: true).<br />
* Trim the database size when closing.
*/
public
final
boolean
pageStoreTrim
=
get
(
"PAGE_STORE_TRIM"
,
true
);
/**
* Database setting <code>PAGE_STORE_INTERNAL_COUNT</code> (default: false).<br />
* Update the row counts on a node level.
*/
public
final
boolean
pageStoreInternalCount
=
get
(
"PAGE_STORE_INTERNAL_COUNT"
,
false
);
/**
* Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br />
* Always recompile prepared statements.
*/
public
final
boolean
recompileAlways
=
get
(
"RECOMPILE_ALWAYS"
,
false
);
// DbSettings
/**
* Database setting <code>RECONNECT_CHECK_DELAY</code> (default: 200).<br />
* Check the .lock.db file every this many milliseconds to detect that the
* database was changed. The process writing to the database must first
* notify a change in the .lock.db file, then wait twice this many
* milliseconds before updating the database.
*/
public
final
int
reconnectCheckDelay
=
get
(
"RECONNECT_CHECK_DELAY"
,
200
);
// DbSettings
private
DbSettings
(
HashMap
<
String
,
String
>
s
)
{
private
DbSettings
(
HashMap
<
String
,
String
>
s
)
{
super
(
s
);
super
(
s
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
a7d663ef
...
@@ -37,12 +37,6 @@ public class SysProperties {
...
@@ -37,12 +37,6 @@ public class SysProperties {
*/
*/
public
static
final
String
H2_SCRIPT_DIRECTORY
=
"h2.scriptDirectory"
;
public
static
final
String
H2_SCRIPT_DIRECTORY
=
"h2.scriptDirectory"
;
/**
* INTERNAL
*/
public
static
final
String
H2_COLLATOR_CACHE_SIZE
=
"h2.collatorCacheSize"
;
// TODO DbSettings
/**
/**
* System property <code>file.encoding</code> (default: Cp1252).<br />
* System property <code>file.encoding</code> (default: Cp1252).<br />
* It is usually set by the system and is the default encoding used for the
* It is usually set by the system and is the default encoding used for the
...
@@ -143,6 +137,13 @@ public class SysProperties {
...
@@ -143,6 +137,13 @@ public class SysProperties {
*/
*/
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
getStringSetting
(
"h2.clientTraceDirectory"
,
"trace.db/"
);
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
getStringSetting
(
"h2.clientTraceDirectory"
,
"trace.db/"
);
/**
* System property <code>h2.collatorCacheSize</code> (default: 32000).<br />
* The cache size for collation keys (in elements). Used when a collator has
* been set for the database.
*/
public
static
final
int
COLLATOR_CACHE_SIZE
=
getIntSetting
(
"h2.collatorCacheSize"
,
32000
);
/**
/**
* System property <code>h2.consoleStream</code> (default: true).<br />
* System property <code>h2.consoleStream</code> (default: true).<br />
* H2 Console: stream query results.
* H2 Console: stream query results.
...
@@ -198,7 +199,6 @@ public class SysProperties {
...
@@ -198,7 +199,6 @@ public class SysProperties {
* Store LOB files in the database.
* Store LOB files in the database.
*/
*/
public
static
final
boolean
LOB_IN_DATABASE
=
getBooleanSetting
(
"h2.lobInDatabase"
,
false
);
public
static
final
boolean
LOB_IN_DATABASE
=
getBooleanSetting
(
"h2.lobInDatabase"
,
false
);
// DbSettings
/**
/**
* System property <code>h2.lobClientMaxSizeMemory</code> (default: 65536).<br />
* System property <code>h2.lobClientMaxSizeMemory</code> (default: 65536).<br />
...
@@ -220,21 +220,6 @@ public class SysProperties {
...
@@ -220,21 +220,6 @@ public class SysProperties {
*/
*/
public
static
final
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
public
static
final
String
LOG_ALL_ERRORS_FILE
=
getStringSetting
(
"h2.logAllErrorsFile"
,
"h2errors.txt"
);
/**
* System property <code>h2.maxCompactCount</code>
* (default: Integer.MAX_VALUE).<br />
* The maximum number of pages to move when closing a database.
*/
public
static
final
int
MAX_COMPACT_COUNT
=
getIntSetting
(
"h2.maxCompactCount"
,
Integer
.
MAX_VALUE
);
// DbSettings
/**
* System property <code>h2.maxCompactTime</code> (default: 200).<br />
* The maximum time in milliseconds used to compact a database when closing.
*/
public
static
final
int
MAX_COMPACT_TIME
=
getIntSetting
(
"h2.maxCompactTime"
,
200
);
// DbSettings
/**
/**
* System property <code>h2.maxFileRetry</code> (default: 16).<br />
* System property <code>h2.maxFileRetry</code> (default: 16).<br />
* Number of times to retry file delete and rename. in Windows, files can't
* Number of times to retry file delete and rename. in Windows, files can't
...
@@ -245,16 +230,6 @@ public class SysProperties {
...
@@ -245,16 +230,6 @@ public class SysProperties {
*/
*/
public
static
final
int
MAX_FILE_RETRY
=
Math
.
max
(
1
,
getIntSetting
(
"h2.maxFileRetry"
,
16
));
public
static
final
int
MAX_FILE_RETRY
=
Math
.
max
(
1
,
getIntSetting
(
"h2.maxFileRetry"
,
16
));
/**
* System property <code>h2.maxMemoryRowsDistinct</code> (default:
* Integer.MAX_VALUE).<br />
* The maximum number of rows kept in-memory for SELECT DISTINCT queries. If
* more than this number of rows are in a result set, a temporary table is
* used.
*/
public
static
final
int
MAX_MEMORY_ROWS_DISTINCT
=
getIntSetting
(
"h2.maxMemoryRowsDistinct"
,
Integer
.
MAX_VALUE
);
// DbSettings
/**
/**
* System property <code>h2.maxReconnect</code> (default: 3).<br />
* System property <code>h2.maxReconnect</code> (default: 3).<br />
* The maximum number of tries to reconnect in a row.
* The maximum number of tries to reconnect in a row.
...
@@ -266,7 +241,6 @@ public class SysProperties {
...
@@ -266,7 +241,6 @@ public class SysProperties {
* The maximum size of a LOB value that is written as data to the trace system.
* The maximum size of a LOB value that is written as data to the trace system.
*/
*/
public
static
final
long
MAX_TRACE_DATA_LENGTH
=
getIntSetting
(
"h2.maxTraceDataLength"
,
65535
);
public
static
final
long
MAX_TRACE_DATA_LENGTH
=
getIntSetting
(
"h2.maxTraceDataLength"
,
65535
);
// DbSettings
/**
/**
* System property <code>h2.minColumnNameMap</code> (default: 3).<br />
* System property <code>h2.minColumnNameMap</code> (default: 3).<br />
...
@@ -275,20 +249,6 @@ public class SysProperties {
...
@@ -275,20 +249,6 @@ public class SysProperties {
*/
*/
public
static
final
int
MIN_COLUMN_NAME_MAP
=
getIntSetting
(
"h2.minColumnNameMap"
,
3
);
public
static
final
int
MIN_COLUMN_NAME_MAP
=
getIntSetting
(
"h2.minColumnNameMap"
,
3
);
/**
* System property <code>h2.minWriteDelay</code> (default: 5).<br />
* The minimum write delay that causes commits to be delayed.
*/
public
static
final
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
// DbSettings
/**
* System property <code>h2.nestedJoins</code> (default: false).<br />
* Whether nested joins should be supported.
*/
public
static
final
boolean
NESTED_JOINS
=
getBooleanSetting
(
"h2.nestedJoins"
,
false
);
// DbSettings
/**
/**
* System property <code>h2.nioLoadMapped</code> (default: false).<br />
* System property <code>h2.nioLoadMapped</code> (default: false).<br />
* If the mapped buffer should be loaded when the file is opened.
* If the mapped buffer should be loaded when the file is opened.
...
@@ -326,104 +286,6 @@ public class SysProperties {
...
@@ -326,104 +286,6 @@ public class SysProperties {
*/
*/
public
static
final
int
OBJECT_CACHE_SIZE
=
MathUtils
.
nextPowerOf2
(
getIntSetting
(
"h2.objectCacheSize"
,
1024
));
public
static
final
int
OBJECT_CACHE_SIZE
=
MathUtils
.
nextPowerOf2
(
getIntSetting
(
"h2.objectCacheSize"
,
1024
));
/**
* System property <code>h2.optimizeInsertFromSelect</code>
* (default: false).<br />
* Insert into table from query directly bypassing temporary disk storage.
* This also applies to create table as select.
*/
public
static
boolean
optimizeInsertFromSelect
=
getBooleanSetting
(
"h2.optimizeInsertFromSelect"
,
false
);
// DbSettings
/**
* System property <code>h2.optimizeDistinct</code> (default: true).<br />
* Improve the performance of simple DISTINCT queries if an index is
* available for the given column. The optimization is used if:
* <ul>
* <li>The select is a single column query without condition </li>
* <li>The query contains only one table, and no group by </li>
* <li>There is only one table involved </li>
* <li>There is an ascending index on the column </li>
* <li>The selectivity of the column is below 20 </li>
* </ul>
*/
public
static
final
boolean
OPTIMIZE_DISTINCT
=
getBooleanSetting
(
"h2.optimizeDistinct"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeUpdate</code> (default: true).<br />
* Speed up inserts, updates, and deletes by not reading all rows from a
* page unless necessary.
*/
public
static
final
boolean
OPTIMIZE_UPDATE
=
getBooleanSetting
(
"h2.optimizeUpdate"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeEvaluatableSubqueries</code> (default:
* true).<br />
* Optimize subqueries that are not dependent on the outer query.
*/
public
static
final
boolean
OPTIMIZE_EVALUATABLE_SUBQUERIES
=
getBooleanSetting
(
"h2.optimizeEvaluatableSubqueries"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeInList</code> (default: true).<br />
* Optimize IN(...) and IN(SELECT ...) comparisons. This includes
* optimization for SELECT, DELETE, and UPDATE.
*/
public
static
final
boolean
OPTIMIZE_IN_LIST
=
getBooleanSetting
(
"h2.optimizeInList"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeIsNull</code> (default: false).<br />
* Use an index for condition of the form columnName IS NULL.
*/
public
static
final
boolean
OPTIMIZE_IS_NULL
=
getBooleanSetting
(
"h2.optimizeIsNull"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeOr</code> (default: false).<br />
* Convert (C=? OR C=?) to (C IN(?, ?)).
*/
public
static
final
boolean
OPTIMIZE_OR
=
getBooleanSetting
(
"h2.optimizeOr"
,
false
);
// DbSettings
/**
* System property <code>h2.optimizeSubqueryCache</code> (default: true).<br />
* Cache subquery results.
*/
public
static
final
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
// DbSettings
/**
* System property <code>h2.optimizeTwoEquals</code> (default: true).<br />
* Optimize expressions of the form A=B AND B=1. In this case, AND A=1 is
* added so an index on A can be used.
*/
public
static
final
boolean
OPTIMIZE_TWO_EQUALS
=
getBooleanSetting
(
"h2.optimizeTwoEquals"
,
true
);
// DbSettings
/**
* System property <code>h2.pageSize</code> (default: 2048).<br />
* The page size to use for new databases.
*/
public
static
final
int
PAGE_SIZE
=
getIntSetting
(
"h2.pageSize"
,
2048
);
// DbSettings (already!)
/**
* System property <code>h2.pageStoreTrim</code> (default: true).<br />
* Trim the database size when closing.
*/
public
static
final
boolean
PAGE_STORE_TRIM
=
getBooleanSetting
(
"h2.pageStoreTrim"
,
true
);
// DbSettings
/**
* System property <code>h2.pageStoreInternalCount</code> (default: false).<br />
* Update the row counts on a node level.
*/
public
static
final
boolean
PAGE_STORE_INTERNAL_COUNT
=
getBooleanSetting
(
"h2.pageStoreInternalCount"
,
false
);
// DbSettings
/**
/**
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
* Default client encoding for PG server. It is used if the client does not
* Default client encoding for PG server. It is used if the client does not
...
@@ -437,23 +299,6 @@ public class SysProperties {
...
@@ -437,23 +299,6 @@ public class SysProperties {
*/
*/
public
static
final
String
PREFIX_TEMP_FILE
=
getStringSetting
(
"h2.prefixTempFile"
,
"h2.temp"
);
public
static
final
String
PREFIX_TEMP_FILE
=
getStringSetting
(
"h2.prefixTempFile"
,
"h2.temp"
);
/**
* System property <code>h2.recompileAlways</code> (default: false).<br />
* Always recompile prepared statements.
*/
public
static
final
boolean
RECOMPILE_ALWAYS
=
getBooleanSetting
(
"h2.recompileAlways"
,
false
);
// DbSettings
/**
* System property <code>h2.reconnectCheckDelay</code> (default: 200).<br />
* Check the .lock.db file every this many milliseconds to detect that the
* database was changed. The process writing to the database must first
* notify a change in the .lock.db file, then wait twice this many
* milliseconds before updating the database.
*/
public
static
final
int
RECONNECT_CHECK_DELAY
=
getIntSetting
(
"h2.reconnectCheckDelay"
,
200
);
// DbSettings
/**
/**
* System property <code>h2.returnLobObjects</code> (default: true).<br />
* System property <code>h2.returnLobObjects</code> (default: true).<br />
* When true, ResultSet.getObject for CLOB or BLOB will return a
* When true, ResultSet.getObject for CLOB or BLOB will return a
...
@@ -632,15 +477,4 @@ public class SysProperties {
...
@@ -632,15 +477,4 @@ public class SysProperties {
return
getStringSetting
(
H2_SCRIPT_DIRECTORY
,
""
);
return
getStringSetting
(
H2_SCRIPT_DIRECTORY
,
""
);
}
}
/**
* System property <code>h2.collatorCacheSize</code> (default: 32000).<br />
* The cache size for collation keys (in elements). Used when a collator has
* been set for the database.
*
* @return the current value
*/
public
static
int
getCollatorCacheSize
()
{
return
getIntSetting
(
H2_COLLATOR_CACHE_SIZE
,
32000
);
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
a7d663ef
...
@@ -400,7 +400,17 @@ public class Constants {
...
@@ -400,7 +400,17 @@ public class Constants {
*/
*/
public
static
final
String
USER_PACKAGE
=
"org.h2.dynamic"
;
public
static
final
String
USER_PACKAGE
=
"org.h2.dynamic"
;
int
sortByName
;
int
sortByNameAndDocument
;
/**
* The default page size to use for new databases.
*/
public
static
final
int
DEFAULT_PAGE_SIZE
=
2048
;
/**
* The minimum write delay that causes commits to be delayed.
*/
public
static
final
int
MIN_WRITE_DELAY
=
5
;
/**
/**
* The default result set concurrency for statements created with
* The default result set concurrency for statements created with
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
a7d663ef
...
@@ -167,13 +167,15 @@ public class Database implements DataHandler {
...
@@ -167,13 +167,15 @@ public class Database implements DataHandler {
private
volatile
boolean
metaTablesInitialized
;
private
volatile
boolean
metaTablesInitialized
;
private
boolean
flushOnEachCommit
;
private
boolean
flushOnEachCommit
;
private
LobStorage
lobStorage
;
private
LobStorage
lobStorage
;
private
int
pageSize
=
SysProperties
.
PAGE_SIZE
;
private
int
pageSize
=
Constants
.
DEFAULT_
PAGE_SIZE
;
private
int
defaultTableType
=
Table
.
TYPE_CACHED
;
private
int
defaultTableType
=
Table
.
TYPE_CACHED
;
private
DbSettings
dbSettings
;
private
final
DbSettings
dbSettings
;
private
final
int
reconnectCheckDelay
;
public
Database
(
ConnectionInfo
ci
,
String
cipher
)
{
public
Database
(
ConnectionInfo
ci
,
String
cipher
)
{
String
name
=
ci
.
getName
();
String
name
=
ci
.
getName
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
reconnectCheckDelay
=
dbSettings
.
reconnectCheckDelay
;
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
);
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
);
this
.
persistent
=
ci
.
isPersistent
();
this
.
persistent
=
ci
.
isPersistent
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
...
@@ -186,7 +188,7 @@ public class Database implements DataHandler {
...
@@ -186,7 +188,7 @@ public class Database implements DataHandler {
this
.
accessModeData
=
ci
.
getProperty
(
"ACCESS_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
accessModeData
=
ci
.
getProperty
(
"ACCESS_MODE_DATA"
,
"rw"
).
toLowerCase
();
this
.
autoServerMode
=
ci
.
getProperty
(
"AUTO_SERVER"
,
false
);
this
.
autoServerMode
=
ci
.
getProperty
(
"AUTO_SERVER"
,
false
);
this
.
cacheSize
=
ci
.
getProperty
(
"CACHE_SIZE"
,
Constants
.
CACHE_SIZE_DEFAULT
);
this
.
cacheSize
=
ci
.
getProperty
(
"CACHE_SIZE"
,
Constants
.
CACHE_SIZE_DEFAULT
);
this
.
pageSize
=
ci
.
getProperty
(
"PAGE_SIZE"
,
SysProperties
.
PAGE_SIZE
);
this
.
pageSize
=
ci
.
getProperty
(
"PAGE_SIZE"
,
Constants
.
DEFAULT_
PAGE_SIZE
);
if
(
"r"
.
equals
(
accessModeData
))
{
if
(
"r"
.
equals
(
accessModeData
))
{
readOnly
=
true
;
readOnly
=
true
;
}
}
...
@@ -315,7 +317,7 @@ public class Database implements DataHandler {
...
@@ -315,7 +317,7 @@ public class Database implements DataHandler {
lock
.
setProperty
(
"logPos"
,
pos
);
lock
.
setProperty
(
"logPos"
,
pos
);
lock
.
save
();
lock
.
save
();
}
}
reconnectCheckNext
=
now
+
SysProperties
.
RECONNECT_CHECK_DELAY
;
reconnectCheckNext
=
now
+
reconnectCheckDelay
;
}
}
return
true
;
return
true
;
}
}
...
@@ -325,7 +327,7 @@ public class Database implements DataHandler {
...
@@ -325,7 +327,7 @@ public class Database implements DataHandler {
return
false
;
return
false
;
}
}
getTrace
().
debug
(
"wait before writing"
);
getTrace
().
debug
(
"wait before writing"
);
Thread
.
sleep
((
int
)
(
SysProperties
.
RECONNECT_CHECK_DELAY
*
1.1
));
Thread
.
sleep
((
int
)
(
reconnectCheckDelay
*
1.1
));
Properties
now
=
lock
.
load
();
Properties
now
=
lock
.
load
();
if
(!
now
.
equals
(
old
))
{
if
(!
now
.
equals
(
old
))
{
// somebody else was faster
// somebody else was faster
...
@@ -341,11 +343,11 @@ public class Database implements DataHandler {
...
@@ -341,11 +343,11 @@ public class Database implements DataHandler {
}
}
// ensure that the writer thread will
// ensure that the writer thread will
// not reset the flag before we are done
// not reset the flag before we are done
reconnectCheckNext
=
System
.
currentTimeMillis
()
+
2
*
SysProperties
.
RECONNECT_CHECK_DELAY
;
reconnectCheckNext
=
System
.
currentTimeMillis
()
+
2
*
reconnectCheckDelay
;
old
=
lock
.
save
();
old
=
lock
.
save
();
if
(
pending
)
{
if
(
pending
)
{
getTrace
().
debug
(
"wait before writing again"
);
getTrace
().
debug
(
"wait before writing again"
);
Thread
.
sleep
((
int
)
(
SysProperties
.
RECONNECT_CHECK_DELAY
*
1.1
));
Thread
.
sleep
((
int
)
(
reconnectCheckDelay
*
1.1
));
Properties
now
=
lock
.
load
();
Properties
now
=
lock
.
load
();
if
(!
now
.
equals
(
old
))
{
if
(!
now
.
equals
(
old
))
{
// somebody else was faster
// somebody else was faster
...
@@ -356,7 +358,7 @@ public class Database implements DataHandler {
...
@@ -356,7 +358,7 @@ public class Database implements DataHandler {
}
}
reconnectLastLock
=
old
;
reconnectLastLock
=
old
;
reconnectChangePending
=
pending
;
reconnectChangePending
=
pending
;
reconnectCheckNext
=
System
.
currentTimeMillis
()
+
SysProperties
.
RECONNECT_CHECK_DELAY
;
reconnectCheckNext
=
System
.
currentTimeMillis
()
+
reconnectCheckDelay
;
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
getTrace
().
error
(
"pending:"
+
pending
,
e
);
getTrace
().
error
(
"pending:"
+
pending
,
e
);
...
@@ -1146,7 +1148,7 @@ public class Database implements DataHandler {
...
@@ -1146,7 +1148,7 @@ public class Database implements DataHandler {
// wait before deleting the .lock file,
// wait before deleting the .lock file,
// otherwise other connections can not detect that
// otherwise other connections can not detect that
try
{
try
{
Thread
.
sleep
((
int
)
(
SysProperties
.
RECONNECT_CHECK_DELAY
*
1.1
));
Thread
.
sleep
((
int
)
(
reconnectCheckDelay
*
1.1
));
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
error
(
"close"
,
e
);
traceSystem
.
getTrace
(
Trace
.
DATABASE
).
error
(
"close"
,
e
);
}
}
...
@@ -1623,7 +1625,7 @@ public class Database implements DataHandler {
...
@@ -1623,7 +1625,7 @@ public class Database implements DataHandler {
if
(
writer
!=
null
)
{
if
(
writer
!=
null
)
{
writer
.
setWriteDelay
(
value
);
writer
.
setWriteDelay
(
value
);
// TODO check if MIN_WRITE_DELAY is a good value
// TODO check if MIN_WRITE_DELAY is a good value
flushOnEachCommit
=
writeDelay
<
SysPropertie
s
.
MIN_WRITE_DELAY
;
flushOnEachCommit
=
writeDelay
<
Constant
s
.
MIN_WRITE_DELAY
;
}
}
}
}
...
@@ -2024,7 +2026,7 @@ public class Database implements DataHandler {
...
@@ -2024,7 +2026,7 @@ public class Database implements DataHandler {
public
PageStore
getPageStore
()
{
public
PageStore
getPageStore
()
{
if
(
pageStore
==
null
)
{
if
(
pageStore
==
null
)
{
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
pageStore
=
new
PageStore
(
this
,
databaseName
+
Constants
.
SUFFIX_PAGE_FILE
,
accessModeData
,
cacheSize
);
if
(
pageSize
!=
SysProperties
.
PAGE_SIZE
)
{
if
(
pageSize
!=
Constants
.
DEFAULT_
PAGE_SIZE
)
{
pageStore
.
setPageSize
(
pageSize
);
pageStore
.
setPageSize
(
pageSize
);
}
}
if
(!
readOnly
&&
fileLockMethod
==
FileLock
.
LOCK_FS
)
{
if
(!
readOnly
&&
fileLockMethod
==
FileLock
.
LOCK_FS
)
{
...
@@ -2072,7 +2074,7 @@ public class Database implements DataHandler {
...
@@ -2072,7 +2074,7 @@ public class Database implements DataHandler {
if
(
now
<
reconnectCheckNext
)
{
if
(
now
<
reconnectCheckNext
)
{
return
false
;
return
false
;
}
}
reconnectCheckNext
=
now
+
SysProperties
.
RECONNECT_CHECK_DELAY
;
reconnectCheckNext
=
now
+
reconnectCheckDelay
;
if
(
lock
==
null
)
{
if
(
lock
==
null
)
{
lock
=
new
FileLock
(
traceSystem
,
databaseName
+
Constants
.
SUFFIX_LOCK_FILE
,
Constants
.
LOCK_SLEEP
);
lock
=
new
FileLock
(
traceSystem
,
databaseName
+
Constants
.
SUFFIX_LOCK_FILE
,
Constants
.
LOCK_SLEEP
);
}
}
...
@@ -2085,7 +2087,7 @@ public class Database implements DataHandler {
...
@@ -2085,7 +2087,7 @@ public class Database implements DataHandler {
if
(
prop
.
getProperty
(
"changePending"
,
null
)
==
null
)
{
if
(
prop
.
getProperty
(
"changePending"
,
null
)
==
null
)
{
break
;
break
;
}
}
if
(
System
.
currentTimeMillis
()
>
now
+
SysProperties
.
RECONNECT_CHECK_DELAY
*
10
)
{
if
(
System
.
currentTimeMillis
()
>
now
+
reconnectCheckDelay
*
10
)
{
if
(
first
.
equals
(
prop
))
{
if
(
first
.
equals
(
prop
))
{
// the writing process didn't update the file -
// the writing process didn't update the file -
// it may have terminated
// it may have terminated
...
@@ -2095,7 +2097,7 @@ public class Database implements DataHandler {
...
@@ -2095,7 +2097,7 @@ public class Database implements DataHandler {
}
}
}
}
getTrace
().
debug
(
"delay (change pending)"
);
getTrace
().
debug
(
"delay (change pending)"
);
Thread
.
sleep
(
SysProperties
.
RECONNECT_CHECK_DELAY
);
Thread
.
sleep
(
reconnectCheckDelay
);
prop
=
lock
.
load
();
prop
=
lock
.
load
();
}
}
reconnectLastLock
=
prop
;
reconnectLastLock
=
prop
;
...
@@ -2118,7 +2120,7 @@ public class Database implements DataHandler {
...
@@ -2118,7 +2120,7 @@ public class Database implements DataHandler {
return
;
return
;
}
}
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
if
(
now
>
reconnectCheckNext
+
SysProperties
.
RECONNECT_CHECK_DELAY
)
{
if
(
now
>
reconnectCheckNext
+
reconnectCheckDelay
)
{
if
(
SysProperties
.
CHECK
&&
checkpointAllowed
<
0
)
{
if
(
SysProperties
.
CHECK
&&
checkpointAllowed
<
0
)
{
DbException
.
throwInternalError
();
DbException
.
throwInternalError
();
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/UndoLog.java
浏览文件 @
a7d663ef
...
@@ -162,10 +162,10 @@ public class UndoLog {
...
@@ -162,10 +162,10 @@ public class UndoLog {
file
=
database
.
openFile
(
fileName
,
"rw"
,
false
);
file
=
database
.
openFile
(
fileName
,
"rw"
,
false
);
file
.
setLength
(
FileStore
.
HEADER_LENGTH
);
file
.
setLength
(
FileStore
.
HEADER_LENGTH
);
}
}
Data
buff
=
Data
.
create
(
database
,
SysProperties
.
PAGE_SIZE
);
Data
buff
=
Data
.
create
(
database
,
Constants
.
DEFAULT_
PAGE_SIZE
);
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
UndoLogRecord
r
=
records
.
get
(
i
);
UndoLogRecord
r
=
records
.
get
(
i
);
buff
.
checkCapacity
(
SysProperties
.
PAGE_SIZE
);
buff
.
checkCapacity
(
Constants
.
DEFAULT_
PAGE_SIZE
);
r
.
append
(
buff
,
this
);
r
.
append
(
buff
,
this
);
if
(
i
==
records
.
size
()
-
1
||
buff
.
length
()
>
Constants
.
UNDO_BLOCK_SIZE
)
{
if
(
i
==
records
.
size
()
-
1
||
buff
.
length
()
>
Constants
.
UNDO_BLOCK_SIZE
)
{
storedEntriesPos
.
add
(
file
.
getFilePointer
());
storedEntriesPos
.
add
(
file
.
getFilePointer
());
...
@@ -188,7 +188,7 @@ public class UndoLog {
...
@@ -188,7 +188,7 @@ public class UndoLog {
String
fileName
=
database
.
createTempFile
();
String
fileName
=
database
.
createTempFile
();
file
=
database
.
openFile
(
fileName
,
"rw"
,
false
);
file
=
database
.
openFile
(
fileName
,
"rw"
,
false
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
rowBuff
=
Data
.
create
(
database
,
SysProperties
.
PAGE_SIZE
);
rowBuff
=
Data
.
create
(
database
,
Constants
.
DEFAULT_
PAGE_SIZE
);
Data
buff
=
rowBuff
;
Data
buff
=
rowBuff
;
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
UndoLogRecord
r
=
records
.
get
(
i
);
UndoLogRecord
r
=
records
.
get
(
i
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Comparison.java
浏览文件 @
a7d663ef
...
@@ -334,7 +334,7 @@ public class Comparison extends Condition {
...
@@ -334,7 +334,7 @@ public class Comparison extends Condition {
if
(
l
!=
null
)
{
if
(
l
!=
null
)
{
switch
(
compareType
)
{
switch
(
compareType
)
{
case
IS_NULL:
case
IS_NULL:
if
(
SysProperties
.
OPTIMIZE_IS_NULL
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
filter
.
addIndexCondition
(
IndexCondition
.
get
(
Comparison
.
EQUAL_NULL_SAFE
,
l
,
ValueExpression
.
getNull
()));
filter
.
addIndexCondition
(
IndexCondition
.
get
(
Comparison
.
EQUAL_NULL_SAFE
,
l
,
ValueExpression
.
getNull
()));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionAndOr.java
浏览文件 @
a7d663ef
...
@@ -137,7 +137,7 @@ public class ConditionAndOr extends Condition {
...
@@ -137,7 +137,7 @@ public class ConditionAndOr extends Condition {
// INSERT INTO TEST VALUES(1, NULL);
// INSERT INTO TEST VALUES(1, NULL);
// SELECT * FROM TEST WHERE NOT (B=A AND B=0); // no rows
// SELECT * FROM TEST WHERE NOT (B=A AND B=0); // no rows
// SELECT * FROM TEST WHERE NOT (B=A AND B=0 AND A=0); // 1, NULL
// SELECT * FROM TEST WHERE NOT (B=A AND B=0 AND A=0); // 1, NULL
if
(
SysProperties
.
OPTIMIZE_TWO_EQUALS
&&
andOrType
==
AND
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeTwoEquals
&&
andOrType
==
AND
)
{
// try to add conditions (A=B AND B=1: add A=1)
// try to add conditions (A=B AND B=1: add A=1)
if
(
left
instanceof
Comparison
&&
right
instanceof
Comparison
)
{
if
(
left
instanceof
Comparison
&&
right
instanceof
Comparison
)
{
Comparison
compLeft
=
(
Comparison
)
left
;
Comparison
compLeft
=
(
Comparison
)
left
;
...
@@ -152,7 +152,7 @@ public class ConditionAndOr extends Condition {
...
@@ -152,7 +152,7 @@ public class ConditionAndOr extends Condition {
}
}
// TODO optimization: convert ((A=1 AND B=2) OR (A=1 AND B=3)) to
// TODO optimization: convert ((A=1 AND B=2) OR (A=1 AND B=3)) to
// (A=1 AND (B=2 OR B=3))
// (A=1 AND (B=2 OR B=3))
if
(
SysProperties
.
OPTIMIZE_OR
&&
andOrType
==
OR
)
{
if
(
andOrType
==
OR
&&
session
.
getDatabase
().
getSettings
().
optimizeOr
)
{
// try to add conditions (A=B AND B=1: add A=1)
// try to add conditions (A=B AND B=1: add A=1)
if
(
left
instanceof
Comparison
&&
right
instanceof
Comparison
)
{
if
(
left
instanceof
Comparison
&&
right
instanceof
Comparison
)
{
Comparison
compLeft
=
(
Comparison
)
left
;
Comparison
compLeft
=
(
Comparison
)
left
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionIn.java
浏览文件 @
a7d663ef
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
package
org
.
h2
.
expression
;
package
org
.
h2
.
expression
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.index.IndexCondition
;
import
org.h2.index.IndexCondition
;
...
@@ -110,7 +109,7 @@ public class ConditionIn extends Condition {
...
@@ -110,7 +109,7 @@ public class ConditionIn extends Condition {
if
(
filter
!=
l
.
getTableFilter
())
{
if
(
filter
!=
l
.
getTableFilter
())
{
return
;
return
;
}
}
if
(
SysProperties
.
OPTIMIZE_IN_LIST
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeInList
)
{
ExpressionVisitor
visitor
=
ExpressionVisitor
.
get
(
ExpressionVisitor
.
NOT_FROM_RESOLVER
);
ExpressionVisitor
visitor
=
ExpressionVisitor
.
get
(
ExpressionVisitor
.
NOT_FROM_RESOLVER
);
visitor
.
setResolver
(
filter
);
visitor
.
setResolver
(
filter
);
for
(
Expression
e
:
valueList
)
{
for
(
Expression
e
:
valueList
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ConditionInSelect.java
浏览文件 @
a7d663ef
...
@@ -8,7 +8,6 @@ package org.h2.expression;
...
@@ -8,7 +8,6 @@ package org.h2.expression;
import
org.h2.command.dml.Query
;
import
org.h2.command.dml.Query
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.index.IndexCondition
;
import
org.h2.index.IndexCondition
;
...
@@ -121,7 +120,7 @@ public class ConditionInSelect extends Condition {
...
@@ -121,7 +120,7 @@ public class ConditionInSelect extends Condition {
}
}
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
public
void
createIndexConditions
(
Session
session
,
TableFilter
filter
)
{
if
(!
SysProperties
.
OPTIMIZE_IN_LIST
)
{
if
(!
session
.
getDatabase
().
getSettings
().
optimizeInList
)
{
return
;
return
;
}
}
if
(!(
left
instanceof
ExpressionColumn
))
{
if
(!(
left
instanceof
ExpressionColumn
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
a7d663ef
...
@@ -11,7 +11,6 @@ import org.h2.command.Parser;
...
@@ -11,7 +11,6 @@ import org.h2.command.Parser;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.SelectListColumnResolver
;
import
org.h2.command.dml.SelectListColumnResolver
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.index.IndexCondition
;
import
org.h2.index.IndexCondition
;
...
@@ -245,7 +244,7 @@ public class ExpressionColumn extends Expression {
...
@@ -245,7 +244,7 @@ public class ExpressionColumn extends Expression {
// if the current value is known (evaluatable set)
// if the current value is known (evaluatable set)
// or if this columns belongs to a 'higher level' query and is
// or if this columns belongs to a 'higher level' query and is
// therefore just a parameter
// therefore just a parameter
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
database
.
getSettings
().
nestedJoins
)
{
if
(
visitor
.
getQueryLevel
()
<
this
.
queryLevel
)
{
if
(
visitor
.
getQueryLevel
()
<
this
.
queryLevel
)
{
return
true
;
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
a7d663ef
...
@@ -8,8 +8,6 @@ package org.h2.index;
...
@@ -8,8 +8,6 @@ package org.h2.index;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Comparison
;
import
org.h2.expression.Comparison
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -121,7 +119,7 @@ public class IndexCursor implements Cursor {
...
@@ -121,7 +119,7 @@ public class IndexCursor implements Cursor {
inList
=
null
;
inList
=
null
;
inResult
=
null
;
inResult
=
null
;
}
}
if
(!
SysProperties
.
OPTIMIZE_IS_NULL
)
{
if
(!
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
if
(
isStart
&&
isEnd
)
{
if
(
isStart
&&
isEnd
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
// join on a column=NULL is always false
// join on a column=NULL is always false
...
@@ -172,7 +170,7 @@ public class IndexCursor implements Cursor {
...
@@ -172,7 +170,7 @@ public class IndexCursor implements Cursor {
}
else
if
(
b
==
null
)
{
}
else
if
(
b
==
null
)
{
return
a
;
return
a
;
}
}
if
(
SysProperties
.
OPTIMIZE_IS_NULL
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
// IS NULL must be checked later
// IS NULL must be checked later
if
(
a
==
ValueNull
.
INSTANCE
)
{
if
(
a
==
ValueNull
.
INSTANCE
)
{
return
b
;
return
b
;
...
@@ -184,8 +182,8 @@ public class IndexCursor implements Cursor {
...
@@ -184,8 +182,8 @@ public class IndexCursor implements Cursor {
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
return
a
;
return
a
;
}
}
if
(
SysProperties
.
OPTIMIZE_IS_NULL
)
{
if
(
a
==
ValueNull
.
INSTANCE
||
b
==
ValueNull
.
INSTANCE
)
{
if
(
a
==
ValueNull
.
INSTANCE
||
b
==
ValueNull
.
INSTANCE
)
{
if
(
session
.
getDatabase
().
getSettings
().
optimizeIsNull
)
{
// column IS NULL AND column <op> <not null> is always false
// column IS NULL AND column <op> <not null> is always false
return
null
;
return
null
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
a7d663ef
...
@@ -33,10 +33,12 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -33,10 +33,12 @@ public class PageBtreeLeaf extends PageBtree {
private
static
final
int
OFFSET_LENGTH
=
2
;
private
static
final
int
OFFSET_LENGTH
=
2
;
private
final
boolean
optimizeUpdate
;
private
boolean
writtenData
;
private
boolean
writtenData
;
private
PageBtreeLeaf
(
PageBtreeIndex
index
,
int
pageId
,
Data
data
)
{
private
PageBtreeLeaf
(
PageBtreeIndex
index
,
int
pageId
,
Data
data
)
{
super
(
index
,
pageId
,
data
);
super
(
index
,
pageId
,
data
);
this
.
optimizeUpdate
=
index
.
getDatabase
().
getSettings
().
optimizeUpdate
;
}
}
/**
/**
...
@@ -130,7 +132,7 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -130,7 +132,7 @@ public class PageBtreeLeaf extends PageBtree {
}
}
}
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
changeCount
=
index
.
getPageStore
().
getChangeCount
();
changeCount
=
index
.
getPageStore
().
getChangeCount
();
...
@@ -143,7 +145,7 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -143,7 +145,7 @@ public class PageBtreeLeaf extends PageBtree {
}
}
start
+=
OFFSET_LENGTH
;
start
+=
OFFSET_LENGTH
;
int
offset
=
(
x
==
0
?
pageSize
:
offsets
[
x
-
1
])
-
rowLength
;
int
offset
=
(
x
==
0
?
pageSize
:
offsets
[
x
-
1
])
-
rowLength
;
if
(
SysProperties
.
OPTIMIZE_UPDATE
&&
writtenData
)
{
if
(
optimizeUpdate
&&
writtenData
)
{
if
(
entryCount
>
0
)
{
if
(
entryCount
>
0
)
{
byte
[]
d
=
data
.
getBytes
();
byte
[]
d
=
data
.
getBytes
();
int
dataStart
=
offsets
[
entryCount
-
1
];
int
dataStart
=
offsets
[
entryCount
-
1
];
...
@@ -162,7 +164,7 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -162,7 +164,7 @@ public class PageBtreeLeaf extends PageBtree {
}
}
private
void
removeRow
(
int
at
)
{
private
void
removeRow
(
int
at
)
{
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
...
@@ -176,7 +178,7 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -176,7 +178,7 @@ public class PageBtreeLeaf extends PageBtree {
int
rowLength
=
startNext
-
offsets
[
at
];
int
rowLength
=
startNext
-
offsets
[
at
];
start
-=
OFFSET_LENGTH
;
start
-=
OFFSET_LENGTH
;
if
(
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(
optimizeUpdate
)
{
if
(
writtenData
)
{
if
(
writtenData
)
{
byte
[]
d
=
data
.
getBytes
();
byte
[]
d
=
data
.
getBytes
();
int
dataStart
=
offsets
[
entryCount
];
int
dataStart
=
offsets
[
entryCount
];
...
@@ -265,14 +267,14 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -265,14 +267,14 @@ public class PageBtreeLeaf extends PageBtree {
if
(
written
)
{
if
(
written
)
{
return
;
return
;
}
}
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
writeHead
();
writeHead
();
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
data
.
writeShortInt
(
offsets
[
i
]);
data
.
writeShortInt
(
offsets
[
i
]);
}
}
if
(!
writtenData
||
!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
writtenData
||
!
optimizeUpdate
)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
index
.
writeRow
(
data
,
offsets
[
i
],
rows
[
i
],
onlyPosition
);
index
.
writeRow
(
data
,
offsets
[
i
],
rows
[
i
],
onlyPosition
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageBtreeNode.java
浏览文件 @
a7d663ef
...
@@ -37,6 +37,8 @@ public class PageBtreeNode extends PageBtree {
...
@@ -37,6 +37,8 @@ public class PageBtreeNode extends PageBtree {
private
static
final
int
CHILD_OFFSET_PAIR_LENGTH
=
6
;
private
static
final
int
CHILD_OFFSET_PAIR_LENGTH
=
6
;
private
static
final
int
MAX_KEY_LENGTH
=
10
;
private
static
final
int
MAX_KEY_LENGTH
=
10
;
private
final
boolean
pageStoreInternalCount
;
/**
/**
* The page ids of the children.
* The page ids of the children.
*/
*/
...
@@ -48,6 +50,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -48,6 +50,7 @@ public class PageBtreeNode extends PageBtree {
private
PageBtreeNode
(
PageBtreeIndex
index
,
int
pageId
,
Data
data
)
{
private
PageBtreeNode
(
PageBtreeIndex
index
,
int
pageId
,
Data
data
)
{
super
(
index
,
pageId
,
data
);
super
(
index
,
pageId
,
data
);
this
.
pageStoreInternalCount
=
index
.
getDatabase
().
getSettings
().
pageStoreInternalCount
;
}
}
/**
/**
...
@@ -80,7 +83,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -80,7 +83,7 @@ public class PageBtreeNode extends PageBtree {
// 4 bytes for the rightmost child page id
// 4 bytes for the rightmost child page id
p
.
start
=
p
.
data
.
length
()
+
4
;
p
.
start
=
p
.
data
.
length
()
+
4
;
p
.
rows
=
SearchRow
.
EMPTY_ARRAY
;
p
.
rows
=
SearchRow
.
EMPTY_ARRAY
;
if
(
SysProperties
.
PAGE_STORE_INTERNAL_COUNT
)
{
if
(
p
.
pageStoreInternalCount
)
{
p
.
rowCount
=
0
;
p
.
rowCount
=
0
;
}
}
return
p
;
return
p
;
...
@@ -180,7 +183,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -180,7 +183,7 @@ public class PageBtreeNode extends PageBtree {
add
(
offsets
,
x
+
1
,
entryCount
+
1
,
-
rowLength
);
add
(
offsets
,
x
+
1
,
entryCount
+
1
,
-
rowLength
);
childPageIds
=
insert
(
childPageIds
,
entryCount
+
1
,
x
+
1
,
childPageId
);
childPageIds
=
insert
(
childPageIds
,
entryCount
+
1
,
x
+
1
,
childPageId
);
start
+=
CHILD_OFFSET_PAIR_LENGTH
;
start
+=
CHILD_OFFSET_PAIR_LENGTH
;
if
(
SysProperties
.
PAGE_STORE_INTERNAL_COUNT
)
{
if
(
pageStoreInternalCount
)
{
if
(
rowCount
!=
UNKNOWN_ROWCOUNT
)
{
if
(
rowCount
!=
UNKNOWN_ROWCOUNT
)
{
rowCount
+=
offset
;
rowCount
+=
offset
;
}
}
...
@@ -278,7 +281,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -278,7 +281,7 @@ public class PageBtreeNode extends PageBtree {
rows
=
SearchRow
.
EMPTY_ARRAY
;
rows
=
SearchRow
.
EMPTY_ARRAY
;
offsets
=
Utils
.
EMPTY_INT_ARRAY
;
offsets
=
Utils
.
EMPTY_INT_ARRAY
;
addChild
(
0
,
page2
.
getPos
(),
pivot
);
addChild
(
0
,
page2
.
getPos
(),
pivot
);
if
(
SysProperties
.
PAGE_STORE_INTERNAL_COUNT
)
{
if
(
pageStoreInternalCount
)
{
rowCount
=
page1
.
getRowCount
()
+
page2
.
getRowCount
();
rowCount
=
page1
.
getRowCount
()
+
page2
.
getRowCount
();
}
}
check
();
check
();
...
@@ -375,7 +378,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -375,7 +378,7 @@ public class PageBtreeNode extends PageBtree {
}
}
void
setRowCountStored
(
int
rowCount
)
{
void
setRowCountStored
(
int
rowCount
)
{
if
(
rowCount
<
0
&&
SysProperties
.
PAGE_STORE_INTERNAL_COUNT
)
{
if
(
rowCount
<
0
&&
pageStoreInternalCount
)
{
return
;
return
;
}
}
this
.
rowCount
=
rowCount
;
this
.
rowCount
=
rowCount
;
...
@@ -446,7 +449,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -446,7 +449,7 @@ public class PageBtreeNode extends PageBtree {
private
void
removeChild
(
int
i
)
{
private
void
removeChild
(
int
i
)
{
readAllRows
();
readAllRows
();
entryCount
--;
entryCount
--;
if
(
SysProperties
.
PAGE_STORE_INTERNAL_COUNT
)
{
if
(
pageStoreInternalCount
)
{
updateRowCount
(-
index
.
getPage
(
childPageIds
[
i
]).
getRowCount
());
updateRowCount
(-
index
.
getPage
(
childPageIds
[
i
]).
getRowCount
());
}
}
written
=
false
;
written
=
false
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
a7d663ef
...
@@ -34,6 +34,8 @@ import org.h2.store.PageStore;
...
@@ -34,6 +34,8 @@ import org.h2.store.PageStore;
*/
*/
public
class
PageDataLeaf
extends
PageData
{
public
class
PageDataLeaf
extends
PageData
{
private
final
boolean
optimizeUpdate
;
/**
/**
* The row offsets.
* The row offsets.
*/
*/
...
@@ -72,6 +74,7 @@ public class PageDataLeaf extends PageData {
...
@@ -72,6 +74,7 @@ public class PageDataLeaf extends PageData {
private
PageDataLeaf
(
PageDataIndex
index
,
int
pageId
,
Data
data
)
{
private
PageDataLeaf
(
PageDataIndex
index
,
int
pageId
,
Data
data
)
{
super
(
index
,
pageId
,
data
);
super
(
index
,
pageId
,
data
);
this
.
optimizeUpdate
=
index
.
getDatabase
().
getSettings
().
optimizeUpdate
;
}
}
/**
/**
...
@@ -183,7 +186,7 @@ public class PageDataLeaf extends PageData {
...
@@ -183,7 +186,7 @@ public class PageDataLeaf extends PageData {
if
(
entryCount
==
0
)
{
if
(
entryCount
==
0
)
{
x
=
0
;
x
=
0
;
}
else
{
}
else
{
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
x
=
findInsertionPoint
(
row
.
getKey
());
x
=
findInsertionPoint
(
row
.
getKey
());
...
@@ -199,7 +202,7 @@ public class PageDataLeaf extends PageData {
...
@@ -199,7 +202,7 @@ public class PageDataLeaf extends PageData {
rows
=
insert
(
rows
,
entryCount
,
x
,
row
);
rows
=
insert
(
rows
,
entryCount
,
x
,
row
);
entryCount
++;
entryCount
++;
index
.
getPageStore
().
update
(
this
);
index
.
getPageStore
().
update
(
this
);
if
(
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(
optimizeUpdate
)
{
if
(
writtenData
&&
offset
>=
start
)
{
if
(
writtenData
&&
offset
>=
start
)
{
byte
[]
d
=
data
.
getBytes
();
byte
[]
d
=
data
.
getBytes
();
int
dataStart
=
offsets
[
entryCount
-
1
]
+
rowLength
;
int
dataStart
=
offsets
[
entryCount
-
1
]
+
rowLength
;
...
@@ -267,7 +270,7 @@ public class PageDataLeaf extends PageData {
...
@@ -267,7 +270,7 @@ public class PageDataLeaf extends PageData {
index
.
getPageStore
().
logUndo
(
this
,
data
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
written
=
false
;
written
=
false
;
changeCount
=
index
.
getPageStore
().
getChangeCount
();
changeCount
=
index
.
getPageStore
().
getChangeCount
();
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
Row
r
=
getRowAt
(
i
);
Row
r
=
getRowAt
(
i
);
...
@@ -288,7 +291,7 @@ public class PageDataLeaf extends PageData {
...
@@ -288,7 +291,7 @@ public class PageDataLeaf extends PageData {
int
keyOffsetPairLen
=
2
+
Data
.
getVarLongLen
(
keys
[
i
]);
int
keyOffsetPairLen
=
2
+
Data
.
getVarLongLen
(
keys
[
i
]);
int
startNext
=
i
>
0
?
offsets
[
i
-
1
]
:
index
.
getPageStore
().
getPageSize
();
int
startNext
=
i
>
0
?
offsets
[
i
-
1
]
:
index
.
getPageStore
().
getPageSize
();
int
rowLength
=
startNext
-
offsets
[
i
];
int
rowLength
=
startNext
-
offsets
[
i
];
if
(
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(
optimizeUpdate
)
{
if
(
writtenData
)
{
if
(
writtenData
)
{
byte
[]
d
=
data
.
getBytes
();
byte
[]
d
=
data
.
getBytes
();
int
dataStart
=
offsets
[
entryCount
];
int
dataStart
=
offsets
[
entryCount
];
...
@@ -481,7 +484,7 @@ public class PageDataLeaf extends PageData {
...
@@ -481,7 +484,7 @@ public class PageDataLeaf extends PageData {
if
(
written
)
{
if
(
written
)
{
return
;
return
;
}
}
if
(!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
optimizeUpdate
)
{
readAllRows
();
readAllRows
();
}
}
writeHead
();
writeHead
();
...
@@ -493,7 +496,7 @@ public class PageDataLeaf extends PageData {
...
@@ -493,7 +496,7 @@ public class PageDataLeaf extends PageData {
data
.
writeVarLong
(
keys
[
i
]);
data
.
writeVarLong
(
keys
[
i
]);
data
.
writeShortInt
(
offsets
[
i
]);
data
.
writeShortInt
(
offsets
[
i
]);
}
}
if
(!
writtenData
||
!
SysProperties
.
OPTIMIZE_UPDATE
)
{
if
(!
writtenData
||
!
optimizeUpdate
)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
data
.
setPos
(
offsets
[
i
]);
data
.
setPos
(
offsets
[
i
]);
Row
r
=
getRowAt
(
i
);
Row
r
=
getRowAt
(
i
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
a7d663ef
...
@@ -9,7 +9,7 @@ package org.h2.result;
...
@@ -9,7 +9,7 @@ package org.h2.result;
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
org.h2.
constant.SysProperties
;
import
org.h2.
engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -226,7 +226,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
...
@@ -226,7 +226,8 @@ public class LocalResult implements ResultInterface, ResultTarget {
ValueArray
array
=
ValueArray
.
get
(
values
);
ValueArray
array
=
ValueArray
.
get
(
values
);
distinctRows
.
put
(
array
,
values
);
distinctRows
.
put
(
array
,
values
);
rowCount
=
distinctRows
.
size
();
rowCount
=
distinctRows
.
size
();
if
(
rowCount
>
SysProperties
.
MAX_MEMORY_ROWS_DISTINCT
&&
session
.
getDatabase
().
isPersistent
())
{
Database
db
=
session
.
getDatabase
();
if
(
rowCount
>
db
.
getSettings
().
maxMemoryRowsDistinct
&&
db
.
isPersistent
())
{
disk
=
new
ResultTempTable
(
session
,
sort
);
disk
=
new
ResultTempTable
(
session
,
sort
);
disk
.
addRows
(
distinctRows
.
values
());
disk
.
addRows
(
distinctRows
.
values
());
distinctRows
=
null
;
distinctRows
=
null
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/ResultDiskBuffer.java
浏览文件 @
a7d663ef
...
@@ -64,7 +64,7 @@ class ResultDiskBuffer implements ResultExternal {
...
@@ -64,7 +64,7 @@ class ResultDiskBuffer implements ResultExternal {
this
.
sort
=
sort
;
this
.
sort
=
sort
;
this
.
columnCount
=
columnCount
;
this
.
columnCount
=
columnCount
;
Database
db
=
session
.
getDatabase
();
Database
db
=
session
.
getDatabase
();
rowBuff
=
Data
.
create
(
db
,
SysProperties
.
PAGE_SIZE
);
rowBuff
=
Data
.
create
(
db
,
Constants
.
DEFAULT_
PAGE_SIZE
);
String
fileName
=
session
.
getDatabase
().
createTempFile
();
String
fileName
=
session
.
getDatabase
().
createTempFile
();
file
=
session
.
getDatabase
().
openFile
(
fileName
,
"rw"
,
false
);
file
=
session
.
getDatabase
().
openFile
(
fileName
,
"rw"
,
false
);
file
.
setCheckedWriting
(
false
);
file
.
setCheckedWriting
(
false
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/result/RowList.java
浏览文件 @
a7d663ef
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
package
org
.
h2
.
result
;
package
org
.
h2
.
result
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
...
@@ -88,7 +87,7 @@ public class RowList {
...
@@ -88,7 +87,7 @@ public class RowList {
String
fileName
=
db
.
createTempFile
();
String
fileName
=
db
.
createTempFile
();
file
=
db
.
openFile
(
fileName
,
"rw"
,
false
);
file
=
db
.
openFile
(
fileName
,
"rw"
,
false
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
rowBuff
=
Data
.
create
(
db
,
SysProperties
.
PAGE_SIZE
);
rowBuff
=
Data
.
create
(
db
,
Constants
.
DEFAULT_
PAGE_SIZE
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
}
}
Data
buff
=
rowBuff
;
Data
buff
=
rowBuff
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
a7d663ef
...
@@ -134,7 +134,7 @@ public class PageStore implements CacheWriter {
...
@@ -134,7 +134,7 @@ public class PageStore implements CacheWriter {
private
String
fileName
;
private
String
fileName
;
private
FileStore
file
;
private
FileStore
file
;
private
String
accessMode
;
private
String
accessMode
;
private
int
pageSize
=
SysProperties
.
PAGE_SIZE
;
private
int
pageSize
=
Constants
.
DEFAULT_
PAGE_SIZE
;
private
int
pageSizeShift
;
private
int
pageSizeShift
;
private
long
writeCountBase
,
writeCount
,
readCount
;
private
long
writeCountBase
,
writeCount
,
readCount
;
private
int
logKey
,
logFirstTrunkPage
,
logFirstDataPage
;
private
int
logKey
,
logFirstTrunkPage
,
logFirstDataPage
;
...
@@ -445,7 +445,7 @@ public class PageStore implements CacheWriter {
...
@@ -445,7 +445,7 @@ public class PageStore implements CacheWriter {
* TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAG
* TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAG
*/
*/
public
void
compact
(
int
compactMode
)
{
public
void
compact
(
int
compactMode
)
{
if
(!
SysProperties
.
PAGE_STORE_TRIM
)
{
if
(!
database
.
getSettings
().
pageStoreTrim
)
{
return
;
return
;
}
}
// find the last used page
// find the last used page
...
@@ -478,8 +478,8 @@ public class PageStore implements CacheWriter {
...
@@ -478,8 +478,8 @@ public class PageStore implements CacheWriter {
isCompactFully
=
isDefrag
=
true
;
isCompactFully
=
isDefrag
=
true
;
}
}
int
maxCompactTime
=
SysProperties
.
MAX_COMPACT_TIME
;
int
maxCompactTime
=
database
.
getSettings
().
maxCompactTime
;
int
maxMove
=
SysProperties
.
MAX_COMPACT_COUNT
;
int
maxMove
=
database
.
getSettings
().
maxCompactCount
;
if
(
isCompactFully
||
isDefrag
)
{
if
(
isCompactFully
||
isDefrag
)
{
maxCompactTime
=
Integer
.
MAX_VALUE
;
maxCompactTime
=
Integer
.
MAX_VALUE
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
a7d663ef
...
@@ -8,7 +8,7 @@ package org.h2.store;
...
@@ -8,7 +8,7 @@ package org.h2.store;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.security.AccessControlException
;
import
java.security.AccessControlException
;
import
org.h2.
constant.SysPropertie
s
;
import
org.h2.
engine.Constant
s
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceSystem
;
import
org.h2.message.TraceSystem
;
...
@@ -79,7 +79,7 @@ public class WriterThread implements Runnable {
...
@@ -79,7 +79,7 @@ public class WriterThread implements Runnable {
int
wait
=
writeDelay
;
int
wait
=
writeDelay
;
try
{
try
{
if
(
database
.
isFileLockSerialized
())
{
if
(
database
.
isFileLockSerialized
())
{
wait
=
SysPropertie
s
.
MIN_WRITE_DELAY
;
wait
=
Constant
s
.
MIN_WRITE_DELAY
;
database
.
checkpointIfRequired
();
database
.
checkpointIfRequired
();
}
else
{
}
else
{
database
.
flush
();
database
.
flush
();
...
@@ -93,9 +93,9 @@ public class WriterThread implements Runnable {
...
@@ -93,9 +93,9 @@ public class WriterThread implements Runnable {
// TODO log writer: could also flush the dirty cache when there is
// TODO log writer: could also flush the dirty cache when there is
// low activity
// low activity
if
(
wait
<
SysPropertie
s
.
MIN_WRITE_DELAY
)
{
if
(
wait
<
Constant
s
.
MIN_WRITE_DELAY
)
{
// wait 0 mean wait forever, which is not what we want
// wait 0 mean wait forever, which is not what we want
wait
=
SysPropertie
s
.
MIN_WRITE_DELAY
;
wait
=
Constant
s
.
MIN_WRITE_DELAY
;
}
}
try
{
try
{
Thread
.
sleep
(
wait
);
Thread
.
sleep
(
wait
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
a7d663ef
...
@@ -194,7 +194,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -194,7 +194,7 @@ public class TableFilter implements ColumnResolver {
}
}
private
void
setEvaluatable
(
TableFilter
join
)
{
private
void
setEvaluatable
(
TableFilter
join
)
{
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
session
.
getDatabase
().
getSettings
().
nestedJoins
)
{
setEvaluatable
(
true
);
setEvaluatable
(
true
);
return
;
return
;
}
}
...
@@ -498,7 +498,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -498,7 +498,7 @@ public class TableFilter implements ColumnResolver {
public
void
addJoin
(
TableFilter
filter
,
boolean
outer
,
boolean
nested
,
final
Expression
on
)
{
public
void
addJoin
(
TableFilter
filter
,
boolean
outer
,
boolean
nested
,
final
Expression
on
)
{
if
(
on
!=
null
)
{
if
(
on
!=
null
)
{
on
.
mapColumns
(
this
,
0
);
on
.
mapColumns
(
this
,
0
);
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
session
.
getDatabase
().
getSettings
().
nestedJoins
)
{
visit
(
new
TableFilterVisitor
()
{
visit
(
new
TableFilterVisitor
()
{
public
void
accept
(
TableFilter
f
)
{
public
void
accept
(
TableFilter
f
)
{
on
.
mapColumns
(
f
,
0
);
on
.
mapColumns
(
f
,
0
);
...
@@ -511,7 +511,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -511,7 +511,7 @@ public class TableFilter implements ColumnResolver {
});
});
}
}
}
}
if
(
nested
&&
SysProperties
.
NESTED_JOINS
)
{
if
(
nested
&&
session
.
getDatabase
().
getSettings
().
nestedJoins
)
{
if
(
nestedJoin
!=
null
)
{
if
(
nestedJoin
!=
null
)
{
throw
DbException
.
throwInternalError
();
throw
DbException
.
throwInternalError
();
}
}
...
@@ -531,7 +531,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -531,7 +531,7 @@ public class TableFilter implements ColumnResolver {
if
(
join
==
null
)
{
if
(
join
==
null
)
{
join
=
filter
;
join
=
filter
;
filter
.
joinOuter
=
outer
;
filter
.
joinOuter
=
outer
;
if
(
SysProperties
.
NESTED_JOINS
)
{
if
(
session
.
getDatabase
().
getSettings
().
nestedJoins
)
{
if
(
outer
)
{
if
(
outer
)
{
filter
.
visit
(
new
TableFilterVisitor
()
{
filter
.
visit
(
new
TableFilterVisitor
()
{
public
void
accept
(
TableFilter
f
)
{
public
void
accept
(
TableFilter
f
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
a7d663ef
...
@@ -23,7 +23,6 @@ import java.util.HashSet;
...
@@ -23,7 +23,6 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.CRC32
;
import
java.util.zip.CRC32
;
import
org.h2.compress.CompressLZF
;
import
org.h2.compress.CompressLZF
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.MetaRecord
;
import
org.h2.engine.MetaRecord
;
...
@@ -381,7 +380,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -381,7 +380,7 @@ public class Recover extends Tool implements DataHandler {
" writeVersion: "
+
writeVersion
+
" writeVersion: "
+
writeVersion
+
" readVersion: "
+
readVersion
);
" readVersion: "
+
readVersion
);
if
(
pageSize
<
PageStore
.
PAGE_SIZE_MIN
||
pageSize
>
PageStore
.
PAGE_SIZE_MAX
)
{
if
(
pageSize
<
PageStore
.
PAGE_SIZE_MIN
||
pageSize
>
PageStore
.
PAGE_SIZE_MAX
)
{
pageSize
=
SysProperties
.
PAGE_SIZE
;
pageSize
=
Constants
.
DEFAULT_
PAGE_SIZE
;
writer
.
println
(
"-- ERROR: page size; using "
+
pageSize
);
writer
.
println
(
"-- ERROR: page size; using "
+
pageSize
);
}
}
long
pageCount
=
length
/
pageSize
;
long
pageCount
=
length
/
pageSize
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
a7d663ef
...
@@ -41,7 +41,7 @@ public class CompareMode {
...
@@ -41,7 +41,7 @@ public class CompareMode {
int
cacheSize
=
0
;
int
cacheSize
=
0
;
if
(
collator
!=
null
)
{
if
(
collator
!=
null
)
{
this
.
collator
.
setStrength
(
strength
);
this
.
collator
.
setStrength
(
strength
);
cacheSize
=
SysProperties
.
getCollatorCacheSize
()
;
cacheSize
=
SysProperties
.
COLLATOR_CACHE_SIZE
;
}
}
if
(
cacheSize
!=
0
)
{
if
(
cacheSize
!=
0
)
{
collationKeys
=
SmallLRUCache
.
newInstance
(
cacheSize
);
collationKeys
=
SmallLRUCache
.
newInstance
(
cacheSize
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/DirectInsert.java
浏览文件 @
a7d663ef
...
@@ -11,7 +11,6 @@ import java.sql.DriverManager;
...
@@ -11,7 +11,6 @@ import java.sql.DriverManager;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.constant.SysProperties
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
/**
/**
...
@@ -29,16 +28,17 @@ public class DirectInsert {
...
@@ -29,16 +28,17 @@ public class DirectInsert {
public
static
void
main
(
String
...
args
)
throws
Exception
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
Class
.
forName
(
"org.h2.Driver"
);
Class
.
forName
(
"org.h2.Driver"
);
DeleteDbFiles
.
execute
(
"~"
,
"test"
,
true
);
DeleteDbFiles
.
execute
(
"~"
,
"test"
,
true
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:~/test;LOG=0"
,
"sa"
,
""
);
String
url
=
"jdbc:h2:~/test"
;
Statement
stat
=
conn
.
createStatement
();
initialInsert
(
url
,
200000
);
initialInsert
(
conn
,
stat
,
200000
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
createAsSelect
(
stat
,
true
);
createAsSelect
(
url
,
true
);
createAsSelect
(
stat
,
false
);
createAsSelect
(
url
,
false
);
}
}
}
}
private
static
void
initialInsert
(
Connection
conn
,
Statement
stat
,
int
len
)
throws
SQLException
{
private
static
void
initialInsert
(
String
url
,
int
len
)
throws
SQLException
{
Connection
conn
=
DriverManager
.
getConnection
(
url
+
";LOG=0"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, 'Test' || SPACE(100))"
);
...
@@ -53,16 +53,19 @@ public class DirectInsert {
...
@@ -53,16 +53,19 @@ public class DirectInsert {
prep
.
execute
();
prep
.
execute
();
}
}
conn
.
commit
();
conn
.
commit
();
conn
.
close
();
}
}
private
static
void
createAsSelect
(
Statement
stat
,
boolean
optimize
)
throws
SQLException
{
private
static
void
createAsSelect
(
String
url
,
boolean
optimize
)
throws
SQLException
{
SysProperties
.
optimizeInsertFromSelect
=
optimize
;
Connection
conn
=
DriverManager
.
getConnection
(
url
+
";OPTIMIZE_INSERT_FROM_SELECT="
+
optimize
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"DROP TABLE IF EXISTS TEST2"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST2"
);
System
.
out
.
println
(
"CREATE TABLE ... AS SELECT "
+
(
optimize
?
"(optimized)"
:
""
));
System
.
out
.
println
(
"CREATE TABLE ... AS SELECT "
+
(
optimize
?
"(optimized)"
:
""
));
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
stat
.
execute
(
"CREATE TABLE TEST2 AS SELECT * FROM TEST"
);
stat
.
execute
(
"CREATE TABLE TEST2 AS SELECT * FROM TEST"
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
stat
.
execute
(
"INSERT INTO TEST2 SELECT * FROM TEST2"
);
stat
.
execute
(
"INSERT INTO TEST2 SELECT * FROM TEST2"
);
conn
.
close
();
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
a7d663ef
...
@@ -250,6 +250,11 @@ java org.h2.test.TestAll timer
...
@@ -250,6 +250,11 @@ java org.h2.test.TestAll timer
*/
*/
public
boolean
splitFileSystem
;
public
boolean
splitFileSystem
;
/**
* Support nested joins.
*/
public
boolean
nestedJoins
;
/**
/**
* If the transaction log should be kept small (that is, the log should be
* If the transaction log should be kept small (that is, the log should be
* switched early).
* switched early).
...
@@ -319,10 +324,10 @@ java org.h2.test.TestAll timer
...
@@ -319,10 +324,10 @@ java org.h2.test.TestAll timer
System
.
setProperty
(
"h2.check2"
,
"true"
);
System
.
setProperty
(
"h2.check2"
,
"true"
);
int
initialTest
;
int
initialTest
;
// System.setProperty("h2.largeTransactions", "true");
// System.setProperty("h2.lobInDatabase", "true");
// System.setProperty("h2.lobInDatabase", "true");
test
.
nestedJoins
=
true
;
// System.setProperty("h2.largeTransactions", "true");
// System.setProperty("h2.analyzeAuto", "100");
// System.setProperty("h2.analyzeAuto", "100");
// System.setProperty("h2.nestedJoins", "true");
// System.setProperty("h2.optimizeOr", "true");
// System.setProperty("h2.optimizeOr", "true");
// System.setProperty("h2.queryCacheSize", "100");
// System.setProperty("h2.queryCacheSize", "100");
// System.setProperty("h2.dropRestrict", "true");
// System.setProperty("h2.dropRestrict", "true");
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
a7d663ef
...
@@ -308,7 +308,9 @@ public abstract class TestBase {
...
@@ -308,7 +308,9 @@ public abstract class TestBase {
if
(
config
.
defrag
)
{
if
(
config
.
defrag
)
{
url
+=
";DEFRAG_ALWAYS=TRUE"
;
url
+=
";DEFRAG_ALWAYS=TRUE"
;
}
}
if
(
config
.
nestedJoins
)
{
url
+=
";NESTED_JOINS=TRUE"
;
}
return
"jdbc:h2:"
+
url
;
return
"jdbc:h2:"
+
url
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/synth/TestNestedJoins.java
浏览文件 @
a7d663ef
...
@@ -16,7 +16,6 @@ import java.sql.Statement;
...
@@ -16,7 +16,6 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.constant.SysProperties
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -35,14 +34,14 @@ public class TestNestedJoins extends TestBase {
...
@@ -35,14 +34,14 @@ public class TestNestedJoins extends TestBase {
* @param a ignored
* @param a ignored
*/
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
public
static
void
main
(
String
...
a
)
throws
Exception
{
System
.
setProperty
(
"h2.nestedJoins"
,
"true"
);
TestBase
test
=
TestBase
.
createCaller
().
init
();
TestBase
test
=
TestBase
.
createCaller
().
init
();
// test.config.traceTest = true;
// test.config.traceTest = true;
test
.
config
.
nestedJoins
=
true
;
test
.
test
();
test
.
test
();
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
if
(!
SysProperties
.
NESTED_JOINS
)
{
if
(!
config
.
nestedJoins
)
{
return
;
return
;
}
}
deleteDb
(
"nestedJoins"
);
deleteDb
(
"nestedJoins"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/synth/TestOuterJoins.java
浏览文件 @
a7d663ef
...
@@ -16,7 +16,6 @@ import java.sql.Statement;
...
@@ -16,7 +16,6 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.constant.SysProperties
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -42,7 +41,7 @@ public class TestOuterJoins extends TestBase {
...
@@ -42,7 +41,7 @@ public class TestOuterJoins extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
if
(!
SysProperties
.
NESTED_JOINS
)
{
if
(!
config
.
nestedJoins
)
{
return
;
return
;
}
}
deleteDb
(
"outerJoins"
);
deleteDb
(
"outerJoins"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestCompress.java
浏览文件 @
a7d663ef
...
@@ -14,7 +14,7 @@ import java.util.ArrayList;
...
@@ -14,7 +14,7 @@ import java.util.ArrayList;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.compress.CompressLZF
;
import
org.h2.compress.CompressLZF
;
import
org.h2.compress.Compressor
;
import
org.h2.compress.Compressor
;
import
org.h2.
constant.SysPropertie
s
;
import
org.h2.
engine.Constant
s
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.CompressTool
;
...
@@ -132,7 +132,7 @@ public class TestCompress extends TestBase {
...
@@ -132,7 +132,7 @@ public class TestCompress extends TestBase {
}
}
conn
.
close
();
conn
.
close
();
Compressor
compress
=
new
CompressLZF
();
Compressor
compress
=
new
CompressLZF
();
int
pageSize
=
SysProperties
.
PAGE_SIZE
;
int
pageSize
=
Constants
.
DEFAULT_
PAGE_SIZE
;
byte
[]
buff
=
new
byte
[
pageSize
];
byte
[]
buff
=
new
byte
[
pageSize
];
byte
[]
test
=
new
byte
[
2
*
pageSize
];
byte
[]
test
=
new
byte
[
2
*
pageSize
];
compress
.
compress
(
buff
,
pageSize
,
test
,
0
);
compress
.
compress
(
buff
,
pageSize
,
test
,
0
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论