Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
31bdce51
提交
31bdce51
authored
10月 25, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various system properties have been replaced with database level settings.
上级
16679fbf
显示空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
270 行增加
和
34 行删除
+270
-34
changelog.html
h2/src/docsrc/html/changelog.html
+5
-1
roadmap.html
h2/src/docsrc/html/roadmap.html
+2
-0
classes.html
h2/src/docsrc/javadoc/classes.html
+1
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+6
-5
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+2
-2
DropTable.java
h2/src/main/org/h2/command/ddl/DropTable.java
+2
-2
DropView.java
h2/src/main/org/h2/command/ddl/DropView.java
+2
-2
DbSettings.java
h2/src/main/org/h2/constant/DbSettings.java
+123
-0
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+21
-1
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+19
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+8
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-1
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-5
SettingsBase.java
h2/src/main/org/h2/engine/SettingsBase.java
+59
-0
CompareLike.java
h2/src/main/org/h2/expression/CompareLike.java
+10
-5
JavaFunction.java
h2/src/main/org/h2/expression/JavaFunction.java
+1
-2
FunctionIndex.java
h2/src/main/org/h2/index/FunctionIndex.java
+1
-2
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+1
-1
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+2
-1
TestPattern.java
h2/src/test/org/h2/test/unit/TestPattern.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
31bdce51
...
...
@@ -18,7 +18,11 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
When the system property h2.nestedJoins was enabled, some outer joins returned the wrong result.
<ul><li>
Various system properties have been replaced with database level settings:
analyzeAuto, analyzeSample, databaseToUpper,...
See the javadoc documentation of DbSettings for details.
The system properties are still supported for backward compatibility.
</li><li>
When the system property h2.nestedJoins was enabled, some outer joins returned the wrong result.
</li><li>
Opening a database could throw a NullPointerException.
</li><li>
After a crash, the database file did not always shrink because
old transaction log pages were not removed from the file.
...
...
h2/src/docsrc/html/roadmap.html
浏览文件 @
31bdce51
...
...
@@ -42,6 +42,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
For RUNSCRIPT and SCRIPT (commands and tools), use UTF-8 by default.
</li><li>
Set h2.maxMemoryRowsDistinct to a lower value.
</li><li>
Enable h2.optimizeInsertFromSelect (speed up CREATE TABLE ... AS SELECT).
</li><li>
Possibly enable h2.queryCacheSize.
</li><li>
Possibly enable h2.databaseToUpper.
</li></ul>
<h2>
Priority 1
</h2>
...
...
h2/src/docsrc/javadoc/classes.html
浏览文件 @
31bdce51
...
...
@@ -82,6 +82,7 @@ org.h2.api<br />
<b>
Constants
</b><br
/>
org.h2.constant
<br
/>
<a
href=
"org/h2/constant/DbSettings.html"
target=
"javadoc"
>
DbSettings
</a><br
/>
<a
href=
"org/h2/constant/ErrorCode.html"
target=
"javadoc"
>
ErrorCode
</a><br
/>
<a
href=
"org/h2/constant/SysProperties.html"
target=
"javadoc"
>
SysProperties
</a><br
/>
<br
/>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
31bdce51
...
...
@@ -183,10 +183,11 @@ public class Parser {
private
boolean
rightsChecked
;
private
boolean
recompileAlways
;
private
ArrayList
<
Parameter
>
indexedParameterList
;
private
boolean
identifiersToUpper
=
SysProperties
.
IDENTIFIERS_TO_UPPER
;
private
final
boolean
identifiersToUpper
;
public
Parser
(
Session
session
)
{
database
=
session
.
getDatabase
();
this
.
identifiersToUpper
=
database
.
getSettings
().
databaseToUpper
;
this
.
session
=
session
;
}
...
...
@@ -1774,10 +1775,10 @@ public class Parser {
esc
=
readConcat
();
}
recompileAlways
=
true
;
r
=
new
CompareLike
(
database
.
getCompareMode
()
,
r
,
b
,
esc
,
false
);
r
=
new
CompareLike
(
database
,
r
,
b
,
esc
,
false
);
}
else
if
(
readIf
(
"REGEXP"
))
{
Expression
b
=
readConcat
();
r
=
new
CompareLike
(
database
.
getCompareMode
()
,
r
,
b
,
null
,
true
);
r
=
new
CompareLike
(
database
,
r
,
b
,
null
,
true
);
}
else
if
(
readIf
(
"IS"
))
{
if
(
readIf
(
"NOT"
))
{
if
(
readIf
(
"NULL"
))
{
...
...
@@ -1898,7 +1899,7 @@ public class Parser {
function
.
setParameter
(
0
,
r
);
r
=
function
;
}
r
=
new
CompareLike
(
database
.
getCompareMode
()
,
r
,
readSum
(),
null
,
true
);
r
=
new
CompareLike
(
database
,
r
,
readSum
(),
null
,
true
);
}
else
if
(
readIf
(
"!~"
))
{
if
(
readIf
(
"*"
))
{
Function
function
=
Function
.
getFunction
(
database
,
"CAST"
);
...
...
@@ -1906,7 +1907,7 @@ public class Parser {
function
.
setParameter
(
0
,
r
);
r
=
function
;
}
r
=
new
ConditionNot
(
new
CompareLike
(
database
.
getCompareMode
()
,
r
,
readSum
(),
null
,
true
));
r
=
new
ConditionNot
(
new
CompareLike
(
database
,
r
,
readSum
(),
null
,
true
));
}
else
{
return
r
;
}
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
31bdce51
...
...
@@ -8,7 +8,6 @@ package org.h2.command.ddl;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Prepared
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
...
...
@@ -27,10 +26,11 @@ public class Analyze extends DefineCommand {
/**
* The sample size.
*/
private
int
sampleRows
=
SysProperties
.
ANALYZE_SAMPLE
;
private
int
sampleRows
;
public
Analyze
(
Session
session
)
{
super
(
session
);
sampleRows
=
session
.
getDatabase
().
getSettings
().
analyzeSample
;
}
public
int
update
()
{
...
...
h2/src/main/org/h2/command/ddl/DropTable.java
浏览文件 @
31bdce51
...
...
@@ -9,7 +9,6 @@ package org.h2.command.ddl;
import
java.util.ArrayList
;
import
org.h2.command.CommandInterface
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.ConstraintReferential
;
import
org.h2.engine.Database
;
import
org.h2.engine.Right
;
...
...
@@ -30,10 +29,11 @@ public class DropTable extends SchemaCommand {
private
String
tableName
;
private
Table
table
;
private
DropTable
next
;
private
int
dropAction
=
SysProperties
.
DROP_RESTRICT
?
ConstraintReferential
.
RESTRICT
:
ConstraintReferential
.
CASCADE
;
private
int
dropAction
;
public
DropTable
(
Session
session
,
Schema
schema
)
{
super
(
session
,
schema
);
dropAction
=
session
.
getDatabase
().
getSettings
().
dropRestrict
?
ConstraintReferential
.
RESTRICT
:
ConstraintReferential
.
CASCADE
;
}
/**
...
...
h2/src/main/org/h2/command/ddl/DropView.java
浏览文件 @
31bdce51
...
...
@@ -8,7 +8,6 @@ package org.h2.command.ddl;
import
org.h2.command.CommandInterface
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.ConstraintReferential
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Right
;
...
...
@@ -26,10 +25,11 @@ public class DropView extends SchemaCommand {
private
String
viewName
;
private
boolean
ifExists
;
private
int
dropAction
=
SysProperties
.
DROP_RESTRICT
?
ConstraintReferential
.
RESTRICT
:
ConstraintReferential
.
CASCADE
;
private
int
dropAction
;
public
DropView
(
Session
session
,
Schema
schema
)
{
super
(
session
,
schema
);
dropAction
=
session
.
getDatabase
().
getSettings
().
dropRestrict
?
ConstraintReferential
.
RESTRICT
:
ConstraintReferential
.
CASCADE
;
}
public
void
setIfExists
(
boolean
b
)
{
...
...
h2/src/main/org/h2/constant/DbSettings.java
0 → 100644
浏览文件 @
31bdce51
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
constant
;
import
java.util.Properties
;
import
org.h2.engine.SettingsBase
;
/**
* This class contains various database-level settings. To override the
* documented default value for a database, append the setting in the database
* URL: "jdbc:h2:test;analyzeSample=100" when opening the first connection to
* the database. The settings can not be changed once the database is open.
* <p>
* Some settings are a last resort and temporary solution to work around a
* problem in the application or database engine. Also, there are system
* properties to enable features that are not yet fully tested or that are not
* backward compatible.
* </p>
*/
public
class
DbSettings
extends
SettingsBase
{
private
static
DbSettings
defaultSettings
;
/**
* Database setting <code>analyzeAuto</code> (default: 0).<br />
* After changing this many rows, ANALYZE is automatically run for a table.
* Automatically running ANALYZE is disabled if set to 0. If set to 1000,
* then ANALYZE will run against each user table after about 1000 changes to
* that table. The time between running ANALYZE doubles each time since
* starting the database. It is not run on local temporary tables, and
* tables that have a trigger on SELECT.
*/
public
int
analyzeAuto
=
get
(
"analyzeAuto"
,
0
);
/**
* Database setting <code>analyzeSample</code> (default: 10000).<br />
* The default sample size when analyzing a table.
*/
public
int
analyzeSample
=
get
(
"analyzeSample"
,
10000
);
/**
* Database setting <code>databaseToUpper</code> (default: true).<br />
* Database short names are converted to uppercase for the DATABASE()
* function, and in the CATALOG column of all database meta data methods.
* Setting this to "false" is experimental.
*/
public
boolean
databaseToUpper
=
get
(
"databaseToUpper"
,
true
);
/**
* Database setting <code>defaultEscape</code> (default: \).<br />
* The default escape character for LIKE comparisons. To select no escape
* character, use an empty string.
*/
public
String
defaultEscape
=
get
(
"defaultEscape"
,
"\\"
);
/**
* Database setting <code>defragAlways</code> (default: false).<br />
* Each time the database is closed, it is fully defragmented (SHUTDOWN DEFRAG).
*/
public
boolean
defragAlways
=
get
(
"defragAlways"
,
false
);
/**
* Database setting <code>dropRestrict</code> (default: false).<br />
* Whether the default action for DROP TABLE and DROP VIEW is RESTRICT. For
* most databases, the default action is RESTRICT, but for compatibility
* with older versions of H2 the default action is currently CASCADE. This will
* change in a future version of H2.
*/
public
boolean
dropRestrict
=
get
(
"dropRestrict"
,
false
);
/**
* Database setting <code>estimatedFunctionTableRows</code> (default:
* 1000).<br />
* The estimated number of rows in a function table (for example, CSVREAD or
* FTL_SEARCH). This value is used by the optimizer.
*/
public
int
estimatedFunctionTableRows
=
get
(
"estimatedFunctionTableRows"
,
1000
);
/**
* Database setting <code>functionsInSchema</code> (default:
* false).<br />
* If set, all functions are stored in a schema. Specially, the SCRIPT statement
* will always include the schema name in the CREATE ALIAS statement.
* This is not backward compatible with H2 versions 1.2.134 and older.
*/
public
boolean
functionsInSchema
=
get
(
"functionsInSchema"
,
false
);
/**
* Database setting <code>queryCacheSize</code> (default: 0).<br />
* The size of the query cache. Each session has it's own cache with the
* given size. The cache is only used if the SQL statement and all
* parameters match. Only the last returned result per query is cached. Only
* SELECT statements are cached (excluding UNION and FOR UPDATE statements).
* This works for both statements and prepared statement.
*/
public
int
queryCacheSize
=
get
(
"queryCacheSize"
,
0
);
private
DbSettings
(
Properties
p
)
{
super
(
p
);
}
/**
* INTERNAL.
* Get the settings for the given properties (may be null).
*
* @param p the properties
* @return the settings
*/
public
static
DbSettings
getInstance
(
Properties
p
)
{
if
(
p
==
null
||
p
.
isEmpty
())
{
if
(
defaultSettings
==
null
)
{
defaultSettings
=
new
DbSettings
(
new
Properties
());
}
return
defaultSettings
;
}
return
new
DbSettings
(
p
);
}
}
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
31bdce51
...
...
@@ -85,6 +85,7 @@ public class SysProperties {
* System property <code>h2.analyzeSample</code> (default: 10000).<br />
* The default sample size when analyzing a table.
*/
// DbSettings
public
static
final
int
ANALYZE_SAMPLE
=
getIntSetting
(
"h2.analyzeSample"
,
10000
);
/**
...
...
@@ -96,6 +97,7 @@ public class SysProperties {
* starting the database. It is not run on local temporary tables, and
* tables that have a trigger on SELECT.
*/
// DbSettings
public
static
final
int
ANALYZE_AUTO
=
getIntSetting
(
"h2.analyzeAuto"
,
0
);
/**
...
...
@@ -109,6 +111,7 @@ public class SysProperties {
* for all databases except MySQL. For MySQL, it is always enabled.
*/
public
static
final
boolean
ALIAS_COLUMN_NAME
=
getBooleanSetting
(
"h2.aliasColumnName"
,
false
);
// TODO Mode
/**
* System property <code>h2.allowBigDecimalExtensions</code> (default:
...
...
@@ -151,6 +154,7 @@ public class SysProperties {
* The default cache size in KB.
*/
public
static
final
int
CACHE_SIZE_DEFAULT
=
getIntSetting
(
"h2.cacheSizeDefault"
,
16
*
1024
);
// TODO constant
/**
* System property <code>h2.cacheTypeDefault</code> (default: LRU).<br />
...
...
@@ -159,6 +163,7 @@ public class SysProperties {
* cacheSizeIndexShift.
*/
public
static
final
String
CACHE_TYPE_DEFAULT
=
getStringSetting
(
"h2.cacheTypeDefault"
,
"LRU"
);
// TODO constant
/**
* System property <code>h2.check</code> (default: true).<br />
...
...
@@ -193,13 +198,14 @@ public class SysProperties {
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
getStringSetting
(
"h2.clientTraceDirectory"
,
"trace.db/"
);
/**
* System property <code>h2.
command
CacheSize</code> (default: 0).<br />
* System property <code>h2.
query
CacheSize</code> (default: 0).<br />
* The size of the query cache. Each session has it's own cache with the
* given size. The cache is only used if the SQL statement and all
* parameters match. Only the last returned result per query is cached. Only
* SELECT statements are cached (excluding UNION and FOR UPDATE statements).
* This works for both statements and prepared statement.
*/
// DbSettings
public
static
final
int
QUERY_CACHE_SIZE
=
getIntSetting
(
"h2.queryCacheSize"
,
0
);
/**
...
...
@@ -214,6 +220,7 @@ public class SysProperties {
* function, and in the CATALOG column of all database meta data methods.
* Setting this to "false" is experimental.
*/
// DbSettings
public
static
final
boolean
DATABASE_TO_UPPER
=
getBooleanSetting
(
"h2.databaseToUpper"
,
true
);
/**
...
...
@@ -221,6 +228,7 @@ public class SysProperties {
* The default escape character for LIKE comparisons. To select no escape
* character, use an empty string.
*/
// DbSettings
public
static
final
String
DEFAULT_ESCAPE
=
getStringSetting
(
"h2.defaultEscape"
,
"\\"
);
/**
...
...
@@ -229,6 +237,7 @@ public class SysProperties {
* The default for the setting MAX_OPERATION_MEMORY.
*/
public
static
final
int
DEFAULT_MAX_OPERATION_MEMORY
=
getIntSetting
(
"h2.defaultMaxOperationMemory"
,
100000
);
// TODO constant
/**
* System property <code>h2.defaultMaxLengthInplaceLob</code>
...
...
@@ -236,6 +245,7 @@ public class SysProperties {
* The default maximum length of an LOB that is stored in the database file.
*/
public
static
final
int
DEFAULT_MAX_LENGTH_INPLACE_LOB
=
getIntSetting
(
"h2.defaultMaxLengthInplaceLob"
,
4096
);
// TODO constant
/**
* System property <code>h2.defaultMaxLengthInplaceLob2</code>
...
...
@@ -244,6 +254,7 @@ public class SysProperties {
* Only used if h2.lobInDatabase is enabled.
*/
public
static
final
int
DEFAULT_MAX_LENGTH_INPLACE_LOB2
=
getIntSetting
(
"h2.defaultMaxLengthInplaceLob2"
,
128
);
// TODO constant
/**
* System property <code>h2.defaultResultSetConcurrency</code> (default:
...
...
@@ -252,12 +263,14 @@ public class SysProperties {
* Connection.createStatement() or prepareStatement(String sql).
*/
public
static
final
int
DEFAULT_RESULT_SET_CONCURRENCY
=
getIntSetting
(
"h2.defaultResultSetConcurrency"
,
ResultSet
.
CONCUR_READ_ONLY
);
// TODO constant
/**
* System property <code>h2.defragAlways</code> (default: false).<br />
* Each time the database is closed, it is fully defragmented (SHUTDOWN DEFRAG).
*/
public
static
boolean
defragAlways
=
getBooleanSetting
(
"h2.defragAlways"
,
false
);
// DbSettings
/**
* System property <code>h2.dataSourceTraceLevel</code> (default: 1).<br />
...
...
@@ -271,12 +284,14 @@ public class SysProperties {
* The default value for the MAX_MEMORY_UNDO setting.
*/
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
getIntSetting
(
"h2.defaultMaxMemoryUndo"
,
50000
);
// TODO constant
/**
* System property <code>h2.defaultLockMode</code> (default: 3).<br />
* The default value for the LOCK_MODE setting.
*/
public
static
final
int
DEFAULT_LOCK_MODE
=
getIntSetting
(
"h2.defaultLockMode"
,
Constants
.
LOCK_MODE_READ_COMMITTED
);
// TODO constant
/**
* System property <code>h2.delayWrongPasswordMin</code> (default: 250).<br />
...
...
@@ -304,6 +319,7 @@ public class SysProperties {
* with older versions of H2 the default action is currently CASCADE. This will
* change in a future version of H2.
*/
// DbSettings
public
static
final
boolean
DROP_RESTRICT
=
getBooleanSetting
(
"h2.dropRestrict"
,
false
);
/**
...
...
@@ -312,6 +328,7 @@ public class SysProperties {
* The estimated number of rows in a function table (for example, CSVREAD or
* FTL_SEARCH). This value is used by the optimizer.
*/
// DbSettings
public
static
final
int
ESTIMATED_FUNCTION_TABLE_ROWS
=
getIntSetting
(
"h2.estimatedFunctionTableRows"
,
1000
);
/**
...
...
@@ -327,6 +344,7 @@ public class SysProperties {
* will always include the schema name in the CREATE ALIAS statement.
* This is not backward compatible with H2 versions 1.2.134 and older.
*/
// DbSettings
public
static
final
boolean
FUNCTIONS_IN_SCHEMA
=
getBooleanSetting
(
"h2.functionsInSchema"
,
false
);
/**
...
...
@@ -334,7 +352,9 @@ public class SysProperties {
* Unquoted identifiers in SQL statements are case insensitive and converted
* to uppercase.
*/
// DbSettings
public
static
final
boolean
IDENTIFIERS_TO_UPPER
=
getBooleanSetting
(
"h2.identifiersToUpper"
,
true
);
/**
* System property <code>h2.largeResultBufferSize</code> (default: 4096).<br />
* Buffer size for large result sets. Set this value to 0 to disable the
...
...
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
31bdce51
...
...
@@ -12,6 +12,7 @@ import java.util.Arrays;
import
java.util.HashSet
;
import
java.util.Properties
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.constant.DbSettings
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.DbException
;
...
...
@@ -204,6 +205,7 @@ public class ConnectionInfo implements Cloneable {
}
private
void
readSettingsFromURL
()
{
DbSettings
dbSettings
=
DbSettings
.
getInstance
(
null
);
int
idx
=
url
.
indexOf
(
';'
);
if
(
idx
>=
0
)
{
String
settings
=
url
.
substring
(
idx
+
1
);
...
...
@@ -217,7 +219,7 @@ public class ConnectionInfo implements Cloneable {
String
value
=
setting
.
substring
(
equal
+
1
);
String
key
=
setting
.
substring
(
0
,
equal
);
key
=
StringUtils
.
toUpperEnglish
(
key
);
if
(!
isKnownSetting
(
key
))
{
if
(!
isKnownSetting
(
key
)
&&
!
dbSettings
.
containsKey
(
key
)
)
{
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_SETTING_1
,
key
);
}
String
old
=
prop
.
getProperty
(
key
);
...
...
@@ -559,4 +561,20 @@ public class ConnectionInfo implements Cloneable {
this
.
name
=
serverKey
;
}
public
DbSettings
getDbSettings
()
{
DbSettings
defaultSettings
=
DbSettings
.
getInstance
(
null
);
Properties
p
=
null
;
for
(
Object
s
:
prop
.
keySet
())
{
String
k
=
s
.
toString
();
if
(!
isKnownSetting
(
k
)
&&
defaultSettings
.
containsKey
(
k
))
{
if
(
p
==
null
)
{
p
=
new
Properties
();
}
p
.
put
(
k
,
prop
.
get
(
k
));
prop
.
remove
(
k
);
}
}
return
DbSettings
.
getInstance
(
p
);
}
}
h2/src/main/org/h2/engine/Database.java
浏览文件 @
31bdce51
...
...
@@ -19,6 +19,7 @@ import java.util.StringTokenizer;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.constant.DbSettings
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.Constraint
;
...
...
@@ -168,9 +169,11 @@ public class Database implements DataHandler {
private
LobStorage
lobStorage
;
private
int
pageSize
=
SysProperties
.
PAGE_SIZE
;
private
int
defaultTableType
=
Table
.
TYPE_CACHED
;
private
DbSettings
dbSettings
;
public
Database
(
ConnectionInfo
ci
,
String
cipher
)
{
String
name
=
ci
.
getName
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
);
this
.
persistent
=
ci
.
isPersistent
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
...
...
@@ -481,7 +484,7 @@ public class Database implements DataHandler {
if
(
n
==
null
||
n
.
length
()
==
0
)
{
n
=
"unnamed"
;
}
return
SysProperties
.
DATABASE_TO_UPPER
?
StringUtils
.
toUpperEnglish
(
n
)
:
n
;
return
getSettings
().
databaseToUpper
?
StringUtils
.
toUpperEnglish
(
n
)
:
n
;
}
private
synchronized
void
open
(
int
traceLevelFile
,
int
traceLevelSystemOut
)
{
...
...
@@ -2275,4 +2278,8 @@ public class Database implements DataHandler {
this
.
multiVersion
=
multiVersion
;
}
public
DbSettings
getSettings
()
{
return
dbSettings
;
}
}
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
31bdce51
...
...
@@ -191,7 +191,7 @@ public class FunctionAlias extends SchemaObjectBase {
public
String
getSQL
()
{
// TODO can remove this method once FUNCTIONS_IN_SCHEMA is enabled
if
(
SysProperties
.
FUNCTIONS_IN_SCHEMA
||
!
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
if
(
database
.
getSettings
().
functionsInSchema
||
!
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
return
super
.
getSQL
();
}
return
Parser
.
quoteIdentifier
(
getName
());
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
31bdce51
...
...
@@ -101,15 +101,12 @@ public class Session extends SessionWithState {
private
int
modificationId
;
private
int
modificationIdState
;
private
int
objectId
;
private
int
queryCacheSize
=
SysProperties
.
QUERY_CACHE_SIZE
;
private
final
int
queryCacheSize
;
private
SmallLRUCache
<
String
,
Command
>
queryCache
;
public
Session
()
{
// to create a new session using the factory
}
public
Session
(
Database
database
,
User
user
,
int
id
)
{
this
.
database
=
database
;
this
.
queryCacheSize
=
database
.
getSettings
().
queryCacheSize
;
this
.
undoLog
=
new
UndoLog
(
this
);
this
.
user
=
user
;
this
.
id
=
id
;
...
...
h2/src/main/org/h2/engine/SettingsBase.java
0 → 100644
浏览文件 @
31bdce51
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
engine
;
import
java.util.Properties
;
import
org.h2.constant.ErrorCode
;
import
org.h2.message.DbException
;
/**
* The base class for settings.
*/
public
class
SettingsBase
{
private
Properties
properties
;
protected
SettingsBase
(
Properties
p
)
{
this
.
properties
=
p
;
}
protected
boolean
get
(
String
key
,
boolean
defaultValue
)
{
String
s
=
get
(
key
,
""
+
defaultValue
);
try
{
return
Boolean
.
valueOf
(
s
).
booleanValue
();
}
catch
(
NumberFormatException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
e
,
"key:"
+
key
+
" value:"
+
s
);
}
}
protected
int
get
(
String
key
,
int
defaultValue
)
{
String
s
=
get
(
key
,
""
+
defaultValue
);
try
{
return
Integer
.
decode
(
s
);
}
catch
(
NumberFormatException
e
)
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
e
,
"key:"
+
key
+
" value:"
+
s
);
}
}
protected
String
get
(
String
key
,
String
defaultValue
)
{
String
keyUpper
=
key
.
toUpperCase
();
String
v
=
properties
.
getProperty
(
keyUpper
);
if
(
v
==
null
)
{
v
=
System
.
getProperty
(
"h2."
+
key
);
}
if
(
v
==
null
)
{
properties
.
put
(
keyUpper
,
defaultValue
);
v
=
defaultValue
;
}
return
v
;
}
public
boolean
containsKey
(
String
k
)
{
return
properties
.
containsKey
(
k
);
}
}
h2/src/main/org/h2/expression/CompareLike.java
浏览文件 @
31bdce51
...
...
@@ -9,7 +9,7 @@ package org.h2.expression;
import
java.util.regex.Pattern
;
import
java.util.regex.PatternSyntaxException
;
import
org.h2.constant.ErrorCode
;
import
org.h2.
constant.SysProperties
;
import
org.h2.
engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.index.IndexCondition
;
import
org.h2.message.DbException
;
...
...
@@ -27,9 +27,9 @@ import org.h2.value.ValueString;
public
class
CompareLike
extends
Condition
{
private
static
final
int
MATCH
=
0
,
ONE
=
1
,
ANY
=
2
;
private
static
final
Character
DEFAULT_ESCAPE_CHAR
=
getEscapeChar
(
SysProperties
.
DEFAULT_ESCAPE
);
private
final
CompareMode
compareMode
;
private
final
String
defaultEscape
;
private
Expression
left
;
private
Expression
right
;
private
Expression
escape
;
...
...
@@ -48,8 +48,13 @@ public class CompareLike extends Condition {
private
boolean
fastCompare
;
private
boolean
invalidPattern
;
public
CompareLike
(
CompareMode
compareMode
,
Expression
left
,
Expression
right
,
Expression
escape
,
boolean
regexp
)
{
public
CompareLike
(
Database
db
,
Expression
left
,
Expression
right
,
Expression
escape
,
boolean
regexp
)
{
this
(
db
.
getCompareMode
(),
db
.
getSettings
().
defaultEscape
,
left
,
right
,
escape
,
regexp
);
}
public
CompareLike
(
CompareMode
compareMode
,
String
defaultEscape
,
Expression
left
,
Expression
right
,
Expression
escape
,
boolean
regexp
)
{
this
.
compareMode
=
compareMode
;
this
.
defaultEscape
=
defaultEscape
;
this
.
regexp
=
regexp
;
this
.
left
=
left
;
this
.
right
=
right
;
...
...
@@ -124,12 +129,12 @@ public class CompareLike extends Condition {
private
Character
getEscapeChar
(
Value
e
)
{
if
(
e
==
null
)
{
return
DEFAULT_ESCAPE_CHAR
;
return
getEscapeChar
(
defaultEscape
)
;
}
String
es
=
e
.
getString
();
Character
esc
;
if
(
es
==
null
)
{
esc
=
DEFAULT_ESCAPE_CHAR
;
esc
=
getEscapeChar
(
defaultEscape
)
;
}
else
if
(
es
.
length
()
==
0
)
{
esc
=
null
;
}
else
if
(
es
.
length
()
>
1
)
{
...
...
h2/src/main/org/h2/expression/JavaFunction.java
浏览文件 @
31bdce51
...
...
@@ -7,7 +7,6 @@
package
org
.
h2
.
expression
;
import
org.h2.command.Parser
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.FunctionAlias
;
import
org.h2.engine.Session
;
...
...
@@ -85,7 +84,7 @@ public class JavaFunction extends Expression implements FunctionCall {
public
String
getSQL
()
{
StatementBuilder
buff
=
new
StatementBuilder
();
// TODO always append the schema once FUNCTIONS_IN_SCHEMA is enabled
if
(
SysProperties
.
FUNCTIONS_IN_SCHEMA
||
if
(
functionAlias
.
getDatabase
().
getSettings
().
functionsInSchema
||
!
functionAlias
.
getSchema
().
getName
().
equals
(
Constants
.
SCHEMA_MAIN
))
{
buff
.
append
(
Parser
.
quoteIdentifier
(
functionAlias
.
getSchema
().
getName
())).
append
(
'.'
);
}
...
...
h2/src/main/org/h2/index/FunctionIndex.java
浏览文件 @
31bdce51
...
...
@@ -6,7 +6,6 @@
*/
package
org
.
h2
.
index
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.result.ResultInterface
;
...
...
@@ -56,7 +55,7 @@ public class FunctionIndex extends BaseIndex {
if
(
functionTable
.
canGetRowCount
())
{
expectedRows
=
functionTable
.
getRowCountApproximation
();
}
else
{
expectedRows
=
SysProperties
.
ESTIMATED_FUNCTION_TABLE_ROWS
;
expectedRows
=
database
.
getSettings
().
estimatedFunctionTableRows
;
}
return
expectedRows
*
10
;
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
31bdce51
...
...
@@ -474,7 +474,7 @@ public class PageStore implements CacheWriter {
boolean
isCompactFully
=
compactMode
==
CommandInterface
.
SHUTDOWN_COMPACT
;
boolean
isDefrag
=
compactMode
==
CommandInterface
.
SHUTDOWN_DEFRAG
;
if
(
SysProperties
.
defragAlways
)
{
if
(
database
.
getSettings
()
.
defragAlways
)
{
isCompactFully
=
isDefrag
=
true
;
}
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
31bdce51
...
...
@@ -59,7 +59,7 @@ public class RegularTable extends TableBase {
private
boolean
containsLargeObject
;
private
PageDataIndex
mainIndex
;
private
int
changesSinceAnalyze
;
private
int
nextAnalyze
=
SysProperties
.
ANALYZE_AUTO
;
private
int
nextAnalyze
;
/**
* True if one thread ever was waiting to lock this table. This is to avoid
...
...
@@ -70,6 +70,7 @@ public class RegularTable extends TableBase {
public
RegularTable
(
CreateTableData
data
)
{
super
(
data
);
nextAnalyze
=
database
.
getSettings
().
analyzeAuto
;
this
.
isHidden
=
data
.
isHidden
;
if
(
data
.
persistData
&&
database
.
isPersistent
())
{
mainIndex
=
new
PageDataIndex
(
this
,
data
.
id
,
IndexColumn
.
wrap
(
getColumns
()),
IndexType
.
createScan
(
data
.
persistData
),
data
.
create
,
data
.
session
);
...
...
h2/src/test/org/h2/test/unit/TestPattern.java
浏览文件 @
31bdce51
...
...
@@ -44,7 +44,7 @@ public class TestPattern extends TestBase {
private
void
testPattern
()
{
CompareMode
mode
=
CompareMode
.
getInstance
(
null
,
0
);
CompareLike
comp
=
new
CompareLike
(
mode
,
null
,
null
,
null
,
false
);
CompareLike
comp
=
new
CompareLike
(
mode
,
"\\"
,
null
,
null
,
null
,
false
);
test
(
comp
,
"B"
,
"%_"
);
test
(
comp
,
"A"
,
"A%"
);
test
(
comp
,
"A"
,
"A%%"
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
31bdce51
...
...
@@ -658,4 +658,4 @@ skiing honor marketing sleeping dlucene timezones shifted analyzed insists
train joining bilingual existed extremely fog bordercolor overlapping
unlocking webkit dalvik recorded defrag marschall helping victor philippe
pyankov enctype multipart boundary mistake enlarge demonstrates aggregating
bypassing khtml doubled inlined defragmented registers
bypassing khtml doubled inlined defragmented registers
leftover
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论