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

Limit line length to 80 characters

上级 06698d68
...@@ -37,7 +37,7 @@ public class Driver implements java.sql.Driver { ...@@ -37,7 +37,7 @@ public class Driver implements java.sql.Driver {
private static final Driver INSTANCE = new Driver(); private static final Driver INSTANCE = new Driver();
private static final String DEFAULT_URL = "jdbc:default:connection"; private static final String DEFAULT_URL = "jdbc:default:connection";
private static final ThreadLocal<Connection> DEFAULT_CONNECTION = private static final ThreadLocal<Connection> DEFAULT_CONNECTION =
new ThreadLocal<Connection>(); new ThreadLocal<Connection>();
private static volatile boolean registered; private static volatile boolean registered;
......
...@@ -22,10 +22,10 @@ public class RuleElement implements Rule { ...@@ -22,10 +22,10 @@ public class RuleElement implements Rule {
public RuleElement(String name, String topic) { public RuleElement(String name, String topic) {
this.name = name; this.name = name;
this.keyword = name.length() == 1 || this.keyword = name.length() == 1 ||
name.equals(StringUtils.toUpperEnglish(name)); name.equals(StringUtils.toUpperEnglish(name));
topic = StringUtils.toLowerEnglish(topic); topic = StringUtils.toLowerEnglish(topic);
this.type = topic.startsWith("function") ? this.type = topic.startsWith("function") ?
Sentence.FUNCTION : Sentence.KEYWORD; Sentence.FUNCTION : Sentence.KEYWORD;
} }
......
...@@ -148,7 +148,7 @@ public class DbContents { ...@@ -148,7 +148,7 @@ public class DbContents {
schemas = new DbSchema[schemaNames.length]; schemas = new DbSchema[schemaNames.length];
for (int i = 0; i < schemaNames.length; i++) { for (int i = 0; i < schemaNames.length; i++) {
String schemaName = schemaNames[i]; String schemaName = schemaNames[i];
boolean isDefault = defaultSchemaName == null || boolean isDefault = defaultSchemaName == null ||
defaultSchemaName.equals(schemaName); defaultSchemaName.equals(schemaName);
DbSchema schema = new DbSchema(this, schemaName, isDefault); DbSchema schema = new DbSchema(this, schemaName, isDefault);
if (isDefault) { if (isDefault) {
...@@ -170,8 +170,8 @@ public class DbContents { ...@@ -170,8 +170,8 @@ public class DbContents {
defaultSchema = schema; defaultSchema = schema;
break; break;
} }
if (defaultSchema == null || if (defaultSchema == null ||
best == null || best == null ||
schema.name.length() < best.length()) { schema.name.length() < best.length()) {
best = schema.name; best = schema.name;
defaultSchema = schema; defaultSchema = schema;
......
...@@ -87,8 +87,8 @@ public class DbContextRule implements Rule { ...@@ -87,8 +87,8 @@ public class DbContextRule implements Rule {
} else if (s.length() == 0 || name.startsWith(up)) { } else if (s.length() == 0 || name.startsWith(up)) {
if (s.length() < name.length()) { if (s.length() < name.length()) {
sentence.add(name, name.substring(s.length()), type); sentence.add(name, name.substring(s.length()), type);
sentence.add(schema.quotedName + ".", sentence.add(schema.quotedName + ".",
schema.quotedName.substring(s.length()) + ".", schema.quotedName.substring(s.length()) + ".",
Sentence.CONTEXT); Sentence.CONTEXT);
} }
} }
...@@ -121,8 +121,8 @@ public class DbContextRule implements Rule { ...@@ -121,8 +121,8 @@ public class DbContextRule implements Rule {
} }
} else if (s.length() == 0 || name.startsWith(compare)) { } else if (s.length() == 0 || name.startsWith(compare)) {
if (s.length() < name.length()) { if (s.length() < name.length()) {
sentence.add(table.getQuotedName(), sentence.add(table.getQuotedName(),
table.getQuotedName().substring(s.length()), table.getQuotedName().substring(s.length()),
Sentence.CONTEXT); Sentence.CONTEXT);
} }
} }
...@@ -173,16 +173,16 @@ public class DbContextRule implements Rule { ...@@ -173,16 +173,16 @@ public class DbContextRule implements Rule {
name = column.getQuotedName(); name = column.getQuotedName();
compare = query; compare = query;
} }
if (compare.startsWith(name) && if (compare.startsWith(name) &&
(columnType == null || (columnType == null ||
column.getDataType().contains(columnType))) { column.getDataType().contains(columnType))) {
String b = s.substring(name.length()); String b = s.substring(name.length());
if (best == null || b.length() < best.length()) { if (best == null || b.length() < best.length()) {
best = b; best = b;
} else if (s.length() == 0 || name.startsWith(compare)) { } else if (s.length() == 0 || name.startsWith(compare)) {
if (s.length() < name.length()) { if (s.length() < name.length()) {
sentence.add(column.getName(), sentence.add(column.getName(),
column.getName().substring(s.length()), column.getName().substring(s.length()),
Sentence.CONTEXT); Sentence.CONTEXT);
} }
} }
...@@ -209,8 +209,8 @@ public class DbContextRule implements Rule { ...@@ -209,8 +209,8 @@ public class DbContextRule implements Rule {
} }
} else if (s.length() == 0 || name.startsWith(up)) { } else if (s.length() == 0 || name.startsWith(up)) {
if (s.length() < name.length()) { if (s.length() < name.length()) {
sentence.add(column.getName(), sentence.add(column.getName(),
column.getName().substring(s.length()), column.getName().substring(s.length()),
Sentence.CONTEXT); Sentence.CONTEXT);
} }
} }
...@@ -246,7 +246,7 @@ public class DbContextRule implements Rule { ...@@ -246,7 +246,7 @@ public class DbContextRule implements Rule {
String incompleteSentence = sentence.getQueryUpper(); String incompleteSentence = sentence.getQueryUpper();
String incompleteFunctionName = incompleteSentence; String incompleteFunctionName = incompleteSentence;
if (incompleteSentence.contains("(")) { if (incompleteSentence.contains("(")) {
incompleteFunctionName = incompleteSentence.substring(0, incompleteFunctionName = incompleteSentence.substring(0,
incompleteSentence.indexOf('(')).trim(); incompleteSentence.indexOf('(')).trim();
} }
...@@ -309,7 +309,7 @@ public class DbContextRule implements Rule { ...@@ -309,7 +309,7 @@ public class DbContextRule implements Rule {
sentence.addAlias(alias, sentence.getLastTable()); sentence.addAlias(alias, sentence.getLastTable());
} }
HashMap<String, DbTableOrView> map = sentence.getAliases(); HashMap<String, DbTableOrView> map = sentence.getAliases();
if ((map != null && map.containsKey(alias)) || if ((map != null && map.containsKey(alias)) ||
(sentence.getLastTable() == null)) { (sentence.getLastTable() == null)) {
if (newAlias && s.length() == alias.length()) { if (newAlias && s.length() == alias.length()) {
return s; return s;
...@@ -324,15 +324,15 @@ public class DbContextRule implements Rule { ...@@ -324,15 +324,15 @@ public class DbContextRule implements Rule {
if (tables != null) { if (tables != null) {
String best = null; String best = null;
for (DbTableOrView table : tables) { for (DbTableOrView table : tables) {
String tableName = String tableName =
StringUtils.toUpperEnglish(table.getName()); StringUtils.toUpperEnglish(table.getName());
if (alias.startsWith(tableName) && if (alias.startsWith(tableName) &&
(best == null || tableName.length() > best.length())) { (best == null || tableName.length() > best.length())) {
sentence.setLastMatchedTable(table); sentence.setLastMatchedTable(table);
best = tableName; best = tableName;
} else if (s.length() == 0 || tableName.startsWith(alias)) { } else if (s.length() == 0 || tableName.startsWith(alias)) {
sentence.add(tableName + ".", sentence.add(tableName + ".",
tableName.substring(s.length()) + ".", tableName.substring(s.length()) + ".",
Sentence.CONTEXT); Sentence.CONTEXT);
} }
} }
......
...@@ -28,7 +28,7 @@ public class DbProcedure { ...@@ -28,7 +28,7 @@ public class DbProcedure {
public DbProcedure(DbSchema schema, ResultSet rs) throws SQLException { public DbProcedure(DbSchema schema, ResultSet rs) throws SQLException {
this.schema = schema; this.schema = schema;
name = rs.getString("PROCEDURE_NAME"); name = rs.getString("PROCEDURE_NAME");
returnsResult = rs.getShort("PROCEDURE_TYPE") == returnsResult = rs.getShort("PROCEDURE_TYPE") ==
DatabaseMetaData.procedureReturnsResult; DatabaseMetaData.procedureReturnsResult;
quotedName = schema.getContents().quoteIdentifier(name); quotedName = schema.getContents().quoteIdentifier(name);
} }
......
...@@ -79,10 +79,10 @@ public class DbSchema { ...@@ -79,10 +79,10 @@ public class DbSchema {
isSystem = true; isSystem = true;
} else if ("INFORMATION_SCHEMA".equals(name)) { } else if ("INFORMATION_SCHEMA".equals(name)) {
isSystem = true; isSystem = true;
} else if (!contents.isH2() && } else if (!contents.isH2() &&
StringUtils.toUpperEnglish(name).startsWith("INFO")) { StringUtils.toUpperEnglish(name).startsWith("INFO")) {
isSystem = true; isSystem = true;
} else if (contents.isPostgreSQL() && } else if (contents.isPostgreSQL() &&
StringUtils.toUpperEnglish(name).startsWith("PG_")) { StringUtils.toUpperEnglish(name).startsWith("PG_")) {
isSystem = true; isSystem = true;
} else if (contents.isDerby() && name.startsWith("SYS")) { } else if (contents.isDerby() && name.startsWith("SYS")) {
......
...@@ -123,7 +123,7 @@ public class CommandRemote implements CommandInterface { ...@@ -123,7 +123,7 @@ public class CommandRemote implements CommandInterface {
writeInt(id).writeInt(objectId); writeInt(id).writeInt(objectId);
session.done(transfer); session.done(transfer);
int columnCount = transfer.readInt(); int columnCount = transfer.readInt();
result = new ResultRemote(session, transfer, objectId, result = new ResultRemote(session, transfer, objectId,
columnCount, Integer.MAX_VALUE); columnCount, Integer.MAX_VALUE);
break; break;
} catch (IOException e) { } catch (IOException e) {
......
...@@ -239,7 +239,7 @@ public class Constants { ...@@ -239,7 +239,7 @@ public class Constants {
* The default result set concurrency for statements created with * The default result set concurrency for statements created with
* Connection.createStatement() or prepareStatement(String sql). * Connection.createStatement() or prepareStatement(String sql).
*/ */
public static final int DEFAULT_RESULT_SET_CONCURRENCY = public static final int DEFAULT_RESULT_SET_CONCURRENCY =
ResultSet.CONCUR_READ_ONLY; ResultSet.CONCUR_READ_ONLY;
/** /**
...@@ -311,13 +311,13 @@ public class Constants { ...@@ -311,13 +311,13 @@ public class Constants {
/** /**
* The memory needed by an object of class PageBtree. * The memory needed by an object of class PageBtree.
*/ */
public static final int MEMORY_PAGE_BTREE = public static final int MEMORY_PAGE_BTREE =
112 + MEMORY_DATA + 2 * MEMORY_OBJECT; 112 + MEMORY_DATA + 2 * MEMORY_OBJECT;
/** /**
* The memory needed by an object of class PageData. * The memory needed by an object of class PageData.
*/ */
public static final int MEMORY_PAGE_DATA = public static final int MEMORY_PAGE_DATA =
144 + MEMORY_DATA + 3 * MEMORY_OBJECT; 144 + MEMORY_DATA + 3 * MEMORY_OBJECT;
/** /**
...@@ -460,7 +460,7 @@ public class Constants { ...@@ -460,7 +460,7 @@ public class Constants {
* The database URL format in simplified Backus-Naur form. * The database URL format in simplified Backus-Naur form.
*/ */
public static final String URL_FORMAT = START_URL + public static final String URL_FORMAT = START_URL +
"{ {.|mem:}[name] | [file:]fileName | " + "{ {.|mem:}[name] | [file:]fileName | " +
"{tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]"; "{tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
/** /**
......
...@@ -105,7 +105,7 @@ public class Database implements DataHandler { ...@@ -105,7 +105,7 @@ public class Database implements DataHandler {
private final HashMap<String, UserAggregate> aggregates = New.hashMap(); private final HashMap<String, UserAggregate> aggregates = New.hashMap();
private final HashMap<String, Comment> comments = New.hashMap(); private final HashMap<String, Comment> comments = New.hashMap();
private final Set<Session> userSessions = private final Set<Session> userSessions =
Collections.synchronizedSet(new HashSet<Session>()); Collections.synchronizedSet(new HashSet<Session>());
private Session exclusiveSession; private Session exclusiveSession;
private final BitField objectIds = new BitField(); private final BitField objectIds = new BitField();
...@@ -155,7 +155,7 @@ public class Database implements DataHandler { ...@@ -155,7 +155,7 @@ public class Database implements DataHandler {
private DatabaseCloser closeOnExit; private DatabaseCloser closeOnExit;
private Mode mode = Mode.getInstance(Mode.REGULAR); private Mode mode = Mode.getInstance(Mode.REGULAR);
private boolean multiThreaded; private boolean multiThreaded;
private int maxOperationMemory = private int maxOperationMemory =
Constants.DEFAULT_MAX_OPERATION_MEMORY; Constants.DEFAULT_MAX_OPERATION_MEMORY;
private SmallLRUCache<String, String[]> lobFileListCache; private SmallLRUCache<String, String[]> lobFileListCache;
private final boolean autoServerMode; private final boolean autoServerMode;
...@@ -230,19 +230,19 @@ public class Database implements DataHandler { ...@@ -230,19 +230,19 @@ public class Database implements DataHandler {
if (modeName != null) { if (modeName != null) {
this.mode = Mode.getInstance(modeName); this.mode = Mode.getInstance(modeName);
} }
this.multiVersion = this.multiVersion =
ci.getProperty("MVCC", false); ci.getProperty("MVCC", false);
this.logMode = this.logMode =
ci.getProperty("LOG", PageStore.LOG_MODE_SYNC); ci.getProperty("LOG", PageStore.LOG_MODE_SYNC);
this.javaObjectSerializerName = this.javaObjectSerializerName =
ci.getProperty("JAVA_OBJECT_SERIALIZER", null); ci.getProperty("JAVA_OBJECT_SERIALIZER", null);
boolean closeAtVmShutdown = boolean closeAtVmShutdown =
dbSettings.dbCloseOnExit; dbSettings.dbCloseOnExit;
int traceLevelFile = int traceLevelFile =
ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE, ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE,
TraceSystem.DEFAULT_TRACE_LEVEL_FILE); TraceSystem.DEFAULT_TRACE_LEVEL_FILE);
int traceLevelSystemOut = int traceLevelSystemOut =
ci.getIntProperty(SetTypes.TRACE_LEVEL_SYSTEM_OUT, ci.getIntProperty(SetTypes.TRACE_LEVEL_SYSTEM_OUT,
TraceSystem.DEFAULT_TRACE_LEVEL_SYSTEM_OUT); TraceSystem.DEFAULT_TRACE_LEVEL_SYSTEM_OUT);
this.cacheType = StringUtils.toUpperEnglish( this.cacheType = StringUtils.toUpperEnglish(
...@@ -686,7 +686,7 @@ public class Database implements DataHandler { ...@@ -686,7 +686,7 @@ public class Database implements DataHandler {
data.session = systemSession; data.session = systemSession;
meta = mainSchema.createTable(data); meta = mainSchema.createTable(data);
IndexColumn[] pkCols = IndexColumn.wrap(new Column[] { columnId }); IndexColumn[] pkCols = IndexColumn.wrap(new Column[] { columnId });
metaIdIndex = meta.addIndex(systemSession, "SYS_ID", metaIdIndex = meta.addIndex(systemSession, "SYS_ID",
0, pkCols, IndexType.createPrimaryKey( 0, pkCols, IndexType.createPrimaryKey(
false, false), true, null); false, false), true, null);
objectIds.set(0); objectIds.set(0);
......
...@@ -30,7 +30,7 @@ public class Engine implements SessionFactory { ...@@ -30,7 +30,7 @@ public class Engine implements SessionFactory {
private static final Engine INSTANCE = new Engine(); private static final Engine INSTANCE = new Engine();
private static final HashMap<String, Database> DATABASES = New.hashMap(); private static final HashMap<String, Database> DATABASES = New.hashMap();
private volatile long wrongPasswordDelay = private volatile long wrongPasswordDelay =
SysProperties.DELAY_WRONG_PASSWORD_MIN; SysProperties.DELAY_WRONG_PASSWORD_MIN;
private boolean jmx; private boolean jmx;
...@@ -38,7 +38,8 @@ public class Engine implements SessionFactory { ...@@ -38,7 +38,8 @@ public class Engine implements SessionFactory {
return INSTANCE; return INSTANCE;
} }
private Session openSession(ConnectionInfo ci, boolean ifExists, String cipher) { private Session openSession(ConnectionInfo ci, boolean ifExists,
String cipher) {
String name = ci.getName(); String name = ci.getName();
Database database; Database database;
ci.removeProperty("NO_UPGRADE", false); ci.removeProperty("NO_UPGRADE", false);
...@@ -59,7 +60,7 @@ public class Engine implements SessionFactory { ...@@ -59,7 +60,7 @@ public class Engine implements SessionFactory {
if (database.getAllUsers().size() == 0) { if (database.getAllUsers().size() == 0) {
// users is the last thing we add, so if no user is around, // users is the last thing we add, so if no user is around,
// the database is new (or not initialized correctly) // the database is new (or not initialized correctly)
user = new User(database, database.allocateObjectId(), user = new User(database, database.allocateObjectId(),
ci.getUserName(), false); ci.getUserName(), false);
user.setAdmin(true); user.setAdmin(true);
user.setUserPasswordHash(ci.getUserPasswordHash()); user.setUserPasswordHash(ci.getUserPasswordHash());
...@@ -188,7 +189,7 @@ public class Engine implements SessionFactory { ...@@ -188,7 +189,7 @@ public class Engine implements SessionFactory {
String value = ci.getProperty(setting); String value = ci.getProperty(setting);
try { try {
CommandInterface command = session.prepareCommand( CommandInterface command = session.prepareCommand(
"SET " + Parser.quoteIdentifier(setting) + " " + value, "SET " + Parser.quoteIdentifier(setting) + " " + value,
Integer.MAX_VALUE); Integer.MAX_VALUE);
command.executeUpdate(); command.executeUpdate();
} catch (DbException e) { } catch (DbException e) {
...@@ -200,7 +201,7 @@ public class Engine implements SessionFactory { ...@@ -200,7 +201,7 @@ public class Engine implements SessionFactory {
} }
if (init != null) { if (init != null) {
try { try {
CommandInterface command = session.prepareCommand(init, CommandInterface command = session.prepareCommand(init,
Integer.MAX_VALUE); Integer.MAX_VALUE);
command.executeUpdate(); command.executeUpdate();
} catch (DbException e) { } catch (DbException e) {
...@@ -231,7 +232,7 @@ public class Engine implements SessionFactory { ...@@ -231,7 +232,7 @@ public class Engine implements SessionFactory {
ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_ALONE); ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_ALONE);
} }
throw DbException.get( throw DbException.get(
ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1, ErrorCode.CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1,
clusterDb); clusterDb);
} }
} }
......
...@@ -271,7 +271,8 @@ public abstract class Expression { ...@@ -271,7 +271,8 @@ public abstract class Expression {
* @param outerJoin if the expression is part of an outer join * @param outerJoin if the expression is part of an outer join
*/ */
public void addFilterConditions(TableFilter filter, boolean outerJoin) { public void addFilterConditions(TableFilter filter, boolean outerJoin) {
if (!addedToFilter && !outerJoin && isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) { if (!addedToFilter && !outerJoin &&
isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) {
filter.addFilterCondition(this, false); filter.addFilterCondition(this, false);
addedToFilter = true; addedToFilter = true;
} }
......
...@@ -173,7 +173,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex { ...@@ -173,7 +173,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
public Cursor find(Session session, SearchRow first, SearchRow last) { public Cursor find(Session session, SearchRow first, SearchRow last) {
return find(session, first, last, null); return find(session, first, last, null);
} }
@Override @Override
public Cursor findByGeometry(TableFilter filter, SearchRow intersection) { public Cursor findByGeometry(TableFilter filter, SearchRow intersection) {
return find(filter.getSession(), null, null, intersection); return find(filter.getSession(), null, null, intersection);
......
...@@ -723,7 +723,7 @@ public class DataUtils { ...@@ -723,7 +723,7 @@ public class DataUtils {
* @param message the message * @param message the message
* @return the exception * @return the exception
*/ */
public static ConcurrentModificationException public static ConcurrentModificationException
newConcurrentModificationException(String message) { newConcurrentModificationException(String message) {
return new ConcurrentModificationException(formatMessage(0, message)); return new ConcurrentModificationException(formatMessage(0, message));
} }
......
...@@ -39,7 +39,7 @@ public class FileStore { ...@@ -39,7 +39,7 @@ public class FileStore {
* The free spaces between the chunks. The first block to use is block 2 * The free spaces between the chunks. The first block to use is block 2
* (the first two blocks are the store header). * (the first two blocks are the store header).
*/ */
protected final FreeSpaceBitSet freeSpace = protected final FreeSpaceBitSet freeSpace =
new FreeSpaceBitSet(2, MVStore.BLOCK_SIZE); new FreeSpaceBitSet(2, MVStore.BLOCK_SIZE);
/** /**
......
...@@ -156,7 +156,7 @@ public class MVStore { ...@@ -156,7 +156,7 @@ public class MVStore {
/** /**
* The map of chunks. * The map of chunks.
*/ */
private final ConcurrentHashMap<Integer, Chunk> chunks = private final ConcurrentHashMap<Integer, Chunk> chunks =
new ConcurrentHashMap<Integer, Chunk>(); new ConcurrentHashMap<Integer, Chunk>();
/** /**
...@@ -173,7 +173,7 @@ public class MVStore { ...@@ -173,7 +173,7 @@ public class MVStore {
*/ */
private MVMapConcurrent<String, String> meta; private MVMapConcurrent<String, String> meta;
private final ConcurrentHashMap<Integer, MVMap<?, ?>> maps = private final ConcurrentHashMap<Integer, MVMap<?, ?>> maps =
new ConcurrentHashMap<Integer, MVMap<?, ?>>(); new ConcurrentHashMap<Integer, MVMap<?, ?>>();
private HashMap<String, Object> fileHeader = New.hashMap(); private HashMap<String, Object> fileHeader = New.hashMap();
...@@ -1911,7 +1911,7 @@ public class MVStore { ...@@ -1911,7 +1911,7 @@ public class MVStore {
c = chunks.get(c.id - 1); c = chunks.get(c.id - 1);
} }
Chunk last = lastChunk; Chunk last = lastChunk;
if (removeChunksNewerThan != null && if (removeChunksNewerThan != null &&
last.version > removeChunksNewerThan.version) { last.version > removeChunksNewerThan.version) {
revertTemp(version); revertTemp(version);
loadFromFile = true; loadFromFile = true;
...@@ -2158,8 +2158,8 @@ public class MVStore { ...@@ -2158,8 +2158,8 @@ public class MVStore {
// start the background thread if needed // start the background thread if needed
if (millis > 0) { if (millis > 0) {
int sleep = Math.max(1, millis / 10); int sleep = Math.max(1, millis / 10);
BackgroundWriterThread t = BackgroundWriterThread t =
new BackgroundWriterThread(this, sleep, new BackgroundWriterThread(this, sleep,
fileStore.toString()); fileStore.toString());
t.start(); t.start();
backgroundWriterThread = t; backgroundWriterThread = t;
......
...@@ -17,7 +17,7 @@ import java.util.TreeMap; ...@@ -17,7 +17,7 @@ import java.util.TreeMap;
*/ */
public class OffHeapStore extends FileStore { public class OffHeapStore extends FileStore {
private final TreeMap<Long, ByteBuffer> memory = private final TreeMap<Long, ByteBuffer> memory =
new TreeMap<Long, ByteBuffer>(); new TreeMap<Long, ByteBuffer>();
@Override @Override
......
...@@ -30,7 +30,7 @@ import org.h2.mvstore.type.DataType; ...@@ -30,7 +30,7 @@ import org.h2.mvstore.type.DataType;
*/ */
public class Page { public class Page {
private static final int SHARED_KEYS = 1, SHARED_VALUES = 2, private static final int SHARED_KEYS = 1, SHARED_VALUES = 2,
SHARED_CHILDREN = 4, SHARED_COUNTS = 8; SHARED_CHILDREN = 4, SHARED_COUNTS = 8;
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
......
...@@ -41,7 +41,7 @@ public class StreamStore { ...@@ -41,7 +41,7 @@ public class StreamStore {
private int minBlockSize = 256; private int minBlockSize = 256;
private int maxBlockSize = 256 * 1024; private int maxBlockSize = 256 * 1024;
private final AtomicLong nextKey = new AtomicLong(); private final AtomicLong nextKey = new AtomicLong();
private final AtomicReference<byte[]> nextBuffer = private final AtomicReference<byte[]> nextBuffer =
new AtomicReference<byte[]>(); new AtomicReference<byte[]>();
/** /**
......
...@@ -627,7 +627,7 @@ public class CacheLongKeyLIRS<V> { ...@@ -627,7 +627,7 @@ public class CacheLongKeyLIRS<V> {
} }
if (e.isHot()) { if (e.isHot()) {
if (e != stack.stackNext) { if (e != stack.stackNext) {
if (stackMoveDistance == 0 || if (stackMoveDistance == 0 ||
stackMoveCounter - e.topMove > stackMoveDistance) { stackMoveCounter - e.topMove > stackMoveDistance) {
access(key, hash); access(key, hash);
} }
...@@ -651,7 +651,7 @@ public class CacheLongKeyLIRS<V> { ...@@ -651,7 +651,7 @@ public class CacheLongKeyLIRS<V> {
} }
if (e.isHot()) { if (e.isHot()) {
if (e != stack.stackNext) { if (e != stack.stackNext) {
if (stackMoveDistance == 0 || if (stackMoveDistance == 0 ||
stackMoveCounter - e.topMove > stackMoveDistance) { stackMoveCounter - e.topMove > stackMoveDistance) {
// move a hot entry to the top of the stack // move a hot entry to the top of the stack
// unless it is already there // unless it is already there
......
...@@ -67,11 +67,11 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex { ...@@ -67,11 +67,11 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex {
@Override @Override
public Cursor find(Session session, SearchRow first, SearchRow last) { public Cursor find(Session session, SearchRow first, SearchRow last) {
ValueLong min = mainIndex.getKey(first, ValueLong min = mainIndex.getKey(first,
MVPrimaryIndex.MIN, MVPrimaryIndex.MIN); MVPrimaryIndex.MIN, MVPrimaryIndex.MIN);
// ifNull is MIN_VALUE as well, because the column is never NULL // ifNull is MIN_VALUE as well, because the column is never NULL
// so avoid returning all rows (returning one row is OK) // so avoid returning all rows (returning one row is OK)
ValueLong max = mainIndex.getKey(last, ValueLong max = mainIndex.getKey(last,
MVPrimaryIndex.MAX, MVPrimaryIndex.MIN); MVPrimaryIndex.MAX, MVPrimaryIndex.MIN);
return mainIndex.find(session, min, max); return mainIndex.find(session, min, max);
} }
......
...@@ -281,7 +281,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -281,7 +281,7 @@ public class MVPrimaryIndex extends BaseIndex {
/** /**
* The maximum number of rows, including uncommitted rows of any session. * The maximum number of rows, including uncommitted rows of any session.
* *
* @return the maximum number of rows * @return the maximum number of rows
*/ */
public long getRowCountMax() { public long getRowCountMax() {
...@@ -314,7 +314,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -314,7 +314,7 @@ public class MVPrimaryIndex extends BaseIndex {
/** /**
* Get the key from the row. * Get the key from the row.
* *
* @param row the row * @param row the row
* @param ifEmpty the value to use if the row is empty * @param ifEmpty the value to use if the row is empty
* @param ifNull the value to use if the column is NULL * @param ifNull the value to use if the column is NULL
...@@ -335,7 +335,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -335,7 +335,7 @@ public class MVPrimaryIndex extends BaseIndex {
/** /**
* Search for a specific row or a set of rows. * Search for a specific row or a set of rows.
* *
* @param session the session * @param session the session
* @param first the key of the first row * @param first the key of the first row
* @param last the key of the last row * @param last the key of the last row
...@@ -353,7 +353,7 @@ public class MVPrimaryIndex extends BaseIndex { ...@@ -353,7 +353,7 @@ public class MVPrimaryIndex extends BaseIndex {
/** /**
* Get the map to store the data. * Get the map to store the data.
* *
* @param session the session * @param session the session
* @return the map * @return the map
*/ */
......
...@@ -308,7 +308,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -308,7 +308,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
public double getCost(Session session, int[] masks, TableFilter filter, public double getCost(Session session, int[] masks, TableFilter filter,
SortOrder sortOrder) { SortOrder sortOrder) {
try { try {
return 10 * getCostRangeIndex(masks, return 10 * getCostRangeIndex(masks,
dataMap.sizeAsLongMax(), filter, sortOrder); dataMap.sizeAsLongMax(), filter, sortOrder);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
...@@ -341,7 +341,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -341,7 +341,7 @@ public class MVSecondaryIndex extends BaseIndex implements MVIndex {
Value key = first ? map.firstKey() : map.lastKey(); Value key = first ? map.firstKey() : map.lastKey();
while (true) { while (true) {
if (key == null) { if (key == null) {
return new MVStoreCursor(session, return new MVStoreCursor(session,
Collections.<Value>emptyList().iterator(), null); Collections.<Value>emptyList().iterator(), null);
} }
if (((ValueArray) key).getList()[0] != ValueNull.INSTANCE) { if (((ValueArray) key).getList()[0] != ValueNull.INSTANCE) {
......
...@@ -212,7 +212,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex { ...@@ -212,7 +212,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
if (intersection == null) { if (intersection == null) {
return find(session); return find(session);
} }
Iterator<SpatialKey> cursor = Iterator<SpatialKey> cursor =
spatialMap.findIntersectingKeys(getEnvelope(intersection)); spatialMap.findIntersectingKeys(getEnvelope(intersection));
TransactionMap<SpatialKey, Value> map = getMap(session); TransactionMap<SpatialKey, Value> map = getMap(session);
Iterator<SpatialKey> it = map.wrapIterator(cursor, false); Iterator<SpatialKey> it = map.wrapIterator(cursor, false);
......
...@@ -135,7 +135,7 @@ public class MVTableEngine implements TableEngine { ...@@ -135,7 +135,7 @@ public class MVTableEngine implements TableEngine {
* The map of open tables. * The map of open tables.
* Key: the map name, value: the table. * Key: the map name, value: the table.
*/ */
final ConcurrentHashMap<String, MVTable> tableMap = final ConcurrentHashMap<String, MVTable> tableMap =
new ConcurrentHashMap<String, MVTable>(); new ConcurrentHashMap<String, MVTable>();
/** /**
......
...@@ -866,7 +866,7 @@ public class TransactionStore { ...@@ -866,7 +866,7 @@ public class TransactionStore {
*/ */
public TransactionMap<K, V> getInstance(Transaction transaction, public TransactionMap<K, V> getInstance(Transaction transaction,
long savepoint) { long savepoint) {
TransactionMap<K, V> m = TransactionMap<K, V> m =
new TransactionMap<K, V>(transaction, map, mapId); new TransactionMap<K, V>(transaction, map, mapId);
m.setSavepoint(savepoint); m.setSavepoint(savepoint);
return m; return m;
......
...@@ -183,7 +183,7 @@ public class ValueDataType implements DataType { ...@@ -183,7 +183,7 @@ public class ValueDataType implements DataType {
int type = v.getType(); int type = v.getType();
switch (type) { switch (type) {
case Value.BOOLEAN: case Value.BOOLEAN:
buff.put((byte) (v.getBoolean().booleanValue() ? buff.put((byte) (v.getBoolean().booleanValue() ?
BOOLEAN_TRUE : BOOLEAN_FALSE)); BOOLEAN_TRUE : BOOLEAN_FALSE));
break; break;
case Value.BYTE: case Value.BYTE:
...@@ -518,11 +518,11 @@ public class ValueDataType implements DataType { ...@@ -518,11 +518,11 @@ public class ValueDataType implements DataType {
int tableId = readVarInt(buff); int tableId = readVarInt(buff);
long lobId = readVarLong(buff); long lobId = readVarLong(buff);
long precision = readVarLong(buff); long precision = readVarLong(buff);
ValueLobDb lob = ValueLobDb.create(type, ValueLobDb lob = ValueLobDb.create(type,
handler, tableId, lobId, null, precision); handler, tableId, lobId, null, precision);
return lob; return lob;
} else { } else {
throw DbException.get(ErrorCode.FILE_CORRUPTED_1, throw DbException.get(ErrorCode.FILE_CORRUPTED_1,
"lob type: " + smallLen); "lob type: " + smallLen);
} }
} }
...@@ -538,9 +538,9 @@ public class ValueDataType implements DataType { ...@@ -538,9 +538,9 @@ public class ValueDataType implements DataType {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
int columns = readVarInt(buff); int columns = readVarInt(buff);
for (int i = 0; i < columns; i++) { for (int i = 0; i < columns; i++) {
rs.addColumn(readString(buff), rs.addColumn(readString(buff),
readVarInt(buff), readVarInt(buff),
readVarInt(buff), readVarInt(buff),
readVarInt(buff)); readVarInt(buff));
} }
while (true) { while (true) {
......
...@@ -43,16 +43,16 @@ public class CipherFactory { ...@@ -43,16 +43,16 @@ public class CipherFactory {
/** /**
* The default password to use for the .h2.keystore file * The default password to use for the .h2.keystore file
*/ */
public static final String KEYSTORE_PASSWORD = public static final String KEYSTORE_PASSWORD =
"h2pass"; "h2pass";
private static final String KEYSTORE = private static final String KEYSTORE =
"~/.h2.keystore"; "~/.h2.keystore";
private static final String KEYSTORE_KEY = private static final String KEYSTORE_KEY =
"javax.net.ssl.keyStore"; "javax.net.ssl.keyStore";
private static final String KEYSTORE_PASSWORD_KEY = private static final String KEYSTORE_PASSWORD_KEY =
"javax.net.ssl.keyStorePassword"; "javax.net.ssl.keyStorePassword";
private static final String ANONYMOUS_CIPHER_SUITE = private static final String ANONYMOUS_CIPHER_SUITE =
"SSL_DH_anon_WITH_RC4_128_MD5"; "SSL_DH_anon_WITH_RC4_128_MD5";
private CipherFactory() { private CipherFactory() {
......
...@@ -32,13 +32,13 @@ public class Fog implements BlockCipher { ...@@ -32,13 +32,13 @@ public class Fog implements BlockCipher {
} }
private void encryptBlock(byte[] in, byte[] out, int off) { private void encryptBlock(byte[] in, byte[] out, int off) {
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) | int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
((in[off+2] & 255) << 8) | (in[off+3] & 255); ((in[off+2] & 255) << 8) | (in[off+3] & 255);
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) | int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
((in[off+6] & 255) << 8) | (in[off+7] & 255); ((in[off+6] & 255) << 8) | (in[off+7] & 255);
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) | int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
((in[off+10] & 255) << 8) | (in[off+11] & 255); ((in[off+10] & 255) << 8) | (in[off+11] & 255);
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) | int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
((in[off+14] & 255) << 8) | (in[off+15] & 255); ((in[off+14] & 255) << 8) | (in[off+15] & 255);
int k = key; int k = key;
int s = x1 & 31; int s = x1 & 31;
...@@ -62,13 +62,13 @@ public class Fog implements BlockCipher { ...@@ -62,13 +62,13 @@ public class Fog implements BlockCipher {
} }
private void decryptBlock(byte[] in, byte[] out, int off) { private void decryptBlock(byte[] in, byte[] out, int off) {
int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) | int x0 = (in[off] << 24) | ((in[off+1] & 255) << 16) |
((in[off+2] & 255) << 8) | (in[off+3] & 255); ((in[off+2] & 255) << 8) | (in[off+3] & 255);
int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) | int x1 = (in[off+4] << 24) | ((in[off+5] & 255) << 16) |
((in[off+6] & 255) << 8) | (in[off+7] & 255); ((in[off+6] & 255) << 8) | (in[off+7] & 255);
int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) | int x2 = (in[off+8] << 24) | ((in[off+9] & 255) << 16) |
((in[off+10] & 255) << 8) | (in[off+11] & 255); ((in[off+10] & 255) << 8) | (in[off+11] & 255);
int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) | int x3 = (in[off+12] << 24) | ((in[off+13] & 255) << 16) |
((in[off+14] & 255) << 8) | (in[off+15] & 255); ((in[off+14] & 255) << 8) | (in[off+15] & 255);
int k = key; int k = key;
int s = 32 - (x0 & 31); int s = 32 - (x0 & 31);
......
...@@ -209,7 +209,7 @@ public class SHA256 { ...@@ -209,7 +209,7 @@ public class SHA256 {
Arrays.fill(hh, 0); Arrays.fill(hh, 0);
} }
private void calculateHash(byte[] data, int len, private void calculateHash(byte[] data, int len,
byte[] byteBuff, int[] intBuff) { byte[] byteBuff, int[] intBuff) {
int[] w = this.w; int[] w = this.w;
int[] hh = this.hh; int[] hh = this.hh;
......
...@@ -83,10 +83,10 @@ public class TcpServerThread implements Runnable { ...@@ -83,10 +83,10 @@ public class TcpServerThread implements Runnable {
} }
int minClientVersion = transfer.readInt(); int minClientVersion = transfer.readInt();
if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) { if (minClientVersion < Constants.TCP_PROTOCOL_VERSION_6) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_6);
} else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_14) { } else if (minClientVersion > Constants.TCP_PROTOCOL_VERSION_14) {
throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2, throw DbException.get(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_14); "" + clientVersion, "" + Constants.TCP_PROTOCOL_VERSION_14);
} }
int maxClientVersion = transfer.readInt(); int maxClientVersion = transfer.readInt();
......
...@@ -33,7 +33,7 @@ public class FileStore { ...@@ -33,7 +33,7 @@ public class FileStore {
/** /**
* The magic file header. * The magic file header.
*/ */
private static final String HEADER = private static final String HEADER =
"-- H2 0.5/B -- ".substring(0, Constants.FILE_BLOCK_SIZE - 1) + "\n"; "-- H2 0.5/B -- ".substring(0, Constants.FILE_BLOCK_SIZE - 1) + "\n";
/** /**
...@@ -125,7 +125,7 @@ public class FileStore { ...@@ -125,7 +125,7 @@ public class FileStore {
if (cipher == null) { if (cipher == null) {
store = new FileStore(handler, name, mode); store = new FileStore(handler, name, mode);
} else { } else {
store = new SecureFileStore(handler, name, mode, store = new SecureFileStore(handler, name, mode,
cipher, key, keyIterations); cipher, key, keyIterations);
} }
return store; return store;
......
...@@ -213,12 +213,14 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -213,12 +213,14 @@ public class LobStorageBackend implements LobStorageInterface {
assertNotHolds(conn.getSession()); assertNotHolds(conn.getSession());
synchronized (database) { synchronized (database) {
synchronized (conn.getSession()) { synchronized (conn.getSession()) {
String sql = "SELECT COMPRESSED, DATA FROM " + LOB_DATA + " WHERE BLOCK = ?"; String sql = "SELECT COMPRESSED, DATA FROM " +
LOB_DATA + " WHERE BLOCK = ?";
PreparedStatement prep = prepare(sql); PreparedStatement prep = prepare(sql);
prep.setLong(1, block); prep.setLong(1, block);
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if (!rs.next()) { if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry, block: " + block) throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry, block: " + block)
.getSQLException(); .getSQLException();
} }
int compressed = rs.getInt(1); int compressed = rs.getInt(1);
...@@ -319,7 +321,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -319,7 +321,8 @@ public class LobStorageBackend implements LobStorageInterface {
} }
@Override @Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException { public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
long byteCount) throws IOException {
try { try {
init(); init();
assertNotHolds(conn.getSession()); assertNotHolds(conn.getSession());
...@@ -335,7 +338,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -335,7 +338,8 @@ public class LobStorageBackend implements LobStorageInterface {
} }
} }
private ValueLobDb addLob(InputStream in, long maxLength, int type, CountingReaderInputStream countingReaderForClob) { private ValueLobDb addLob(InputStream in, long maxLength, int type,
CountingReaderInputStream countingReaderForClob) {
try { try {
byte[] buff = new byte[BLOCK_LENGTH]; byte[] buff = new byte[BLOCK_LENGTH];
if (maxLength < 0) { if (maxLength < 0) {
...@@ -385,13 +389,15 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -385,13 +389,15 @@ public class LobStorageBackend implements LobStorageInterface {
if (small != null) { if (small != null) {
// For a BLOB, precision is length in bytes. // For a BLOB, precision is length in bytes.
// For a CLOB, precision is length in chars // For a CLOB, precision is length in chars
long precision = countingReaderForClob == null ? small.length : countingReaderForClob.getLength(); long precision = countingReaderForClob == null ?
small.length : countingReaderForClob.getLength();
ValueLobDb v = ValueLobDb.createSmallLob(type, small, precision); ValueLobDb v = ValueLobDb.createSmallLob(type, small, precision);
return v; return v;
} }
// For a BLOB, precision is length in bytes. // For a BLOB, precision is length in bytes.
// For a CLOB, precision is length in chars // For a CLOB, precision is length in chars
long precision = countingReaderForClob == null ? length : countingReaderForClob.getLength(); long precision = countingReaderForClob == null ?
length : countingReaderForClob.getLength();
return registerLob(type, lobId, LobStorageFrontend.TABLE_TEMP, length, precision); return registerLob(type, lobId, LobStorageFrontend.TABLE_TEMP, length, precision);
} catch (IOException e) { } catch (IOException e) {
if (lobId != -1) { if (lobId != -1) {
...@@ -404,7 +410,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -404,7 +410,8 @@ public class LobStorageBackend implements LobStorageInterface {
} }
} }
private ValueLobDb registerLob(int type, long lobId, int tableId, long byteCount, long precision) throws SQLException { private ValueLobDb registerLob(int type, long lobId, int tableId,
long byteCount, long precision) throws SQLException {
assertNotHolds(conn.getSession()); assertNotHolds(conn.getSession());
// see locking discussion at the top // see locking discussion at the top
synchronized (database) { synchronized (database) {
...@@ -495,7 +502,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -495,7 +502,8 @@ public class LobStorageBackend implements LobStorageInterface {
* @param b the data * @param b the data
* @param compressAlgorithm the compression algorithm (may be null) * @param compressAlgorithm the compression algorithm (may be null)
*/ */
void storeBlock(long lobId, int seq, long pos, byte[] b, String compressAlgorithm) throws SQLException { void storeBlock(long lobId, int seq, long pos, byte[] b,
String compressAlgorithm) throws SQLException {
long block; long block;
boolean blockExists = false; boolean blockExists = false;
if (compressAlgorithm != null) { if (compressAlgorithm != null) {
...@@ -523,7 +531,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -523,7 +531,8 @@ public class LobStorageBackend implements LobStorageInterface {
if (!blockExists) { if (!blockExists) {
block = nextBlock++; block = nextBlock++;
setHashCacheBlock(hash, block); setHashCacheBlock(hash, block);
String sql = "INSERT INTO " + LOB_DATA + "(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)"; String sql = "INSERT INTO " + LOB_DATA +
"(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)";
PreparedStatement prep = prepare(sql); PreparedStatement prep = prepare(sql);
prep.setLong(1, block); prep.setLong(1, block);
prep.setInt(2, compressAlgorithm == null ? 0 : 1); prep.setInt(2, compressAlgorithm == null ? 0 : 1);
...@@ -531,7 +540,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -531,7 +540,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.execute(); prep.execute();
reuse(sql, prep); reuse(sql, prep);
} }
String sql = "INSERT INTO " + LOB_MAP + "(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)"; String sql = "INSERT INTO " + LOB_MAP +
"(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)";
PreparedStatement prep = prepare(sql); PreparedStatement prep = prepare(sql);
prep.setLong(1, lobId); prep.setLong(1, lobId);
prep.setInt(2, seq); prep.setInt(2, seq);
...@@ -641,7 +651,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -641,7 +651,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.setLong(1, lobId); prep.setLong(1, lobId);
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if (!rs.next()) { if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException(); throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry: " + lobId).getSQLException();
} }
byteCount = rs.getLong(1); byteCount = rs.getLong(1);
reuse(sql, prep); reuse(sql, prep);
...@@ -653,7 +664,8 @@ public class LobStorageBackend implements LobStorageInterface { ...@@ -653,7 +664,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep.setLong(1, lobId); prep.setLong(1, lobId);
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
if (!rs.next()) { if (!rs.next()) {
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException(); throw DbException.get(ErrorCode.IO_EXCEPTION_1,
"Missing lob entry: " + lobId).getSQLException();
} }
int lobMapCount = rs.getInt(1); int lobMapCount = rs.getInt(1);
reuse(sql, prep); reuse(sql, prep);
......
...@@ -49,11 +49,13 @@ public class LobStorageFrontend implements LobStorageInterface { ...@@ -49,11 +49,13 @@ public class LobStorageFrontend implements LobStorageInterface {
* @return the stream * @return the stream
*/ */
@Override @Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac, long byteCount) throws IOException { public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
long byteCount) throws IOException {
if (byteCount < 0) { if (byteCount < 0) {
byteCount = Long.MAX_VALUE; byteCount = Long.MAX_VALUE;
} }
return new BufferedInputStream(new LobStorageRemoteInputStream(handler, lob, hmac, byteCount)); return new BufferedInputStream(new LobStorageRemoteInputStream(
handler, lob, hmac, byteCount));
} }
@Override @Override
......
...@@ -153,10 +153,12 @@ public class LobStorageMap implements LobStorageInterface { ...@@ -153,10 +153,12 @@ public class LobStorageMap implements LobStorageInterface {
b.reset(); b.reset();
reader = b; reader = b;
} }
CountingReaderInputStream in = new CountingReaderInputStream(reader, maxLength); CountingReaderInputStream in =
new CountingReaderInputStream(reader, maxLength);
ValueLobDb lob = createLob(in, type); ValueLobDb lob = createLob(in, type);
// the length is not correct // the length is not correct
lob = ValueLobDb.create(type, database, lob.getTableId(), lob.getLobId(), null, in.getLength()); lob = ValueLobDb.create(type, database,
lob.getTableId(), lob.getLobId(), null, in.getLength());
return lob; return lob;
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
...@@ -179,7 +181,8 @@ public class LobStorageMap implements LobStorageInterface { ...@@ -179,7 +181,8 @@ public class LobStorageMap implements LobStorageInterface {
lobMap.put(lobId, value); lobMap.put(lobId, value);
Object[] key = new Object[] { streamStoreId, lobId }; Object[] key = new Object[] { streamStoreId, lobId };
refMap.put(key, Boolean.TRUE); refMap.put(key, Boolean.TRUE);
ValueLobDb lob = ValueLobDb.create(type, database, tableId, lobId, null, length); ValueLobDb lob = ValueLobDb.create(
type, database, tableId, lobId, null, length);
if (TRACE) { if (TRACE) {
trace("create " + tableId + "/" + lobId); trace("create " + tableId + "/" + lobId);
} }
...@@ -208,9 +211,11 @@ public class LobStorageMap implements LobStorageInterface { ...@@ -208,9 +211,11 @@ public class LobStorageMap implements LobStorageInterface {
lobMap.put(lobId, value); lobMap.put(lobId, value);
Object[] key = new Object[] { streamStoreId, lobId }; Object[] key = new Object[] { streamStoreId, lobId };
refMap.put(key, Boolean.TRUE); refMap.put(key, Boolean.TRUE);
ValueLobDb lob = ValueLobDb.create(type, database, tableId, lobId, null, length); ValueLobDb lob = ValueLobDb.create(
type, database, tableId, lobId, null, length);
if (TRACE) { if (TRACE) {
trace("copy " + old.getTableId() + "/" + old.getLobId() + " > " + tableId + "/" + lobId); trace("copy " + old.getTableId() + "/" + old.getLobId() +
" > " + tableId + "/" + lobId);
} }
return lob; return lob;
} }
...@@ -230,7 +235,8 @@ public class LobStorageMap implements LobStorageInterface { ...@@ -230,7 +235,8 @@ public class LobStorageMap implements LobStorageInterface {
long lobId = lob.getLobId(); long lobId = lob.getLobId();
Object[] value = lobMap.remove(lobId); Object[] value = lobMap.remove(lobId);
if (TRACE) { if (TRACE) {
trace("move " + lob.getTableId() + "/" + lob.getLobId() + " > " + tableId + "/" + lobId); trace("move " + lob.getTableId() + "/" + lob.getLobId() +
" > " + tableId + "/" + lobId);
} }
value[1] = tableId; value[1] = tableId;
lobMap.put(lobId, value); lobMap.put(lobId, value);
......
...@@ -39,7 +39,8 @@ class LobStorageRemoteInputStream extends InputStream { ...@@ -39,7 +39,8 @@ class LobStorageRemoteInputStream extends InputStream {
*/ */
private long remainingBytes; private long remainingBytes;
public LobStorageRemoteInputStream(DataHandler handler, ValueLobDb lob, byte[] hmac, long byteCount) { public LobStorageRemoteInputStream(DataHandler handler, ValueLobDb lob,
byte[] hmac, long byteCount) {
this.handler = handler; this.handler = handler;
this.lob = lob.getLobId(); this.lob = lob.getLobId();
this.hmac = hmac; this.hmac = hmac;
......
...@@ -476,7 +476,7 @@ public class Csv implements SimpleRowSource { ...@@ -476,7 +476,7 @@ public class Csv implements SimpleRowSource {
break; break;
} }
} }
String s = new String(inputBuffer, String s = new String(inputBuffer,
inputBufferStart, inputBufferPos - inputBufferStart - sep); inputBufferStart, inputBufferPos - inputBufferStart - sep);
if (containsEscape) { if (containsEscape) {
s = unEscape(s); s = unEscape(s);
...@@ -528,7 +528,7 @@ public class Csv implements SimpleRowSource { ...@@ -528,7 +528,7 @@ public class Csv implements SimpleRowSource {
break; break;
} }
} }
String s = new String(inputBuffer, String s = new String(inputBuffer,
inputBufferStart, inputBufferPos - inputBufferStart - 1); inputBufferStart, inputBufferPos - inputBufferStart - 1);
if (!preserveWhitespace) { if (!preserveWhitespace) {
s = s.trim(); s = s.trim();
......
...@@ -123,7 +123,7 @@ public class NetUtils { ...@@ -123,7 +123,7 @@ public class NetUtils {
SysProperties.SOCKET_CONNECT_TIMEOUT); SysProperties.SOCKET_CONNECT_TIMEOUT);
return socket; return socket;
} catch (IOException e) { } catch (IOException e) {
if (System.currentTimeMillis() - start >= if (System.currentTimeMillis() - start >=
SysProperties.SOCKET_CONNECT_TIMEOUT) { SysProperties.SOCKET_CONNECT_TIMEOUT) {
// either it was a connect timeout, // either it was a connect timeout,
// or list of different exceptions // or list of different exceptions
......
...@@ -30,7 +30,7 @@ import java.util.Map; ...@@ -30,7 +30,7 @@ import java.util.Map;
public class Profiler implements Runnable { public class Profiler implements Runnable {
private static Instrumentation instrumentation; private static Instrumentation instrumentation;
private static final String LINE_SEPARATOR = private static final String LINE_SEPARATOR =
System.getProperty("line.separator", "\n"); System.getProperty("line.separator", "\n");
private static final int MAX_ELEMENTS = 1000; private static final int MAX_ELEMENTS = 1000;
...@@ -73,14 +73,14 @@ public class Profiler implements Runnable { ...@@ -73,14 +73,14 @@ public class Profiler implements Runnable {
).split(","); ).split(",");
private volatile boolean stop; private volatile boolean stop;
private final HashMap<String, Integer> counts = private final HashMap<String, Integer> counts =
new HashMap<String, Integer>(); new HashMap<String, Integer>();
/** /**
* The summary (usually one entry per package, unless sumClasses is enabled, * The summary (usually one entry per package, unless sumClasses is enabled,
* in which case it's one entry per class). * in which case it's one entry per class).
*/ */
private final HashMap<String, Integer> summary = private final HashMap<String, Integer> summary =
new HashMap<String, Integer>(); new HashMap<String, Integer>();
private int minCount = 1; private int minCount = 1;
private int total; private int total;
...@@ -122,7 +122,7 @@ public class Profiler implements Runnable { ...@@ -122,7 +122,7 @@ public class Profiler implements Runnable {
private void run(String... args) { private void run(String... args) {
if (args.length == 0) { if (args.length == 0) {
System.out.println("Show profiling data"); System.out.println("Show profiling data");
System.out.println("Usage: java " + getClass().getName() + System.out.println("Usage: java " + getClass().getName() +
" <pid> | <stackTraceFileNames>"); " <pid> | <stackTraceFileNames>");
System.out.println("Processes:"); System.out.println("Processes:");
String processes = exec("jps", "-l"); String processes = exec("jps", "-l");
...@@ -409,7 +409,7 @@ public class Profiler implements Runnable { ...@@ -409,7 +409,7 @@ public class Profiler implements Runnable {
map.put(trace, oldCount + 1); map.put(trace, oldCount + 1);
} }
while (map.size() > MAX_ELEMENTS) { while (map.size() > MAX_ELEMENTS) {
for (Iterator<Map.Entry<String, Integer>> ei = for (Iterator<Map.Entry<String, Integer>> ei =
map.entrySet().iterator(); ei.hasNext();) { map.entrySet().iterator(); ei.hasNext();) {
Map.Entry<String, Integer> e = ei.next(); Map.Entry<String, Integer> e = ei.next();
if (e.getValue() <= minCount) { if (e.getValue() <= minCount) {
......
...@@ -114,7 +114,8 @@ public class SourceCompiler { ...@@ -114,7 +114,8 @@ public class SourceCompiler {
* @param packageAndClassName the class name * @param packageAndClassName the class name
* @return the class * @return the class
*/ */
public Class<?> getClass(String packageAndClassName) throws ClassNotFoundException { public Class<?> getClass(String packageAndClassName)
throws ClassNotFoundException {
Class<?> compiledClass = compiled.get(packageAndClassName); Class<?> compiledClass = compiled.get(packageAndClassName);
if (compiledClass != null) { if (compiledClass != null) {
...@@ -238,7 +239,8 @@ public class SourceCompiler { ...@@ -238,7 +239,8 @@ public class SourceCompiler {
* @param source the (possibly shortened) source code * @param source the (possibly shortened) source code
* @return the full source code * @return the full source code
*/ */
static String getCompleteSourceCode(String packageName, String className, String source) { static String getCompleteSourceCode(String packageName, String className,
String source) {
if (source.startsWith("package ")) { if (source.startsWith("package ")) {
return source; return source;
} }
...@@ -410,15 +412,18 @@ public class SourceCompiler { ...@@ -410,15 +412,18 @@ public class SourceCompiler {
INIT_FAIL_EXCEPTION = initFailException; INIT_FAIL_EXCEPTION = initFailException;
} }
public static Class<?> parseClass(String source, String packageAndClassName) { public static Class<?> parseClass(String source,
String packageAndClassName) {
if (LOADER == null) { if (LOADER == null) {
throw new RuntimeException("Compile fail: no Groovy jar in the classpath", INIT_FAIL_EXCEPTION); throw new RuntimeException(
"Compile fail: no Groovy jar in the classpath", INIT_FAIL_EXCEPTION);
} }
try { try {
Object codeSource = Utils.newInstance("groovy.lang.GroovyCodeSource", Object codeSource = Utils.newInstance("groovy.lang.GroovyCodeSource",
source, packageAndClassName + ".groovy", "UTF-8"); source, packageAndClassName + ".groovy", "UTF-8");
Utils.callMethod(codeSource, "setCachable", false); Utils.callMethod(codeSource, "setCachable", false);
Class<?> clazz = (Class<?>) Utils.callMethod(LOADER, "parseClass", codeSource); Class<?> clazz = (Class<?>) Utils.callMethod(
LOADER, "parseClass", codeSource);
return clazz; return clazz;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -471,7 +476,8 @@ public class SourceCompiler { ...@@ -471,7 +476,8 @@ public class SourceCompiler {
/** /**
* An in-memory class file manager. * An in-memory class file manager.
*/ */
static class ClassFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> { static class ClassFileManager extends
ForwardingJavaFileManager<StandardJavaFileManager> {
/** /**
* The class (only one class is kept). * The class (only one class is kept).
......
...@@ -20,7 +20,7 @@ import org.h2.message.DbException; ...@@ -20,7 +20,7 @@ import org.h2.message.DbException;
*/ */
public class StringUtils { public class StringUtils {
private static SoftReference<String[]> softCache = private static SoftReference<String[]> softCache =
new SoftReference<String[]>(null); new SoftReference<String[]>(null);
private static long softCacheCreated; private static long softCacheCreated;
private static final char[] HEX = "0123456789abcdef".toCharArray(); private static final char[] HEX = "0123456789abcdef".toCharArray();
......
...@@ -111,7 +111,8 @@ public class TempFileDeleter { ...@@ -111,7 +111,8 @@ public class TempFileDeleter {
String f2 = refMap.remove(ref); String f2 = refMap.remove(ref);
if (SysProperties.CHECK) { if (SysProperties.CHECK) {
if (f2 == null || !f2.equals(fileName)) { if (f2 == null || !f2.equals(fileName)) {
DbException.throwInternalError("f2:" + f2 + " " + (f2 == null ? "" : f2) + " f:" + fileName); DbException.throwInternalError("f2:" + f2 +
" " + (f2 == null ? "" : f2) + " f:" + fileName);
} }
} }
} }
......
...@@ -120,7 +120,8 @@ public class ToChar { ...@@ -120,7 +120,8 @@ public class ToChar {
* @param nlsParam the NLS parameter (if any) * @param nlsParam the NLS parameter (if any)
* @return the formatted number * @return the formatted number
*/ */
public static String toChar(BigDecimal number, String format, String nlsParam) { public static String toChar(BigDecimal number, String format,
String nlsParam) {
// short-circuit logic for formats that don't follow common logic below // short-circuit logic for formats that don't follow common logic below
String formatUp = format != null ? format.toUpperCase() : null; String formatUp = format != null ? format.toUpperCase() : null;
...@@ -130,7 +131,8 @@ public class ToChar { ...@@ -130,7 +131,8 @@ public class ToChar {
} else if (formatUp.equals("TME")) { } else if (formatUp.equals("TME")) {
int pow = number.precision() - number.scale() - 1; int pow = number.precision() - number.scale() - 1;
number = number.movePointLeft(pow); number = number.movePointLeft(pow);
return number.toPlainString() + "E" + (pow < 0 ? '-' : '+') + (abs(pow) < 10 ? "0" : "") + abs(pow); return number.toPlainString() + "E" +
(pow < 0 ? '-' : '+') + (abs(pow) < 10 ? "0" : "") + abs(pow);
} else if (formatUp.equals("RN")) { } else if (formatUp.equals("RN")) {
boolean lowercase = format.startsWith("r"); boolean lowercase = format.startsWith("r");
String rn = StringUtils.pad(toRomanNumeral(number.intValue()), 15, " ", false); String rn = StringUtils.pad(toRomanNumeral(number.intValue()), 15, " ", false);
...@@ -256,7 +258,8 @@ public class ToChar { ...@@ -256,7 +258,8 @@ public class ToChar {
String cs = currency.getSymbol(); String cs = currency.getSymbol();
output.insert(0, cs); output.insert(0, cs);
} else { } else {
throw DbException.get(ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat); throw DbException.get(
ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
} }
} }
...@@ -295,12 +298,14 @@ public class ToChar { ...@@ -295,12 +298,14 @@ public class ToChar {
} }
} }
} else { } else {
throw DbException.get(ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat); throw DbException.get(
ErrorCode.INVALID_TO_CHAR_FORMAT, originalFormat);
} }
} }
} }
addSign(output, number.signum(), leadingSign, trailingSign, trailingMinus, angleBrackets, fillMode); addSign(output, number.signum(), leadingSign, trailingSign,
trailingMinus, angleBrackets, fillMode);
if (power != null) { if (power != null) {
output.append('E'); output.append('E');
...@@ -322,8 +327,9 @@ public class ToChar { ...@@ -322,8 +327,9 @@ public class ToChar {
return output.toString(); return output.toString();
} }
private static void addSign(StringBuilder output, int signum, boolean leadingSign, boolean trailingSign, private static void addSign(StringBuilder output, int signum,
boolean trailingMinus, boolean angleBrackets, boolean fillMode) { boolean leadingSign, boolean trailingSign, boolean trailingMinus,
boolean angleBrackets, boolean fillMode) {
if (angleBrackets) { if (angleBrackets) {
if (signum < 0) { if (signum < 0) {
output.insert(0, '<'); output.insert(0, '<');
...@@ -381,8 +387,10 @@ public class ToChar { ...@@ -381,8 +387,10 @@ public class ToChar {
} }
private static String toRomanNumeral(int number) { private static String toRomanNumeral(int number) {
int[] values = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; int[] values = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9,
String[] numerals = new String[] { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; 5, 4, 1 };
String[] numerals = new String[] { "M", "CM", "D", "CD", "C", "XC",
"L", "XL", "X", "IX", "V", "IV", "I" };
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
int value = values[i]; int value = values[i];
...@@ -673,7 +681,8 @@ public class ToChar { ...@@ -673,7 +681,8 @@ public class ToChar {
// Fractional seconds // Fractional seconds
} else if ((cap = containsAt(format, i, "FF1", "FF2", "FF3", "FF4", "FF5", "FF6", "FF7", "FF8", "FF9")) != null) { } else if ((cap = containsAt(format, i, "FF1", "FF2",
"FF3", "FF4", "FF5", "FF6", "FF7", "FF8", "FF9")) != null) {
int x = Integer.parseInt(format.substring(i + 2, i + 3)); int x = Integer.parseInt(format.substring(i + 2, i + 3));
int ff = (int) (cal.get(Calendar.MILLISECOND) * Math.pow(10, x - 3)); int ff = (int) (cal.get(Calendar.MILLISECOND) * Math.pow(10, x - 3));
output.append(ff); output.append(ff);
...@@ -780,8 +789,12 @@ public class ToChar { ...@@ -780,8 +789,12 @@ public class ToChar {
break; break;
} }
} }
} else if (format.charAt(i) == '-' || format.charAt(i) == '/' || format.charAt(i) == ',' } else if (format.charAt(i) == '-'
|| format.charAt(i) == '.' || format.charAt(i) == ';' || format.charAt(i) == ':' || format.charAt(i) == '/'
|| format.charAt(i) == ','
|| format.charAt(i) == '.'
|| format.charAt(i) == ';'
|| format.charAt(i) == ':'
|| format.charAt(i) == ' ') { || format.charAt(i) == ' ') {
output.append(format.charAt(i)); output.append(format.charAt(i));
i += 1; i += 1;
...@@ -818,7 +831,8 @@ public class ToChar { ...@@ -818,7 +831,8 @@ public class ToChar {
* the specified substrings at the specified index, * the specified substrings at the specified index,
* <code>null</code> otherwise * <code>null</code> otherwise
*/ */
private static Capitalization containsAt(String s, int index, String... substrings) { private static Capitalization containsAt(String s, int index,
String... substrings) {
for (String substring : substrings) { for (String substring : substrings) {
if (index + substring.length() <= s.length()) { if (index + substring.length() <= s.length()) {
boolean found = true; boolean found = true;
...@@ -902,9 +916,11 @@ public class ToChar { ...@@ -902,9 +916,11 @@ public class ToChar {
case LOWERCASE: case LOWERCASE:
return s.toLowerCase(); return s.toLowerCase();
case CAPITALIZE: case CAPITALIZE:
return Character.toUpperCase(s.charAt(0)) + (s.length() > 1 ? s.toLowerCase().substring(1) : ""); return Character.toUpperCase(s.charAt(0)) +
(s.length() > 1 ? s.toLowerCase().substring(1) : "");
default: default:
throw new IllegalArgumentException("Unknown capitalization strategy: " + this); throw new IllegalArgumentException(
"Unknown capitalization strategy: " + this);
} }
} }
} }
......
...@@ -51,7 +51,8 @@ public abstract class Tool { ...@@ -51,7 +51,8 @@ public abstract class Tool {
* @param option the unsupported option * @param option the unsupported option
* @return this method never returns normally * @return this method never returns normally
*/ */
protected SQLException showUsageAndThrowUnsupportedOption(String option) throws SQLException { protected SQLException showUsageAndThrowUnsupportedOption(String option)
throws SQLException {
showUsage(); showUsage();
throw throwUnsupportedOption(option); throw throwUnsupportedOption(option);
} }
...@@ -62,8 +63,10 @@ public abstract class Tool { ...@@ -62,8 +63,10 @@ public abstract class Tool {
* @param option the unsupported option * @param option the unsupported option
* @return this method never returns normally * @return this method never returns normally
*/ */
protected SQLException throwUnsupportedOption(String option) throws SQLException { protected SQLException throwUnsupportedOption(String option)
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException(); throws SQLException {
throw DbException.get(
ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException();
} }
/** /**
...@@ -109,7 +112,8 @@ public abstract class Tool { ...@@ -109,7 +112,8 @@ public abstract class Tool {
out.println(resources.get(className)); out.println(resources.get(className));
out.println("Usage: java "+getClass().getName() + " <options>"); out.println("Usage: java "+getClass().getName() + " <options>");
out.println(resources.get(className + ".main")); out.println(resources.get(className + ".main"));
out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html"); out.println("See also http://h2database.com/javadoc/" +
className.replace('.', '/') + ".html");
} }
/** /**
...@@ -125,7 +129,8 @@ public abstract class Tool { ...@@ -125,7 +129,8 @@ public abstract class Tool {
if (arg.equals(option)) { if (arg.equals(option)) {
return true; return true;
} else if (arg.startsWith(option)) { } else if (arg.startsWith(option)) {
throw DbException.getUnsupportedException("expected: " + option + " got: " + arg); throw DbException.getUnsupportedException(
"expected: " + option + " got: " + arg);
} }
return false; return false;
} }
......
...@@ -67,7 +67,7 @@ public class Utils { ...@@ -67,7 +67,7 @@ public class Utils {
/** /**
* In order to manage more than one class loader * In order to manage more than one class loader
*/ */
private static ArrayList<ClassFactory> userClassFactories = private static ArrayList<ClassFactory> userClassFactories =
new ArrayList<ClassFactory>(); new ArrayList<ClassFactory>();
private static String[] allowedClassNamePrefixes; private static String[] allowedClassNamePrefixes;
...@@ -115,9 +115,9 @@ public class Utils { ...@@ -115,9 +115,9 @@ public class Utils {
} }
private static int readInt(byte[] buff, int pos) { private static int readInt(byte[] buff, int pos) {
return (buff[pos++] << 24) + return (buff[pos++] << 24) +
((buff[pos++] & 0xff) << 16) + ((buff[pos++] & 0xff) << 16) +
((buff[pos++] & 0xff) << 8) + ((buff[pos++] & 0xff) << 8) +
(buff[pos] & 0xff); (buff[pos] & 0xff);
} }
...@@ -150,7 +150,8 @@ public class Utils { ...@@ -150,7 +150,8 @@ public class Utils {
* @return the value * @return the value
*/ */
public static long readLong(byte[] buff, int pos) { public static long readLong(byte[] buff, int pos) {
return (((long) readInt(buff, pos)) << 32) + (readInt(buff, pos + 4) & 0xffffffffL); return (((long) readInt(buff, pos)) << 32) +
(readInt(buff, pos + 4) & 0xffffffffL);
} }
/** /**
...@@ -401,7 +402,7 @@ public class Utils { ...@@ -401,7 +402,7 @@ public class Utils {
final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final ClassLoader loader = Thread.currentThread().getContextClassLoader();
is = new ObjectInputStream(in) { is = new ObjectInputStream(in) {
@Override @Override
protected Class<?> resolveClass(ObjectStreamClass desc) protected Class<?> resolveClass(ObjectStreamClass desc)
throws IOException, ClassNotFoundException { throws IOException, ClassNotFoundException {
try { try {
return Class.forName(desc.getName(), true, loader); return Class.forName(desc.getName(), true, loader);
...@@ -520,7 +521,8 @@ public class Utils { ...@@ -520,7 +521,8 @@ public class Utils {
public static <X> void sortTopN(X[] array, int offset, int limit, public static <X> void sortTopN(X[] array, int offset, int limit,
Comparator<? super X> comp) { Comparator<? super X> comp) {
partitionTopN(array, offset, limit, comp); partitionTopN(array, offset, limit, comp);
Arrays.sort(array, offset, (int) Math.min((long) offset + limit, array.length), comp); Arrays.sort(array, offset,
(int) Math.min((long) offset + limit, array.length), comp);
} }
/** /**
...@@ -664,7 +666,7 @@ public class Utils { ...@@ -664,7 +666,7 @@ public class Utils {
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
try { try {
return Class.forName( return Class.forName(
className, true, className, true,
Thread.currentThread().getContextClassLoader()); Thread.currentThread().getContextClassLoader());
} catch (Exception e2) { } catch (Exception e2) {
throw DbException.get( throw DbException.get(
...@@ -775,7 +777,7 @@ public class Utils { ...@@ -775,7 +777,7 @@ public class Utils {
int bestMatch = 0; int bestMatch = 0;
boolean isStatic = instance == null; boolean isStatic = instance == null;
for (Method m : clazz.getMethods()) { for (Method m : clazz.getMethods()) {
if (Modifier.isStatic(m.getModifiers()) == isStatic && if (Modifier.isStatic(m.getModifiers()) == isStatic &&
m.getName().equals(methodName)) { m.getName().equals(methodName)) {
int p = match(m.getParameterTypes(), params); int p = match(m.getParameterTypes(), params);
if (p > bestMatch) { if (p > bestMatch) {
......
...@@ -162,7 +162,7 @@ public class CompareMode { ...@@ -162,7 +162,7 @@ public class CompareMode {
*/ */
public static String getName(Locale l) { public static String getName(Locale l) {
Locale english = Locale.ENGLISH; Locale english = Locale.ENGLISH;
String name = l.getDisplayLanguage(english) + ' ' + String name = l.getDisplayLanguage(english) + ' ' +
l.getDisplayCountry(english) + ' ' + l.getVariant(); l.getDisplayCountry(english) + ' ' + l.getVariant();
name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_')); name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
return name; return name;
...@@ -177,7 +177,7 @@ public class CompareMode { ...@@ -177,7 +177,7 @@ public class CompareMode {
* @return true if they match * @return true if they match
*/ */
static boolean compareLocaleNames(Locale locale, String name) { static boolean compareLocaleNames(Locale locale, String name) {
return name.equalsIgnoreCase(locale.toString()) || return name.equalsIgnoreCase(locale.toString()) ||
name.equalsIgnoreCase(getName(locale)); name.equalsIgnoreCase(getName(locale));
} }
......
...@@ -54,7 +54,7 @@ public class DataType { ...@@ -54,7 +54,7 @@ public class DataType {
*/ */
public static final Class<?> GEOMETRY_CLASS; public static final Class<?> GEOMETRY_CLASS;
private static final String GEOMETRY_CLASS_NAME = private static final String GEOMETRY_CLASS_NAME =
"com.vividsolutions.jts.geom.Geometry"; "com.vividsolutions.jts.geom.Geometry";
/** /**
...@@ -194,7 +194,7 @@ public class DataType { ...@@ -194,7 +194,7 @@ public class DataType {
); );
add(Value.STRING, Types.VARCHAR, "String", add(Value.STRING, Types.VARCHAR, "String",
createString(true), createString(true),
new String[]{"VARCHAR", "VARCHAR2", "NVARCHAR", "NVARCHAR2", new String[]{"VARCHAR", "VARCHAR2", "NVARCHAR", "NVARCHAR2",
"VARCHAR_CASESENSITIVE", "CHARACTER VARYING", "TID"}, "VARCHAR_CASESENSITIVE", "CHARACTER VARYING", "TID"},
// 24 for ValueString, 24 for String // 24 for ValueString, 24 for String
48 48
...@@ -308,7 +308,7 @@ public class DataType { ...@@ -308,7 +308,7 @@ public class DataType {
56 56
); );
add(Value.TIMESTAMP, Types.TIMESTAMP, "Timestamp", add(Value.TIMESTAMP, Types.TIMESTAMP, "Timestamp",
createDate(ValueTimestamp.PRECISION, "TIMESTAMP", createDate(ValueTimestamp.PRECISION, "TIMESTAMP",
ValueTimestamp.DEFAULT_SCALE, ValueTimestamp.DISPLAY_SIZE), ValueTimestamp.DEFAULT_SCALE, ValueTimestamp.DISPLAY_SIZE),
new String[]{"TIMESTAMP", "DATETIME", "SMALLDATETIME"}, new String[]{"TIMESTAMP", "DATETIME", "SMALLDATETIME"},
// 24 for ValueTimestamp, 32 for java.sql.Timestamp // 24 for ValueTimestamp, 32 for java.sql.Timestamp
...@@ -341,14 +341,14 @@ public class DataType { ...@@ -341,14 +341,14 @@ public class DataType {
); );
add(Value.BLOB, Types.BLOB, "Blob", add(Value.BLOB, Types.BLOB, "Blob",
createLob(), createLob(),
new String[]{"BLOB", "TINYBLOB", "MEDIUMBLOB", new String[]{"BLOB", "TINYBLOB", "MEDIUMBLOB",
"LONGBLOB", "IMAGE", "OID"}, "LONGBLOB", "IMAGE", "OID"},
// 80 for ValueLob, 24 for String // 80 for ValueLob, 24 for String
104 104
); );
add(Value.CLOB, Types.CLOB, "Clob", add(Value.CLOB, Types.CLOB, "Clob",
createLob(), createLob(),
new String[]{"CLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT", new String[]{"CLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT",
"LONGTEXT", "NTEXT", "NCLOB"}, "LONGTEXT", "NTEXT", "NCLOB"},
// 80 for ValueLob, 24 for String // 80 for ValueLob, 24 for String
104 104
...@@ -498,97 +498,97 @@ public class DataType { ...@@ -498,97 +498,97 @@ public class DataType {
} }
case Value.BYTES: { case Value.BYTES: {
byte[] buff = rs.getBytes(columnIndex); byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? (Value) ValueNull.INSTANCE : v = buff == null ? (Value) ValueNull.INSTANCE :
ValueBytes.getNoCopy(buff); ValueBytes.getNoCopy(buff);
break; break;
} }
case Value.UUID: { case Value.UUID: {
byte[] buff = rs.getBytes(columnIndex); byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? (Value) ValueNull.INSTANCE : v = buff == null ? (Value) ValueNull.INSTANCE :
ValueUuid.get(buff); ValueUuid.get(buff);
break; break;
} }
case Value.BOOLEAN: { case Value.BOOLEAN: {
boolean value = rs.getBoolean(columnIndex); boolean value = rs.getBoolean(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueBoolean.get(value); ValueBoolean.get(value);
break; break;
} }
case Value.BYTE: { case Value.BYTE: {
byte value = rs.getByte(columnIndex); byte value = rs.getByte(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueByte.get(value); ValueByte.get(value);
break; break;
} }
case Value.DATE: { case Value.DATE: {
Date value = rs.getDate(columnIndex); Date value = rs.getDate(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE : v = value == null ? (Value) ValueNull.INSTANCE :
ValueDate.get(value); ValueDate.get(value);
break; break;
} }
case Value.TIME: { case Value.TIME: {
Time value = rs.getTime(columnIndex); Time value = rs.getTime(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE : v = value == null ? (Value) ValueNull.INSTANCE :
ValueTime.get(value); ValueTime.get(value);
break; break;
} }
case Value.TIMESTAMP: { case Value.TIMESTAMP: {
Timestamp value = rs.getTimestamp(columnIndex); Timestamp value = rs.getTimestamp(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE : v = value == null ? (Value) ValueNull.INSTANCE :
ValueTimestamp.get(value); ValueTimestamp.get(value);
break; break;
} }
case Value.DECIMAL: { case Value.DECIMAL: {
BigDecimal value = rs.getBigDecimal(columnIndex); BigDecimal value = rs.getBigDecimal(columnIndex);
v = value == null ? (Value) ValueNull.INSTANCE : v = value == null ? (Value) ValueNull.INSTANCE :
ValueDecimal.get(value); ValueDecimal.get(value);
break; break;
} }
case Value.DOUBLE: { case Value.DOUBLE: {
double value = rs.getDouble(columnIndex); double value = rs.getDouble(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueDouble.get(value); ValueDouble.get(value);
break; break;
} }
case Value.FLOAT: { case Value.FLOAT: {
float value = rs.getFloat(columnIndex); float value = rs.getFloat(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueFloat.get(value); ValueFloat.get(value);
break; break;
} }
case Value.INT: { case Value.INT: {
int value = rs.getInt(columnIndex); int value = rs.getInt(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueInt.get(value); ValueInt.get(value);
break; break;
} }
case Value.LONG: { case Value.LONG: {
long value = rs.getLong(columnIndex); long value = rs.getLong(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueLong.get(value); ValueLong.get(value);
break; break;
} }
case Value.SHORT: { case Value.SHORT: {
short value = rs.getShort(columnIndex); short value = rs.getShort(columnIndex);
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : v = rs.wasNull() ? (Value) ValueNull.INSTANCE :
ValueShort.get(value); ValueShort.get(value);
break; break;
} }
case Value.STRING_IGNORECASE: { case Value.STRING_IGNORECASE: {
String s = rs.getString(columnIndex); String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE : v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueStringIgnoreCase.get(s); ValueStringIgnoreCase.get(s);
break; break;
} }
case Value.STRING_FIXED: { case Value.STRING_FIXED: {
String s = rs.getString(columnIndex); String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE : v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueStringFixed.get(s); ValueStringFixed.get(s);
break; break;
} }
case Value.STRING: { case Value.STRING: {
String s = rs.getString(columnIndex); String s = rs.getString(columnIndex);
v = (s == null) ? (Value) ValueNull.INSTANCE : v = (s == null) ? (Value) ValueNull.INSTANCE :
ValueString.get(s); ValueString.get(s);
break; break;
} }
...@@ -613,7 +613,7 @@ public class DataType { ...@@ -613,7 +613,7 @@ public class DataType {
Value.BLOB, rs.getBytes(columnIndex)); Value.BLOB, rs.getBytes(columnIndex));
} else { } else {
InputStream in = rs.getBinaryStream(columnIndex); InputStream in = rs.getBinaryStream(columnIndex);
v = (in == null) ? (Value) ValueNull.INSTANCE : v = (in == null) ? (Value) ValueNull.INSTANCE :
session.getDataHandler().getLobStorage().createBlob(in, -1); session.getDataHandler().getLobStorage().createBlob(in, -1);
} }
break; break;
...@@ -621,11 +621,11 @@ public class DataType { ...@@ -621,11 +621,11 @@ public class DataType {
case Value.JAVA_OBJECT: { case Value.JAVA_OBJECT: {
if (SysProperties.serializeJavaObject) { if (SysProperties.serializeJavaObject) {
byte[] buff = rs.getBytes(columnIndex); byte[] buff = rs.getBytes(columnIndex);
v = buff == null ? ValueNull.INSTANCE : v = buff == null ? ValueNull.INSTANCE :
ValueJavaObject.getNoCopy(null, buff, session.getDataHandler()); ValueJavaObject.getNoCopy(null, buff, session.getDataHandler());
} else { } else {
Object o = rs.getObject(columnIndex); Object o = rs.getObject(columnIndex);
v = o == null ? ValueNull.INSTANCE : v = o == null ? ValueNull.INSTANCE :
ValueJavaObject.getNoCopy(o, null, session.getDataHandler()); ValueJavaObject.getNoCopy(o, null, session.getDataHandler());
} }
break; break;
......
...@@ -164,11 +164,11 @@ public abstract class Value { ...@@ -164,11 +164,11 @@ public abstract class Value {
*/ */
public static final int TYPE_COUNT = GEOMETRY + 1; public static final int TYPE_COUNT = GEOMETRY + 1;
private static SoftReference<Value[]> softCache = private static SoftReference<Value[]> softCache =
new SoftReference<Value[]>(null); new SoftReference<Value[]>(null);
private static final BigDecimal MAX_LONG_DECIMAL = private static final BigDecimal MAX_LONG_DECIMAL =
BigDecimal.valueOf(Long.MAX_VALUE); BigDecimal.valueOf(Long.MAX_VALUE);
private static final BigDecimal MIN_LONG_DECIMAL = private static final BigDecimal MIN_LONG_DECIMAL =
BigDecimal.valueOf(Long.MIN_VALUE); BigDecimal.valueOf(Long.MIN_VALUE);
/** /**
...@@ -376,7 +376,7 @@ public abstract class Value { ...@@ -376,7 +376,7 @@ public abstract class Value {
} }
// cacheMiss++; // cacheMiss++;
// cache[cacheCleaner] = null; // cache[cacheCleaner] = null;
// cacheCleaner = (cacheCleaner + 1) & // cacheCleaner = (cacheCleaner + 1) &
// (Constants.OBJECT_CACHE_SIZE - 1); // (Constants.OBJECT_CACHE_SIZE - 1);
cache[index] = v; cache[index] = v;
} }
...@@ -863,7 +863,7 @@ public abstract class Value { ...@@ -863,7 +863,7 @@ public abstract class Value {
return ValueBytes.getNoCopy( return ValueBytes.getNoCopy(
StringUtils.convertHexToBytes(s.trim())); StringUtils.convertHexToBytes(s.trim()));
case JAVA_OBJECT: case JAVA_OBJECT:
return ValueJavaObject.getNoCopy(null, return ValueJavaObject.getNoCopy(null,
StringUtils.convertHexToBytes(s.trim()), getDataHandler()); StringUtils.convertHexToBytes(s.trim()), getDataHandler());
case STRING: case STRING:
return ValueString.get(s); return ValueString.get(s);
...@@ -1010,7 +1010,7 @@ public abstract class Value { ...@@ -1010,7 +1010,7 @@ public abstract class Value {
} }
private static long convertToLong(BigDecimal x) { private static long convertToLong(BigDecimal x) {
if (x.compareTo(MAX_LONG_DECIMAL) > 0 || if (x.compareTo(MAX_LONG_DECIMAL) > 0 ||
x.compareTo(Value.MIN_LONG_DECIMAL) < 0) { x.compareTo(Value.MIN_LONG_DECIMAL) < 0) {
throw DbException.get( throw DbException.get(
ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, x.toString()); ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, x.toString());
......
...@@ -93,8 +93,8 @@ public class ValueDecimal extends Value { ...@@ -93,8 +93,8 @@ public class ValueDecimal extends Value {
if (dec.value.signum() == 0) { if (dec.value.signum() == 0) {
throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL()); throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getSQL());
} }
BigDecimal bd = value.divide(dec.value, BigDecimal bd = value.divide(dec.value,
value.scale() + DIVIDE_SCALE_ADD, value.scale() + DIVIDE_SCALE_ADD,
BigDecimal.ROUND_HALF_DOWN); BigDecimal.ROUND_HALF_DOWN);
if (bd.signum() == 0) { if (bd.signum() == 0) {
bd = BigDecimal.ZERO; bd = BigDecimal.ZERO;
...@@ -254,7 +254,7 @@ public class ValueDecimal extends Value { ...@@ -254,7 +254,7 @@ public class ValueDecimal extends Value {
// value and scale (thus 2.0 is not equal to 2.00 when using equals; // value and scale (thus 2.0 is not equal to 2.00 when using equals;
// however -0.0 and 0.0 are). Can not use compareTo because 2.0 and 2.00 // however -0.0 and 0.0 are). Can not use compareTo because 2.0 and 2.00
// have different hash codes // have different hash codes
return other instanceof ValueDecimal && return other instanceof ValueDecimal &&
value.equals(((ValueDecimal) other).value); value.equals(((ValueDecimal) other).value);
} }
......
...@@ -35,7 +35,7 @@ public class ValueGeometry extends Value { ...@@ -35,7 +35,7 @@ public class ValueGeometry extends Value {
/** /**
* As conversion from/to WKB cost a significant amount of CPU cycles, WKB * As conversion from/to WKB cost a significant amount of CPU cycles, WKB
* are kept in ValueGeometry instance. * are kept in ValueGeometry instance.
* *
* We always calculate the WKB, because not all WKT values can be * We always calculate the WKB, because not all WKT values can be
* represented in WKB, but since we persist it in WKB format, it has to be * represented in WKB, but since we persist it in WKB format, it has to be
* valid in WKB * valid in WKB
...@@ -43,7 +43,7 @@ public class ValueGeometry extends Value { ...@@ -43,7 +43,7 @@ public class ValueGeometry extends Value {
private final byte[] bytes; private final byte[] bytes;
private final int hashCode; private final int hashCode;
/** /**
* The value. Converted from WKB only on request as conversion from/to WKB * The value. Converted from WKB only on request as conversion from/to WKB
* cost a significant amount of CPU cycles. * cost a significant amount of CPU cycles.
...@@ -52,7 +52,7 @@ public class ValueGeometry extends Value { ...@@ -52,7 +52,7 @@ public class ValueGeometry extends Value {
/** /**
* Create a new geometry objects. * Create a new geometry objects.
* *
* @param bytes the bytes (always known) * @param bytes the bytes (always known)
* @param geometry the geometry object (may be null) * @param geometry the geometry object (may be null)
*/ */
...@@ -76,20 +76,20 @@ public class ValueGeometry extends Value { ...@@ -76,20 +76,20 @@ public class ValueGeometry extends Value {
byte[] bytes = convertToWKB(g); byte[] bytes = convertToWKB(g);
return (ValueGeometry) Value.cache(new ValueGeometry(bytes, g)); return (ValueGeometry) Value.cache(new ValueGeometry(bytes, g));
} }
private static byte[] convertToWKB(Geometry g) { private static byte[] convertToWKB(Geometry g) {
boolean includeSRID = g.getSRID() != 0; boolean includeSRID = g.getSRID() != 0;
int dimensionCount = getDimensionCount(g); int dimensionCount = getDimensionCount(g);
WKBWriter writer = new WKBWriter(dimensionCount, includeSRID); WKBWriter writer = new WKBWriter(dimensionCount, includeSRID);
return writer.write(g); return writer.write(g);
} }
private static int getDimensionCount(Geometry geometry) { private static int getDimensionCount(Geometry geometry) {
ZVisitor finder = new ZVisitor(); ZVisitor finder = new ZVisitor();
geometry.apply(finder); geometry.apply(finder);
return finder.isFoundZ() ? 3 : 2; return finder.isFoundZ() ? 3 : 2;
} }
/** /**
* Get or create a geometry value for the given geometry. * Get or create a geometry value for the given geometry.
* *
...@@ -125,7 +125,7 @@ public class ValueGeometry extends Value { ...@@ -125,7 +125,7 @@ public class ValueGeometry extends Value {
} }
return geometry; return geometry;
} }
/** /**
* Test if this geometry envelope intersects with the other geometry * Test if this geometry envelope intersects with the other geometry
* envelope. * envelope.
...@@ -241,7 +241,7 @@ public class ValueGeometry extends Value { ...@@ -241,7 +241,7 @@ public class ValueGeometry extends Value {
public boolean equals(Object other) { public boolean equals(Object other) {
// The JTS library only does half-way support for 3D coordinates, so // The JTS library only does half-way support for 3D coordinates, so
// their equals method only checks the first two coordinates. // their equals method only checks the first two coordinates.
return other instanceof ValueGeometry && return other instanceof ValueGeometry &&
Arrays.equals(getWKB(), ((ValueGeometry) other).getWKB()); Arrays.equals(getWKB(), ((ValueGeometry) other).getWKB());
} }
......
...@@ -19,7 +19,7 @@ import org.h2.util.Utils; ...@@ -19,7 +19,7 @@ import org.h2.util.Utils;
*/ */
public class ValueJavaObject extends ValueBytes { public class ValueJavaObject extends ValueBytes {
private static final ValueJavaObject EMPTY = private static final ValueJavaObject EMPTY =
new ValueJavaObject(Utils.EMPTY_BYTES, null); new ValueJavaObject(Utils.EMPTY_BYTES, null);
private final DataHandler dataHandler; private final DataHandler dataHandler;
......
...@@ -115,7 +115,7 @@ public class ValueLob extends Value { ...@@ -115,7 +115,7 @@ public class ValueLob extends Value {
DbException.throwInternalError("0 LOB"); DbException.throwInternalError("0 LOB");
} }
String table = tableId < 0 ? ".temp" : ".t" + tableId; String table = tableId < 0 ? ".temp" : ".t" + tableId;
return getFileNamePrefix(handler.getDatabasePath(), objectId) + return getFileNamePrefix(handler.getDatabasePath(), objectId) +
table + Constants.SUFFIX_LOB_FILE; table + Constants.SUFFIX_LOB_FILE;
} }
...@@ -204,7 +204,7 @@ public class ValueLob extends Value { ...@@ -204,7 +204,7 @@ public class ValueLob extends Value {
remaining = Integer.MAX_VALUE; remaining = Integer.MAX_VALUE;
} }
int inplace = handler.getMaxLengthInplaceLob(); int inplace = handler.getMaxLengthInplaceLob();
long m = compress ? long m = compress ?
Constants.IO_BUFFER_SIZE_COMPRESS : Constants.IO_BUFFER_SIZE; Constants.IO_BUFFER_SIZE_COMPRESS : Constants.IO_BUFFER_SIZE;
if (m < remaining && m <= inplace) { if (m < remaining && m <= inplace) {
// using "1L" to force long arithmetic // using "1L" to force long arithmetic
...@@ -256,11 +256,11 @@ public class ValueLob extends Value { ...@@ -256,11 +256,11 @@ public class ValueLob extends Value {
objectId /= SysProperties.LOB_FILES_PER_DIRECTORY; objectId /= SysProperties.LOB_FILES_PER_DIRECTORY;
while (objectId > 0) { while (objectId > 0) {
f = objectId % SysProperties.LOB_FILES_PER_DIRECTORY; f = objectId % SysProperties.LOB_FILES_PER_DIRECTORY;
name = SysProperties.FILE_SEPARATOR + f + name = SysProperties.FILE_SEPARATOR + f +
Constants.SUFFIX_LOBS_DIRECTORY + name; Constants.SUFFIX_LOBS_DIRECTORY + name;
objectId /= SysProperties.LOB_FILES_PER_DIRECTORY; objectId /= SysProperties.LOB_FILES_PER_DIRECTORY;
} }
name = FileUtils.toRealPath(path + name = FileUtils.toRealPath(path +
Constants.SUFFIX_LOBS_DIRECTORY + name); Constants.SUFFIX_LOBS_DIRECTORY + name);
return name; return name;
} }
...@@ -268,7 +268,7 @@ public class ValueLob extends Value { ...@@ -268,7 +268,7 @@ public class ValueLob extends Value {
private static int getNewObjectId(DataHandler h) { private static int getNewObjectId(DataHandler h) {
String path = h.getDatabasePath(); String path = h.getDatabasePath();
if ((path != null) && (path.length() == 0)) { if ((path != null) && (path.length() == 0)) {
path = new File(Utils.getProperty("java.io.tmpdir", "."), path = new File(Utils.getProperty("java.io.tmpdir", "."),
SysProperties.PREFIX_TEMP_FILE).getAbsolutePath(); SysProperties.PREFIX_TEMP_FILE).getAbsolutePath();
} }
int newId = 0; int newId = 0;
...@@ -406,7 +406,7 @@ public class ValueLob extends Value { ...@@ -406,7 +406,7 @@ public class ValueLob extends Value {
synchronized (h) { synchronized (h) {
String path = h.getDatabasePath(); String path = h.getDatabasePath();
if ((path != null) && (path.length() == 0)) { if ((path != null) && (path.length() == 0)) {
path = new File(Utils.getProperty("java.io.tmpdir", "."), path = new File(Utils.getProperty("java.io.tmpdir", "."),
SysProperties.PREFIX_TEMP_FILE).getAbsolutePath(); SysProperties.PREFIX_TEMP_FILE).getAbsolutePath();
} }
objectId = getNewObjectId(h); objectId = getNewObjectId(h);
...@@ -568,7 +568,7 @@ public class ValueLob extends Value { ...@@ -568,7 +568,7 @@ public class ValueLob extends Value {
@Override @Override
public String getString() { public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ? int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision; Integer.MAX_VALUE : (int) precision;
try { try {
if (type == Value.CLOB) { if (type == Value.CLOB) {
......
...@@ -204,7 +204,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -204,7 +204,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override @Override
public boolean isLinked() { public boolean isLinked() {
return tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE && return tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE &&
small == null; small == null;
} }
...@@ -231,7 +231,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -231,7 +231,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override @Override
public void unlink(DataHandler database) { public void unlink(DataHandler database) {
if (small == null && if (small == null &&
tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE) { tableId != LobStorageFrontend.TABLE_ID_SESSION_VARIABLE) {
database.getLobStorage().setTable(this, database.getLobStorage().setTable(this,
LobStorageFrontend.TABLE_ID_SESSION_VARIABLE); LobStorageFrontend.TABLE_ID_SESSION_VARIABLE);
...@@ -283,7 +283,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -283,7 +283,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override @Override
public String getString() { public String getString() {
int len = precision > Integer.MAX_VALUE || precision == 0 ? int len = precision > Integer.MAX_VALUE || precision == 0 ?
Integer.MAX_VALUE : (int) precision; Integer.MAX_VALUE : (int) precision;
try { try {
if (type == Value.CLOB) { if (type == Value.CLOB) {
......
...@@ -14,7 +14,7 @@ import org.h2.util.StringUtils; ...@@ -14,7 +14,7 @@ import org.h2.util.StringUtils;
*/ */
public class ValueStringIgnoreCase extends ValueString { public class ValueStringIgnoreCase extends ValueString {
private static final ValueStringIgnoreCase EMPTY = private static final ValueStringIgnoreCase EMPTY =
new ValueStringIgnoreCase(""); new ValueStringIgnoreCase("");
private int hash; private int hash;
......
...@@ -152,7 +152,7 @@ public class ValueTimestamp extends Value { ...@@ -152,7 +152,7 @@ public class ValueTimestamp extends Value {
long millis = DateTimeUtils.getMillis( long millis = DateTimeUtils.getMillis(
tz, year, month, day, hour, minute, (int) second, (int) ms); tz, year, month, day, hour, minute, (int) second, (int) ms);
ms = DateTimeUtils.convertToLocal( ms = DateTimeUtils.convertToLocal(
new Date(millis), new Date(millis),
Calendar.getInstance(TimeZone.getTimeZone("UTC"))); Calendar.getInstance(TimeZone.getTimeZone("UTC")));
long md = DateTimeUtils.MILLIS_PER_DAY; long md = DateTimeUtils.MILLIS_PER_DAY;
long absoluteDay = (ms >= 0 ? ms : ms - md + 1) / md; long absoluteDay = (ms >= 0 ? ms : ms - md + 1) / md;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论