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

Reduce number of Column() constructors

上级 847ab2c2
...@@ -216,7 +216,6 @@ import org.h2.table.TableFilter; ...@@ -216,7 +216,6 @@ import org.h2.table.TableFilter;
import org.h2.table.TableFilter.TableFilterVisitor; import org.h2.table.TableFilter.TableFilterVisitor;
import org.h2.table.TableView; import org.h2.table.TableView;
import org.h2.util.IntervalUtils; import org.h2.util.IntervalUtils;
import org.h2.util.MathUtils;
import org.h2.util.ParserUtil; import org.h2.util.ParserUtil;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -5351,7 +5350,6 @@ public class Parser { ...@@ -5351,7 +5350,6 @@ public class Parser {
regular = true; regular = true;
} }
long precision = -1; long precision = -1;
int displaySize = -1;
ExtTypeInfo extTypeInfo = null; ExtTypeInfo extTypeInfo = null;
int scale = -1; int scale = -1;
String comment = null; String comment = null;
...@@ -5368,7 +5366,6 @@ public class Parser { ...@@ -5368,7 +5366,6 @@ public class Parser {
comment = templateColumn.getComment(); comment = templateColumn.getComment();
original = forTable ? domain.getSQL() : templateColumn.getOriginalSQL(); original = forTable ? domain.getSQL() : templateColumn.getOriginalSQL();
precision = type.getPrecision(); precision = type.getPrecision();
displaySize = type.getDisplaySize();
scale = type.getScale(); scale = type.getScale();
extTypeInfo = type.getExtTypeInfo(); extTypeInfo = type.getExtTypeInfo();
} else { } else {
...@@ -5388,8 +5385,6 @@ public class Parser { ...@@ -5388,8 +5385,6 @@ public class Parser {
read(); read();
} }
precision = precision == -1 ? dataType.defaultPrecision : precision; precision = precision == -1 ? dataType.defaultPrecision : precision;
displaySize = displaySize == -1 ? dataType.defaultDisplaySize
: displaySize;
scale = scale == -1 ? dataType.defaultScale : scale; scale = scale == -1 ? dataType.defaultScale : scale;
if (dataType.supportsPrecision || dataType.supportsScale) { if (dataType.supportsPrecision || dataType.supportsScale) {
int t = dataType.type; int t = dataType.type;
...@@ -5403,7 +5398,6 @@ public class Parser { ...@@ -5403,7 +5398,6 @@ public class Parser {
} else { } else {
original = original + '(' + originalScale + ')'; original = original + '(' + originalScale + ')';
} }
precision = displaySize = ValueTime.getDisplaySize(originalScale);
break; break;
case Value.TIMESTAMP: case Value.TIMESTAMP:
if (original.equals("TIMESTAMP WITHOUT TIME ZONE")) { if (original.equals("TIMESTAMP WITHOUT TIME ZONE")) {
...@@ -5411,11 +5405,9 @@ public class Parser { ...@@ -5411,11 +5405,9 @@ public class Parser {
} else { } else {
original = original + '(' + originalScale + ')'; original = original + '(' + originalScale + ')';
} }
precision = displaySize = ValueTimestamp.getDisplaySize(originalScale);
break; break;
case Value.TIMESTAMP_TZ: case Value.TIMESTAMP_TZ:
original = "TIMESTAMP(" + originalScale + ") WITH TIME ZONE"; original = "TIMESTAMP(" + originalScale + ") WITH TIME ZONE";
precision = displaySize = ValueTimestampTimeZone.getDisplaySize(originalScale);
break; break;
} }
} else if (original.equals("DATETIME") || original.equals("DATETIME2")) { } else if (original.equals("DATETIME") || original.equals("DATETIME2")) {
...@@ -5428,11 +5420,9 @@ public class Parser { ...@@ -5428,11 +5420,9 @@ public class Parser {
read(CLOSE_PAREN); read(CLOSE_PAREN);
scale = originalScale; scale = originalScale;
original = original + '(' + originalScale + ')'; original = original + '(' + originalScale + ')';
precision = displaySize = ValueTimestamp.getDisplaySize(originalScale);
} }
} else if (original.equals("SMALLDATETIME")) { } else if (original.equals("SMALLDATETIME")) {
scale = 0; scale = 0;
precision = displaySize = ValueTimestamp.getDisplaySize(0);
} }
} else if (DataType.isIntervalType(t)) { } else if (DataType.isIntervalType(t)) {
if (originalPrecision >= 0 || originalScale >= 0) { if (originalPrecision >= 0 || originalScale >= 0) {
...@@ -5466,7 +5456,6 @@ public class Parser { ...@@ -5466,7 +5456,6 @@ public class Parser {
} }
} }
precision = p; precision = p;
displaySize = MathUtils.convertLongToInt(precision);
original += ")"; original += ")";
} }
read(CLOSE_PAREN); read(CLOSE_PAREN);
...@@ -5547,13 +5536,13 @@ public class Parser { ...@@ -5547,13 +5536,13 @@ public class Parser {
// MySQL compatibility // MySQL compatibility
readIf("UNSIGNED"); readIf("UNSIGNED");
int type = dataType.type; int type = dataType.type;
if (scale > precision && !DataType.isIntervalType(type)) { if (scale > precision && dataType.supportsPrecision && dataType.supportsScale
&& !DataType.isIntervalType(type)) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION,
Integer.toString(scale), Long.toString(precision)); Integer.toString(scale), Long.toString(precision));
} }
Column column = new Column(columnName, type, precision, scale, Column column = new Column(columnName, TypeInfo.getTypeInfo(type, precision, scale, extTypeInfo));
displaySize, extTypeInfo);
if (templateColumn != null) { if (templateColumn != null) {
column.setNullable(templateColumn.isNullable()); column.setNullable(templateColumn.isNullable());
column.setDefaultExpression(session, column.setDefaultExpression(session,
...@@ -5883,7 +5872,7 @@ public class Parser { ...@@ -5883,7 +5872,7 @@ public class Parser {
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
Column c = columns.get(i); Column c = columns.get(i);
if (c.getType().getValueType() == Value.UNKNOWN) { if (c.getType().getValueType() == Value.UNKNOWN) {
c = new Column(c.getName(), Value.STRING, 0, 0, 0); c = new Column(c.getName(), Value.STRING);
columns.set(i, c); columns.set(i, c);
} }
Expression[] array = new Expression[rowCount]; Expression[] array = new Expression[rowCount];
......
...@@ -15,17 +15,12 @@ import org.h2.engine.Database; ...@@ -15,17 +15,12 @@ import org.h2.engine.Database;
import org.h2.engine.DbObject; import org.h2.engine.DbObject;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.schema.Sequence; import org.h2.schema.Sequence;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ColumnNamer; import org.h2.util.ColumnNamer;
import org.h2.value.DataType;
import org.h2.value.ExtTypeInfo;
import org.h2.value.TypeInfo;
import org.h2.value.Value;
/** /**
* This class represents the statement * This class represents the statement
...@@ -181,39 +176,8 @@ public class CreateTable extends CommandWithColumns { ...@@ -181,39 +176,8 @@ public class CreateTable extends CommandWithColumns {
ColumnNamer columnNamer= new ColumnNamer(session); ColumnNamer columnNamer= new ColumnNamer(session);
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
Expression expr = expressions.get(i); Expression expr = expressions.get(i);
TypeInfo type = expr.getType(); String name = columnNamer.getColumnName(expr, i, expr.getAlias());
int valueType = type.getValueType(); Column col = new Column(name, expr.getType());
String name = columnNamer.getColumnName(expr,i,expr.getAlias());
long precision = type.getPrecision();
int displaySize = type.getDisplaySize();
DataType dt = DataType.getDataType(valueType);
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
precision = dt.defaultPrecision;
}
int scale = type.getScale();
if (scale > 0 && (dt.defaultScale == 0 ||
(dt.defaultScale > scale && dt.defaultScale < precision))) {
scale = dt.defaultScale;
}
if (scale > precision) {
precision = scale;
}
ExtTypeInfo extTypeInfo = null;
int t = dt.type;
if (DataType.isExtInfoType(t)) {
if (expr instanceof ExpressionColumn) {
extTypeInfo = ((ExpressionColumn) expr).getColumn().getType().getExtTypeInfo();
} else if (t == Value.ENUM) {
/*
* Only columns of tables may be enumerated.
*/
throw DbException.get(ErrorCode.GENERAL_ERROR_1,
"Unable to resolve enumerators of expression");
}
}
Column col = new Column(name, valueType, precision, scale, displaySize, extTypeInfo);
addColumn(col); addColumn(col);
} }
} }
......
...@@ -18,6 +18,7 @@ import org.h2.table.Column; ...@@ -18,6 +18,7 @@ import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableType; import org.h2.table.TableType;
import org.h2.table.TableView; import org.h2.table.TableView;
import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
...@@ -110,7 +111,7 @@ public class CreateView extends SchemaCommand { ...@@ -110,7 +111,7 @@ public class CreateView extends SchemaCommand {
columnTemplatesAsStrings = new Column[columnNames.length]; columnTemplatesAsStrings = new Column[columnNames.length];
for (int i = 0; i < columnNames.length; ++i) { for (int i = 0; i < columnNames.length; ++i) {
// non table expressions are fine to use unknown column type // non table expressions are fine to use unknown column type
columnTemplatesAsUnknowns[i] = new Column(columnNames[i], Value.UNKNOWN); columnTemplatesAsUnknowns[i] = new Column(columnNames[i], TypeInfo.TYPE_UNKNOWN);
// table expressions can't have unknown types - so we use string instead // table expressions can't have unknown types - so we use string instead
columnTemplatesAsStrings[i] = new Column(columnNames[i], Value.STRING); columnTemplatesAsStrings[i] = new Column(columnNames[i], Value.STRING);
} }
......
...@@ -60,6 +60,7 @@ import org.h2.util.JdbcUtils; ...@@ -60,6 +60,7 @@ import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.TypeInfo; import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueArray; import org.h2.value.ValueArray;
...@@ -2546,8 +2547,14 @@ public class Function extends Expression implements FunctionCall { ...@@ -2546,8 +2547,14 @@ public class Function extends Expression implements FunctionCall {
type = typeInfo; type = typeInfo;
if (allConst) { if (allConst) {
Value v = getValue(session); Value v = getValue(session);
if (v == ValueNull.INSTANCE) {
if (info.type == CAST || info.type == CONVERT) { if (info.type == CAST || info.type == CONVERT) {
if (v == ValueNull.INSTANCE) {
return this;
}
DataType dt = DataType.getDataType(type.getValueType());
TypeInfo vt = v.getType();
if (dt.supportsPrecision && type.getPrecision() != vt.getPrecision()
|| dt.supportsScale && type.getScale() != vt.getScale()) {
return this; return this;
} }
} }
......
...@@ -27,7 +27,6 @@ import org.h2.schema.Sequence; ...@@ -27,7 +27,6 @@ import org.h2.schema.Sequence;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
import org.h2.value.ExtTypeInfo;
import org.h2.value.TypeInfo; import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueInt; import org.h2.value.ValueInt;
...@@ -88,22 +87,7 @@ public class Column { ...@@ -88,22 +87,7 @@ public class Column {
private Domain domain; private Domain domain;
public Column(String name, int valueType) { public Column(String name, int valueType) {
this(name, valueType, -1, -1, -1, null); this(name, TypeInfo.getTypeInfo(valueType));
}
public Column(String name, int valueType, long precision, int scale, int displaySize) {
this(name, valueType, precision, scale, displaySize, null);
}
public Column(String name, int valueType, long precision, int scale, int displaySize, ExtTypeInfo extTypeInfo) {
this.name = name;
if (precision == -1 && scale == -1 && displaySize == -1 && valueType != Value.UNKNOWN) {
DataType dt = DataType.getDataType(valueType);
precision = dt.defaultPrecision;
scale = dt.defaultScale;
displaySize = dt.defaultDisplaySize;
}
this.type = new TypeInfo(valueType, precision, scale, displaySize, extTypeInfo);
} }
public Column(String name, TypeInfo type) { public Column(String name, TypeInfo type) {
......
...@@ -28,11 +28,11 @@ import org.h2.message.DbException; ...@@ -28,11 +28,11 @@ import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.RowList; import org.h2.result.RowList;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.util.MathUtils;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.DataType; import org.h2.value.DataType;
import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueDate; import org.h2.value.ValueDate;
import org.h2.value.ValueTime; import org.h2.value.ValueTime;
...@@ -156,9 +156,8 @@ public class TableLink extends Table { ...@@ -156,9 +156,8 @@ public class TableLink extends Table {
precision = convertPrecision(sqlType, precision); precision = convertPrecision(sqlType, precision);
int scale = rs.getInt("DECIMAL_DIGITS"); int scale = rs.getInt("DECIMAL_DIGITS");
scale = convertScale(sqlType, scale); scale = convertScale(sqlType, scale);
int displaySize = MathUtils.convertLongToInt(precision);
int type = DataType.convertSQLTypeToValueType(sqlType, sqlTypeName); int type = DataType.convertSQLTypeToValueType(sqlType, sqlTypeName);
Column col = new Column(n, type, precision, scale, displaySize); Column col = new Column(n, TypeInfo.getTypeInfo(type, precision, scale, null));
col.setTable(this, i++); col.setTable(this, i++);
columnList.add(col); columnList.add(col);
columnMap.put(n, col); columnMap.put(n, col);
...@@ -185,9 +184,8 @@ public class TableLink extends Table { ...@@ -185,9 +184,8 @@ public class TableLink extends Table {
precision = convertPrecision(sqlType, precision); precision = convertPrecision(sqlType, precision);
int scale = rsMeta.getScale(i + 1); int scale = rsMeta.getScale(i + 1);
scale = convertScale(sqlType, scale); scale = convertScale(sqlType, scale);
int displaySize = rsMeta.getColumnDisplaySize(i + 1);
int type = DataType.getValueTypeFromResultSet(rsMeta, i + 1); int type = DataType.getValueTypeFromResultSet(rsMeta, i + 1);
Column col = new Column(n, type, precision, scale, displaySize); Column col = new Column(n, TypeInfo.getTypeInfo(type, precision, scale, null));
col.setTable(this, i++); col.setTable(this, i++);
columnList.add(col); columnList.add(col);
columnMap.put(n, col); columnMap.put(n, col);
......
...@@ -38,8 +38,6 @@ import org.h2.util.ColumnNamer; ...@@ -38,8 +38,6 @@ import org.h2.util.ColumnNamer;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.ExtTypeInfo;
import org.h2.value.TypeInfo; import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
...@@ -182,29 +180,19 @@ public class TableView extends Table { ...@@ -182,29 +180,19 @@ public class TableView extends Table {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Expression expr = expressions.get(i); Expression expr = expressions.get(i);
String name = null; String name = null;
int valueType = Value.UNKNOWN; TypeInfo type = TypeInfo.TYPE_UNKNOWN;
if (columnTemplates != null && columnTemplates.length > i) { if (columnTemplates != null && columnTemplates.length > i) {
name = columnTemplates[i].getName(); name = columnTemplates[i].getName();
valueType = columnTemplates[i].getType().getValueType(); type = columnTemplates[i].getType();
} }
if (name == null) { if (name == null) {
name = expr.getAlias(); name = expr.getAlias();
} }
name = columnNamer.getColumnName(expr, i, name); name = columnNamer.getColumnName(expr, i, name);
if (valueType == Value.UNKNOWN) { if (type.getValueType() == Value.UNKNOWN) {
valueType = expr.getType().getValueType(); type = expr.getType();
}
TypeInfo type = expr.getType();
long precision = type.getPrecision();
int scale = type.getScale();
int displaySize = type.getDisplaySize();
ExtTypeInfo extTypeInfo = null;
if (DataType.isExtInfoType(valueType)) {
if (expr instanceof ExpressionColumn) {
extTypeInfo = ((ExpressionColumn) expr).getColumn().getType().getExtTypeInfo();
}
} }
Column col = new Column(name, valueType, precision, scale, displaySize, extTypeInfo); Column col = new Column(name, type);
col.setTable(this, i); col.setTable(this, i);
// Fetch check constraint from view column source // Fetch check constraint from view column source
ExpressionColumn fromColumn = null; ExpressionColumn fromColumn = null;
......
...@@ -257,29 +257,36 @@ public class TypeInfo { ...@@ -257,29 +257,36 @@ public class TypeInfo {
if (scale < 0) { if (scale < 0) {
scale = ValueDecimal.DEFAULT_SCALE; scale = ValueDecimal.DEFAULT_SCALE;
} }
if (precision < scale) {
precision = scale;
}
return new TypeInfo(Value.DECIMAL, precision, scale, MathUtils.convertLongToInt(precision + 2), null); return new TypeInfo(Value.DECIMAL, precision, scale, MathUtils.convertLongToInt(precision + 2), null);
case Value.TIME: case Value.TIME: {
if (scale < 0 || scale >= ValueTime.MAXIMUM_SCALE) { if (scale < 0 || scale >= ValueTime.MAXIMUM_SCALE) {
return TYPE_TIME; return TYPE_TIME;
} }
return new TypeInfo(Value.TIME, ValueTime.MAXIMUM_PRECISION, scale, ValueTime.DEFAULT_PRECISION, null); int d = scale == 0 ? 8 : 9 + scale;
case Value.TIMESTAMP: return new TypeInfo(Value.TIME, d, scale, d, null);
}
case Value.TIMESTAMP: {
if (scale < 0 || scale >= ValueTimestamp.MAXIMUM_SCALE) { if (scale < 0 || scale >= ValueTimestamp.MAXIMUM_SCALE) {
return TYPE_TIMESTAMP; return TYPE_TIMESTAMP;
} }
return new TypeInfo(Value.TIMESTAMP, ValueTimestamp.MAXIMUM_PRECISION, scale, int d = scale == 0 ? 19 : 20 + scale;
ValueTimestamp.MAXIMUM_PRECISION, null); return new TypeInfo(Value.TIMESTAMP, d, scale, d, null);
case Value.TIMESTAMP_TZ: }
case Value.TIMESTAMP_TZ: {
if (scale < 0 || scale >= ValueTimestampTimeZone.MAXIMUM_SCALE) { if (scale < 0 || scale >= ValueTimestampTimeZone.MAXIMUM_SCALE) {
return TYPE_TIMESTAMP_TZ; return TYPE_TIMESTAMP_TZ;
} }
return new TypeInfo(Value.TIMESTAMP_TZ, ValueTimestampTimeZone.MAXIMUM_PRECISION, scale, int d = scale == 0 ? 25 : 26 + scale;
ValueTimestampTimeZone.MAXIMUM_PRECISION, null); return new TypeInfo(Value.TIMESTAMP_TZ, d, scale, d, null);
}
case Value.BYTES: case Value.BYTES:
if (precision < 0) { if (precision < 0) {
precision = Integer.MAX_VALUE; precision = Integer.MAX_VALUE;
} }
return new TypeInfo(Value.BYTES, precision, scale, MathUtils.convertLongToInt(precision) * 2, null); return new TypeInfo(Value.BYTES, precision, 0, MathUtils.convertLongToInt(precision) * 2, null);
case Value.STRING: case Value.STRING:
if (precision < 0) { if (precision < 0) {
return TYPE_STRING_DEFAULT; return TYPE_STRING_DEFAULT;
......
...@@ -39,16 +39,6 @@ public class ValueTime extends Value { ...@@ -39,16 +39,6 @@ public class ValueTime extends Value {
*/ */
public static final int MAXIMUM_SCALE = 9; public static final int MAXIMUM_SCALE = 9;
/**
* Get display size for the specified scale.
*
* @param scale scale
* @return display size
*/
public static int getDisplaySize(int scale) {
return scale == 0 ? 8 : 9 + scale;
}
/** /**
* Nanoseconds since midnight * Nanoseconds since midnight
*/ */
......
...@@ -40,16 +40,6 @@ public class ValueTimestamp extends Value { ...@@ -40,16 +40,6 @@ public class ValueTimestamp extends Value {
*/ */
public static final int MAXIMUM_SCALE = 9; public static final int MAXIMUM_SCALE = 9;
/**
* Get display size for the specified scale.
*
* @param scale scale
* @return display size
*/
public static int getDisplaySize(int scale) {
return scale == 0 ? 19 : 20 + scale;
}
/** /**
* A bit field with bits for the year, month, and day (see DateTimeUtils for * A bit field with bits for the year, month, and day (see DateTimeUtils for
* encoding) * encoding)
......
...@@ -45,16 +45,6 @@ public class ValueTimestampTimeZone extends Value { ...@@ -45,16 +45,6 @@ public class ValueTimestampTimeZone extends Value {
*/ */
static final int MAXIMUM_SCALE = ValueTimestamp.MAXIMUM_SCALE; static final int MAXIMUM_SCALE = ValueTimestamp.MAXIMUM_SCALE;
/**
* Get display size for the specified scale.
*
* @param scale scale
* @return display size
*/
public static int getDisplaySize(int scale) {
return scale == 0 ? 25 : 26 + scale;
}
/** /**
* A bit field with bits for the year, month, and day (see DateTimeUtils for * A bit field with bits for the year, month, and day (see DateTimeUtils for
* encoding) * encoding)
......
...@@ -356,7 +356,7 @@ public class TestCases extends TestDb { ...@@ -356,7 +356,7 @@ public class TestCases extends TestDb {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test as select cast(0 as dec(10, 2)) x"); stat.execute("create table test as select cast(0 as dec(10, 2)) x");
ResultSetMetaData meta = stat.executeQuery("select * from test").getMetaData(); ResultSetMetaData meta = stat.executeQuery("select * from test").getMetaData();
assertEquals(2, meta.getPrecision(1)); assertEquals(10, meta.getPrecision(1));
assertEquals(2, meta.getScale(1)); assertEquals(2, meta.getScale(1));
stat.execute("alter table test add column y int"); stat.execute("alter table test add column y int");
stat.execute("drop table test"); stat.execute("drop table test");
......
...@@ -253,8 +253,8 @@ SELECT * FROM V3; ...@@ -253,8 +253,8 @@ SELECT * FROM V3;
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'E' ORDER BY TABLE_NAME;
> TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE > TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_PRECISION_RADIX NUMERIC_SCALE DATETIME_PRECISION INTERVAL_TYPE INTERVAL_PRECISION CHARACTER_SET_NAME COLLATION_NAME TYPE_NAME NULLABLE IS_COMPUTED SELECTIVITY CHECK_CONSTRAINT SEQUENCE_NAME REMARKS SOURCE_DATA_TYPE COLUMN_TYPE COLUMN_ON_UPDATE IS_VISIBLE
> ------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ---------- > ------------- ------------ ---------- ----------- ---------------- -------------- ------------- ----------- -------------- ----------- --------- ------------------------ ---------------------- ----------------- ----------------------- ------------- ------------------ ------------- ------------------ ------------------ -------------- --------- -------- ----------- ----------- ---------------- ------------- ------- ---------------- -------------- ---------------- ----------
> SCRIPT PUBLIC TEST E 1 null null null null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE > SCRIPT PUBLIC TEST E 1 null null null null YES 1111 10 10 10 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V E 1 null null null null YES 1111 2147483647 2147483647 2147483647 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE > SCRIPT PUBLIC V E 1 null null null null YES 1111 10 10 10 10 0 null null null Unicode OFF ENUM 1 FALSE 50 null null ENUM('A', 'B') null TRUE
> SCRIPT PUBLIC V1 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE > SCRIPT PUBLIC V1 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V2 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE > SCRIPT PUBLIC V2 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
> SCRIPT PUBLIC V3 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE > SCRIPT PUBLIC V3 E 1 null null null null YES 4 10 10 10 10 0 null null null Unicode OFF INTEGER 1 FALSE 50 null null INTEGER null TRUE
......
...@@ -6084,17 +6084,17 @@ SELECT ID FROM TEST WHERE XVI LIKE 'abc%'; ...@@ -6084,17 +6084,17 @@ SELECT ID FROM TEST WHERE XVI LIKE 'abc%';
> 3 > 3
> rows: 1 > rows: 1
SELECT 'abc', 'Papa Joe''s', CAST(-1 AS SMALLINT), CAST(2 AS BIGINT), CAST(0 AS DOUBLE), CAST('0a0f' AS BINARY), CAST(125 AS TINYINT), TRUE, FALSE FROM TEST WHERE ID=1; SELECT 'abc', 'Papa Joe''s', CAST(-1 AS SMALLINT), CAST(2 AS BIGINT), CAST(0 AS DOUBLE), CAST('0a0f' AS BINARY) B, CAST(125 AS TINYINT), TRUE, FALSE FROM TEST WHERE ID=1;
> 'abc' 'Papa Joe''s' -1 2 0.0 X'0a0f' 125 TRUE FALSE > 'abc' 'Papa Joe''s' -1 2 0.0 B 125 TRUE FALSE
> ----- ------------- -- - --- ------- --- ---- ----- > ----- ------------- -- - --- ---- --- ---- -----
> abc Papa Joe's -1 2 0.0 0a0f 125 TRUE FALSE > abc Papa Joe's -1 2 0.0 0a0f 125 TRUE FALSE
> rows: 1 > rows: 1
-- ' This apostrophe is here to fix syntax highlighting in the text editors. -- ' This apostrophe is here to fix syntax highlighting in the text editors.
SELECT CAST('abcd' AS VARCHAR(255)), CAST('ef_gh' AS VARCHAR(3)); SELECT CAST('abcd' AS VARCHAR(255)) C1, CAST('ef_gh' AS VARCHAR(3)) C2;
> 'abcd' 'ef_' > C1 C2
> ------ ----- > ---- ---
> abcd ef_ > abcd ef_
> rows: 1 > rows: 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论