Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9646d854
提交
9646d854
authored
3月 28, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changes to prepare for version 1.4.x beta
上级
183fcbbd
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
911 行增加
和
21 行删除
+911
-21
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+10
-3
Database.java
h2/src/main/org/h2/engine/Database.java
+2
-4
DbSettings.java
h2/src/main/org/h2/engine/DbSettings.java
+370
-0
Engine.java
h2/src/main/org/h2/engine/Engine.java
+2
-3
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+1
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-2
SessionRemote.java
h2/src/main/org/h2/engine/SessionRemote.java
+1
-2
SettingsBase.java
h2/src/main/org/h2/engine/SettingsBase.java
+2
-1
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+519
-0
UndoLog.java
h2/src/main/org/h2/engine/UndoLog.java
+0
-1
UndoLogRecord.java
h2/src/main/org/h2/engine/UndoLogRecord.java
+1
-2
User.java
h2/src/main/org/h2/engine/User.java
+2
-1
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
9646d854
...
@@ -13,10 +13,8 @@ import java.util.HashMap;
...
@@ -13,10 +13,8 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.dml.SetTypes
;
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
;
import
org.h2.message.DbException
;
import
org.h2.security.SHA256
;
import
org.h2.security.SHA256
;
import
org.h2.store.fs.FilePathEncrypt
;
import
org.h2.store.fs.FilePathEncrypt
;
...
@@ -385,6 +383,15 @@ public class ConnectionInfo implements Cloneable {
...
@@ -385,6 +383,15 @@ public class ConnectionInfo implements Cloneable {
public
String
getName
()
{
public
String
getName
()
{
if
(
persistent
)
{
if
(
persistent
)
{
if
(
nameNormalized
==
null
)
{
if
(
nameNormalized
==
null
)
{
if
(!
SysProperties
.
IMPLICIT_RELATIVE_PATH
)
{
if
(!
FileUtils
.
isAbsolute
(
name
)
&&
name
.
indexOf
(
"./"
)
<
0
)
{
// the name could start with "./", or
// it could start with a prefix such as "nio:./"
throw
DbException
.
get
(
ErrorCode
.
URL_RELATIVE_TO_CWD
,
originalURL
);
}
}
String
suffix
=
Constants
.
SUFFIX_PAGE_FILE
;
String
suffix
=
Constants
.
SUFFIX_PAGE_FILE
;
String
n
;
String
n
;
if
(
FileUtils
.
exists
(
name
+
suffix
))
{
if
(
FileUtils
.
exists
(
name
+
suffix
))
{
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
9646d854
...
@@ -16,12 +16,10 @@ import java.util.Properties;
...
@@ -16,12 +16,10 @@ import java.util.Properties;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.StringTokenizer
;
import
java.util.StringTokenizer
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.JavaObjectSerializer
;
import
org.h2.api.JavaObjectSerializer
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.command.dml.SetTypes
;
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
;
import
org.h2.constraint.Constraint
;
import
org.h2.index.Cursor
;
import
org.h2.index.Cursor
;
import
org.h2.index.Index
;
import
org.h2.index.Index
;
...
@@ -194,7 +192,7 @@ public class Database implements DataHandler {
...
@@ -194,7 +192,7 @@ public class Database implements DataHandler {
String
name
=
ci
.
getName
();
String
name
=
ci
.
getName
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
dbSettings
=
ci
.
getDbSettings
();
this
.
reconnectCheckDelay
=
dbSettings
.
reconnectCheckDelay
;
this
.
reconnectCheckDelay
=
dbSettings
.
reconnectCheckDelay
;
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
,
false
);
this
.
compareMode
=
CompareMode
.
getInstance
(
null
,
0
);
this
.
persistent
=
ci
.
isPersistent
();
this
.
persistent
=
ci
.
isPersistent
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
this
.
filePasswordHash
=
ci
.
getFilePasswordHash
();
this
.
fileEncryptionKey
=
ci
.
getFileEncryptionKey
();
this
.
fileEncryptionKey
=
ci
.
getFileEncryptionKey
();
...
...
h2/src/main/org/h2/engine/DbSettings.java
0 → 100644
浏览文件 @
9646d854
/*
* Copyright 2004-2013 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.HashMap
;
/**
* 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;ALIAS_COLUMN_NAME=TRUE" 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>ALIAS_COLUMN_NAME</code> (default: false).<br />
* When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the
* alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in
* getTableName(). If disabled, the real column name (ID in this case) and
* table name is returned.
* <br />
* This setting only affects the default and the MySQL mode. When using
* any other mode, this feature is enabled for compatibility, even if this
* database setting is not enabled explicitly.
*/
public
final
boolean
aliasColumnName
=
get
(
"ALIAS_COLUMN_NAME"
,
false
);
/**
* Database setting <code>ANALYZE_AUTO</code> (default: 2000).<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
final
int
analyzeAuto
=
get
(
"ANALYZE_AUTO"
,
2000
);
/**
* Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
* The default sample size when analyzing a table.
*/
public
final
int
analyzeSample
=
get
(
"ANALYZE_SAMPLE"
,
10000
);
/**
* Database setting <code>DATABASE_TO_UPPER</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. When set to false, all
* identifier names (table names, column names) are case sensitive (except
* aggregate, built-in functions, data types, and keywords).
*/
public
final
boolean
databaseToUpper
=
get
(
"DATABASE_TO_UPPER"
,
true
);
/**
* Database setting <code>DB_CLOSE_ON_EXIT</code> (default: true).<br />
* Close the database when the virtual machine exits normally, using a
* shutdown hook.
*/
public
final
boolean
dbCloseOnExit
=
get
(
"DB_CLOSE_ON_EXIT"
,
true
);
/**
* Database setting <code>DEFAULT_CONNECTION</code> (default: false).<br />
* Whether Java functions can use
* <code>DriverManager.getConnection("jdbc:default:connection")</code> to
* get a database connection. This feature is disabled by default for
* performance reasons. Please note the Oracle JDBC driver will try to
* resolve this database URL if it is loaded before the H2 driver.
*/
public
boolean
defaultConnection
=
get
(
"DEFAULT_CONNECTION"
,
false
);
/**
* Database setting <code>DEFAULT_ESCAPE</code> (default: \).<br />
* The default escape character for LIKE comparisons. To select no escape
* character, use an empty string.
*/
public
final
String
defaultEscape
=
get
(
"DEFAULT_ESCAPE"
,
"\\"
);
/**
* Database setting <code>DEFRAG_ALWAYS</code> (default: false).<br />
* Each time the database is closed, it is fully defragmented (SHUTDOWN
* DEFRAG).
*/
public
final
boolean
defragAlways
=
get
(
"DEFRAG_ALWAYS"
,
false
);
/**
* Database setting <code>DROP_RESTRICT</code> (default: true).<br />
* Whether the default action for DROP TABLE and DROP VIEW is RESTRICT.
*/
public
final
boolean
dropRestrict
=
get
(
"DROP_RESTRICT"
,
true
);
/**
* Database setting <code>EARLY_FILTER</code> (default: false).<br />
* This setting allows table implementations to apply filter conditions
* early on.
*/
public
final
boolean
earlyFilter
=
get
(
"EARLY_FILTER"
,
false
);
/**
* Database setting <code>ESTIMATED_FUNCTION_TABLE_ROWS</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
final
int
estimatedFunctionTableRows
=
get
(
"ESTIMATED_FUNCTION_TABLE_ROWS"
,
1000
);
/**
* Database setting <code>FUNCTIONS_IN_SCHEMA</code>
* (default: true).<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
final
boolean
functionsInSchema
=
get
(
"FUNCTIONS_IN_SCHEMA"
,
true
);
/**
* 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.
*/
public
final
int
largeResultBufferSize
=
get
(
"LARGE_RESULT_BUFFER_SIZE"
,
4
*
1024
);
/**
* Database setting <code>LARGE_TRANSACTIONS</code> (default: true).<br />
* Support very large transactions
*/
public
final
boolean
largeTransactions
=
get
(
"LARGE_TRANSACTIONS"
,
true
);
/**
* 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:
* 10000).<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"
,
10000
);
/**
* Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br />
* The maximum timeout of a query in milliseconds. The default is 0, meaning
* no limit. Please note the actual query timeout may be set to a lower
* value.
*/
public
int
maxQueryTimeout
=
get
(
"MAX_QUERY_TIMEOUT"
,
0
);
/**
* Database setting <code>NESTED_JOINS</code> (default: true).<br />
* Whether nested joins should be supported.
*/
public
final
boolean
nestedJoins
=
get
(
"NESTED_JOINS"
,
true
);
/**
* 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_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_INSERT_FROM_SELECT</code>
* (default: true).<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"
,
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_IN_SELECT</code> (default: true).<br />
* Optimize IN(SELECT ...) comparisons. This includes
* optimization for SELECT, DELETE, and UPDATE.
*/
public
final
boolean
optimizeInSelect
=
get
(
"OPTIMIZE_IN_SELECT"
,
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: true).<br />
* Convert (C=? OR C=?) to (C IN(?, ?)).
*/
public
final
boolean
optimizeOr
=
get
(
"OPTIMIZE_OR"
,
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>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>PAGE_STORE_MAX_GROWTH</code>
* (default: 128 * 1024).<br />
* The maximum number of pages the file grows at any time.
*/
public
final
int
pageStoreMaxGrowth
=
get
(
"PAGE_STORE_MAX_GROWTH"
,
128
*
1024
);
/**
* 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>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>QUERY_CACHE_SIZE</code> (default: 8).<br />
* The size of the query cache, in number of cached statements. 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. The following statement types are cached: SELECT
* statements are cached (excluding UNION and FOR UPDATE statements), CALL
* if it returns a single value, DELETE, INSERT, MERGE, UPDATE, and
* transactional statements such as COMMIT. This works for both statements
* and prepared statement.
*/
public
final
int
queryCacheSize
=
get
(
"QUERY_CACHE_SIZE"
,
8
);
/**
* Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br />
* Always recompile prepared statements.
*/
public
final
boolean
recompileAlways
=
get
(
"RECOMPILE_ALWAYS"
,
false
);
/**
* 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
);
/**
* Database setting <code>ROWID</code> (default: true).<br />
* If set, each table has a pseudo-column _ROWID_.
*/
public
final
boolean
rowId
=
get
(
"ROWID"
,
true
);
/**
* Database setting <code>SELECT_FOR_UPDATE_MVCC</code>
* (default: true).<br />
* If set, SELECT .. FOR UPDATE queries lock only the selected rows when
* using MVCC.
*/
public
final
boolean
selectForUpdateMvcc
=
get
(
"SELECT_FOR_UPDATE_MVCC"
,
true
);
/**
* Database setting <code>SHARE_LINKED_CONNECTIONS</code>
* (default: true).<br />
* Linked connections should be shared, that means connections to the same
* database should be used for all linked tables that connect to the same
* database.
*/
public
final
boolean
shareLinkedConnections
=
get
(
"SHARE_LINKED_CONNECTIONS"
,
true
);
/**
* Database setting <code>DEFAULT_TABLE_ENGINE</code>
* (default: null).<br />
* The default table engine to use for new tables.
*/
public
String
defaultTableEngine
=
get
(
"DEFAULT_TABLE_ENGINE"
,
null
);
/**
* Database setting <code>MV_STORE</code>
* (default: false).<br />
* Use the MVStore storage engine.
*/
public
final
boolean
mvStore
=
get
(
"MV_STORE"
,
false
);
/**
* Database setting <code>COMPRESS</code>
* (default: false).<br />
* Compress data when storing.
*/
public
final
boolean
compressData
=
get
(
"COMPRESS"
,
false
);
private
DbSettings
(
HashMap
<
String
,
String
>
s
)
{
super
(
s
);
}
/**
* INTERNAL.
* Get the settings for the given properties (may be null).
*
* @param s the settings
* @return the settings
*/
public
static
DbSettings
getInstance
(
HashMap
<
String
,
String
>
s
)
{
if
(
s
==
null
||
s
.
isEmpty
())
{
if
(
defaultSettings
==
null
)
{
defaultSettings
=
new
DbSettings
(
new
HashMap
<
String
,
String
>());
}
return
defaultSettings
;
}
return
new
DbSettings
(
s
);
}
}
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
9646d854
...
@@ -7,12 +7,11 @@
...
@@ -7,12 +7,11 @@
package
org
.
h2
.
engine
;
package
org
.
h2
.
engine
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.command.dml.SetTypes
;
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
;
import
org.h2.message.DbException
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLock
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
9646d854
...
@@ -14,9 +14,8 @@ import java.sql.Connection;
...
@@ -14,9 +14,8 @@ import java.sql.Connection;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.Driver
;
import
org.h2.Driver
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
9646d854
...
@@ -12,13 +12,12 @@ import java.util.HashSet;
...
@@ -12,13 +12,12 @@ import java.util.HashSet;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Command
;
import
org.h2.command.Command
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.Constraint
;
import
org.h2.constraint.Constraint
;
import
org.h2.index.Index
;
import
org.h2.index.Index
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
...
...
h2/src/main/org/h2/engine/SessionRemote.java
浏览文件 @
9646d854
...
@@ -10,12 +10,11 @@ import java.io.IOException;
...
@@ -10,12 +10,11 @@ import java.io.IOException;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.JavaObjectSerializer
;
import
org.h2.api.JavaObjectSerializer
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandRemote
;
import
org.h2.command.CommandRemote
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.command.dml.SetTypes
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
...
...
h2/src/main/org/h2/engine/SettingsBase.java
浏览文件 @
9646d854
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
package
org
.
h2
.
engine
;
package
org
.
h2
.
engine
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.constant.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
...
...
h2/src/main/org/h2/engine/SysProperties.java
0 → 100644
浏览文件 @
9646d854
/*
* Copyright 2004-2013 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
org.h2.message.TraceSystem
;
import
org.h2.util.MathUtils
;
import
org.h2.util.Utils
;
/**
* The constants defined in this class are initialized from system properties.
* Some system properties are per machine settings, and others are as 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>
* System properties can be set when starting the virtual machine:
* </p>
*
* <pre>
* java -Dh2.baseDir=/temp
* </pre>
*
* They can be set within the application, but this must be done before loading
* any classes of this database (before loading the JDBC driver):
*
* <pre>
* System.setProperty("h2.baseDir", "/temp");
* </pre>
*/
public
class
SysProperties
{
/**
* INTERNAL
*/
public
static
final
String
H2_SCRIPT_DIRECTORY
=
"h2.scriptDirectory"
;
/**
* INTERNAL
*/
public
static
final
String
H2_BROWSER
=
"h2.browser"
;
/**
* System property <code>file.encoding</code> (default: Cp1252).<br />
* It is usually set by the system and is the default encoding used for the
* RunScript and CSV tool.
*/
public
static
final
String
FILE_ENCODING
=
Utils
.
getProperty
(
"file.encoding"
,
"Cp1252"
);
/**
* System property <code>file.separator</code> (default: /).<br />
* It is usually set by the system, and used to build absolute file names.
*/
public
static
final
String
FILE_SEPARATOR
=
Utils
.
getProperty
(
"file.separator"
,
"/"
);
/**
* System property <code>java.specification.version</code>.<br />
* It is set by the system. Examples: 1.4, 1.5, 1.6.
*/
public
static
final
String
JAVA_SPECIFICATION_VERSION
=
Utils
.
getProperty
(
"java.specification.version"
,
"1.4"
);
/**
* System property <code>line.separator</code> (default: \n).<br />
* It is usually set by the system, and used by the script and trace tools.
*/
public
static
final
String
LINE_SEPARATOR
=
Utils
.
getProperty
(
"line.separator"
,
"\n"
);
/**
* System property <code>user.home</code> (empty string if not set).<br />
* It is usually set by the system, and used as a replacement for ~ in file
* names.
*/
public
static
final
String
USER_HOME
=
Utils
.
getProperty
(
"user.home"
,
""
);
/**
* System property <code>h2.allowedClasses</code> (default: *).<br />
* Comma separated list of class names or prefixes.
*/
public
static
final
String
ALLOWED_CLASSES
=
Utils
.
getProperty
(
"h2.allowedClasses"
,
"*"
);
/**
* System property <code>h2.browser</code> (default: null).<br />
* The preferred browser to use. If not set, the default browser is used.
* For Windows, to use the Internet Explorer, set this property to
* 'explorer'. For Mac OS, if the default browser is not Safari and you want
* to use Safari, use:
* <code>java -Dh2.browser="open,-a,Safari,%url" ...</code>.
*/
public
static
final
String
BROWSER
=
Utils
.
getProperty
(
H2_BROWSER
,
null
);
/**
* System property <code>h2.enableAnonymousSSL</code> (default: true).<br />
* When using SSL connection, the anonymous cipher suite
* SSL_DH_anon_WITH_RC4_128_MD5 should be enabled.
*/
public
static
final
boolean
ENABLE_ANONYMOUS_SSL
=
Utils
.
getProperty
(
"h2.enableAnonymousSSL"
,
true
);
/**
* System property <code>h2.bindAddress</code> (default: null).<br />
* The bind address to use.
*/
public
static
final
String
BIND_ADDRESS
=
Utils
.
getProperty
(
"h2.bindAddress"
,
null
);
/**
* System property <code>h2.check</code> (default: true).<br />
* Assertions in the database engine.
*/
//## CHECK ##
public
static
final
boolean
CHECK
=
Utils
.
getProperty
(
"h2.check"
,
true
);
/*/
public static final boolean CHECK = false;
//*/
/**
* System property <code>h2.check2</code> (default: true).<br />
* Additional assertions in the database engine.
*/
//## CHECK ##
public
static
final
boolean
CHECK2
=
Utils
.
getProperty
(
"h2.check2"
,
false
);
/*/
public static final boolean CHECK2 = false;
//*/
/**
* System property <code>h2.clientTraceDirectory</code> (default:
* trace.db/).<br />
* Directory where the trace files of the JDBC client are stored (only for
* client / server).
*/
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
Utils
.
getProperty
(
"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
=
Utils
.
getProperty
(
"h2.collatorCacheSize"
,
32000
);
/**
* System property <code>h2.consoleStream</code> (default: true).<br />
* H2 Console: stream query results.
*/
public
static
final
boolean
CONSOLE_STREAM
=
Utils
.
getProperty
(
"h2.consoleStream"
,
true
);
/**
* System property <code>h2.consoleTimeout</code> (default: 1800000).<br />
* H2 Console: session timeout in milliseconds. The default is 30 minutes.
*/
public
static
final
int
CONSOLE_TIMEOUT
=
Utils
.
getProperty
(
"h2.consoleTimeout"
,
30
*
60
*
1000
);
/**
* System property <code>h2.dataSourceTraceLevel</code> (default: 1).<br />
* The trace level of the data source implementation. Default is 1 for
* error.
*/
public
static
final
int
DATASOURCE_TRACE_LEVEL
=
Utils
.
getProperty
(
"h2.dataSourceTraceLevel"
,
TraceSystem
.
ERROR
);
/**
* System property <code>h2.delayWrongPasswordMin</code>
* (default: 250).<br />
* The minimum delay in milliseconds before an exception is thrown for using
* the wrong user name or password. This slows down brute force attacks. The
* delay is reset to this value after a successful login. Unsuccessful
* logins will double the time until DELAY_WRONG_PASSWORD_MAX.
* To disable the delay, set this system property to 0.
*/
public
static
final
int
DELAY_WRONG_PASSWORD_MIN
=
Utils
.
getProperty
(
"h2.delayWrongPasswordMin"
,
250
);
/**
* System property <code>h2.delayWrongPasswordMax</code>
* (default: 4000).<br />
* The maximum delay in milliseconds before an exception is thrown for using
* the wrong user name or password. This slows down brute force attacks. The
* delay is reset after a successful login. The value 0 means there is no
* maximum delay.
*/
public
static
final
int
DELAY_WRONG_PASSWORD_MAX
=
Utils
.
getProperty
(
"h2.delayWrongPasswordMax"
,
4000
);
/**
* System property <code>h2.javaSystemCompiler</code> (default: true).<br />
* Whether to use the Java system compiler
* (ToolProvider.getSystemJavaCompiler()) if it is available to compile user
* defined functions. If disabled or if the system compiler is not
* available, the com.sun.tools.javac compiler is used if available, and
* "javac" (as an external process) is used if not.
*/
public
static
final
boolean
JAVA_SYSTEM_COMPILER
=
Utils
.
getProperty
(
"h2.javaSystemCompiler"
,
true
);
/**
* System property <code>h2.lobCloseBetweenReads</code>
* (default: false).<br />
* Close LOB files between read operations.
*/
public
static
boolean
lobCloseBetweenReads
=
Utils
.
getProperty
(
"h2.lobCloseBetweenReads"
,
false
);
/**
* System property <code>h2.lobFilesPerDirectory</code>
* (default: 256).<br />
* Maximum number of LOB files per directory.
*/
public
static
final
int
LOB_FILES_PER_DIRECTORY
=
Utils
.
getProperty
(
"h2.lobFilesPerDirectory"
,
256
);
/**
* System property <code>h2.lobClientMaxSizeMemory</code> (default:
* 1048576).<br />
* The maximum size of a LOB object to keep in memory on the client side
* when using the server mode.
*/
public
static
final
int
LOB_CLIENT_MAX_SIZE_MEMORY
=
Utils
.
getProperty
(
"h2.lobClientMaxSizeMemory"
,
1024
*
1024
);
/**
* System property <code>h2.maxFileRetry</code> (default: 16).<br />
* Number of times to retry file delete and rename. in Windows, files can't
* be deleted if they are open. Waiting a bit can help (sometimes the
* Windows Explorer opens the files for a short time) may help. Sometimes,
* running garbage collection may close files if the user forgot to call
* Connection.close() or InputStream.close().
*/
public
static
final
int
MAX_FILE_RETRY
=
Math
.
max
(
1
,
Utils
.
getProperty
(
"h2.maxFileRetry"
,
16
));
/**
* System property <code>h2.maxReconnect</code> (default: 3).<br />
* The maximum number of tries to reconnect in a row.
*/
public
static
final
int
MAX_RECONNECT
=
Utils
.
getProperty
(
"h2.maxReconnect"
,
3
);
/**
* System property <code>h2.maxTraceDataLength</code>
* (default: 65535).<br />
* The maximum size of a LOB value that is written as data to the trace
* system.
*/
public
static
final
long
MAX_TRACE_DATA_LENGTH
=
Utils
.
getProperty
(
"h2.maxTraceDataLength"
,
65535
);
/**
* System property <code>h2.modifyOnWrite</code> (default: false).<br />
* Only modify the database file when recovery is necessary, or when writing
* to the database. If disabled, opening the database always writes to the
* file (except if the database is read-only). When enabled, the serialized
* file lock is faster.
*/
public
static
final
boolean
MODIFY_ON_WRITE
=
Utils
.
getProperty
(
"h2.modifyOnWrite"
,
false
);
/**
* System property <code>h2.nioLoadMapped</code> (default: false).<br />
* If the mapped buffer should be loaded when the file is opened.
* This can improve performance.
*/
public
static
final
boolean
NIO_LOAD_MAPPED
=
Utils
.
getProperty
(
"h2.nioLoadMapped"
,
false
);
/**
* System property <code>h2.nioCleanerHack</code> (default: false).<br />
* If enabled, use the reflection hack to un-map the mapped file if
* possible. If disabled, System.gc() is called in a loop until the object
* is garbage collected. See also
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4724038
*/
public
static
final
boolean
NIO_CLEANER_HACK
=
Utils
.
getProperty
(
"h2.nioCleanerHack"
,
false
);
/**
* System property <code>h2.objectCache</code> (default: true).<br />
* Cache commonly used values (numbers, strings). There is a shared cache
* for all values.
*/
public
static
final
boolean
OBJECT_CACHE
=
Utils
.
getProperty
(
"h2.objectCache"
,
true
);
/**
* System property <code>h2.objectCacheMaxPerElementSize</code> (default:
* 4096).<br />
* The maximum size (precision) of an object in the cache.
*/
public
static
final
int
OBJECT_CACHE_MAX_PER_ELEMENT_SIZE
=
Utils
.
getProperty
(
"h2.objectCacheMaxPerElementSize"
,
4096
);
/**
* System property <code>h2.objectCacheSize</code> (default: 1024).<br />
* The maximum number of objects in the cache.
* This value must be a power of 2.
*/
public
static
final
int
OBJECT_CACHE_SIZE
=
MathUtils
.
nextPowerOf2
(
Utils
.
getProperty
(
"h2.objectCacheSize"
,
1024
));
/**
* System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br />
* Default client encoding for PG server. It is used if the client does not
* sends his encoding.
*/
public
static
final
String
PG_DEFAULT_CLIENT_ENCODING
=
Utils
.
getProperty
(
"h2.pgClientEncoding"
,
"UTF-8"
);
/**
* System property <code>h2.prefixTempFile</code> (default: h2.temp).<br />
* The prefix for temporary files in the temp directory.
*/
public
static
final
String
PREFIX_TEMP_FILE
=
Utils
.
getProperty
(
"h2.prefixTempFile"
,
"h2.temp"
);
/**
* System property <code>h2.serverCachedObjects</code> (default: 64).<br />
* TCP Server: number of cached objects per session.
*/
public
static
final
int
SERVER_CACHED_OBJECTS
=
Utils
.
getProperty
(
"h2.serverCachedObjects"
,
64
);
/**
* System property <code>h2.serverResultSetFetchSize</code>
* (default: 100).<br />
* The default result set fetch size when using the server mode.
*/
public
static
final
int
SERVER_RESULT_SET_FETCH_SIZE
=
Utils
.
getProperty
(
"h2.serverResultSetFetchSize"
,
100
);
/**
* System property <code>h2.socketConnectRetry</code> (default: 16).<br />
* The number of times to retry opening a socket. Windows sometimes fails
* to open a socket, see bug
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213296
*/
public
static
final
int
SOCKET_CONNECT_RETRY
=
Utils
.
getProperty
(
"h2.socketConnectRetry"
,
16
);
/**
* System property <code>h2.socketConnectTimeout</code>
* (default: 2000).<br />
* The timeout in milliseconds to connect to a server.
*/
public
static
final
int
SOCKET_CONNECT_TIMEOUT
=
Utils
.
getProperty
(
"h2.socketConnectTimeout"
,
2000
);
/**
* System property <code>h2.sortBinaryUnsigned</code> (default: false).<br />
* Whether binary data should be sorted in unsigned mode (0xff is larger than 0x00).
*/
;
public
static
final
boolean
SORT_BINARY_UNSIGNED
=
Utils
.
getProperty
(
"h2.sortBinaryUnsigned"
,
false
);
/**
* System property <code>h2.sortNullsHigh</code> (default: false).<br />
* Invert the default sorting behavior for NULL, such that NULL
* is at the end of a result set in an ascending sort and at
* the beginning of a result set in a descending sort.
*/
public
static
final
boolean
SORT_NULLS_HIGH
=
Utils
.
getProperty
(
"h2.sortNullsHigh"
,
false
);
/**
* System property <code>h2.splitFileSizeShift</code> (default: 30).<br />
* The maximum file size of a split file is 1L << x.
*/
public
static
final
long
SPLIT_FILE_SIZE_SHIFT
=
Utils
.
getProperty
(
"h2.splitFileSizeShift"
,
30
);
/**
* System property <code>h2.storeLocalTime</code> (default: false).<br />
* Store the local time. If disabled, the daylight saving offset is not
* taken into account.
*/
public
static
final
boolean
STORE_LOCAL_TIME
=
Utils
.
getProperty
(
"h2.storeLocalTime"
,
false
);
/**
* System property <code>h2.syncMethod</code> (default: sync).<br />
* What method to call when closing the database, on checkpoint, and on
* CHECKPOINT SYNC. The following options are supported:
* "sync" (default): RandomAccessFile.getFD().sync();
* "force": RandomAccessFile.getChannel().force(true);
* "forceFalse": RandomAccessFile.getChannel().force(false);
* "": do not call a method (fast but there is a risk of data loss
* on power failure).
*/
public
static
final
String
SYNC_METHOD
=
Utils
.
getProperty
(
"h2.syncMethod"
,
"sync"
);
/**
* System property <code>h2.traceIO</code> (default: false).<br />
* Trace all I/O operations.
*/
public
static
final
boolean
TRACE_IO
=
Utils
.
getProperty
(
"h2.traceIO"
,
false
);
/**
* System property <code>h2.implicitRelativePath</code> (default: true).<br />
* If disabled, relative paths in database URLs need to be written as
* jdbc:h2:./test instead of jdbc:h2:test.
*/
;
public
static
final
boolean
IMPLICIT_RELATIVE_PATH
=
Utils
.
getProperty
(
"h2.implicitRelativePath"
,
false
);
/**
* System property <code>h2.urlMap</code> (default: null).<br />
* A properties file that contains a mapping between database URLs. New
* connections are written into the file. An empty value in the map means no
* redirection is used for the given URL.
*/
public
static
final
String
URL_MAP
=
Utils
.
getProperty
(
"h2.urlMap"
,
null
);
/**
* System property <code>h2.useThreadContextClassLoader</code>
* (default: false).<br />
* Instead of using the default class loader when deserializing objects, the
* current thread-context class loader will be used.
*/
public
static
final
boolean
USE_THREAD_CONTEXT_CLASS_LOADER
=
Utils
.
getProperty
(
"h2.useThreadContextClassLoader"
,
false
);
/**
* System property <code>h2.serializeJavaObject</code>
* (default: true).<br />
* <b>If true</b>, values of type OTHER will be stored in serialized form
* and have the semantics of binary data for all operations (such as sorting
* and conversion to string).
* <br />
* <b>If false</b>, the objects will be serialized only for I/O operations
* and a few other special cases (for example when someone tries to get the
* value in binary form or when comparing objects that are not comparable
* otherwise).
* <br />
* If the object implements the Comparable interface, the method compareTo
* will be used for sorting (but only if objects being compared have a
* common comparable super type). Otherwise the objects will be compared by
* type, and if they are the same by hashCode, and if the hash codes are
* equal, but objects are not, the serialized forms (the byte arrays) are
* compared.
* <br />
* The string representation of the values use the toString method of
* object.
* <br />
* In client-server mode, the server must have all required classes in the
* class path. On the client side, this setting is required to be disabled
* as well, to have correct string representation and display size.
* <br />
* In embedded mode, no data copying occurs, so the user has to make
* defensive copy himself before storing, or ensure that the value object is
* immutable.
*/
public
static
boolean
serializeJavaObject
=
Utils
.
getProperty
(
"h2.serializeJavaObject"
,
true
);
/**
* System property <code>h2.javaObjectSerializer</code>
* (default: null).<br />
* The JavaObjectSerializer class name for java objects being stored in
* column of type OTHER. It must be the same on client and server to work
* correctly.
*/
public
static
final
String
JAVA_OBJECT_SERIALIZER
=
Utils
.
getProperty
(
"h2.javaObjectSerializer"
,
null
);
private
static
final
String
H2_BASE_DIR
=
"h2.baseDir"
;
private
SysProperties
()
{
// utility class
}
/**
* INTERNAL
*/
public
static
void
setBaseDir
(
String
dir
)
{
if
(!
dir
.
endsWith
(
"/"
))
{
dir
+=
"/"
;
}
System
.
setProperty
(
H2_BASE_DIR
,
dir
);
}
/**
* INTERNAL
*/
public
static
String
getBaseDir
()
{
return
Utils
.
getProperty
(
H2_BASE_DIR
,
null
);
}
/**
* System property <code>h2.scriptDirectory</code> (default: empty
* string).<br />
* Relative or absolute directory where the script files are stored to or
* read from.
*
* @return the current value
*/
public
static
String
getScriptDirectory
()
{
return
Utils
.
getProperty
(
H2_SCRIPT_DIRECTORY
,
""
);
}
}
h2/src/main/org/h2/engine/UndoLog.java
浏览文件 @
9646d854
...
@@ -8,7 +8,6 @@ package org.h2.engine;
...
@@ -8,7 +8,6 @@ package org.h2.engine;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.Data
;
import
org.h2.store.Data
;
import
org.h2.store.FileStore
;
import
org.h2.store.FileStore
;
...
...
h2/src/main/org/h2/engine/UndoLogRecord.java
浏览文件 @
9646d854
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
*/
*/
package
org
.
h2
.
engine
;
package
org
.
h2
.
engine
;
import
org.h2.constant.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.store.Data
;
import
org.h2.store.Data
;
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
9646d854
...
@@ -8,7 +8,8 @@ package org.h2.engine;
...
@@ -8,7 +8,8 @@ package org.h2.engine;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.constant.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.schema.Schema
;
import
org.h2.schema.Schema
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论