提交 edf7bba7 authored 作者: Thomas Mueller's avatar Thomas Mueller

Various system properties have been replaced with database level settings.

上级 85acb30b
...@@ -22,10 +22,24 @@ Change Log ...@@ -22,10 +22,24 @@ Change Log
</li><li>When the system property h2.lobInDatabase is set, CREATE TABLE ... AS SELECT </li><li>When the system property h2.lobInDatabase is set, CREATE TABLE ... AS SELECT
with a LOB column did not always work. with a LOB column did not always work.
</li><li>Some system properties are not supported any longer, because they can </li><li>Some system properties are not supported any longer, because they can
already be set in the database URL. Those settings are: already be set in the database URL. The constants are:
h2.cacheSizeDefault, h2.cacheTypeDefault CACHE_SIZE_DEFAULT, CACHE_TYPE_DEFAULT, DEFAULT_LOCK_MODE,
LOCK_MODE_READ_COMMITTED, DEFAULT_MAX_LENGTH_INPLACE_LOB,
DEFAULT_MAX_LENGTH_INPLACE_LOB2, DEFAULT_MAX_MEMORY_UNDO,
DEFAULT_MAX_OPERATION_MEMORY, DEFAULT_PAGE_SIZE,
DEFAULT_RESULT_SET_CONCURRENCY, MIN_WRITE_DELAY.
</li><li>Various system properties have been replaced with database level settings: </li><li>Various system properties have been replaced with database level settings:
ALIAS_COLUMN_NAME, ANALYZE_AUTO, ANALYZE_SAMPLE, DATABASE_TO_UPPER,... ALIAS_COLUMN_NAME, ANALYZE_AUTO, ANALYZE_SAMPLE, DATABASE_TO_UPPER,
DEFAULT_ESCAPE, DEFRAG_ALWAYS, DROP_RESTRICT,
ESTIMATED_FUNCTION_TABLE_ROWS, FUNCTIONS_IN_SCHEMA,
LARGE_RESULT_BUFFER_SIZE, LARGE_TRANSACTIONS, MAX_COMPACT_COUNT,
MAX_COMPACT_TIME, MAX_MEMORY_ROWS_DISTINCT, MAX_QUERY_TIMEOUT,
NESTED_JOINS, OPTIMIZE_DISTINCT, OPTIMIZE_EVALUATABLE_SUBQUERIES,
OPTIMIZE_INSERT_FROM_SELECT, OPTIMIZE_IN_LIST, OPTIMIZE_IS_NULL,
OPTIMIZE_OR, OPTIMIZE_SUBQUERY_CACHE, OPTIMIZE_TWO_EQUALS,
OPTIMIZE_UPDATE, PAGE_STORE_INTERNAL_COUNT, PAGE_STORE_TRIM,
QUERY_CACHE_SIZE, RECOMPILE_ALWAYS, RECONNECT_CHECK_DELAY,
SELECT_FOR_UPDATE_MVCC, SHARE_LINKED_CONNECTIONS.
See the Javadoc documentation of DbSettings for details. See the Javadoc documentation of DbSettings for details.
The system properties are still supported for backward compatibility. 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>When the system property h2.nestedJoins was enabled, some outer joins returned the wrong result.
......
...@@ -24,7 +24,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -24,7 +24,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
<h2>Version 1.3.x: Planned Changes</h2> <h2>Version 1.3.x: Planned Changes</h2>
<ul><li>Enable h2.lobInDatabase (store CLOB and BLOB in the database file). <ul><li>Enable h2.lobInDatabase (store CLOB and BLOB in the database file).
</li><li>Set h2.analyzeAuto to 2000 (automatic ANALYZE). </li><li>Set AUTO_ANALYZE to 2000 (automatic ANALYZE).
</li><li>Enable h2.functionsInSchema (allow to store functions in a schema). </li><li>Enable h2.functionsInSchema (allow to store functions in a schema).
</li><li>Enable h2.selectForUpdateMvcc (MVCC and SELECT FOR UPDATE). </li><li>Enable h2.selectForUpdateMvcc (MVCC and SELECT FOR UPDATE).
</li><li>Enable h2.largeTransactions (support for very large transactions). </li><li>Enable h2.largeTransactions (support for very large transactions).
...@@ -60,6 +60,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -60,6 +60,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Access rights: remember the owner of an object. Create, alter and drop privileges. COMMENT: allow owner of object to change it. Issue 208. Access rights for schemas. </li><li>Access rights: remember the owner of an object. Create, alter and drop privileges. COMMENT: allow owner of object to change it. Issue 208. Access rights for schemas.
</li><li>Test multi-threaded in-memory db access. </li><li>Test multi-threaded in-memory db access.
</li><li>Support hints for the optimizer (which index to use, enforce the join order). </li><li>Support hints for the optimizer (which index to use, enforce the join order).
</li><li>Migrate database tool (also from other database engines). For Oracle, maybe use
DBMS_METADATA.GET_DDL / GET_DEPENDENT_DDL.
</li><li>Full outer joins. </li><li>Full outer joins.
</li><li>Clustering: support mixed clustering mode (one embedded, others in server mode). </li><li>Clustering: support mixed clustering mode (one embedded, others in server mode).
</li><li>Clustering: reads should be randomly distributed (optional) or to a designated database on RAM (parameter: READ_FROM=3). </li><li>Clustering: reads should be randomly distributed (optional) or to a designated database on RAM (parameter: READ_FROM=3).
...@@ -70,8 +72,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -70,8 +72,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED). </li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED).
</li><li>Groovy Stored Procedures: http://groovy.codehaus.org/Groovy+SQL </li><li>Groovy Stored Procedures: http://groovy.codehaus.org/Groovy+SQL
</li><li>Add a migration guide (list differences between databases). </li><li>Add a migration guide (list differences between databases).
</li><li>Migrate database tool (also from other database engines). For Oracle, maybe use
DBMS_METADATA.GET_DDL / GET_DEPENDENT_DDL.
</li><li>Optimization: automatic index creation suggestion using the trace file? </li><li>Optimization: automatic index creation suggestion using the trace file?
</li><li>Compression performance: don't allocate buffers, compress / expand in to out buffer. </li><li>Compression performance: don't allocate buffers, compress / expand in to out buffer.
</li><li>Rebuild index functionality to shrink index size and improve performance. </li><li>Rebuild index functionality to shrink index size and improve performance.
......
...@@ -1067,7 +1067,7 @@ public class Select extends Query { ...@@ -1067,7 +1067,7 @@ public class Select extends Query {
public void setForUpdate(boolean b) { public void setForUpdate(boolean b) {
this.isForUpdate = b; this.isForUpdate = b;
if (SysProperties.SELECT_FOR_UPDATE_MVCC && session.getDatabase().isMultiVersion()) { if (session.getDatabase().getSettings().selectForUpdateMvcc && session.getDatabase().isMultiVersion()) {
isForUpdateMvcc = b; isForUpdateMvcc = b;
} }
} }
......
...@@ -137,22 +137,6 @@ public class DbSettings extends SettingsBase { ...@@ -137,22 +137,6 @@ public class DbSettings extends SettingsBase {
*/ */
public final int maxMemoryRowsDistinct = get("MAX_MEMORY_ROWS_DISTINCT", Integer.MAX_VALUE); 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 />
* 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 final int queryCacheSize = get("QUERY_CACHE_SIZE", 0);
/** /**
* Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br /> * Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br />
* The maximum timeout of a query in milliseconds. The default is 0, meaning * The maximum timeout of a query in milliseconds. The default is 0, meaning
...@@ -162,12 +146,10 @@ public class DbSettings extends SettingsBase { ...@@ -162,12 +146,10 @@ 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> * Database setting <code>h2.nestedJoins</code> (default: false).<br />
* (default: false).<br /> * Whether nested joins should be supported.
* 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); public final boolean nestedJoins = get("NESTED_JOINS", false);
/** /**
* Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br /> * Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br />
...@@ -183,13 +165,6 @@ public class DbSettings extends SettingsBase { ...@@ -183,13 +165,6 @@ public class DbSettings extends SettingsBase {
*/ */
public final boolean optimizeDistinct = get("OPTIMIZE_DISTINCT", true); 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: * Database setting <code>OPTIMIZE_EVALUATABLE_SUBQUERIES</code> (default:
* true).<br /> * true).<br />
...@@ -197,6 +172,14 @@ public class DbSettings extends SettingsBase { ...@@ -197,6 +172,14 @@ public class DbSettings extends SettingsBase {
*/ */
public final boolean optimizeEvaluatableSubqueries = get("OPTIMIZE_EVALUATABLE_SUBQUERIES", true); public final boolean optimizeEvaluatableSubqueries = get("OPTIMIZE_EVALUATABLE_SUBQUERIES", true);
/**
* 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_IN_LIST</code> (default: true).<br /> * Database setting <code>OPTIMIZE_IN_LIST</code> (default: true).<br />
* Optimize IN(...) and IN(SELECT ...) comparisons. This includes * Optimize IN(...) and IN(SELECT ...) comparisons. This includes
...@@ -230,10 +213,11 @@ public class DbSettings extends SettingsBase { ...@@ -230,10 +213,11 @@ public class DbSettings extends SettingsBase {
public final boolean optimizeTwoEquals = get("OPTIMIZE_TWO_EQUALS", true); public final boolean optimizeTwoEquals = get("OPTIMIZE_TWO_EQUALS", true);
/** /**
* Database setting <code>PAGE_STORE_TRIM</code> (default: true).<br /> * Database setting <code>OPTIMIZE_UPDATE</code> (default: true).<br />
* Trim the database size when closing. * Speed up inserts, updates, and deletes by not reading all rows from a
* page unless necessary.
*/ */
public final boolean pageStoreTrim = get("PAGE_STORE_TRIM", true); public final boolean optimizeUpdate = get("OPTIMIZE_UPDATE", true);
/** /**
* Database setting <code>PAGE_STORE_INTERNAL_COUNT</code> (default: false).<br /> * Database setting <code>PAGE_STORE_INTERNAL_COUNT</code> (default: false).<br />
...@@ -241,12 +225,27 @@ public class DbSettings extends SettingsBase { ...@@ -241,12 +225,27 @@ public class DbSettings extends SettingsBase {
*/ */
public final boolean pageStoreInternalCount = get("PAGE_STORE_INTERNAL_COUNT", false); 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: 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 final int queryCacheSize = get("QUERY_CACHE_SIZE", 0);
/** /**
* Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br /> * Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br />
* Always recompile prepared statements. * Always recompile prepared statements.
*/ */
public final boolean recompileAlways = get("RECOMPILE_ALWAYS", false); public final boolean recompileAlways = get("RECOMPILE_ALWAYS", false);
// DbSettings
/** /**
* Database setting <code>RECONNECT_CHECK_DELAY</code> (default: 200).<br /> * Database setting <code>RECONNECT_CHECK_DELAY</code> (default: 200).<br />
...@@ -256,8 +255,21 @@ public class DbSettings extends SettingsBase { ...@@ -256,8 +255,21 @@ public class DbSettings extends SettingsBase {
* milliseconds before updating the database. * milliseconds before updating the database.
*/ */
public final int reconnectCheckDelay = get("RECONNECT_CHECK_DELAY", 200); public final int reconnectCheckDelay = get("RECONNECT_CHECK_DELAY", 200);
// DbSettings
/**
* Database setting <code>SELECT_FOR_UPDATE_MVCC</code> (default: false).<br />
* If set, SELECT .. FOR UPDATE queries lock only the selected rows when using MVCC.
*/
public final boolean selectForUpdateMvcc = get("SELECT_FOR_UPDATE_MVCC", false);
/**
* 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);
private DbSettings(HashMap<String, String> s) { private DbSettings(HashMap<String, String> s) {
super(s); super(s);
...@@ -267,7 +279,7 @@ public class DbSettings extends SettingsBase { ...@@ -267,7 +279,7 @@ public class DbSettings extends SettingsBase {
* INTERNAL. * INTERNAL.
* Get the settings for the given properties (may be null). * Get the settings for the given properties (may be null).
* *
* @param p the properties * @param s the settings
* @return the settings * @return the settings
*/ */
public static DbSettings getInstance(HashMap<String, String> s) { public static DbSettings getInstance(HashMap<String, String> s) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
package org.h2.constant; package org.h2.constant;
import org.h2.engine.Constants;
import org.h2.message.TraceSystem; import org.h2.message.TraceSystem;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
...@@ -198,7 +199,7 @@ public class SysProperties { ...@@ -198,7 +199,7 @@ public class SysProperties {
* System property <code>h2.lobInDatabase</code> (default: false).<br /> * System property <code>h2.lobInDatabase</code> (default: false).<br />
* 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", Constants.VERSION_MINOR < 3 ? false : true);
/** /**
* System property <code>h2.lobClientMaxSizeMemory</code> (default: 65536).<br /> * System property <code>h2.lobClientMaxSizeMemory</code> (default: 65536).<br />
...@@ -313,13 +314,6 @@ public class SysProperties { ...@@ -313,13 +314,6 @@ public class SysProperties {
*/ */
public static boolean runFinalize = getBooleanSetting("h2.runFinalize", true); public static boolean runFinalize = getBooleanSetting("h2.runFinalize", true);
/**
* System property <code>h2.selectForUpdateMvcc</code> (default: false).<br />
* If set, SELECT .. FOR UPDATE queries lock the rows when using MVCC.
*/
public static final boolean SELECT_FOR_UPDATE_MVCC = getBooleanSetting("h2.selectForUpdateMvcc", false);
// DbSettings
/** /**
* System property <code>h2.serverCachedObjects</code> (default: 64).<br /> * System property <code>h2.serverCachedObjects</code> (default: 64).<br />
* TCP Server: number of cached objects per session. * TCP Server: number of cached objects per session.
...@@ -333,16 +327,6 @@ public class SysProperties { ...@@ -333,16 +327,6 @@ public class SysProperties {
*/ */
public static final int SERVER_RESULT_SET_FETCH_SIZE = getIntSetting("h2.serverResultSetFetchSize", 100); public static final int SERVER_RESULT_SET_FETCH_SIZE = getIntSetting("h2.serverResultSetFetchSize", 100);
/**
* System property <code>h2.shareLinkedConnections</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 static final boolean SHARE_LINKED_CONNECTIONS = getBooleanSetting("h2.shareLinkedConnections", true);
// DbSettings
/** /**
* System property <code>h2.socketConnectRetry</code> (default: 16).<br /> * System property <code>h2.socketConnectRetry</code> (default: 16).<br />
* The number of times to retry opening a socket. Windows sometimes fails * The number of times to retry opening a socket. Windows sometimes fails
......
...@@ -7,13 +7,22 @@ ...@@ -7,13 +7,22 @@
package org.h2.engine; package org.h2.engine;
import java.sql.ResultSet; import java.sql.ResultSet;
import org.h2.constant.SysProperties;
/** /**
* Constants are fixed values that are used in the whole database code. * Constants are fixed values that are used in the whole database code.
*/ */
public class Constants { public class Constants {
/**
* The build date is updated for each public release.
*/
public static final String BUILD_DATE = "2010-10-15";
/**
* The build date is updated for each public release.
*/
public static final String BUILD_DATE_STABLE = "2010-09-18";
/** /**
* The build id is incremented for each public release. * The build id is incremented for each public release.
*/ */
...@@ -32,16 +41,6 @@ public class Constants { ...@@ -32,16 +41,6 @@ public class Constants {
*/ */
public static final String BUILD_VENDOR_AND_VERSION = null; public static final String BUILD_VENDOR_AND_VERSION = null;
/**
* The build date is updated for each public release.
*/
public static final String BUILD_DATE = "2010-10-15";
/**
* The build date is updated for each public release.
*/
public static final String BUILD_DATE_STABLE = "2010-09-18";
/** /**
* The TCP protocol version number 6. * The TCP protocol version number 6.
*/ */
...@@ -57,12 +56,6 @@ public class Constants { ...@@ -57,12 +56,6 @@ public class Constants {
*/ */
public static final int TCP_PROTOCOL_VERSION_8 = 8; public static final int TCP_PROTOCOL_VERSION_8 = 8;
/**
* The TCP protocol version number. This protocol is used by the TCP
* server and remote JDBC client.
*/
public static final int TCP_PROTOCOL_VERSION = TCP_PROTOCOL_VERSION_8;
/** /**
* The major version of this database. * The major version of this database.
*/ */
...@@ -73,6 +66,30 @@ public class Constants { ...@@ -73,6 +66,30 @@ public class Constants {
*/ */
public static final int VERSION_MINOR = 2; public static final int VERSION_MINOR = 2;
/**
* The lock mode that means no locking is used at all.
*/
public static final int LOCK_MODE_OFF = 0;
/**
* The lock mode that means read locks are acquired, but they are released
* immediately after the statement is executed.
*/
public static final int LOCK_MODE_READ_COMMITTED = 3;
/**
* The lock mode that means table level locking is used for reads and
* writes.
*/
public static final int LOCK_MODE_TABLE = 1;
/**
* The lock mode that means table level locking is used for reads and
* writes. If a table is locked, System.gc is called to close forgotten
* connections.
*/
public static final int LOCK_MODE_TABLE_GC = 2;
/** /**
* Constant meaning both numbers and text is allowed in SQL statements. * Constant meaning both numbers and text is allowed in SQL statements.
*/ */
...@@ -89,11 +106,26 @@ public class Constants { ...@@ -89,11 +106,26 @@ public class Constants {
*/ */
public static final int ALLOW_LITERALS_NUMBERS = 1; public static final int ALLOW_LITERALS_NUMBERS = 1;
/**
* Whether searching in Blob values should be supported.
*/
public static final boolean BLOB_SEARCH = false;
/** /**
* The minimum number of entries to keep in the cache. * The minimum number of entries to keep in the cache.
*/ */
public static final int CACHE_MIN_RECORDS = 16; public static final int CACHE_MIN_RECORDS = 16;
/**
* The default cache size in KB.
*/
public static final int CACHE_SIZE_DEFAULT = 16 * 1024;
/**
* The default cache type.
*/
public static final String CACHE_TYPE_DEFAULT = "LRU";
/** /**
* The value of the cluster setting if clustering is disabled. * The value of the cluster setting if clustering is disabled.
*/ */
...@@ -136,6 +168,22 @@ public class Constants { ...@@ -136,6 +168,22 @@ public class Constants {
*/ */
public static final int DEFAULT_HTTP_PORT = 8082; public static final int DEFAULT_HTTP_PORT = 8082;
/**
* The default value for the LOCK_MODE setting.
*/
public static final int DEFAULT_LOCK_MODE = LOCK_MODE_READ_COMMITTED;
/**
* The default maximum length of an LOB that is stored in the database file.
*/
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 4096;
/**
* The default maximum length of an LOB that is stored with the record itself.
* Only used if h2.lobInDatabase is enabled.
*/
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB2 = 128;
/** /**
* The default value for the maximum transaction log size. * The default value for the maximum transaction log size.
*/ */
...@@ -146,6 +194,27 @@ public class Constants { ...@@ -146,6 +194,27 @@ public class Constants {
*/ */
public static final int DEFAULT_MAX_MEMORY_ROWS = 10000; public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
/**
* The default value for the MAX_MEMORY_UNDO setting.
*/
public static final int DEFAULT_MAX_MEMORY_UNDO = 50000;
/**
* The default for the setting MAX_OPERATION_MEMORY.
*/
public static final int DEFAULT_MAX_OPERATION_MEMORY = 100000;
/**
* The default page size to use for new databases.
*/
public static final int DEFAULT_PAGE_SIZE = 2048;
/**
* The default result set concurrency for statements created with
* Connection.createStatement() or prepareStatement(String sql).
*/
public static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY;
/** /**
* The default port of the TCP server. * The default port of the TCP server.
* This port is also used in the documentation and in the Server javadoc. * This port is also used in the documentation and in the Server javadoc.
...@@ -184,30 +253,6 @@ public class Constants { ...@@ -184,30 +253,6 @@ public class Constants {
*/ */
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024; public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
/**
* The lock mode that means no locking is used at all.
*/
public static final int LOCK_MODE_OFF = 0;
/**
* The lock mode that means read locks are acquired, but they are released
* immediately after the statement is executed.
*/
public static final int LOCK_MODE_READ_COMMITTED = 3;
/**
* The lock mode that means table level locking is used for reads and
* writes.
*/
public static final int LOCK_MODE_TABLE = 1;
/**
* The lock mode that means table level locking is used for reads and
* writes. If a table is locked, System.gc is called to close forgotten
* connections.
*/
public static final int LOCK_MODE_TABLE_GC = 2;
/** /**
* The number of milliseconds to wait between checking the .lock.db file * The number of milliseconds to wait between checking the .lock.db file
* still exists once a database is locked. * still exists once a database is locked.
...@@ -264,14 +309,9 @@ public class Constants { ...@@ -264,14 +309,9 @@ public class Constants {
public static final int MEMORY_ROW = 40; public static final int MEMORY_ROW = 40;
/** /**
* The number of bytes in random salt that is used to hash passwords. * The minimum write delay that causes commits to be delayed.
*/
public static final int SALT_LEN = 8;
/**
* The database URL prefix of this database.
*/ */
public static final String START_URL = "jdbc:h2:"; public static final int MIN_WRITE_DELAY = 5;
/** /**
* The name prefix used for indexes that are not explicitly named. * The name prefix used for indexes that are not explicitly named.
...@@ -294,6 +334,11 @@ public class Constants { ...@@ -294,6 +334,11 @@ public class Constants {
*/ */
public static final String PUBLIC_ROLE_NAME = "PUBLIC"; public static final String PUBLIC_ROLE_NAME = "PUBLIC";
/**
* The number of bytes in random salt that is used to hash passwords.
*/
public static final int SALT_LEN = 8;
/** /**
* The name of the default schema. * The name of the default schema.
*/ */
...@@ -321,21 +366,15 @@ public class Constants { ...@@ -321,21 +366,15 @@ public class Constants {
public static final long SLOW_QUERY_LIMIT_MS = 100; public static final long SLOW_QUERY_LIMIT_MS = 100;
/** /**
* The file name suffix of page files. * The database URL prefix of this database.
*/ */
public static final String SUFFIX_PAGE_FILE = ".h2.db"; public static final String START_URL = "jdbc:h2:";
/** /**
* The file name suffix of all database files. * The file name suffix of all database files.
*/ */
public static final String SUFFIX_DB_FILE = ".db"; public static final String SUFFIX_DB_FILE = ".db";
/**
* The file name suffix of file lock files that are used to make sure a
* database is open by only one process at any time.
*/
public static final String SUFFIX_LOCK_FILE = ".lock.db";
/** /**
* The file name suffix of large object files. * The file name suffix of large object files.
*/ */
...@@ -347,6 +386,17 @@ public class Constants { ...@@ -347,6 +386,17 @@ public class Constants {
*/ */
public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db"; public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
/**
* The file name suffix of file lock files that are used to make sure a
* database is open by only one process at any time.
*/
public static final String SUFFIX_LOCK_FILE = ".lock.db";
/**
* The file name suffix of page files.
*/
public static final String SUFFIX_PAGE_FILE = ".h2.db";
/** /**
* The file name suffix of temporary files. * The file name suffix of temporary files.
*/ */
...@@ -373,6 +423,11 @@ public class Constants { ...@@ -373,6 +423,11 @@ public class Constants {
public static final String URL_FORMAT = START_URL + public static final String URL_FORMAT = START_URL +
"{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]"; "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
/**
* The package name of user defined classes.
*/
public static final String USER_PACKAGE = "org.h2.dynamic";
/** /**
* Name of the character encoding format. * Name of the character encoding format.
*/ */
...@@ -390,70 +445,6 @@ public class Constants { ...@@ -390,70 +445,6 @@ public class Constants {
*/ */
public static final int VIEW_INDEX_CACHE_SIZE = 64; public static final int VIEW_INDEX_CACHE_SIZE = 64;
/**
* Whether searching in Blob values should be supported.
*/
public static final boolean BLOB_SEARCH = false;
/**
* The package name of user defined classes.
*/
public static final String USER_PACKAGE = "org.h2.dynamic";
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
* Connection.createStatement() or prepareStatement(String sql).
*/
public static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY;
/**
* The default maximum length of an LOB that is stored with the record itself.
* Only used if h2.lobInDatabase is enabled.
*/
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB2 = 128;
/**
* The default value for the LOCK_MODE setting.
*/
public static final int DEFAULT_LOCK_MODE = LOCK_MODE_READ_COMMITTED;
/**
* The default value for the MAX_MEMORY_UNDO setting.
*/
public static final int DEFAULT_MAX_MEMORY_UNDO = 50000;
/**
* The default maximum length of an LOB that is stored in the database file.
*/
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 4096;
/**
* The default cache size in KB.
*/
public static final int CACHE_SIZE_DEFAULT = 16 * 1024;
/**
* The default cache type.
*/
public static final String CACHE_TYPE_DEFAULT = "LRU";
/**
* The default for the setting MAX_OPERATION_MEMORY.
*/
public static final int DEFAULT_MAX_OPERATION_MEMORY = 100000;
private Constants() { private Constants() {
// utility class // utility class
} }
......
...@@ -1995,7 +1995,7 @@ public class Database implements DataHandler { ...@@ -1995,7 +1995,7 @@ public class Database implements DataHandler {
if (linkConnections == null) { if (linkConnections == null) {
linkConnections = New.hashMap(); linkConnections = New.hashMap();
} }
return TableLinkConnection.open(linkConnections, driver, url, user, password); return TableLinkConnection.open(linkConnections, driver, url, user, password, dbSettings.shareLinkedConnections);
} }
public String toString() { public String toString() {
......
...@@ -21,6 +21,13 @@ public class SettingsBase { ...@@ -21,6 +21,13 @@ public class SettingsBase {
this.settings = s; this.settings = s;
} }
/**
* Get the setting for the given key.
*
* @param key the key
* @param defaultValue the default value
* @return the setting
*/
protected boolean get(String key, boolean defaultValue) { protected boolean get(String key, boolean defaultValue) {
String s = get(key, "" + defaultValue); String s = get(key, "" + defaultValue);
try { try {
...@@ -30,6 +37,13 @@ public class SettingsBase { ...@@ -30,6 +37,13 @@ public class SettingsBase {
} }
} }
/**
* Get the setting for the given key.
*
* @param key the key
* @param defaultValue the default value
* @return the setting
*/
protected int get(String key, int defaultValue) { protected int get(String key, int defaultValue) {
String s = get(key, "" + defaultValue); String s = get(key, "" + defaultValue);
try { try {
...@@ -39,6 +53,13 @@ public class SettingsBase { ...@@ -39,6 +53,13 @@ public class SettingsBase {
} }
} }
/**
* Get the setting for the given key.
*
* @param key the key
* @param defaultValue the default value
* @return the setting
*/
protected String get(String key, String defaultValue) { protected String get(String key, String defaultValue) {
StringBuilder buff = new StringBuilder("h2."); StringBuilder buff = new StringBuilder("h2.");
boolean nextUpper = false; boolean nextUpper = false;
...@@ -54,19 +75,27 @@ public class SettingsBase { ...@@ -54,19 +75,27 @@ public class SettingsBase {
String sysProperty = buff.toString(); String sysProperty = buff.toString();
String v = settings.get(key); String v = settings.get(key);
if (v == null) { if (v == null) {
v = System.getProperty(sysProperty); v = System.getProperty(sysProperty, defaultValue);
} settings.put(key, v);
if (v == null) {
settings.put(key, defaultValue);
v = defaultValue;
} }
return v; return v;
} }
/**
* Check if the settings contains the given key.
*
* @param k the key
* @return true if they do
*/
public boolean containsKey(String k) { public boolean containsKey(String k) {
return settings.containsKey(k); return settings.containsKey(k);
} }
/**
* Get all settings.
*
* @return the settings
*/
public HashMap<String, String> getSettings() { public HashMap<String, String> getSettings() {
return settings; return settings;
} }
......
...@@ -9,12 +9,10 @@ package org.h2.table; ...@@ -9,12 +9,10 @@ package org.h2.table;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
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.util.Utils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils;
/** /**
* A connection for a linked table. The same connection may be used for multiple * A connection for a linked table. The same connection may be used for multiple
...@@ -59,11 +57,12 @@ public class TableLinkConnection { ...@@ -59,11 +57,12 @@ public class TableLinkConnection {
* @param url the database URL * @param url the database URL
* @param user the user name * @param user the user name
* @param password the password * @param password the password
* @param shareLinkedConnections if connections should be shared
* @return a connection * @return a connection
*/ */
public static TableLinkConnection open(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password) { public static TableLinkConnection open(HashMap<TableLinkConnection, TableLinkConnection> map, String driver, String url, String user, String password, boolean shareLinkedConnections) {
TableLinkConnection t = new TableLinkConnection(map, driver, url, user, password); TableLinkConnection t = new TableLinkConnection(map, driver, url, user, password);
if (!SysProperties.SHARE_LINKED_CONNECTIONS) { if (!shareLinkedConnections) {
t.open(); t.open();
return t; return t;
} }
......
...@@ -15,7 +15,6 @@ import java.sql.ResultSetMetaData; ...@@ -15,7 +15,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
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.IOUtils; import org.h2.util.IOUtils;
...@@ -96,12 +95,12 @@ public class TestLinkedTable extends TestBase { ...@@ -96,12 +95,12 @@ public class TestLinkedTable extends TestBase {
} }
private void testHiddenSQL() throws SQLException { private void testHiddenSQL() throws SQLException {
if (config.memory || !SysProperties.SHARE_LINKED_CONNECTIONS) { if (config.memory) {
return; return;
} }
org.h2.Driver.load(); org.h2.Driver.load();
deleteDb("linkedTable"); deleteDb("linkedTable");
Connection conn = getConnection("linkedTable"); Connection conn = getConnection("linkedTable;SHARE_LINKED_CONNECTIONS=TRUE");
try { try {
conn.createStatement().execute( conn.createStatement().execute(
"create linked table test(null, 'jdbc:h2:mem:', 'sa', 'pwd', 'DUAL2')"); "create linked table test(null, 'jdbc:h2:mem:', 'sa', 'pwd', 'DUAL2')");
...@@ -140,12 +139,12 @@ public class TestLinkedTable extends TestBase { ...@@ -140,12 +139,12 @@ public class TestLinkedTable extends TestBase {
// } // }
private void testNestedQueriesToSameTable() throws SQLException { private void testNestedQueriesToSameTable() throws SQLException {
if (config.memory || !SysProperties.SHARE_LINKED_CONNECTIONS) { if (config.memory) {
return; return;
} }
org.h2.Driver.load(); org.h2.Driver.load();
deleteDb("linkedTable"); deleteDb("linkedTable");
String url = getURL("linkedTable", true); String url = getURL("linkedTable;SHARE_LINKED_CONNECTIONS=TRUE", true);
String user = getUser(); String user = getUser();
String password = getPassword(); String password = getPassword();
Connection ca = getConnection(url, user, password); Connection ca = getConnection(url, user, password);
...@@ -161,12 +160,12 @@ public class TestLinkedTable extends TestBase { ...@@ -161,12 +160,12 @@ public class TestLinkedTable extends TestBase {
} }
private void testSharedConnection() throws SQLException { private void testSharedConnection() throws SQLException {
if (config.memory || !SysProperties.SHARE_LINKED_CONNECTIONS) { if (config.memory) {
return; return;
} }
org.h2.Driver.load(); org.h2.Driver.load();
deleteDb("linkedTable"); deleteDb("linkedTable");
String url = getURL("linkedTable", true); String url = getURL("linkedTable;SHARE_LINKED_CONNECTIONS=TRUE", true);
String user = getUser(); String user = getUser();
String password = getPassword(); String password = getPassword();
Connection ca = getConnection(url, user, password); Connection ca = getConnection(url, user, password);
......
...@@ -140,6 +140,7 @@ public class TestPowerOff extends TestBase { ...@@ -140,6 +140,7 @@ public class TestPowerOff extends TestBase {
} }
} }
} }
SysProperties.runFinalize = true;
} }
private void testShutdown() throws SQLException { private void testShutdown() throws SQLException {
......
...@@ -11,7 +11,6 @@ import java.sql.ResultSet; ...@@ -11,7 +11,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
...@@ -30,7 +29,6 @@ public class TestMvcc2 extends TestBase { ...@@ -30,7 +29,6 @@ public class TestMvcc2 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.selectForUpdateMvcc", "true");
TestBase test = TestBase.createCaller().init(); TestBase test = TestBase.createCaller().init();
test.config.mvcc = true; test.config.mvcc = true;
test.test(); test.test();
...@@ -134,11 +132,8 @@ public class TestMvcc2 extends TestBase { ...@@ -134,11 +132,8 @@ public class TestMvcc2 extends TestBase {
} }
private void testSelectForUpdate() throws SQLException { private void testSelectForUpdate() throws SQLException {
if (!SysProperties.SELECT_FOR_UPDATE_MVCC) { Connection conn = getConnection("mvcc2;SELECT_FOR_UPDATE_MVCC=true");
return; Connection conn2 = getConnection("mvcc2;SELECT_FOR_UPDATE_MVCC=true");
}
Connection conn = getConnection();
Connection conn2 = getConnection();
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)"); stat.execute("create table test(id int primary key, name varchar)");
conn.setAutoCommit(false); conn.setAutoCommit(false);
......
...@@ -34,9 +34,9 @@ public class TestOuterJoins extends TestBase { ...@@ -34,9 +34,9 @@ public class TestOuterJoins 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();
} }
......
...@@ -35,15 +35,13 @@ public class TestTempTableCrash { ...@@ -35,15 +35,13 @@ public class TestTempTableCrash {
System.setProperty("h2.delayWrongPasswordMin", "0"); System.setProperty("h2.delayWrongPasswordMin", "0");
System.setProperty("h2.check2", "false"); System.setProperty("h2.check2", "false");
System.setProperty("h2.lobInDatabase", "true"); System.setProperty("h2.lobInDatabase", "true");
System.setProperty("h2.analyzeAuto", "100");
System.setProperty("h2.pageSize", "64");
RecordingFileSystem.register(); RecordingFileSystem.register();
System.setProperty("reopenShift", "4"); System.setProperty("reopenShift", "4");
TestReopen reopen = new TestReopen(); TestReopen reopen = new TestReopen();
RecordingFileSystem.setRecorder(reopen); RecordingFileSystem.setRecorder(reopen);
String url = "jdbc:h2:" + RecordingFileSystem.PREFIX + String url = "jdbc:h2:" + RecordingFileSystem.PREFIX +
"memFS:data;PAGE_SIZE=64"; "memFS:data;PAGE_SIZE=64;ANALYZE_AUTO=100";
// String url = "jdbc:h2:" + RecordingFileSystem.PREFIX + // String url = "jdbc:h2:" + RecordingFileSystem.PREFIX +
// "data/test;PAGE_SIZE=64"; // "data/test;PAGE_SIZE=64";
......
...@@ -23,20 +23,17 @@ public class TestUndoLogMemory { ...@@ -23,20 +23,17 @@ public class TestUndoLogMemory {
* @param args ignored * @param args ignored
*/ */
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
System.setProperty("h2.largeTransactions", "true");
new TestUndoLogMemory().test(10, "null"); new TestUndoLogMemory().test(10, "null");
new TestUndoLogMemory().test(100, "space(100000)"); new TestUndoLogMemory().test(100, "space(100000)");
// new TestUndoLogMemory().test(100000, "null"); // new TestUndoLogMemory().test(100000, "null");
// new TestUndoLogMemory().test(1000, "space(100000)"); // new TestUndoLogMemory().test(1000, "space(100000)");
} }
private void test(int count, String defaultValue) throws SQLException { private void test(int count, String defaultValue) throws SQLException {
// -Xmx1m -XX:+HeapDumpOnOutOfMemoryError // -Xmx1m -XX:+HeapDumpOnOutOfMemoryError
DeleteDbFiles.execute("data", "test", true); DeleteDbFiles.execute("data", "test", true);
Connection conn = DriverManager.getConnection("jdbc:h2:data/test"); Connection conn = DriverManager.getConnection("jdbc:h2:data/test;large_transactions=true");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("set cache_size 32"); stat.execute("set cache_size 32");
stat.execute("SET max_operation_memory 100"); stat.execute("SET max_operation_memory 100");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论