提交 2dd76e97 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 003d1ab8
......@@ -323,7 +323,6 @@ Roadmap
</li><li>Translated .pdf
</li><li>Cluster: hot deploy (adding a node on runtime)
</li><li>Test with PostgreSQL Version 8.2
</li><li>Submit again to http://www.docjar.com/
</li><li>Website: Don't use frames.
</li><li>Try again with Lobo browser (pure Java)
</li><li>Recovery tool: bad blocks should be converted to INSERT INTO SYSTEM_ERRORS(...), and things should go into the .trace.db file
......@@ -356,6 +355,9 @@ Roadmap
</li><li>Support flashback queries as in Oracle.
</li><li>Import / Export of fixed with text files.
</li><li>Support for OUT parameters in user-defined procedures.
</li><li>Support getGeneratedKeys to return multiple rows when used with batch updates.
This is supported by MySQL, but not Derby. Both PostgreSQL and HSQLDB don't support getGeneratedKeys.
Also support it when using INSERT ... SELECT.
</li></ul>
<h2>Not Planned</h2>
......
......@@ -74,7 +74,7 @@ public class CommandRemote implements CommandInterface {
for (int j = 0; j < paramCount; j++) {
if (readParams) {
ParameterRemote p = new ParameterRemote(j);
p.read(transfer);
p.readMetaData(transfer);
parameters.add(p);
} else {
parameters.add(new ParameterRemote(j));
......
......@@ -3072,8 +3072,10 @@ public class Parser {
Expression defaultExpression = readExpression();
column.setDefaultExpression(session, defaultExpression);
} else if (readIf("GENERATED")) {
read("BY");
read("DEFAULT");
if (!readIf("ALWAYS")) {
read("BY");
read("DEFAULT");
}
read("AS");
read("IDENTITY");
long start = 1, increment = 1;
......
......@@ -89,7 +89,7 @@ public class BackupCommand extends Prepared {
ArrayList fileList = FileLister.getDatabaseFiles(dir, name, true);
for (int i = 0; i < fileList.size(); i++) {
fn = (String) fileList.get(i);
if (fn.endsWith(Constants.SUFFIX_HASH_FILE) || fn.endsWith(Constants.SUFFIX_LOB_FILE)) {
if (fn.endsWith(Constants.SUFFIX_LOB_FILE)) {
backupFile(out, base, fn);
}
}
......
......@@ -93,10 +93,22 @@ public class Comment extends DbObjectBase {
throw Message.getInternalError();
}
/**
* Get the comment key name for the given database object. This key name is
* used internally to associate the comment to the object.
*
* @param obj the object
* @return the key name
*/
public static String getKey(DbObject obj) {
return getTypeName(obj.getType()) + " " + obj.getSQL();
}
/**
* Set the comment text.
*
* @param comment the text
*/
public void setCommentText(String comment) {
this.commentText = comment;
}
......
......@@ -33,6 +33,10 @@ public class ConnectionInfo {
private String user;
private byte[] filePasswordHash;
private byte[] userPasswordHash;
/**
* The database name
*/
private String name;
private boolean remote;
private boolean ssl;
......@@ -57,21 +61,32 @@ public class ConnectionInfo {
}
}
/**
* Create a connection info object.
*
* @param name the database name (including tags)
*/
public ConnectionInfo(String name) {
this.name = name;
parseName();
}
public ConnectionInfo(String u, Properties info) throws SQLException {
this.originalURL = u;
if (!u.startsWith(Constants.START_URL)) {
throw Message.getInvalidValueException(u, "url");
/**
* Create a connection info object.
*
* @param url the database URL (must start with jdbc:h2:)
* @param info the connection properties
*/
public ConnectionInfo(String url, Properties info) throws SQLException {
this.originalURL = url;
if (!url.startsWith(Constants.START_URL)) {
throw Message.getInvalidValueException(url, "url");
}
this.url = u;
this.url = url;
readProperties(info);
readSettingsFromURL();
setUserName(removeProperty("USER", ""));
readPasswords();
convertPasswords();
name = url.substring(Constants.START_URL.length());
parseName();
}
......@@ -100,19 +115,12 @@ public class ConnectionInfo {
}
}
public String getDatabaseName() {
if (remote) {
if (ssl) {
return "ssl:" + name;
} else {
return "tcp:" + name;
}
} else if (persistent) {
return "file:" + name;
}
return name;
}
/**
* Set the base directory of persistent databases, unless the database is in
* the user home folder (~).
*
* @param dir the new base directory
*/
public void setBaseDir(String dir) {
if (persistent) {
if (!name.startsWith("~")) {
......@@ -121,15 +129,30 @@ public class ConnectionInfo {
}
}
/**
* Check if this is a remote connection.
*
* @return true if it is
*/
public boolean isRemote() {
return remote;
}
public boolean isPersistent() {
/**
* Check if the referenced database is persistent.
*
* @return true if it is
*/
boolean isPersistent() {
return persistent;
}
public boolean isUnnamed() {
/**
* Check if the referenced database is an unnamed in-memory database.
*
* @return true if it is
*/
boolean isUnnamedInMemory() {
return unnamed;
}
......@@ -196,7 +219,11 @@ public class ConnectionInfo {
}
}
public void readPasswords() throws SQLException {
/**
* Split the password property into file password and user password if
* necessary, and convert them to the internal hash format.
*/
public void convertPasswords() throws SQLException {
char[] password = removePassword();
SHA256 sha = new SHA256();
if (getProperty("CIPHER", null) != null) {
......@@ -222,12 +249,26 @@ public class ConnectionInfo {
userPasswordHash = sha.getKeyPasswordHash(user, password);
}
public boolean removeProperty(String key, boolean defaultValue) {
/**
* Remove a boolean property if it is set and return the value.
*
* @param key the property name
* @param defaultValue the default value
* @return the value
*/
boolean removeProperty(String key, boolean defaultValue) {
String x = removeProperty(key, null);
return x == null ? defaultValue : Boolean.valueOf(x).booleanValue();
}
public String removeProperty(String key, String defaultValue) {
/**
* Remove a String property if it is set and return the value.
*
* @param key the property name
* @param defaultValue the default value
* @return the value
*/
String removeProperty(String key, String defaultValue) {
if (SysProperties.CHECK && !KNOWN_SETTINGS.contains(key)) {
throw Message.getInternalError(key);
}
......@@ -235,7 +276,12 @@ public class ConnectionInfo {
return x == null ? defaultValue : x.toString();
}
public String getName() throws SQLException {
/**
* Get the unique and normalized database name (excluding settings).
*
* @return the database name
*/
String getName() throws SQLException {
if (persistent) {
String n = FileUtils.normalize(name + Constants.SUFFIX_DATA_FILE);
n = n.substring(0, n.length() - Constants.SUFFIX_DATA_FILE.length());
......@@ -244,25 +290,51 @@ public class ConnectionInfo {
return name;
}
public byte[] getFilePasswordHash() {
/**
* Get the file password hash if it is set.
*
* @return the password hash or null
*/
byte[] getFilePasswordHash() {
return filePasswordHash;
}
/**
* Get the name of the user.
*
* @return the user name
*/
public String getUserName() {
return user;
}
public byte[] getUserPasswordHash() {
/**
* Get the user password hash.
*
* @return the password hash
*/
byte[] getUserPasswordHash() {
return userPasswordHash;
}
public String[] getKeys() {
/**
* Get the property keys.
*
* @return the property keys
*/
String[] getKeys() {
String[] keys = new String[prop.size()];
prop.keySet().toArray(keys);
return keys;
}
public String getProperty(String key) {
/**
* Get the value of the given property.
*
* @param key the property key
* @return the value as a String
*/
String getProperty(String key) {
Object value = prop.get(key);
if (value == null || !(value instanceof String)) {
return null;
......@@ -270,7 +342,14 @@ public class ConnectionInfo {
return value.toString();
}
public String getProperty(String key, String defaultValue) {
/**
* Get the value of the given property.
*
* @param key the property key
* @param defaultValue the default value
* @return the value as a String
*/
String getProperty(String key, String defaultValue) {
if (SysProperties.CHECK && !KNOWN_SETTINGS.contains(key)) {
throw Message.getInternalError(key);
}
......@@ -278,13 +357,27 @@ public class ConnectionInfo {
return s == null ? defaultValue : s;
}
public String getProperty(int setting, String defaultValue) {
/**
* Get the value of the given property.
*
* @param setting the setting id
* @param defaultValue the default value
* @return the value as a String
*/
String getProperty(int setting, String defaultValue) {
String key = SetTypes.getTypeName(setting);
String s = getProperty(key);
return s == null ? defaultValue : s;
}
public int getIntProperty(int setting, int defaultValue) {
/**
* Get the value of the given property.
*
* @param setting the setting id
* @param defaultValue the default value
* @return the value as an integer
*/
int getIntProperty(int setting, int defaultValue) {
String key = SetTypes.getTypeName(setting);
String s = getProperty(key, null);
try {
......@@ -294,24 +387,49 @@ public class ConnectionInfo {
}
}
public boolean isSSL() {
/**
* Check if this is a remote connection with SSL enabled.
*
* @return true if it is
*/
boolean isSSL() {
return ssl;
}
/**
* Overwrite the user name. The user name is case-insensitive and stored in
* uppercase. English conversion is used.
*
* @param name the user name
*/
public void setUserName(String name) {
// TODO document: the user name is case-insensitive (stored uppercase)
// and english conversion is used
this.user = StringUtils.toUpperEnglish(name);
}
public void setUserPasswordHash(byte[] bs) {
this.userPasswordHash = bs;
/**
* Set the user password hash.
*
* @param hash the new hash value
*/
public void setUserPasswordHash(byte[] hash) {
this.userPasswordHash = hash;
}
public void setFilePasswordHash(byte[] bs) {
this.filePasswordHash = bs;
/**
* Set the file password hash.
*
* @param hash the new hash value
*/
public void setFilePasswordHash(byte[] hash) {
this.filePasswordHash = hash;
}
/**
* Overwrite a property.
*
* @param key the property name
* @param value the value
*/
public void setProperty(String key, String value) {
// value is null if the value is an object
if (value != null) {
......@@ -319,18 +437,38 @@ public class ConnectionInfo {
}
}
/**
* Get the database URL.
*
* @return the URL
*/
public String getURL() {
return url;
}
/**
* Get the complete original database URL.
*
* @return the database URL
*/
public String getOriginalURL() {
return originalURL;
}
/**
* Set the original database URL.
*
* @param url the database url
*/
public void setOriginalURL(String url) {
originalURL = url;
}
/**
* Check if this database URL references a text based database explicitly.
*
* @return true if the storage has been set to text
*/
boolean getTextStorage() throws SQLException {
String storage = removeProperty("STORAGE", "BINARY");
if ("BINARY".equalsIgnoreCase(storage)) {
......@@ -342,7 +480,12 @@ public class ConnectionInfo {
}
}
public SQLException getFormatException() {
/**
* Generate an URL format exception.
*
* @return the exception
*/
SQLException getFormatException() {
String format = Constants.URL_FORMAT;
return Message.getSQLException(ErrorCode.URL_FORMAT_ERROR_2, new String[] { format, url });
}
......
......@@ -6,7 +6,6 @@
*/
package org.h2.engine;
/*
* Release checklist
* - Test with Hibernate
......@@ -87,6 +86,18 @@ public class Constants {
*/
private static final String BUILD_DATE = "2008-04-30";
/**
* The TCP protocol version number 5. This protocol is used by the TCP
* server and remote JDBC client.
*/
public static final int TCP_PROTOCOL_VERSION_5 = 5;
/**
* The TCP protocol version number 6. This protocol is used by the TCP
* server and remote JDBC client.
*/
public static final int TCP_PROTOCOL_VERSION_6 = 6;
/**
* The major version of this product.
*/
......@@ -96,13 +107,18 @@ public class Constants {
* The minor version of this product.
*/
public static final int VERSION_MINOR = 0;
/**
* If empty b-tree pages are allowed. This is supported for backward
* compatibility.
*/
public static final boolean ALLOW_EMPTY_BTREE_PAGES = true;
/**
* Constant meaning both numbers and text is allowed in SQL statements.
*/
public static final int ALLOW_LITERALS_ALL = 2;
/**
* Constant meaning no literals are allowed in SQL statements.
*/
......@@ -114,11 +130,6 @@ public class Constants {
*/
public static final int ALLOW_LITERALS_NUMBERS = 1;
/**
* Constant meaning both numbers and text is allowed in SQL statements.
*/
public static final int ALLOW_LITERALS_ALL = 2;
/**
* Automatically convert large LOB objects to files even if they have been
* set using setBytes.
......@@ -126,9 +137,140 @@ public class Constants {
public static final boolean AUTO_CONVERT_LOB_TO_FILES = true;
/**
* The version of this product, consisting of major version, minor version, and build id.
* The maximum scale of a BigDecimal value.
*/
public static final String VERSION = VERSION_MAJOR + "." + VERSION_MINOR + "." + BUILD_ID;
public static final int BIG_DECIMAL_SCALE_MAX = 100000;
/**
* The minimum number of entries to keep in the cache.
*/
public static final int CACHE_MIN_RECORDS = 16;
/**
* The name of the character set used in this database.
*/
public static final String CHARACTER_SET_NAME = "Unicode";
/**
* The value of the cluster setting if clustering is disabled.
*/
public static final String CLUSTERING_DISABLED = "''";
/**
* The database URL used when calling a function if only the column list
* should be returned.
*/
public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
/**
* The database URL used when calling a function if the data should be
* returned.
*/
public static final String CONN_URL_INTERNAL = "jdbc:default:connection";
/**
* If the rounding mode should be BigDecimal.ROUND_HALF_UP when rounding
* from a decimal value to a long value.
*/
public static final boolean CONVERT_TO_LONG_ROUND = true;
/**
* The cost is calculated on rowcount + this offset,
* to avoid using the wrong or no index if the table
* contains no rows _currently_ (when preparing the statement)
*/
public static final int COST_ROW_OFFSET = 1000;
/**
* The default name of the system user. This name is only used as long as
* there is no administrator user registered.
*/
public static final String DBA_NAME = "DBA";
/**
* The default value of the ALLOW_LITERALS setting
*/
public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL;
/**
* The default data page size.
*/
public static final int DEFAULT_DATA_PAGE_SIZE = 512;
/**
* The default escape character for LIKE comparisons.
*/
public static final char DEFAULT_ESCAPE_CHAR = '\\';
/**
* The default port number of the FTP server.
*/
public static final int DEFAULT_FTP_PORT = 8021;
/**
* If the HTTP server should allow connections from other computers by
* default.
*/
public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false;
/**
* The default port number of the HTTP server (for the H2 Console). This
* value is also in the documentation.
*/
public static final int DEFAULT_HTTP_PORT = 8082;
/**
* The default SSL setting for the HTTP server.
*/
public static final boolean DEFAULT_HTTP_SSL = false;
/**
* The default value for the maximum log file size.
*/
public static final long DEFAULT_MAX_LOG_SIZE = 32 * 1024 * 1024;
/**
* The default maximum length on an in-memory LOB object.
* Larger objects will be written to a temporary file.
*/
public static final int DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB = 65536;
/**
* The default maximum length of an LOB that is stored in the data file itself.
*/
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 1024;
/**
* The default maximum number of rows to be kept in memory in a result set.
*/
public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
/**
* The default port of the TCP server.
* This port is also used in the documentation.
*/
public static final int DEFAULT_SERVER_PORT = 9092;
/**
* The default table type when creating new tables.
*/
public static final int DEFAULT_TABLE_TYPE = 0;
/**
* The default delay in milliseconds before the log file is written.
*/
public static final int DEFAULT_WRITE_DELAY = 500;
/**
* The name of the JDBC driver.
*/
public static final String DRIVER_NAME = "H2 JDBC Driver";
/**
* The password is hashed this many times
* to slow down dictionary attacks.
*/
public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
/**
* The 'word size' of a file (the minimum allocation size).
......@@ -136,137 +278,295 @@ public class Constants {
public static final int FILE_BLOCK_SIZE = 16;
/**
* The file header used for text files.
* The maximum number of bytes a file should be expanded in one step.
*/
public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
public static final int FILE_MAX_INCREMENT = 32 * 1024 * 1024;
/**
* The file header used for binary files.
* The minimum file size in bytes.
*/
public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
public static final int FILE_MIN_SIZE = 128 * 1024;
/**
* The TCP protocol version number 5. This protocol is used by the TCP
* server and remote JDBC client.
* The page size of a file.
*/
public static final int TCP_PROTOCOL_VERSION_5 = 5;
public static final int FILE_PAGE_SIZE = 8 * 1024;
/**
* The TCP protocol version number 6. This protocol is used by the TCP
* server and remote JDBC client.
* The default delay to flush indexes. 0 means indexes are not flushed.
*/
public static final int TCP_PROTOCOL_VERSION_6 = 6;
public static final long FLUSH_INDEX_DELAY = 0;
/**
* For testing, the lock timeout is smaller than for interactive use cases.
* This value could be increased to about 5 or 10 seconds.
*/
public static final int INITIAL_LOCK_TIMEOUT = 1000;
/**
* The block size for I/O operations.
*/
public static final int IO_BUFFER_SIZE = 4 * 1024;
/**
* The major version number of the supported JDBC API.
* The block size used to compress data in the LZFOutputStream.
*/
public static final int VERSION_JDBC_MAJOR = 3;
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
/**
* The minor version number of the supported JDBC API.
* The lock mode that means no locking is used at all.
*/
public static final int VERSION_JDBC_MINOR = 0;
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
* still exists once a database is locked.
*/
public static final int LOCK_SLEEP = 1000;
/**
* The divider used to calculate the minimum log file size as a function of
* the largest file (data file or index file).
*/
public static final long LOG_SIZE_DIVIDER = 10;
/**
* Queries that take longer than this number of milliseconds are written to
* the trace file with the level info.
*/
public static final long LONG_QUERY_LIMIT_MS = 100;
/**
* Get the complete version number of this database, consisting of
* the major version, the minor version, the build id, and the build date.
*
* @return the complete version
* The file header used for binary files.
*/
public static String getFullVersion() {
return VERSION+ " (" + BUILD_DATE + ")";
}
public static final String MAGIC_FILE_HEADER = "-- H2 0.5/B -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
/**
* The file header used for text files.
*/
public static final String MAGIC_FILE_HEADER_TEXT = "-- H2 0.5/T -- ".substring(0, FILE_BLOCK_SIZE - 1) + "\n";
/**
* The name of the in-memory management database used by the TCP server
* to keep the active sessions.
*/
public static final String MANAGEMENT_DB_PREFIX = "management_db_";
/**
* The user name of the management database.
*/
public static final String MANAGEMENT_DB_USER = "sa";
public static final int DEFAULT_SERVER_PORT = 9092; // this is also in the docs
/**
* The highest possible parameter index.
*/
public static final int MAX_PARAMETER_INDEX = 100000;
/**
* The number of bytes in random salt that is used to hash passwords.
*/
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 String URL_FORMAT = START_URL +
"{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
/**
* The name prefix used for indexes that are not explicitly named.
*/
public static final String PREFIX_INDEX = "INDEX_";
// must stay like that, see
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-2682
public static final String PRODUCT_NAME = "H2";
public static final String DRIVER_NAME = "H2 JDBC Driver";
public static final int IO_BUFFER_SIZE = 4 * 1024;
public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
public static final int DEFAULT_CACHE_SIZE_LINEAR_INDEX = 64 * 1024;
public static final int FILE_PAGE_SIZE = 8 * 1024;
public static final int FILE_MIN_SIZE = 128 * 1024;
public static final int FILE_MAX_INCREMENT = 32 * 1024 * 1024;
public static final String SUFFIX_DB_FILE = ".db";
/**
* The name prefix used for primary key constraints that are not explicitly
* named.
*/
public static final String PREFIX_PRIMARY_KEY = "PRIMARY_KEY_";
/**
* The product name. This value must stay like that, see
* http://opensource.atlassian.com/projects/hibernate/browse/HHH-2682
*/
public static final String PRODUCT_NAME = "H2";
/**
* Every user belongs to this role.
*/
public static final String PUBLIC_ROLE_NAME = "PUBLIC";
/**
* The name of the schema that contains the information schema tables.
*/
public static final String SCHEMA_INFORMATION = "INFORMATION_SCHEMA";
/**
* The name of the default schema.
*/
public static final String SCHEMA_MAIN = "PUBLIC";
/**
* The default name of the script file if .zip compression is used.
*/
public static final String SCRIPT_SQL = "script.sql";
/**
* The default sample size for the ANALYZE statement.
*/
public static final int SELECTIVITY_ANALYZE_SAMPLE_ROWS = 10000;
/**
* The default selectivity (used if the selectivity is not calculated).
*/
public static final int SELECTIVITY_DEFAULT = 50;
/**
* The number of distinct values to keep in memory when running ANALYZE.
*/
public static final int SELECTIVITY_DISTINCT_COUNT = 10000;
/**
* Whether Java objects should be serialized / de-serialized in the JDBC API.
*/
public static final boolean SERIALIZE_JAVA_OBJECTS = true;
/**
* The name of the server properties file.
*/
public static final String SERVER_PROPERTIES_FILE = ".h2.server.properties";
/**
* The title of the server properties file.
*/
public static final String SERVER_PROPERTIES_TITLE = "H2 Server Properties";
/**
* The file name suffix of data files.
*/
public static final String SUFFIX_DATA_FILE = ".data.db";
public static final String SUFFIX_LOG_FILE = ".log.db";
/**
* The file name suffix of all database files.
*/
public static final String SUFFIX_DB_FILE = ".db";
/**
* The file name suffix of index files.
*/
public static final String SUFFIX_INDEX_FILE = ".index.db";
public static final String SUFFIX_HASH_FILE = ".hash.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.
*/
public static final String SUFFIX_LOB_FILE = ".lob.db";
/**
* The suffix of the directory name used if LOB objects are stored in a
* directory.
*/
public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
/**
* The file name suffix of transaction log files.
*/
public static final String SUFFIX_LOG_FILE = ".log.db";
/**
* The file name suffix of temporary files.
*/
public static final String SUFFIX_TEMP_FILE = ".temp.db";
/**
* The file name suffix of trace files.
*/
public static final String SUFFIX_TRACE_FILE = ".trace.db";
public static final String SUFFIX_LOB_FILE = ".lob.db";
/**
* The file name suffix of the signal file that starts trace output.
*/
public static final String SUFFIX_TRACE_START_FILE = ".start";
public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
/**
* The table name suffix used to create internal temporary tables.
*/
public static final String TEMP_TABLE_PREFIX = "TEMP_TABLE_";
/**
* The delay that is to be used if throttle has been enabled.
*/
public static final int THROTTLE_DELAY = 50;
/**
* The database URL format in simplified Backus-Naur form.
*/
public static final String URL_FORMAT = START_URL +
"{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
/**
* Name of the character encoding format.
*/
public static final String UTF8 = "UTF8";
public static final int DEFAULT_TABLE_TYPE = 0;
public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 1024;
public static final int DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB = 65536;
public static final int SALT_LEN = 8;
public static final int DEFAULT_DATA_PAGE_SIZE = 512;
public static final String PREFIX_PRIMARY_KEY = "PRIMARY_KEY_";
public static final String PREFIX_INDEX = "INDEX_";
public static final int LOCK_SLEEP = 1000;
/**
* The version of this product, consisting of major version, minor version,
* and build id.
*/
public static final String VERSION = VERSION_MAJOR + "." + VERSION_MINOR + "." + BUILD_ID;
/**
* The major version number of the supported JDBC API.
*/
public static final int VERSION_JDBC_MAJOR = 3;
// TODO for testing, the lock timeout is smaller than for interactive use cases
// public static final int INITIAL_LOCK_TIMEOUT = 60 * 1000;
public static final int INITIAL_LOCK_TIMEOUT = 1000;
public static final char DEFAULT_ESCAPE_CHAR = '\\';
public static final int DEFAULT_HTTP_PORT = 8082; // also in the docs
public static final boolean DEFAULT_HTTP_SSL = false;
public static final boolean DEFAULT_HTTP_ALLOW_OTHERS = false;
public static final int DEFAULT_FTP_PORT = 8021;
public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
public static final int DEFAULT_WRITE_DELAY = 500;
public static final String SERVER_PROPERTIES_TITLE = "H2 Server Properties";
public static final String SERVER_PROPERTIES_FILE = ".h2.server.properties";
public static final long LONG_QUERY_LIMIT_MS = 100;
public static final String PUBLIC_ROLE_NAME = "PUBLIC";
public static final String TEMP_TABLE_PREFIX = "TEMP_TABLE_";
public static final int BIG_DECIMAL_SCALE_MAX = 100000;
public static final String SCHEMA_MAIN = "PUBLIC";
public static final String SCHEMA_INFORMATION = "INFORMATION_SCHEMA";
public static final String DBA_NAME = "DBA";
public static final String CHARACTER_SET_NAME = "Unicode";
public static final String CLUSTERING_DISABLED = "''";
public static final int LOCK_MODE_OFF = 0;
public static final int LOCK_MODE_TABLE = 1;
public static final int LOCK_MODE_TABLE_GC = 2;
public static final int LOCK_MODE_READ_COMMITTED = 3;
public static final int SELECTIVITY_DISTINCT_COUNT = 10000;
public static final int SELECTIVITY_DEFAULT = 50;
public static final int SELECTIVITY_ANALYZE_SAMPLE_ROWS = 10000;
public static final boolean CONVERT_TO_LONG_ROUND = true;
/**
* The minor version number of the supported JDBC API.
*/
public static final int VERSION_JDBC_MINOR = 0;
// the cost is calculated on rowcount + this offset,
// to avoid using the wrong or no index if the table
// contains no rows _currently_ (when preparing the statement)
public static final int COST_ROW_OFFSET = 1000;
public static final long FLUSH_INDEX_DELAY = 0;
public static final int THROTTLE_DELAY = 50;
public static final String MANAGEMENT_DB_PREFIX = "management_db_";
public static final String MANAGEMENT_DB_USER = "sa";
public static final boolean SERIALIZE_JAVA_OBJECTS = true;
public static final long DEFAULT_MAX_LOG_SIZE = 32 * 1024 * 1024;
public static final long LOG_SIZE_DIVIDER = 10;
public static final int DEFAULT_ALLOW_LITERALS = ALLOW_LITERALS_ALL;
public static final String CONN_URL_INTERNAL = "jdbc:default:connection";
public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
/**
* The maximum time in milliseconds to keep the cost of a view.
* 10000 means 10 seconds.
*/
public static final int VIEW_COST_CACHE_MAX_AGE = 10000;
/**
* The name of the index cache that is used for temporary view (subqueries
* used as tables).
*/
public static final int VIEW_INDEX_CACHE_SIZE = 64;
public static final int VIEW_COST_CACHE_MAX_AGE = 10000; // 10 seconds
public static final int MAX_PARAMETER_INDEX = 100000;
/**
* The password is hashed this many times
* to slow down dictionary attacks.
* Get the complete version number of this database, consisting of
* the major version, the minor version, the build id, and the build date.
*
* @return the complete version
*/
public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
public static final String SCRIPT_SQL = "script.sql";
public static final int CACHE_MIN_RECORDS = 16;
public static String getFullVersion() {
return VERSION+ " (" + BUILD_DATE + ")";
}
}
......@@ -44,7 +44,7 @@ public class Engine {
// if it is required to call it twice
String name = ci.getName();
Database database;
if (ci.isUnnamed()) {
if (ci.isUnnamedInMemory()) {
database = null;
} else {
database = (Database) databases.get(name);
......@@ -65,7 +65,7 @@ public class Engine {
user.setUserPasswordHash(ci.getUserPasswordHash());
database.setMasterUser(user);
}
if (!ci.isUnnamed()) {
if (!ci.isUnnamedInMemory()) {
databases.put(name, database);
}
database.opened();
......
......@@ -22,7 +22,37 @@ import org.h2.value.ValueString;
* A mathematical expression, or string concatenation.
*/
public class Operation extends Expression {
public static final int CONCAT = 0, PLUS = 1, MINUS = 2, MULTIPLY = 3, DIVIDE = 4, NEGATE = 5;
/**
* This operation represents a string concatenation as in 'Hello' || 'World'.
*/
public static final int CONCAT = 0;
/**
* This operation represents an addition as in 1 + 2.
*/
public static final int PLUS = 1;
/**
* This operation represents a subtraction as in 2 - 1.
*/
public static final int MINUS = 2;
/**
* This operation represents a multiplication as in 2 * 3.
*/
public static final int MULTIPLY = 3;
/**
* This operation represents a division as in 4 * 2.
*/
public static final int DIVIDE = 4;
/**
* This operation represents a negation as in - ID.
*/
public static final int NEGATE = 5;
private int opType;
private Expression left, right;
private int dataType;
......
......@@ -64,14 +64,25 @@ public class ParameterRemote implements ParameterInterface {
return nullable;
}
public void read(Transfer transfer) throws IOException {
/**
* Write the parameter meta data from the transfer object.
*
* @param transfer the transfer object
*/
public void readMetaData(Transfer transfer) throws IOException {
dataType = transfer.readInt();
precision = transfer.readLong();
scale = transfer.readInt();
nullable = transfer.readInt();
}
public static void write(Transfer transfer, ParameterInterface p) throws IOException {
/**
* Write the parameter meta data to the transfer object.
*
* @param transfer the transfer object
* @param p the parameter
*/
public static void writeMetaData(Transfer transfer, ParameterInterface p) throws IOException {
transfer.writeInt(p.getType());
transfer.writeLong(p.getPrecision());
transfer.writeInt(p.getScale());
......
......@@ -42,10 +42,6 @@ public class SequenceValue extends Expression {
// nothing to do
}
public void checkMapped() {
// nothing to do
}
public Expression optimize(Session session) {
return this;
}
......
......@@ -68,6 +68,12 @@ public class TableFunction extends Function implements FunctionCall {
return distinct ? "TABLE_DISTINCT" : "TABLE";
}
/**
* Get the row count of the table.
*
* @param session the session
* @return the row count
*/
public int getRowCount(Session session) throws SQLException {
int len = columnList.length;
int rowCount = 0;
......
......@@ -23,14 +23,29 @@ import org.h2.value.ValueNull;
public class ValueExpression extends Expression {
private Value value;
/**
* The expression represents ValueNull.INSTANCE.
*/
public static final ValueExpression NULL = new ValueExpression(ValueNull.INSTANCE);
/**
* This special expression represents the default value. It is used for
* UPDATE statements of the form SET COLUMN = DEFAULT. The value is
* ValueNull.INSTANCE, but should never be accessed.
*/
public static final ValueExpression DEFAULT = new ValueExpression(ValueNull.INSTANCE);
public static ValueExpression get(Value v) {
if (v == ValueNull.INSTANCE) {
/**
* Create a new expression with the given value.
*
* @param value the value
* @return the expression
*/
public static ValueExpression get(Value value) {
if (value == ValueNull.INSTANCE) {
return ValueExpression.NULL;
}
return new ValueExpression(v);
return new ValueExpression(value);
}
private ValueExpression(Value value) {
......
......@@ -146,14 +146,16 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
lastChange = 0;
if (storage != null) {
storage.flushFile();
deletePage(session, head);
// if we log index changes now, then the index is consistent
// if we don't log index changes, then the index is only consistent
// if there are no in doubt transactions
if (database.getLogIndexChanges() || !database.getLog().containsInDoubtTransactions()) {
head.setConsistent(true);
if (!database.getReadOnly()) {
deletePage(session, head);
// if we log index changes now, then the index is consistent
// if we don't log index changes, then the index is only consistent
// if there are no in doubt transactions
if (database.getLogIndexChanges() || !database.getLog().containsInDoubtTransactions()) {
head.setConsistent(true);
}
flushHead(session);
}
flushHead(session);
}
}
......
......@@ -215,7 +215,7 @@ public class TcpServerThread implements Runnable {
if (operation == SessionRemote.SESSION_PREPARE_READ_PARAMS) {
for (int i = 0; i < paramCount; i++) {
Parameter p = (Parameter) params.get(i);
ParameterRemote.write(transfer, p);
ParameterRemote.writeMetaData(transfer, p);
}
}
transfer.flush();
......
......@@ -197,7 +197,7 @@ public class PgServerThread implements Runnable {
ci.setOriginalURL("jdbc:h2:" + databaseName + ";MODE=PostgreSQL");
ci.setUserName(userName);
ci.setProperty("PASSWORD", password);
ci.readPasswords();
ci.convertPasswords();
conn = new JdbcConnection(ci, false);
// can not do this because when called inside
// DriverManager.getConnection, a deadlock occurs
......
......@@ -58,8 +58,6 @@ public class FileLister {
ok = true;
} else if (f.endsWith(Constants.SUFFIX_LOG_FILE)) {
ok = true;
} else if (f.endsWith(Constants.SUFFIX_HASH_FILE)) {
ok = true;
} else if (f.endsWith(Constants.SUFFIX_LOBS_DIRECTORY)) {
files.addAll(getDatabaseFiles(f, null, all));
ok = true;
......
......@@ -294,10 +294,10 @@ public class Shell {
private String readPassword() throws IOException {
try {
Method getConsole = System.class.getMethod("console", new Class[0]);
Object console = getConsole.invoke(null, null);
Object console = getConsole.invoke(null, (Object[]) null);
Method readPassword = console.getClass().getMethod("readPassword", new Class[0]);
System.out.print("Password ");
char[] password = (char[]) readPassword.invoke(console, null);
char[] password = (char[]) readPassword.invoke(console, (Object[]) null);
return password == null ? null : new String(password);
} catch (Throwable t) {
// ignore, use the default solution
......
......@@ -160,7 +160,6 @@ java org.h2.test.TestAll timer
/*
improve javadocs
upload jazoon
......@@ -222,6 +221,8 @@ History:
(when using remote connections).
The Shell tool now uses java.io.Console to read the password
when using JDK 1.6
When using read-only databases and setting LOG=2, an exception
was written to the trace file when closing the database. Fixed.
Roadmap:
......
......@@ -509,4 +509,4 @@ worldwide everyone additions expense lawsuit checksums jazoon flashback
dieguez dfile mvn dversion dgroup dpackaging dartifact durl dpom pom
subpackages slowed deactivate throttled noindex expired arizona export
intentional knowing jcl plug facade deployment logback confusion visited
pickle
pickle associate subtraction negation multiplication
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论