提交 b3fbef16 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Pass values to MetaTable.add()

上级 65413027
...@@ -65,7 +65,12 @@ import org.h2.util.Utils; ...@@ -65,7 +65,12 @@ import org.h2.util.Utils;
import org.h2.value.CompareMode; import org.h2.value.CompareMode;
import org.h2.value.DataType; import org.h2.value.DataType;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueBoolean;
import org.h2.value.ValueDouble;
import org.h2.value.ValueInt;
import org.h2.value.ValueLong;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
import org.h2.value.ValueShort;
import org.h2.value.ValueString; import org.h2.value.ValueString;
import org.h2.value.ValueStringIgnoreCase; import org.h2.value.ValueStringIgnoreCase;
...@@ -801,15 +806,15 @@ public class MetaTable extends Table { ...@@ -801,15 +806,15 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(table.getComment()), replaceNullWithEmpty(table.getComment()),
// LAST_MODIFICATION // LAST_MODIFICATION
Long.toString(table.getMaxDataModificationId()), ValueLong.get(table.getMaxDataModificationId()),
// ID // ID
Integer.toString(table.getId()), ValueInt.get(table.getId()),
// TYPE_NAME // TYPE_NAME
null, null,
// TABLE_CLASS // TABLE_CLASS
table.getClass().getName(), table.getClass().getName(),
// ROW_COUNT_ESTIMATE // ROW_COUNT_ESTIMATE
Long.toString(table.getRowCountApproximation()) ValueLong.get(table.getRowCountApproximation())
); );
} }
break; break;
...@@ -837,7 +842,8 @@ public class MetaTable extends Table { ...@@ -837,7 +842,8 @@ public class MetaTable extends Table {
for (int j = 0; j < cols.length; j++) { for (int j = 0; j < cols.length; j++) {
Column c = cols[j]; Column c = cols[j];
DataType dataType = c.getDataType(); DataType dataType = c.getDataType();
String precision = Integer.toString(c.getPrecisionAsInt()); ValueInt precision = ValueInt.get(c.getPrecisionAsInt());
ValueInt scale = ValueInt.get(c.getScale());
Sequence sequence = c.getSequence(); Sequence sequence = c.getSequence();
add(rows, add(rows,
// TABLE_CATALOG // TABLE_CATALOG
...@@ -849,13 +855,13 @@ public class MetaTable extends Table { ...@@ -849,13 +855,13 @@ public class MetaTable extends Table {
// COLUMN_NAME // COLUMN_NAME
identifier(c.getName()), identifier(c.getName()),
// ORDINAL_POSITION // ORDINAL_POSITION
Integer.toString(j + 1), ValueInt.get(j + 1),
// COLUMN_DEFAULT // COLUMN_DEFAULT
c.getDefaultSQL(), c.getDefaultSQL(),
// IS_NULLABLE // IS_NULLABLE
c.isNullable() ? "YES" : "NO", c.isNullable() ? "YES" : "NO",
// DATA_TYPE // DATA_TYPE
Integer.toString(dataType.sqlType), ValueInt.get(dataType.sqlType),
// CHARACTER_MAXIMUM_LENGTH // CHARACTER_MAXIMUM_LENGTH
precision, precision,
// CHARACTER_OCTET_LENGTH // CHARACTER_OCTET_LENGTH
...@@ -863,11 +869,11 @@ public class MetaTable extends Table { ...@@ -863,11 +869,11 @@ public class MetaTable extends Table {
// NUMERIC_PRECISION // NUMERIC_PRECISION
precision, precision,
// NUMERIC_PRECISION_RADIX // NUMERIC_PRECISION_RADIX
"10", ValueInt.get(10),
// NUMERIC_SCALE // NUMERIC_SCALE
Integer.toString(c.getScale()), scale,
// DATETIME_PRECISION // DATETIME_PRECISION
DataType.isDateTimeType(dataType.type) ? Integer.toString(c.getScale()) : null, DataType.isDateTimeType(dataType.type) ? scale : null,
// CHARACTER_SET_NAME // CHARACTER_SET_NAME
CHARACTER_SET_NAME, CHARACTER_SET_NAME,
// COLLATION_NAME // COLLATION_NAME
...@@ -875,13 +881,12 @@ public class MetaTable extends Table { ...@@ -875,13 +881,12 @@ public class MetaTable extends Table {
// TYPE_NAME // TYPE_NAME
identifier(dataType.name), identifier(dataType.name),
// NULLABLE // NULLABLE
c.isNullable() ? ValueInt.get(c.isNullable()
"" + DatabaseMetaData.columnNullable : ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls),
"" + DatabaseMetaData.columnNoNulls,
// IS_COMPUTED // IS_COMPUTED
c.getComputed() ? "TRUE" : "FALSE", ValueBoolean.get(c.getComputed()),
// SELECTIVITY // SELECTIVITY
Integer.toString(c.getSelectivity()), ValueInt.get(c.getSelectivity()),
// CHECK_CONSTRAINT // CHECK_CONSTRAINT
c.getCheckConstraintSQL(session, c.getName()), c.getCheckConstraintSQL(session, c.getName()),
// SEQUENCE_NAME // SEQUENCE_NAME
...@@ -889,6 +894,7 @@ public class MetaTable extends Table { ...@@ -889,6 +894,7 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(c.getComment()), replaceNullWithEmpty(c.getComment()),
// SOURCE_DATA_TYPE // SOURCE_DATA_TYPE
// SMALLINT
null, null,
// COLUMN_TYPE // COLUMN_TYPE
c.getCreateSQLWithoutName(), c.getCreateSQLWithoutName(),
...@@ -950,31 +956,27 @@ public class MetaTable extends Table { ...@@ -950,31 +956,27 @@ public class MetaTable extends Table {
// TABLE_NAME // TABLE_NAME
tableName, tableName,
// NON_UNIQUE // NON_UNIQUE
index.getIndexType().isUnique() ? ValueBoolean.get(!index.getIndexType().isUnique()),
"FALSE" : "TRUE",
// INDEX_NAME // INDEX_NAME
identifier(index.getName()), identifier(index.getName()),
// ORDINAL_POSITION // ORDINAL_POSITION
Integer.toString(k + 1), ValueShort.get((short) (k + 1)),
// COLUMN_NAME // COLUMN_NAME
identifier(column.getName()), identifier(column.getName()),
// CARDINALITY // CARDINALITY
"0", ValueInt.get(0),
// PRIMARY_KEY // PRIMARY_KEY
index.getIndexType().isPrimaryKey() ? ValueBoolean.get(index.getIndexType().isPrimaryKey()),
"TRUE" : "FALSE",
// INDEX_TYPE_NAME // INDEX_TYPE_NAME
index.getIndexType().getSQL(), index.getIndexType().getSQL(),
// IS_GENERATED // IS_GENERATED
index.getIndexType().getBelongsToConstraint() ? ValueBoolean.get(index.getIndexType().getBelongsToConstraint()),
"TRUE" : "FALSE",
// INDEX_TYPE // INDEX_TYPE
"" + DatabaseMetaData.tableIndexOther, ValueShort.get(DatabaseMetaData.tableIndexOther),
// ASC_OR_DESC // ASC_OR_DESC
(idxCol.sortType & SortOrder.DESCENDING) != 0 ? (idxCol.sortType & SortOrder.DESCENDING) != 0 ? "D" : "A",
"D" : "A",
// PAGES // PAGES
"0", ValueInt.get(0),
// FILTER_CONDITION // FILTER_CONDITION
"", "",
// REMARKS // REMARKS
...@@ -982,16 +984,15 @@ public class MetaTable extends Table { ...@@ -982,16 +984,15 @@ public class MetaTable extends Table {
// SQL // SQL
index.getCreateSQL(), index.getCreateSQL(),
// ID // ID
Integer.toString(index.getId()), ValueInt.get(index.getId()),
// SORT_TYPE // SORT_TYPE
Integer.toString(idxCol.sortType), ValueInt.get(idxCol.sortType),
// CONSTRAINT_NAME // CONSTRAINT_NAME
constraintName, constraintName,
// INDEX_CLASS // INDEX_CLASS
indexClass, indexClass,
// AFFINITY // AFFINITY
index.getIndexType().isAffinity() ? ValueBoolean.get(index.getIndexType().isAffinity())
"TRUE" : "FALSE"
); );
} }
} }
...@@ -1015,9 +1016,9 @@ public class MetaTable extends Table { ...@@ -1015,9 +1016,9 @@ public class MetaTable extends Table {
// TYPE_NAME // TYPE_NAME
t.name, t.name,
// DATA_TYPE // DATA_TYPE
Integer.toString(t.sqlType), ValueInt.get(t.sqlType),
// PRECISION // PRECISION
Integer.toString(MathUtils.convertLongToInt(t.maxPrecision)), ValueInt.get(MathUtils.convertLongToInt(t.maxPrecision)),
// PREFIX // PREFIX
t.prefix, t.prefix,
// SUFFIX // SUFFIX
...@@ -1025,21 +1026,21 @@ public class MetaTable extends Table { ...@@ -1025,21 +1026,21 @@ public class MetaTable extends Table {
// PARAMS // PARAMS
t.params, t.params,
// AUTO_INCREMENT // AUTO_INCREMENT
String.valueOf(t.autoIncrement), ValueBoolean.get(t.autoIncrement),
// MINIMUM_SCALE // MINIMUM_SCALE
Integer.toString(t.minScale), ValueShort.get((short) t.minScale),
// MAXIMUM_SCALE // MAXIMUM_SCALE
Integer.toString(t.maxScale), ValueShort.get((short) t.maxScale),
// RADIX // RADIX
t.decimal ? "10" : null, t.decimal ? ValueInt.get(10) : null,
// POS // POS
Integer.toString(t.sqlTypePos), ValueInt.get(t.sqlTypePos),
// CASE_SENSITIVE // CASE_SENSITIVE
String.valueOf(t.caseSensitive), ValueBoolean.get(t.caseSensitive),
// NULLABLE // NULLABLE
"" + DatabaseMetaData.typeNullable, ValueShort.get((short) DatabaseMetaData.typeNullable),
// SEARCHABLE // SEARCHABLE
"" + DatabaseMetaData.typeSearchable ValueShort.get((short) DatabaseMetaData.typeSearchable)
); );
} }
break; break;
...@@ -1149,7 +1150,7 @@ public class MetaTable extends Table { ...@@ -1149,7 +1150,7 @@ public class MetaTable extends Table {
for (int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
add(rows, add(rows,
// ID // ID
Integer.toString(i), ValueInt.get(i),
// SECTION // SECTION
rs.getString(1).trim(), rs.getString(1).trim(),
// TOPIC // TOPIC
...@@ -1177,23 +1178,23 @@ public class MetaTable extends Table { ...@@ -1177,23 +1178,23 @@ public class MetaTable extends Table {
// SEQUENCE_NAME // SEQUENCE_NAME
identifier(s.getName()), identifier(s.getName()),
// CURRENT_VALUE // CURRENT_VALUE
Long.toString(s.getCurrentValue()), ValueLong.get(s.getCurrentValue()),
// INCREMENT // INCREMENT
Long.toString(s.getIncrement()), ValueLong.get(s.getIncrement()),
// IS_GENERATED // IS_GENERATED
s.getBelongsToTable() ? "TRUE" : "FALSE", ValueBoolean.get(s.getBelongsToTable()),
// REMARKS // REMARKS
replaceNullWithEmpty(s.getComment()), replaceNullWithEmpty(s.getComment()),
// CACHE // CACHE
Long.toString(s.getCacheSize()), ValueLong.get(s.getCacheSize()),
// MIN_VALUE // MIN_VALUE
Long.toString(s.getMinValue()), ValueLong.get(s.getMinValue()),
// MAX_VALUE // MAX_VALUE
Long.toString(s.getMaxValue()), ValueLong.get(s.getMaxValue()),
// IS_CYCLE // IS_CYCLE
s.getCycle() ? "TRUE" : "FALSE", ValueBoolean.get(s.getCycle()),
// ID // ID
Integer.toString(s.getId()) ValueInt.get(s.getId())
); );
} }
break; break;
...@@ -1209,7 +1210,7 @@ public class MetaTable extends Table { ...@@ -1209,7 +1210,7 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(u.getComment()), replaceNullWithEmpty(u.getComment()),
// ID // ID
Integer.toString(u.getId()) ValueInt.get(u.getId())
); );
} }
} }
...@@ -1224,7 +1225,7 @@ public class MetaTable extends Table { ...@@ -1224,7 +1225,7 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(r.getComment()), replaceNullWithEmpty(r.getComment()),
// ID // ID
Integer.toString(r.getId()) ValueInt.get(r.getId())
); );
} }
} }
...@@ -1235,8 +1236,7 @@ public class MetaTable extends Table { ...@@ -1235,8 +1236,7 @@ public class MetaTable extends Table {
for (Right r : database.getAllRights()) { for (Right r : database.getAllRights()) {
Role role = r.getGrantedRole(); Role role = r.getGrantedRole();
DbObject grantee = r.getGrantee(); DbObject grantee = r.getGrantee();
String rightType = grantee.getType() == DbObject.USER ? String rightType = grantee.getType() == DbObject.USER ? "USER" : "ROLE";
"USER" : "ROLE";
if (role == null) { if (role == null) {
DbObject object = r.getGrantedObject(); DbObject object = r.getGrantedObject();
Schema schema = null; Schema schema = null;
...@@ -1268,7 +1268,7 @@ public class MetaTable extends Table { ...@@ -1268,7 +1268,7 @@ public class MetaTable extends Table {
// TABLE_NAME // TABLE_NAME
tableName, tableName,
// ID // ID
Integer.toString(r.getId()) ValueInt.get(r.getId())
); );
} else { } else {
add(rows, add(rows,
...@@ -1285,7 +1285,7 @@ public class MetaTable extends Table { ...@@ -1285,7 +1285,7 @@ public class MetaTable extends Table {
// TABLE_NAME // TABLE_NAME
"", "",
// ID // ID
Integer.toString(r.getId()) ValueInt.get(r.getId())
); );
} }
} }
...@@ -1303,9 +1303,6 @@ public class MetaTable extends Table { ...@@ -1303,9 +1303,6 @@ public class MetaTable extends Table {
methods = new JavaMethod[0]; methods = new JavaMethod[0];
} }
for (FunctionAlias.JavaMethod method : methods) { for (FunctionAlias.JavaMethod method : methods) {
int returnsResult = method.getDataType() == Value.NULL ?
DatabaseMetaData.procedureNoResult :
DatabaseMetaData.procedureReturnsResult;
add(rows, add(rows,
// ALIAS_CATALOG // ALIAS_CATALOG
catalog, catalog,
...@@ -1318,17 +1315,19 @@ public class MetaTable extends Table { ...@@ -1318,17 +1315,19 @@ public class MetaTable extends Table {
// JAVA_METHOD // JAVA_METHOD
alias.getJavaMethodName(), alias.getJavaMethodName(),
// DATA_TYPE // DATA_TYPE
Integer.toString(DataType.convertTypeToSQLType(method.getDataType())), ValueInt.get(DataType.convertTypeToSQLType(method.getDataType())),
// TYPE_NAME // TYPE_NAME
DataType.getDataType(method.getDataType()).name, DataType.getDataType(method.getDataType()).name,
// COLUMN_COUNT INT // COLUMN_COUNT
Integer.toString(method.getParameterCount()), ValueInt.get(method.getParameterCount()),
// RETURNS_RESULT SMALLINT // RETURNS_RESULT
Integer.toString(returnsResult), ValueShort.get(method.getDataType() == Value.NULL
? (short) DatabaseMetaData.procedureNoResult
: (short) DatabaseMetaData.procedureReturnsResult),
// REMARKS // REMARKS
replaceNullWithEmpty(alias.getComment()), replaceNullWithEmpty(alias.getComment()),
// ID // ID
Integer.toString(alias.getId()), ValueInt.get(alias.getId()),
// SOURCE // SOURCE
alias.getSource() alias.getSource()
// when adding more columns, see also below // when adding more columns, see also below
...@@ -1336,7 +1335,6 @@ public class MetaTable extends Table { ...@@ -1336,7 +1335,6 @@ public class MetaTable extends Table {
} }
} }
for (UserAggregate agg : database.getAllAggregates()) { for (UserAggregate agg : database.getAllAggregates()) {
int returnsResult = DatabaseMetaData.procedureReturnsResult;
add(rows, add(rows,
// ALIAS_CATALOG // ALIAS_CATALOG
catalog, catalog,
...@@ -1349,17 +1347,17 @@ public class MetaTable extends Table { ...@@ -1349,17 +1347,17 @@ public class MetaTable extends Table {
// JAVA_METHOD // JAVA_METHOD
"", "",
// DATA_TYPE // DATA_TYPE
"" + Types.NULL, ValueInt.get(Types.NULL),
// TYPE_NAME // TYPE_NAME
DataType.getDataType(Value.NULL).name, DataType.getDataType(Value.NULL).name,
// COLUMN_COUNT INT // COLUMN_COUNT
"1", ValueInt.get(1),
// RETURNS_RESULT SMALLINT // RETURNS_RESULT
Integer.toString(returnsResult), ValueShort.get((short) DatabaseMetaData.procedureReturnsResult),
// REMARKS // REMARKS
replaceNullWithEmpty(agg.getComment()), replaceNullWithEmpty(agg.getComment()),
// ID // ID
Integer.toString(agg.getId()), ValueInt.get(agg.getId()),
// SOURCE // SOURCE
"" ""
// when adding more columns, see also below // when adding more columns, see also below
...@@ -1393,25 +1391,25 @@ public class MetaTable extends Table { ...@@ -1393,25 +1391,25 @@ public class MetaTable extends Table {
// JAVA_METHOD // JAVA_METHOD
alias.getJavaMethodName(), alias.getJavaMethodName(),
// COLUMN_COUNT // COLUMN_COUNT
Integer.toString(method.getParameterCount()), ValueInt.get(method.getParameterCount()),
// POS INT // POS
"0", ValueInt.get(0),
// COLUMN_NAME // COLUMN_NAME
"P0", "P0",
// DATA_TYPE // DATA_TYPE
Integer.toString(DataType.convertTypeToSQLType(method.getDataType())), ValueInt.get(DataType.convertTypeToSQLType(method.getDataType())),
// TYPE_NAME // TYPE_NAME
dt.name, dt.name,
// PRECISION INT // PRECISION
Integer.toString(MathUtils.convertLongToInt(dt.defaultPrecision)), ValueInt.get(MathUtils.convertLongToInt(dt.defaultPrecision)),
// SCALE // SCALE
Integer.toString(dt.defaultScale), ValueShort.get((short) dt.defaultScale),
// RADIX // RADIX
"10", ValueShort.get((short) 10),
// NULLABLE SMALLINT // NULLABLE
"" + DatabaseMetaData.columnNullableUnknown, ValueShort.get((short) DatabaseMetaData.columnNullableUnknown),
// COLUMN_TYPE // COLUMN_TYPE
"" + DatabaseMetaData.procedureColumnReturn, ValueShort.get((short) DatabaseMetaData.procedureColumnReturn),
// REMARKS // REMARKS
"", "",
// COLUMN_DEFAULT // COLUMN_DEFAULT
...@@ -1426,8 +1424,6 @@ public class MetaTable extends Table { ...@@ -1426,8 +1424,6 @@ public class MetaTable extends Table {
Class<?> clazz = columnList[k]; Class<?> clazz = columnList[k];
int dataType = DataType.getTypeFromClass(clazz); int dataType = DataType.getTypeFromClass(clazz);
DataType dt = DataType.getDataType(dataType); DataType dt = DataType.getDataType(dataType);
int nullable = clazz.isPrimitive() ? DatabaseMetaData.columnNoNulls
: DatabaseMetaData.columnNullable;
add(rows, add(rows,
// ALIAS_CATALOG // ALIAS_CATALOG
catalog, catalog,
...@@ -1440,25 +1436,27 @@ public class MetaTable extends Table { ...@@ -1440,25 +1436,27 @@ public class MetaTable extends Table {
// JAVA_METHOD // JAVA_METHOD
alias.getJavaMethodName(), alias.getJavaMethodName(),
// COLUMN_COUNT // COLUMN_COUNT
Integer.toString(method.getParameterCount()), ValueInt.get(method.getParameterCount()),
// POS INT // POS
Integer.toString(k + (method.hasConnectionParam() ? 0 : 1)), ValueInt.get(k + (method.hasConnectionParam() ? 0 : 1)),
// COLUMN_NAME // COLUMN_NAME
"P" + (k + 1), "P" + (k + 1),
// DATA_TYPE // DATA_TYPE
Integer.toString(DataType.convertTypeToSQLType(dt.type)), ValueInt.get(DataType.convertTypeToSQLType(dt.type)),
// TYPE_NAME // TYPE_NAME
dt.name, dt.name,
// PRECISION INT // PRECISION
Integer.toString(MathUtils.convertLongToInt(dt.defaultPrecision)), ValueInt.get(MathUtils.convertLongToInt(dt.defaultPrecision)),
// SCALE // SCALE
Integer.toString(dt.defaultScale), ValueShort.get((short) dt.defaultScale),
// RADIX // RADIX
"10", ValueShort.get((short) 10),
// NULLABLE SMALLINT // NULLABLE
Integer.toString(nullable), ValueShort.get(clazz.isPrimitive()
? (short) DatabaseMetaData.columnNoNulls
: (short) DatabaseMetaData.columnNullable),
// COLUMN_TYPE // COLUMN_TYPE
"" + DatabaseMetaData.procedureColumnIn, ValueShort.get((short) DatabaseMetaData.procedureColumnIn),
// REMARKS // REMARKS
"", "",
// COLUMN_DEFAULT // COLUMN_DEFAULT
...@@ -1484,12 +1482,11 @@ public class MetaTable extends Table { ...@@ -1484,12 +1482,11 @@ public class MetaTable extends Table {
// DEFAULT_COLLATION_NAME // DEFAULT_COLLATION_NAME
collation, collation,
// IS_DEFAULT // IS_DEFAULT
Constants.SCHEMA_MAIN.equals( ValueBoolean.get(Constants.SCHEMA_MAIN.equals(schema.getName())),
schema.getName()) ? "TRUE" : "FALSE",
// REMARKS // REMARKS
replaceNullWithEmpty(schema.getComment()), replaceNullWithEmpty(schema.getComment()),
// ID // ID
Integer.toString(schema.getId()) ValueInt.get(schema.getId())
); );
} }
break; break;
...@@ -1575,7 +1572,7 @@ public class MetaTable extends Table { ...@@ -1575,7 +1572,7 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(view.getComment()), replaceNullWithEmpty(view.getComment()),
// ID // ID
Integer.toString(view.getId()) ValueInt.get(view.getId())
); );
} }
break; break;
...@@ -1610,8 +1607,8 @@ public class MetaTable extends Table { ...@@ -1610,8 +1607,8 @@ public class MetaTable extends Table {
if (!checkIndex(session, tableName, indexFrom, indexTo)) { if (!checkIndex(session, tableName, indexFrom, indexTo)) {
continue; continue;
} }
int update = getRefAction(ref.getUpdateAction()); ValueShort update = ValueShort.get(getRefAction(ref.getUpdateAction()));
int delete = getRefAction(ref.getDeleteAction()); ValueShort delete = ValueShort.get(getRefAction(ref.getDeleteAction()));
for (int j = 0; j < cols.length; j++) { for (int j = 0; j < cols.length; j++) {
add(rows, add(rows,
// PKTABLE_CATALOG // PKTABLE_CATALOG
...@@ -1631,17 +1628,17 @@ public class MetaTable extends Table { ...@@ -1631,17 +1628,17 @@ public class MetaTable extends Table {
// FKCOLUMN_NAME // FKCOLUMN_NAME
identifier(cols[j].column.getName()), identifier(cols[j].column.getName()),
// ORDINAL_POSITION // ORDINAL_POSITION
Integer.toString(j + 1), ValueShort.get((short) (j + 1)),
// UPDATE_RULE SMALLINT // UPDATE_RULE
Integer.toString(update), update,
// DELETE_RULE SMALLINT // DELETE_RULE
Integer.toString(delete), delete,
// FK_NAME // FK_NAME
identifier(ref.getName()), identifier(ref.getName()),
// PK_NAME // PK_NAME
identifier(ref.getUniqueIndex().getName()), identifier(ref.getUniqueIndex().getName()),
// DEFERRABILITY // DEFERRABILITY
"" + DatabaseMetaData.importedKeyNotDeferrable ValueShort.get((short) DatabaseMetaData.importedKeyNotDeferrable)
); );
} }
} }
...@@ -1711,7 +1708,7 @@ public class MetaTable extends Table { ...@@ -1711,7 +1708,7 @@ public class MetaTable extends Table {
// SQL // SQL
constraint.getCreateSQL(), constraint.getCreateSQL(),
// ID // ID
Integer.toString(constraint.getId()) ValueInt.get(constraint.getId())
); );
} }
break; break;
...@@ -1728,14 +1725,14 @@ public class MetaTable extends Table { ...@@ -1728,14 +1725,14 @@ public class MetaTable extends Table {
identifier(constant.getSchema().getName()), identifier(constant.getSchema().getName()),
// CONSTANT_NAME // CONSTANT_NAME
identifier(constant.getName()), identifier(constant.getName()),
// CONSTANT_TYPE // DATA_TYPE
Integer.toString(DataType.convertTypeToSQLType(expr.getType())), ValueInt.get(DataType.convertTypeToSQLType(expr.getType())),
// REMARKS // REMARKS
replaceNullWithEmpty(constant.getComment()), replaceNullWithEmpty(constant.getComment()),
// SQL // SQL
expr.getSQL(), expr.getSQL(),
// ID // ID
Integer.toString(constant.getId()) ValueInt.get(constant.getId())
); );
} }
break; break;
...@@ -1755,15 +1752,15 @@ public class MetaTable extends Table { ...@@ -1755,15 +1752,15 @@ public class MetaTable extends Table {
// IS_NULLABLE // IS_NULLABLE
col.isNullable() ? "YES" : "NO", col.isNullable() ? "YES" : "NO",
// DATA_TYPE // DATA_TYPE
Integer.toString(col.getDataType().sqlType), ValueInt.get(col.getDataType().sqlType),
// PRECISION INT // PRECISION
Integer.toString(col.getPrecisionAsInt()), ValueInt.get(col.getPrecisionAsInt()),
// SCALE INT // SCALE
Integer.toString(col.getScale()), ValueInt.get(col.getScale()),
// TYPE_NAME // TYPE_NAME
col.getDataType().name, col.getDataType().name,
// SELECTIVITY INT // SELECTIVITY INT
Integer.toString(col.getSelectivity()), ValueInt.get(col.getSelectivity()),
// CHECK_CONSTRAINT // CHECK_CONSTRAINT
col.getCheckConstraintSQL(session, "VALUE"), col.getCheckConstraintSQL(session, "VALUE"),
// REMARKS // REMARKS
...@@ -1771,7 +1768,7 @@ public class MetaTable extends Table { ...@@ -1771,7 +1768,7 @@ public class MetaTable extends Table {
// SQL // SQL
dt.getCreateSQL(), dt.getCreateSQL(),
// ID // ID
Integer.toString(dt.getId()) ValueInt.get(dt.getId())
); );
} }
break; break;
...@@ -1796,20 +1793,20 @@ public class MetaTable extends Table { ...@@ -1796,20 +1793,20 @@ public class MetaTable extends Table {
identifier(table.getSchema().getName()), identifier(table.getSchema().getName()),
// TABLE_NAME // TABLE_NAME
identifier(table.getName()), identifier(table.getName()),
// BEFORE BIT // BEFORE
Boolean.toString(trigger.isBefore()), ValueBoolean.get(trigger.isBefore()),
// JAVA_CLASS // JAVA_CLASS
trigger.getTriggerClassName(), trigger.getTriggerClassName(),
// QUEUE_SIZE INT // QUEUE_SIZE
Integer.toString(trigger.getQueueSize()), ValueInt.get(trigger.getQueueSize()),
// NO_WAIT BIT // NO_WAIT
Boolean.toString(trigger.isNoWait()), ValueBoolean.get(trigger.isNoWait()),
// REMARKS // REMARKS
replaceNullWithEmpty(trigger.getComment()), replaceNullWithEmpty(trigger.getComment()),
// SQL // SQL
trigger.getCreateSQL(), trigger.getCreateSQL(),
// ID // ID
Integer.toString(trigger.getId()) ValueInt.get(trigger.getId())
); );
} }
break; break;
...@@ -1826,7 +1823,7 @@ public class MetaTable extends Table { ...@@ -1826,7 +1823,7 @@ public class MetaTable extends Table {
int blockingSessionId = s.getBlockingSessionId(); int blockingSessionId = s.getBlockingSessionId();
add(rows, add(rows,
// ID // ID
Integer.toString(s.getId()), ValueInt.get(s.getId()),
// USER_NAME // USER_NAME
s.getUser().getName(), s.getUser().getName(),
// SESSION_START // SESSION_START
...@@ -1839,8 +1836,8 @@ public class MetaTable extends Table { ...@@ -1839,8 +1836,8 @@ public class MetaTable extends Table {
Boolean.toString(s.containsUncommitted()), Boolean.toString(s.containsUncommitted()),
// STATE // STATE
String.valueOf(s.getState()), String.valueOf(s.getState()),
// BLOCKER_ID INT // BLOCKER_ID
blockingSessionId == 0 ? null : String.valueOf(blockingSessionId) blockingSessionId == 0 ? null : ValueInt.get(blockingSessionId)
); );
} }
} }
...@@ -1856,7 +1853,7 @@ public class MetaTable extends Table { ...@@ -1856,7 +1853,7 @@ public class MetaTable extends Table {
// TABLE_NAME // TABLE_NAME
table.getName(), table.getName(),
// SESSION_ID // SESSION_ID
Integer.toString(s.getId()), ValueInt.get(s.getId()),
// LOCK_TYPE // LOCK_TYPE
table.isLockedExclusivelyBy(s) ? "WRITE" : "READ" table.isLockedExclusivelyBy(s) ? "WRITE" : "READ"
); );
...@@ -1917,27 +1914,27 @@ public class MetaTable extends Table { ...@@ -1917,27 +1914,27 @@ public class MetaTable extends Table {
// SQL_STATEMENT // SQL_STATEMENT
entry.sqlStatement, entry.sqlStatement,
// EXECUTION_COUNT // EXECUTION_COUNT
Integer.toString(entry.count), ValueInt.get(entry.count),
// MIN_EXECUTION_TIME // MIN_EXECUTION_TIME
Double.toString(entry.executionTimeMinNanos / 1_000_000d), ValueDouble.get(entry.executionTimeMinNanos / 1_000_000d),
// MAX_EXECUTION_TIME // MAX_EXECUTION_TIME
Double.toString(entry.executionTimeMaxNanos / 1_000_000d), ValueDouble.get(entry.executionTimeMaxNanos / 1_000_000d),
// CUMULATIVE_EXECUTION_TIME // CUMULATIVE_EXECUTION_TIME
Double.toString(entry.executionTimeCumulativeNanos / 1_000_000d), ValueDouble.get(entry.executionTimeCumulativeNanos / 1_000_000d),
// AVERAGE_EXECUTION_TIME // AVERAGE_EXECUTION_TIME
Double.toString(entry.executionTimeMeanNanos / 1_000_000d), ValueDouble.get(entry.executionTimeMeanNanos / 1_000_000d),
// STD_DEV_EXECUTION_TIME // STD_DEV_EXECUTION_TIME
Double.toString(entry.getExecutionTimeStandardDeviation() / 1_000_000d), ValueDouble.get(entry.getExecutionTimeStandardDeviation() / 1_000_000d),
// MIN_ROW_COUNT // MIN_ROW_COUNT
Integer.toString(entry.rowCountMin), ValueInt.get(entry.rowCountMin),
// MAX_ROW_COUNT // MAX_ROW_COUNT
Integer.toString(entry.rowCountMax), ValueInt.get(entry.rowCountMax),
// CUMULATIVE_ROW_COUNT // CUMULATIVE_ROW_COUNT
Long.toString(entry.rowCountCumulative), ValueLong.get(entry.rowCountCumulative),
// AVERAGE_ROW_COUNT // AVERAGE_ROW_COUNT
Double.toString(entry.rowCountMean), ValueDouble.get(entry.rowCountMean),
// STD_DEV_ROW_COUNT // STD_DEV_ROW_COUNT
Double.toString(entry.getRowCountStandardDeviation()) ValueDouble.get(entry.getRowCountStandardDeviation())
); );
} }
} }
...@@ -1963,7 +1960,7 @@ public class MetaTable extends Table { ...@@ -1963,7 +1960,7 @@ public class MetaTable extends Table {
// REMARKS // REMARKS
replaceNullWithEmpty(synonym.getComment()), replaceNullWithEmpty(synonym.getComment()),
// ID // ID
Integer.toString(synonym.getId()) ValueInt.get(synonym.getId())
); );
} }
break; break;
...@@ -2033,8 +2030,8 @@ public class MetaTable extends Table { ...@@ -2033,8 +2030,8 @@ public class MetaTable extends Table {
} }
for (int i = 0; i < indexColumns.length; i++) { for (int i = 0; i < indexColumns.length; i++) {
IndexColumn indexColumn = indexColumns[i]; IndexColumn indexColumn = indexColumns[i];
String ordinalPosition = Integer.toString(i + 1); ValueInt ordinalPosition = ValueInt.get(i + 1);
String positionInUniqueConstraint; ValueInt positionInUniqueConstraint;
if (constraintType == Constraint.Type.REFERENTIAL) { if (constraintType == Constraint.Type.REFERENTIAL) {
positionInUniqueConstraint = ordinalPosition; positionInUniqueConstraint = ordinalPosition;
if (referenced != null) { if (referenced != null) {
...@@ -2042,7 +2039,7 @@ public class MetaTable extends Table { ...@@ -2042,7 +2039,7 @@ public class MetaTable extends Table {
IndexColumn[] refColumns = referenced.getColumns(); IndexColumn[] refColumns = referenced.getColumns();
for (int j = 0; j < refColumns.length; j++) { for (int j = 0; j < refColumns.length; j++) {
if (refColumns[j].column.equals(c)) { if (refColumns[j].column.equals(c)) {
positionInUniqueConstraint = Integer.toString(j + 1); positionInUniqueConstraint = ValueInt.get(j + 1);
break; break;
} }
} }
...@@ -2120,7 +2117,7 @@ public class MetaTable extends Table { ...@@ -2120,7 +2117,7 @@ public class MetaTable extends Table {
return rows; return rows;
} }
private static int getRefAction(ConstraintActionType action) { private static short getRefAction(ConstraintActionType action) {
switch (action) { switch (action) {
case CASCADE: case CASCADE:
return DatabaseMetaData.importedKeyCascade; return DatabaseMetaData.importedKeyCascade;
...@@ -2238,14 +2235,12 @@ public class MetaTable extends Table { ...@@ -2238,14 +2235,12 @@ public class MetaTable extends Table {
} }
} }
private void add(ArrayList<Row> rows, String... strings) { private void add(ArrayList<Row> rows, Object... stringsOrValues) {
Value[] values = new Value[strings.length]; Value[] values = new Value[stringsOrValues.length];
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < stringsOrValues.length; i++) {
String s = strings[i]; Object s = stringsOrValues[i];
Value v = (s == null) ? (Value) ValueNull.INSTANCE : ValueString.get(s); Value v = s == null ? ValueNull.INSTANCE : s instanceof String ? ValueString.get((String) s) : (Value) s;
Column col = columns[i]; values[i] = columns[i].convert(v);
v = col.convert(v);
values[i] = v;
} }
Row row = database.createRow(values, 1); Row row = database.createRow(values, 1);
row.setKey(rows.size()); row.setKey(rows.size());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论