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

Split long lines.

上级 a7b804e6
...@@ -4165,7 +4165,9 @@ public class Parser { ...@@ -4165,7 +4165,9 @@ public class Parser {
private CreateFunctionAlias parseCreateFunctionAlias(boolean force) { private CreateFunctionAlias parseCreateFunctionAlias(boolean force) {
boolean ifNotExists = readIfNoExists(); boolean ifNotExists = readIfNoExists();
String aliasName = readIdentifierWithSchema(); String aliasName = readIdentifierWithSchema();
if (isKeyword(aliasName) || Function.getFunction(database, aliasName) != null || Aggregate.getAggregateType(aliasName) >= 0) { if (isKeyword(aliasName) ||
Function.getFunction(database, aliasName) != null ||
Aggregate.getAggregateType(aliasName) >= 0) {
throw DbException.get(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, aliasName); throw DbException.get(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, aliasName);
} }
CreateFunctionAlias command = new CreateFunctionAlias(session, getSchema()); CreateFunctionAlias command = new CreateFunctionAlias(session, getSchema());
...@@ -4912,7 +4914,9 @@ public class Parser { ...@@ -4912,7 +4914,9 @@ public class Parser {
boolean ifNotExists = readIfNoExists(); boolean ifNotExists = readIfNoExists();
Schema schema = table.getSchema(); Schema schema = table.getSchema();
AlterTableAlterColumn command = new AlterTableAlterColumn(session, schema); AlterTableAlterColumn command = new AlterTableAlterColumn(session, schema);
command.setType(ifNotExists ? CommandInterface.ALTER_TABLE_ADD_COLUMN_IF_NOT_EXISTS : CommandInterface.ALTER_TABLE_ADD_COLUMN); command.setType(ifNotExists ?
CommandInterface.ALTER_TABLE_ADD_COLUMN_IF_NOT_EXISTS :
CommandInterface.ALTER_TABLE_ADD_COLUMN);
command.setTable(table); command.setTable(table);
String columnName = readColumnIdentifier(); String columnName = readColumnIdentifier();
Column column = parseColumnForTable(columnName, true); Column column = parseColumnForTable(columnName, true);
......
...@@ -74,7 +74,8 @@ public class CreateLinkedTable extends SchemaCommand { ...@@ -74,7 +74,8 @@ public class CreateLinkedTable extends SchemaCommand {
tableName); tableName);
} }
int id = getObjectId(); int id = getObjectId();
TableLink table = getSchema().createTableLink(id, tableName, driver, url, user, password, originalSchema, originalTable, emitUpdates, force); TableLink table = getSchema().createTableLink(id, tableName, driver, url,
user, password, originalSchema, originalTable, emitUpdates, force);
table.setTemporary(temporary); table.setTemporary(temporary);
table.setGlobalTemporary(globalTemporary); table.setGlobalTemporary(globalTemporary);
table.setComment(comment); table.setComment(comment);
......
...@@ -199,12 +199,14 @@ public class CreateTable extends SchemaCommand { ...@@ -199,12 +199,14 @@ public class CreateTable extends SchemaCommand {
long precision = expr.getPrecision(); long precision = expr.getPrecision();
int displaySize = expr.getDisplaySize(); int displaySize = expr.getDisplaySize();
DataType dt = DataType.getDataType(type); DataType dt = DataType.getDataType(type);
if (precision > 0 && (dt.defaultPrecision == 0 || (dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) { if (precision > 0 && (dt.defaultPrecision == 0 ||
(dt.defaultPrecision > precision && dt.defaultPrecision < Byte.MAX_VALUE))) {
// dont' set precision to MAX_VALUE if this is the default // dont' set precision to MAX_VALUE if this is the default
precision = dt.defaultPrecision; precision = dt.defaultPrecision;
} }
int scale = expr.getScale(); int scale = expr.getScale();
if (scale > 0 && (dt.defaultScale == 0 || (dt.defaultScale > scale && dt.defaultScale < precision))) { if (scale > 0 && (dt.defaultScale == 0 ||
(dt.defaultScale > scale && dt.defaultScale < precision))) {
scale = dt.defaultScale; scale = dt.defaultScale;
} }
if (scale > precision) { if (scale > precision) {
......
...@@ -33,7 +33,9 @@ public class DropTable extends SchemaCommand { ...@@ -33,7 +33,9 @@ public class DropTable extends SchemaCommand {
public DropTable(Session session, Schema schema) { public DropTable(Session session, Schema schema) {
super(session, schema); super(session, schema);
dropAction = session.getDatabase().getSettings().dropRestrict ? ConstraintReferential.RESTRICT : ConstraintReferential.CASCADE; dropAction = session.getDatabase().getSettings().dropRestrict ?
ConstraintReferential.RESTRICT :
ConstraintReferential.CASCADE;
} }
/** /**
......
...@@ -29,7 +29,9 @@ public class DropView extends SchemaCommand { ...@@ -29,7 +29,9 @@ public class DropView extends SchemaCommand {
public DropView(Session session, Schema schema) { public DropView(Session session, Schema schema) {
super(session, schema); super(session, schema);
dropAction = session.getDatabase().getSettings().dropRestrict ? ConstraintReferential.RESTRICT : ConstraintReferential.CASCADE; dropAction = session.getDatabase().getSettings().dropRestrict ?
ConstraintReferential.RESTRICT :
ConstraintReferential.CASCADE;
} }
public void setIfExists(boolean b) { public void setIfExists(boolean b) {
......
...@@ -317,7 +317,10 @@ public abstract class Query extends Prepared { ...@@ -317,7 +317,10 @@ public abstract class Query extends Prepared {
* @param visible the number of visible columns in the select list * @param visible the number of visible columns in the select list
* @param mustBeInResult all order by expressions must be in the select list * @param mustBeInResult all order by expressions must be in the select list
*/ */
static void initOrder(ArrayList<Expression> expressions, ArrayList<String> expressionSQL, ArrayList<SelectOrderBy> orderList, int visible, static void initOrder(ArrayList<Expression> expressions,
ArrayList<String> expressionSQL,
ArrayList<SelectOrderBy> orderList,
int visible,
boolean mustBeInResult) { boolean mustBeInResult) {
for (SelectOrderBy o : orderList) { for (SelectOrderBy o : orderList) {
Expression e = o.expression; Expression e = o.expression;
......
...@@ -345,10 +345,14 @@ public class ScriptCommand extends ScriptBase { ...@@ -345,10 +345,14 @@ public class ScriptCommand extends ScriptBase {
private int writeLobStream(Value v) throws IOException { private int writeLobStream(Value v) throws IOException {
if (!tempLobTableCreated) { if (!tempLobTableCreated) {
add("CREATE TABLE IF NOT EXISTS SYSTEM_LOB_STREAM(ID INT NOT NULL, PART INT NOT NULL, CDATA VARCHAR, BDATA BINARY)", true); add("CREATE TABLE IF NOT EXISTS SYSTEM_LOB_STREAM" +
add("CREATE PRIMARY KEY SYSTEM_LOB_STREAM_PRIMARY_KEY ON SYSTEM_LOB_STREAM(ID, PART)", true); "(ID INT NOT NULL, PART INT NOT NULL, CDATA VARCHAR, BDATA BINARY)", true);
add("CREATE ALIAS IF NOT EXISTS SYSTEM_COMBINE_CLOB FOR \"" + this.getClass().getName() + ".combineClob\"", true); add("CREATE PRIMARY KEY SYSTEM_LOB_STREAM_PRIMARY_KEY " +
add("CREATE ALIAS IF NOT EXISTS SYSTEM_COMBINE_BLOB FOR \"" + this.getClass().getName() + ".combineBlob\"", true); "ON SYSTEM_LOB_STREAM(ID, PART)", true);
add("CREATE ALIAS IF NOT EXISTS " +
"SYSTEM_COMBINE_CLOB FOR \"" + this.getClass().getName() + ".combineClob\"", true);
add("CREATE ALIAS IF NOT EXISTS " +
"SYSTEM_COMBINE_BLOB FOR \"" + this.getClass().getName() + ".combineBlob\"", true);
tempLobTableCreated = true; tempLobTableCreated = true;
} }
int id = nextLobId++; int id = nextLobId++;
......
...@@ -816,7 +816,9 @@ public class Select extends Query { ...@@ -816,7 +816,9 @@ public class Select extends Query {
} }
} }
cost = preparePlan(); cost = preparePlan();
if (distinct && session.getDatabase().getSettings().optimizeDistinct && !isGroupQuery && filters.size() == 1 && expressions.size() == 1 && condition == null) { if (distinct && session.getDatabase().getSettings().optimizeDistinct &&
!isGroupQuery && filters.size() == 1 &&
expressions.size() == 1 && condition == null) {
Expression expr = expressions.get(0); Expression expr = expressions.get(0);
expr = expr.getNonAliasExpression(); expr = expr.getNonAliasExpression();
if (expr instanceof ExpressionColumn) { if (expr instanceof ExpressionColumn) {
...@@ -828,7 +830,8 @@ public class Select extends Query { ...@@ -828,7 +830,8 @@ public class Select extends Query {
boolean ascending = columnIndex.getIndexColumns()[0].sortType == SortOrder.ASCENDING; boolean ascending = columnIndex.getIndexColumns()[0].sortType == SortOrder.ASCENDING;
Index current = topTableFilter.getIndex(); Index current = topTableFilter.getIndex();
// if another index is faster // if another index is faster
if (columnIndex.canFindNext() && ascending && (current == null || current.getIndexType().isScan() || columnIndex == current)) { if (columnIndex.canFindNext() && ascending &&
(current == null || current.getIndexType().isScan() || columnIndex == current)) {
IndexType type = columnIndex.getIndexType(); IndexType type = columnIndex.getIndexType();
// hash indexes don't work, and unique single column indexes don't work // hash indexes don't work, and unique single column indexes don't work
if (!type.isHash() && (!type.isUnique() || columnIndex.getColumns().length > 1)) { if (!type.isHash() && (!type.isUnique() || columnIndex.getColumns().length > 1)) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
package org.h2.constant; package org.h2.constant;
import java.util.HashMap; import java.util.HashMap;
import org.h2.engine.Constants;
import org.h2.engine.SettingsBase; import org.h2.engine.SettingsBase;
/** /**
...@@ -48,7 +47,7 @@ public class DbSettings extends SettingsBase { ...@@ -48,7 +47,7 @@ public class DbSettings extends SettingsBase {
* starting the database. It is not run on local temporary tables, and * starting the database. It is not run on local temporary tables, and
* tables that have a trigger on SELECT. * tables that have a trigger on SELECT.
*/ */
public final int analyzeAuto = get("ANALYZE_AUTO", Constants.VERSION_MINOR >= 3 ? 2000 : 0); public final int analyzeAuto = get("ANALYZE_AUTO", 2000);
/** /**
* Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br /> * Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
...@@ -101,7 +100,7 @@ public class DbSettings extends SettingsBase { ...@@ -101,7 +100,7 @@ public class DbSettings extends SettingsBase {
* with older versions of H2 the default action is currently CASCADE. This will * with older versions of H2 the default action is currently CASCADE. This will
* change in a future version of H2. * change in a future version of H2.
*/ */
public final boolean dropRestrict = get("DROP_RESTRICT", Constants.VERSION_MINOR >= 3); public final boolean dropRestrict = get("DROP_RESTRICT", true);
/** /**
* Database setting <code>EARLY_FILTER</code> (default: false).<br /> * Database setting <code>EARLY_FILTER</code> (default: false).<br />
...@@ -125,7 +124,7 @@ public class DbSettings extends SettingsBase { ...@@ -125,7 +124,7 @@ public class DbSettings extends SettingsBase {
* will always include the schema name in the CREATE ALIAS statement. * will always include the schema name in the CREATE ALIAS statement.
* This is not backward compatible with H2 versions 1.2.134 and older. * This is not backward compatible with H2 versions 1.2.134 and older.
*/ */
public final boolean functionsInSchema = get("FUNCTIONS_IN_SCHEMA", Constants.VERSION_MINOR >= 3); public final boolean functionsInSchema = get("FUNCTIONS_IN_SCHEMA", true);
/** /**
* Database setting <code>LARGE_RESULT_BUFFER_SIZE</code> (default: 4096).<br /> * Database setting <code>LARGE_RESULT_BUFFER_SIZE</code> (default: 4096).<br />
...@@ -138,7 +137,7 @@ public class DbSettings extends SettingsBase { ...@@ -138,7 +137,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>LARGE_TRANSACTIONS</code> (default: true).<br /> * Database setting <code>LARGE_TRANSACTIONS</code> (default: true).<br />
* Support very large transactions * Support very large transactions
*/ */
public final boolean largeTransactions = get("LARGE_TRANSACTIONS", Constants.VERSION_MINOR >= 3); public final boolean largeTransactions = get("LARGE_TRANSACTIONS", true);
/** /**
* Database setting <code>MAX_COMPACT_COUNT</code> * Database setting <code>MAX_COMPACT_COUNT</code>
...@@ -160,7 +159,7 @@ public class DbSettings extends SettingsBase { ...@@ -160,7 +159,7 @@ public class DbSettings extends SettingsBase {
* more than this number of rows are in a result set, a temporary table is * more than this number of rows are in a result set, a temporary table is
* used. * used.
*/ */
public final int maxMemoryRowsDistinct = get("MAX_MEMORY_ROWS_DISTINCT", Constants.VERSION_MINOR >= 3 ? 10000 : Integer.MAX_VALUE); public final int maxMemoryRowsDistinct = get("MAX_MEMORY_ROWS_DISTINCT", 10000);
/** /**
* Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br /> * Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br />
...@@ -174,7 +173,7 @@ public class DbSettings extends SettingsBase { ...@@ -174,7 +173,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>NESTED_JOINS</code> (default: true).<br /> * Database setting <code>NESTED_JOINS</code> (default: true).<br />
* Whether nested joins should be supported. * Whether nested joins should be supported.
*/ */
public final boolean nestedJoins = get("NESTED_JOINS", Constants.VERSION_MINOR >= 3); public final boolean nestedJoins = get("NESTED_JOINS", true);
/** /**
* Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br /> * Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br />
...@@ -203,7 +202,7 @@ public class DbSettings extends SettingsBase { ...@@ -203,7 +202,7 @@ public class DbSettings extends SettingsBase {
* Insert into table from query directly bypassing temporary disk storage. * Insert into table from query directly bypassing temporary disk storage.
* This also applies to create table as select. * This also applies to create table as select.
*/ */
public final boolean optimizeInsertFromSelect = get("OPTIMIZE_INSERT_FROM_SELECT", Constants.VERSION_MINOR >= 3); public final boolean optimizeInsertFromSelect = get("OPTIMIZE_INSERT_FROM_SELECT", true);
/** /**
* Database setting <code>OPTIMIZE_IN_LIST</code> (default: true).<br /> * Database setting <code>OPTIMIZE_IN_LIST</code> (default: true).<br />
...@@ -217,7 +216,7 @@ public class DbSettings extends SettingsBase { ...@@ -217,7 +216,7 @@ public class DbSettings extends SettingsBase {
* Optimize IN(SELECT ...) comparisons. This includes * Optimize IN(SELECT ...) comparisons. This includes
* optimization for SELECT, DELETE, and UPDATE. * optimization for SELECT, DELETE, and UPDATE.
*/ */
public final boolean optimizeInSelect = get("OPTIMIZE_IN_SELECT", Constants.VERSION_MINOR >= 3); public final boolean optimizeInSelect = get("OPTIMIZE_IN_SELECT", true);
/** /**
* Database setting <code>OPTIMIZE_IS_NULL</code> (default: false).<br /> * Database setting <code>OPTIMIZE_IS_NULL</code> (default: false).<br />
...@@ -229,7 +228,7 @@ public class DbSettings extends SettingsBase { ...@@ -229,7 +228,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>OPTIMIZE_OR</code> (default: true).<br /> * Database setting <code>OPTIMIZE_OR</code> (default: true).<br />
* Convert (C=? OR C=?) to (C IN(?, ?)). * Convert (C=? OR C=?) to (C IN(?, ?)).
*/ */
public final boolean optimizeOr = get("OPTIMIZE_OR", Constants.VERSION_MINOR >= 3); public final boolean optimizeOr = get("OPTIMIZE_OR", true);
/** /**
* Database setting <code>OPTIMIZE_TWO_EQUALS</code> (default: true).<br /> * Database setting <code>OPTIMIZE_TWO_EQUALS</code> (default: true).<br />
...@@ -273,7 +272,7 @@ public class DbSettings extends SettingsBase { ...@@ -273,7 +272,7 @@ public class DbSettings extends SettingsBase {
* SELECT statements are cached (excluding UNION and FOR UPDATE statements). * SELECT statements are cached (excluding UNION and FOR UPDATE statements).
* This works for both statements and prepared statement. * This works for both statements and prepared statement.
*/ */
public final int queryCacheSize = get("QUERY_CACHE_SIZE", Constants.VERSION_MINOR >= 3 ? 8 : 0); public final int queryCacheSize = get("QUERY_CACHE_SIZE", 8);
/** /**
* Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br /> * Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br />
...@@ -294,7 +293,7 @@ public class DbSettings extends SettingsBase { ...@@ -294,7 +293,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>ROWID</code> (default: true).<br /> * Database setting <code>ROWID</code> (default: true).<br />
* If set, each table has a pseudo-column _ROWID_. * If set, each table has a pseudo-column _ROWID_.
*/ */
public final boolean rowId = get("ROWID", Constants.VERSION_MINOR >= 3); public final boolean rowId = get("ROWID", true);
/** /**
* Database setting <code>SELECT_FOR_UPDATE_MVCC</code> * Database setting <code>SELECT_FOR_UPDATE_MVCC</code>
...@@ -302,7 +301,7 @@ public class DbSettings extends SettingsBase { ...@@ -302,7 +301,7 @@ public class DbSettings extends SettingsBase {
* If set, SELECT .. FOR UPDATE queries lock only the selected rows when * If set, SELECT .. FOR UPDATE queries lock only the selected rows when
* using MVCC. * using MVCC.
*/ */
public final boolean selectForUpdateMvcc = get("SELECT_FOR_UPDATE_MVCC", Constants.VERSION_MINOR >= 3); public final boolean selectForUpdateMvcc = get("SELECT_FOR_UPDATE_MVCC", true);
/** /**
* Database setting <code>SHARE_LINKED_CONNECTIONS</code> * Database setting <code>SHARE_LINKED_CONNECTIONS</code>
......
...@@ -520,7 +520,11 @@ public class Database implements DataHandler { ...@@ -520,7 +520,11 @@ public class Database implements DataHandler {
trace = traceSystem.getTrace(Trace.DATABASE); trace = traceSystem.getTrace(Trace.DATABASE);
trace.info("opening {0} (build {1})", databaseName, Constants.BUILD_ID); trace.info("opening {0} (build {1})", databaseName, Constants.BUILD_ID);
if (autoServerMode) { if (autoServerMode) {
if (readOnly || fileLockMethod == FileLock.LOCK_NO || fileLockMethod == FileLock.LOCK_SERIALIZED || fileLockMethod == FileLock.LOCK_FS || !persistent) { if (readOnly ||
fileLockMethod == FileLock.LOCK_NO ||
fileLockMethod == FileLock.LOCK_SERIALIZED ||
fileLockMethod == FileLock.LOCK_FS ||
!persistent) {
throw DbException.getUnsupportedException("autoServerMode && (readOnly || fileLockMethod == NO" + throw DbException.getUnsupportedException("autoServerMode && (readOnly || fileLockMethod == NO" +
" || fileLockMethod == SERIALIZED || inMemory)"); " || fileLockMethod == SERIALIZED || inMemory)");
} }
......
...@@ -245,7 +245,8 @@ public class FunctionAlias extends SchemaObjectBase { ...@@ -245,7 +245,8 @@ public class FunctionAlias extends SchemaObjectBase {
return m; return m;
} }
} }
throw DbException.get(ErrorCode.METHOD_NOT_FOUND_1, methodName + " (" + className + ", parameter count: " + parameterCount + ")"); throw DbException.get(ErrorCode.METHOD_NOT_FOUND_1,
methodName + " (" + className + ", parameter count: " + parameterCount + ")");
} }
public String getJavaClassName() { public String getJavaClassName() {
......
...@@ -48,11 +48,13 @@ public class CompareLike extends Condition { ...@@ -48,11 +48,13 @@ public class CompareLike extends Condition {
private boolean fastCompare; private boolean fastCompare;
private boolean invalidPattern; private boolean invalidPattern;
public CompareLike(Database db, Expression left, Expression right, Expression escape, boolean regexp) { public CompareLike(Database db, Expression left, Expression right,
Expression escape, boolean regexp) {
this(db.getCompareMode(), db.getSettings().defaultEscape, left, right, escape, regexp); this(db.getCompareMode(), db.getSettings().defaultEscape, left, right, escape, regexp);
} }
public CompareLike(CompareMode compareMode, String defaultEscape, Expression left, Expression right, Expression escape, boolean regexp) { public CompareLike(CompareMode compareMode, String defaultEscape,
Expression left, Expression right, Expression escape, boolean regexp) {
this.compareMode = compareMode; this.compareMode = compareMode;
this.defaultEscape = defaultEscape; this.defaultEscape = defaultEscape;
this.regexp = regexp; this.regexp = regexp;
......
...@@ -109,7 +109,12 @@ public class ExpressionVisitor { ...@@ -109,7 +109,12 @@ public class ExpressionVisitor {
private final long[] maxDataModificationId; private final long[] maxDataModificationId;
private final ColumnResolver resolver; private final ColumnResolver resolver;
private ExpressionVisitor(int type, int queryLevel, HashSet<DbObject> dependencies, HashSet<Column> columns, Table table, ColumnResolver resolver, long[] maxDataModificationId) { private ExpressionVisitor(int type,
int queryLevel,
HashSet<DbObject> dependencies,
HashSet<Column> columns,
Table table, ColumnResolver resolver,
long[] maxDataModificationId) {
this.type = type; this.type = type;
this.queryLevel = queryLevel; this.queryLevel = queryLevel;
this.dependencies = dependencies; this.dependencies = dependencies;
......
...@@ -1994,7 +1994,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -1994,7 +1994,8 @@ public class Function extends Expression implements FunctionCall {
return (ValueResultSet) getValueWithArgs(session, argList); return (ValueResultSet) getValueWithArgs(session, argList);
} }
private static void setCsvDelimiterEscape(Csv csv, String fieldSeparator, String fieldDelimiter, String escapeCharacter) { private static void setCsvDelimiterEscape(Csv csv, String fieldSeparator,
String fieldDelimiter, String escapeCharacter) {
if (fieldSeparator != null) { if (fieldSeparator != null) {
csv.setFieldSeparatorWrite(fieldSeparator); csv.setFieldSeparatorWrite(fieldSeparator);
if (fieldSeparator.length() > 0) { if (fieldSeparator.length() > 0) {
......
...@@ -563,7 +563,8 @@ public class FullText { ...@@ -563,7 +563,8 @@ public class FullText {
* @param data whether the raw data should be returned * @param data whether the raw data should be returned
* @return the result set * @return the result set
*/ */
protected static ResultSet search(Connection conn, String text, int limit, int offset, boolean data) throws SQLException { protected static ResultSet search(Connection conn, String text, int limit,
int offset, boolean data) throws SQLException {
SimpleResultSet result = createResultSet(data); SimpleResultSet result = createResultSet(data);
if (conn.getMetaData().getURL().startsWith("jdbc:columnlist:")) { if (conn.getMetaData().getURL().startsWith("jdbc:columnlist:")) {
// this is just to query the result set columns // this is just to query the result set columns
...@@ -722,7 +723,8 @@ public class FullText { ...@@ -722,7 +723,8 @@ public class FullText {
createOrDropTrigger(conn, schema, table, true); createOrDropTrigger(conn, schema, table, true);
} }
private static void createOrDropTrigger(Connection conn, String schema, String table, boolean create) throws SQLException { private static void createOrDropTrigger(Connection conn,
String schema, String table, boolean create) throws SQLException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String trigger = StringUtils.quoteIdentifier(schema) + "." String trigger = StringUtils.quoteIdentifier(schema) + "."
+ StringUtils.quoteIdentifier(TRIGGER_PREFIX + table); + StringUtils.quoteIdentifier(TRIGGER_PREFIX + table);
......
...@@ -372,7 +372,8 @@ public class FullTextLucene extends FullText { ...@@ -372,7 +372,8 @@ public class FullTextLucene extends FullText {
* @param data whether the raw data should be returned * @param data whether the raw data should be returned
* @return the result set * @return the result set
*/ */
protected static ResultSet search(Connection conn, String text, int limit, int offset, boolean data) throws SQLException { protected static ResultSet search(Connection conn, String text,
int limit, int offset, boolean data) throws SQLException {
SimpleResultSet result = createResultSet(data); SimpleResultSet result = createResultSet(data);
if (conn.getMetaData().getURL().startsWith("jdbc:columnlist:")) { if (conn.getMetaData().getURL().startsWith("jdbc:columnlist:")) {
// this is just to query the result set columns // this is just to query the result set columns
......
...@@ -49,7 +49,8 @@ public class FullTextSettings { ...@@ -49,7 +49,8 @@ public class FullTextSettings {
/** /**
* The prepared statement cache. * The prepared statement cache.
*/ */
protected SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>> cache = new SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>>(); protected SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>> cache =
new SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>>();
/** /**
* The whitespace characters. * The whitespace characters.
......
...@@ -49,7 +49,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -49,7 +49,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
* not yet known * not yet known
* @param newIndexType the index type * @param newIndexType the index type
*/ */
protected void initBaseIndex(Table newTable, int id, String name, IndexColumn[] newIndexColumns, IndexType newIndexType) { protected void initBaseIndex(Table newTable, int id, String name,
IndexColumn[] newIndexColumns, IndexType newIndexType) {
initSchemaObjectBase(newTable.getSchema(), id, name, Trace.INDEX); initSchemaObjectBase(newTable.getSchema(), id, name, Trace.INDEX);
this.indexType = newIndexType; this.indexType = newIndexType;
this.table = newTable; this.table = newTable;
......
...@@ -54,7 +54,8 @@ public class PageDataIndex extends PageIndex { ...@@ -54,7 +54,8 @@ public class PageDataIndex extends PageIndex {
private boolean multiVersion; private boolean multiVersion;
public PageDataIndex(RegularTable table, int id, IndexColumn[] columns, IndexType indexType, boolean create, Session session) { public PageDataIndex(RegularTable table, int id, IndexColumn[] columns,
IndexType indexType, boolean create, Session session) {
initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType); initBaseIndex(table, id, table.getName() + "_DATA", columns, indexType);
this.multiVersion = database.isMultiVersion(); this.multiVersion = database.isMultiVersion();
......
...@@ -252,7 +252,8 @@ public class PageDataLeaf extends PageData { ...@@ -252,7 +252,8 @@ public class PageDataLeaf extends PageData {
size = pageSize - PageDataOverflow.START_MORE; size = pageSize - PageDataOverflow.START_MORE;
next = index.getPageStore().allocatePage(); next = index.getPageStore().allocatePage();
} }
PageDataOverflow overflow = PageDataOverflow.create(index.getPageStore(), page, type, previous, next, all, dataOffset, size); PageDataOverflow overflow = PageDataOverflow.create(index.getPageStore(),
page, type, previous, next, all, dataOffset, size);
index.getPageStore().update(overflow); index.getPageStore().update(overflow);
dataOffset += size; dataOffset += size;
remaining -= size; remaining -= size;
...@@ -407,7 +408,8 @@ public class PageDataLeaf extends PageData { ...@@ -407,7 +408,8 @@ public class PageDataLeaf extends PageData {
boolean remove(long key) { boolean remove(long key) {
int i = find(key); int i = find(key);
if (keys == null || keys[i] != key) { if (keys == null || keys[i] != key) {
throw DbException.get(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1, index.getSQL() + ": " + key + " " + (keys == null ? -1 : keys[i])); throw DbException.get(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1,
index.getSQL() + ": " + key + " " + (keys == null ? -1 : keys[i]));
} }
index.getPageStore().logUndo(this, data); index.getPageStore().logUndo(this, data);
if (entryCount == 1) { if (entryCount == 1) {
......
...@@ -280,7 +280,8 @@ public class PageDataNode extends PageData { ...@@ -280,7 +280,8 @@ public class PageDataNode extends PageData {
throw DbException.throwInternalError("Page it its own child: " + getPos()); throw DbException.throwInternalError("Page it its own child: " + getPos());
} }
count += page.getRowCount(); count += page.getRowCount();
index.getDatabase().setProgress(DatabaseEventListener.STATE_SCAN_FILE, index.getTable() + "." + index.getName(), count, Integer.MAX_VALUE); index.getDatabase().setProgress(DatabaseEventListener.STATE_SCAN_FILE,
index.getTable() + "." + index.getName(), count, Integer.MAX_VALUE);
} }
rowCount = count; rowCount = count;
} }
...@@ -363,7 +364,8 @@ public class PageDataNode extends PageData { ...@@ -363,7 +364,8 @@ public class PageDataNode extends PageData {
} }
public String toString() { public String toString() {
return "page[" + getPos() + "] data node table:" + index.getId() + " entries:" + entryCount + " " + Arrays.toString(childPageIds); return "page[" + getPos() + "] data node table:" + index.getId() +
" entries:" + entryCount + " " + Arrays.toString(childPageIds);
} }
public void moveTo(Session session, int newPos) { public void moveTo(Session session, int newPos) {
......
...@@ -105,7 +105,9 @@ public class PageDataOverflow extends Page { ...@@ -105,7 +105,9 @@ public class PageDataOverflow extends Page {
* @param size the number of bytes * @param size the number of bytes
* @return the page * @return the page
*/ */
static PageDataOverflow create(PageStore store, int page, int type, int parentPageId, int next, Data all, int offset, int size) { static PageDataOverflow create(PageStore store, int page,
int type, int parentPageId, int next,
Data all, int offset, int size) {
Data data = store.createData(); Data data = store.createData();
PageDataOverflow p = new PageDataOverflow(store, page, data); PageDataOverflow p = new PageDataOverflow(store, page, data);
store.logUndo(p, null); store.logUndo(p, null);
......
...@@ -22,7 +22,8 @@ public class PageDelegateIndex extends PageIndex { ...@@ -22,7 +22,8 @@ public class PageDelegateIndex extends PageIndex {
private final PageDataIndex mainIndex; private final PageDataIndex mainIndex;
public PageDelegateIndex(RegularTable table, int id, String name, IndexType indexType, PageDataIndex mainIndex, boolean create, Session session) { public PageDelegateIndex(RegularTable table, int id, String name,
IndexType indexType, PageDataIndex mainIndex, boolean create, Session session) {
IndexColumn[] cols = IndexColumn.wrap(new Column[] { table.getColumn(mainIndex.getMainIndexColumn())}); IndexColumn[] cols = IndexColumn.wrap(new Column[] { table.getColumn(mainIndex.getMainIndexColumn())});
this.initBaseIndex(table, id, name, cols, indexType); this.initBaseIndex(table, id, name, cols, indexType);
this.mainIndex = mainIndex; this.mainIndex = mainIndex;
......
...@@ -36,7 +36,8 @@ public class ViewIndex extends BaseIndex { ...@@ -36,7 +36,8 @@ public class ViewIndex extends BaseIndex {
private final TableView view; private final TableView view;
private final String querySQL; private final String querySQL;
private final ArrayList<Parameter> originalParameters; private final ArrayList<Parameter> originalParameters;
private final SmallLRUCache<IntArray, CostElement> costCache = SmallLRUCache.newInstance(Constants.VIEW_INDEX_CACHE_SIZE); private final SmallLRUCache<IntArray, CostElement> costCache =
SmallLRUCache.newInstance(Constants.VIEW_INDEX_CACHE_SIZE);
private boolean recursive; private boolean recursive;
private int[] indexMasks; private int[] indexMasks;
private String planSQL; private String planSQL;
......
...@@ -209,7 +209,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -209,7 +209,8 @@ public class JdbcConnection extends TraceObject implements Connection {
try { try {
int id = getNextId(TraceObject.STATEMENT); int id = getNextId(TraceObject.STATEMENT);
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement(" + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("Statement", TraceObject.STATEMENT, id,
"createStatement(" + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkTypeConcurrency(resultSetType, resultSetConcurrency); checkTypeConcurrency(resultSetType, resultSetConcurrency);
checkClosed(); checkClosed();
...@@ -263,7 +264,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -263,7 +264,8 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
checkClosed(); checkClosed();
sql = translateSQL(sql); sql = translateSQL(sql);
return new JdbcPreparedStatement(this, sql, id, ResultSet.TYPE_FORWARD_ONLY, Constants.DEFAULT_RESULT_SET_CONCURRENCY, false); return new JdbcPreparedStatement(this, sql, id,
ResultSet.TYPE_FORWARD_ONLY, Constants.DEFAULT_RESULT_SET_CONCURRENCY, false);
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
} }
...@@ -284,7 +286,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -284,7 +286,8 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
checkClosed(); checkClosed();
sql = translateSQL(sql); sql = translateSQL(sql);
return new JdbcPreparedStatement(this, sql, id, ResultSet.TYPE_FORWARD_ONLY, Constants.DEFAULT_RESULT_SET_CONCURRENCY, true); return new JdbcPreparedStatement(this, sql, id,
ResultSet.TYPE_FORWARD_ONLY, Constants.DEFAULT_RESULT_SET_CONCURRENCY, true);
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
} }
...@@ -623,7 +626,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -623,7 +626,8 @@ public class JdbcConnection extends TraceObject implements Connection {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id,
"prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkTypeConcurrency(resultSetType, resultSetConcurrency); checkTypeConcurrency(resultSetType, resultSetConcurrency);
checkClosed(); checkClosed();
...@@ -865,7 +869,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -865,7 +869,8 @@ public class JdbcConnection extends TraceObject implements Connection {
try { try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT); int id = getNextId(TraceObject.CALLABLE_STATEMENT);
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id,
"prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkTypeConcurrency(resultSetType, resultSetConcurrency); checkTypeConcurrency(resultSetType, resultSetConcurrency);
checkClosed(); checkClosed();
...@@ -1006,7 +1011,8 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1006,7 +1011,8 @@ public class JdbcConnection extends TraceObject implements Connection {
* @throws SQLException if the connection is closed or the result set type, * @throws SQLException if the connection is closed or the result set type,
* concurrency, or holdability are not supported * concurrency, or holdability are not supported
*/ */
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability) throws SQLException {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) { if (isDebugEnabled()) {
......
...@@ -125,7 +125,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -125,7 +125,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* @return the list of columns * @return the list of columns
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
*/ */
public ResultSet getTables(String catalogPattern, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { public ResultSet getTables(String catalogPattern, String schemaPattern,
String tableNamePattern, String[] types) throws SQLException {
try { try {
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCode("getTables(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableNamePattern) debugCode("getTables(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableNamePattern)
...@@ -301,7 +302,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -301,7 +302,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* @return the list of indexes and columns * @return the list of indexes and columns
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
*/ */
public ResultSet getIndexInfo(String catalogPattern, String schemaPattern, String tableName, boolean unique, boolean approximate) public ResultSet getIndexInfo(String catalogPattern, String schemaPattern,
String tableName, boolean unique, boolean approximate)
throws SQLException { throws SQLException {
try { try {
if (isDebugEnabled()) { if (isDebugEnabled()) {
...@@ -829,7 +831,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -829,7 +831,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* @return the list of privileges * @return the list of privileges
* @throws SQLException if the connection is closed * @throws SQLException if the connection is closed
*/ */
public ResultSet getTablePrivileges(String catalogPattern, String schemaPattern, String tableNamePattern) throws SQLException { public ResultSet getTablePrivileges(String catalogPattern, String schemaPattern,
String tableNamePattern) throws SQLException {
try { try {
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCode("getTablePrivileges(" debugCode("getTablePrivileges("
......
...@@ -63,7 +63,8 @@ import java.util.logging.Logger; ...@@ -63,7 +63,8 @@ import java.util.logging.Logger;
* In this example the user name and password are serialized as * In this example the user name and password are serialized as
* well; this may be a security problem in some cases. * well; this may be a security problem in some cases.
*/ */
public class JdbcDataSource extends TraceObject implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Referenceable { public class JdbcDataSource extends TraceObject
implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Referenceable {
private static final long serialVersionUID = 1288136338451857771L; private static final long serialVersionUID = 1288136338451857771L;
......
...@@ -76,7 +76,8 @@ public class JdbcDataSourceFactory implements ObjectFactory { ...@@ -76,7 +76,8 @@ public class JdbcDataSourceFactory implements ObjectFactory {
public static TraceSystem getTraceSystem() { public static TraceSystem getTraceSystem() {
synchronized (JdbcDataSourceFactory.class) { synchronized (JdbcDataSourceFactory.class) {
if (cachedTraceSystem == null) { if (cachedTraceSystem == null) {
cachedTraceSystem = new TraceSystem(SysProperties.CLIENT_TRACE_DIRECTORY + "h2datasource" + Constants.SUFFIX_TRACE_FILE); cachedTraceSystem = new TraceSystem(
SysProperties.CLIENT_TRACE_DIRECTORY + "h2datasource" + Constants.SUFFIX_TRACE_FILE);
cachedTraceSystem.setLevelFile(SysProperties.DATASOURCE_TRACE_LEVEL); cachedTraceSystem.setLevelFile(SysProperties.DATASOURCE_TRACE_LEVEL);
} }
return cachedTraceSystem; return cachedTraceSystem;
......
...@@ -141,7 +141,8 @@ public class DatabaseInfo implements DatabaseInfoMBean { ...@@ -141,7 +141,8 @@ public class DatabaseInfo implements DatabaseInfoMBean {
} }
public long getFileSize() { public long getFileSize() {
return database.isPersistent() ? (database.getPageStore().getPageCount() * database.getPageStore().getPageSize() / 1024) : 0; return database.isPersistent() ?
(database.getPageStore().getPageCount() * database.getPageStore().getPageSize() / 1024) : 0;
} }
public int getCacheSizeMax() { public int getCacheSizeMax() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论