Unverified 提交 46ac2ec7 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1714 from katzyn/value

Assorted changes
...@@ -21,6 +21,12 @@ Change Log ...@@ -21,6 +21,12 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1715: Postgres mode: Domain "regproc" already exists
</li>
<li>PR #1714: Assorted changes
</li>
<li>PR #1713: Remove DataType.defaultDisplaySize and fix display size in TypeInfo
</li>
<li>PR #1711: Add QUALIFY clause to SELECT command <li>PR #1711: Add QUALIFY clause to SELECT command
</li> </li>
<li>Issue #1708: CREATE TABLE AS doesn't support column lists without data types <li>Issue #1708: CREATE TABLE AS doesn't support column lists without data types
......
...@@ -279,12 +279,12 @@ public class Mode { ...@@ -279,12 +279,12 @@ public class Mode {
// MS SQL Server does not support client info properties. See // MS SQL Server does not support client info properties. See
// https://msdn.microsoft.com/en-Us/library/dd571296%28v=sql.110%29.aspx // https://msdn.microsoft.com/en-Us/library/dd571296%28v=sql.110%29.aspx
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
DataType dt = DataType.createDecimal(19, 19, 4, 21, false, false); DataType dt = DataType.createNumeric(19, 4, false);
dt.type = Value.DECIMAL; dt.type = Value.DECIMAL;
dt.sqlType = Types.NUMERIC; dt.sqlType = Types.NUMERIC;
dt.name = "MONEY"; dt.name = "MONEY";
mode.typeByNameMap.put("MONEY", dt); mode.typeByNameMap.put("MONEY", dt);
dt = DataType.createDecimal(10, 10, 4, 12, false, false); dt = DataType.createNumeric(10, 4, false);
dt.type = Value.DECIMAL; dt.type = Value.DECIMAL;
dt.sqlType = Types.NUMERIC; dt.sqlType = Types.NUMERIC;
dt.name = "SMALLMONEY"; dt.name = "SMALLMONEY";
...@@ -348,7 +348,7 @@ public class Mode { ...@@ -348,7 +348,7 @@ public class Mode {
disallowedTypes.add("TINYINT"); disallowedTypes.add("TINYINT");
disallowedTypes.add("BLOB"); disallowedTypes.add("BLOB");
mode.disallowedTypes = disallowedTypes; mode.disallowedTypes = disallowedTypes;
dt = DataType.createDecimal(19, 19, 2, 21, false, false); dt = DataType.createNumeric(19, 2, false);
dt.type = Value.DECIMAL; dt.type = Value.DECIMAL;
dt.sqlType = Types.NUMERIC; dt.sqlType = Types.NUMERIC;
dt.name = "MONEY"; dt.name = "MONEY";
......
...@@ -15,7 +15,7 @@ import org.h2.table.ColumnResolver; ...@@ -15,7 +15,7 @@ import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
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.ValueCollectionBase;
/** /**
* An expression is a operation, a value, or a function in a query. * An expression is a operation, a value, or a function in a query.
...@@ -370,7 +370,7 @@ public abstract class Expression { ...@@ -370,7 +370,7 @@ public abstract class Expression {
* @param value the value to extract columns from * @param value the value to extract columns from
* @return array of expression columns * @return array of expression columns
*/ */
protected static Expression[] getExpressionColumns(Session session, ValueArray value) { protected static Expression[] getExpressionColumns(Session session, ValueCollectionBase value) {
Value[] list = value.getList(); Value[] list = value.getList();
ExpressionColumn[] expr = new ExpressionColumn[list.length]; ExpressionColumn[] expr = new ExpressionColumn[list.length];
for (int i = 0, len = list.length; i < len; i++) { for (int i = 0, len = list.length; i < len; i++) {
......
...@@ -13,8 +13,8 @@ import org.h2.table.ColumnResolver; ...@@ -13,8 +13,8 @@ import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
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.ValueBoolean; import org.h2.value.ValueBoolean;
import org.h2.value.ValueCollectionBase;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
/** /**
...@@ -163,8 +163,9 @@ public class ValueExpression extends Expression { ...@@ -163,8 +163,9 @@ public class ValueExpression extends Expression {
@Override @Override
public Expression[] getExpressionColumns(Session session) { public Expression[] getExpressionColumns(Session session) {
if (getType().getValueType() == Value.ARRAY) { int valueType = getType().getValueType();
return getExpressionColumns(session, (ValueArray) getValue(session)); if (valueType == Value.ARRAY || valueType == Value.ROW) {
return getExpressionColumns(session, (ValueCollectionBase) getValue(session));
} }
return super.getExpressionColumns(session); return super.getExpressionColumns(session);
} }
......
...@@ -161,6 +161,7 @@ public class JavaFunction extends Expression implements FunctionCall { ...@@ -161,6 +161,7 @@ public class JavaFunction extends Expression implements FunctionCall {
ValueResultSet rs = getValueForColumnList(session, getArgs()); ValueResultSet rs = getValueForColumnList(session, getArgs());
return getExpressionColumns(session, rs.getResult()); return getExpressionColumns(session, rs.getResult());
case Value.ARRAY: case Value.ARRAY:
case Value.ROW:
return getExpressionColumns(session, (ValueArray) getValue(session)); return getExpressionColumns(session, (ValueArray) getValue(session));
} }
return super.getExpressionColumns(session); return super.getExpressionColumns(session);
......
...@@ -107,6 +107,7 @@ merge into pg_catalog.pg_type values( ...@@ -107,6 +107,7 @@ merge into pg_catalog.pg_type values(
null null
); );
drop domain if exists regproc cascade;
create domain regproc as varchar_ignorecase; create domain regproc as varchar_ignorecase;
create view pg_catalog.pg_class -- (oid, relname, relnamespace, relkind, relam, reltuples, reltablespace, relpages, relhasindex, relhasrules, relhasoids, relchecks, reltriggers) create view pg_catalog.pg_class -- (oid, relname, relnamespace, relkind, relam, reltuples, reltablespace, relpages, relhasindex, relhasrules, relhasoids, relchecks, reltriggers)
......
...@@ -456,8 +456,8 @@ public final class JTSUtils { ...@@ -456,8 +456,8 @@ public final class JTSUtils {
int d = sequence.getDimension(); int d = sequence.getDimension();
if (M_IS_SUPPORTED) { if (M_IS_SUPPORTED) {
d -= measures; d -= measures;
z = d > 2 ? sequence.getOrdinate(index, Z) : Double.NaN; z = d > 2 ? toCanonicalDouble(sequence.getOrdinate(index, Z)) : Double.NaN;
m = measures >= 1 ? sequence.getOrdinate(index, d) : Double.NaN; m = measures >= 1 ? toCanonicalDouble(sequence.getOrdinate(index, d)) : Double.NaN;
} else { } else {
z = d >= 3 ? toCanonicalDouble(sequence.getOrdinate(index, Z)) : Double.NaN; z = d >= 3 ? toCanonicalDouble(sequence.getOrdinate(index, Z)) : Double.NaN;
m = d >= 4 ? toCanonicalDouble(sequence.getOrdinate(index, M)) : Double.NaN; m = d >= 4 ? toCanonicalDouble(sequence.getOrdinate(index, M)) : Double.NaN;
......
...@@ -314,7 +314,11 @@ public abstract class Value extends VersionedValue { ...@@ -314,7 +314,11 @@ public abstract class Value extends VersionedValue {
* @return the memory used in bytes * @return the memory used in bytes
*/ */
public int getMemory() { public int getMemory() {
return DataType.getDataType(getValueType()).memory; /*
* Java 11 with -XX:-UseCompressedOops for all values up to ValueLong
* and ValueDouble.
*/
return 24;
} }
/** /**
......
...@@ -50,6 +50,12 @@ public class ValueBoolean extends Value { ...@@ -50,6 +50,12 @@ public class ValueBoolean extends Value {
return BOOLEAN; return BOOLEAN;
} }
@Override
public int getMemory() {
// Singleton TRUE and FALSE values
return 0;
}
@Override @Override
public StringBuilder getSQL(StringBuilder builder) { public StringBuilder getSQL(StringBuilder builder) {
return builder.append(getString()); return builder.append(getString());
......
...@@ -123,7 +123,7 @@ public abstract class ValueCollectionBase extends Value { ...@@ -123,7 +123,7 @@ public abstract class ValueCollectionBase extends Value {
@Override @Override
public int getMemory() { public int getMemory() {
int memory = 32; int memory = 72;
for (Value v : values) { for (Value v : values) {
memory += v.getMemory() + Constants.MEMORY_POINTER; memory += v.getMemory() + Constants.MEMORY_POINTER;
} }
......
...@@ -103,6 +103,11 @@ public class ValueEnumBase extends Value { ...@@ -103,6 +103,11 @@ public class ValueEnumBase extends Value {
return ENUM; return ENUM;
} }
@Override
public int getMemory() {
return 120;
}
@Override @Override
public int hashCode() { public int hashCode() {
int results = 31; int results = 31;
......
...@@ -171,6 +171,12 @@ public class ValueInterval extends Value { ...@@ -171,6 +171,12 @@ public class ValueInterval extends Value {
return valueType; return valueType;
} }
@Override
public int getMemory() {
// Java 11 with -XX:-UseCompressedOops
return 48;
}
@Override @Override
public Value convertScale(boolean onlyToSmallerScale, int targetScale) { public Value convertScale(boolean onlyToSmallerScale, int targetScale) {
if (targetScale >= MAXIMUM_SCALE) { if (targetScale >= MAXIMUM_SCALE) {
......
...@@ -183,9 +183,9 @@ public class ValueJavaObject extends ValueBytes { ...@@ -183,9 +183,9 @@ public class ValueJavaObject extends ValueBytes {
@Override @Override
public int getMemory() { public int getMemory() {
if (value == null) { if (value == null) {
return DataType.getDataType(getValueType()).memory; return 40;
} }
int mem = super.getMemory(); int mem = 40;
if (javaObject != null) { if (javaObject != null) {
mem *= 2; mem *= 2;
} }
......
...@@ -515,7 +515,12 @@ public class ValueLobDb extends Value { ...@@ -515,7 +515,12 @@ public class ValueLobDb extends Value {
@Override @Override
public int getMemory() { public int getMemory() {
if (small != null) { if (small != null) {
return small.length + 104; /*
* Java 11 with -XX:-UseCompressedOops
* 0 bytes: 120 bytes
* 1 byte: 128 bytes
*/
return small.length + 127;
} }
return 140; return 140;
} }
......
...@@ -63,6 +63,12 @@ public class ValueNull extends Value { ...@@ -63,6 +63,12 @@ public class ValueNull extends Value {
return NULL; return NULL;
} }
@Override
public int getMemory() {
// Singleton value
return 0;
}
@Override @Override
public String getString() { public String getString() {
return null; return null;
......
...@@ -106,6 +106,11 @@ public class ValueResultSet extends Value { ...@@ -106,6 +106,11 @@ public class ValueResultSet extends Value {
return RESULT_SET; return RESULT_SET;
} }
@Override
public int getMemory() {
return result.getRowCount() * result.getVisibleColumnCount() * 32 + 400;
}
@Override @Override
public String getString() { public String getString() {
StringBuilder buff = new StringBuilder("("); StringBuilder buff = new StringBuilder("(");
......
...@@ -69,7 +69,12 @@ public class ValueString extends Value { ...@@ -69,7 +69,12 @@ public class ValueString extends Value {
@Override @Override
public int getMemory() { public int getMemory() {
return value.length() * 2 + 48; /*
* Java 11 with -XX:-UseCompressedOops
* Empty string: 88 bytes
* 1 to 4 UTF-16 chars: 96 bytes
*/
return value.length() * 2 + 94;
} }
@Override @Override
......
...@@ -176,6 +176,11 @@ public class ValueTimestamp extends Value { ...@@ -176,6 +176,11 @@ public class ValueTimestamp extends Value {
return TIMESTAMP; return TIMESTAMP;
} }
@Override
public int getMemory() {
return 32;
}
@Override @Override
public String getString() { public String getString() {
StringBuilder buff = new StringBuilder(MAXIMUM_PRECISION); StringBuilder buff = new StringBuilder(MAXIMUM_PRECISION);
......
...@@ -168,6 +168,12 @@ public class ValueTimestampTimeZone extends Value { ...@@ -168,6 +168,12 @@ public class ValueTimestampTimeZone extends Value {
return TIMESTAMP_TZ; return TIMESTAMP_TZ;
} }
@Override
public int getMemory() {
// Java 11 with -XX:-UseCompressedOops
return 40;
}
@Override @Override
public String getString() { public String getString() {
StringBuilder builder = new StringBuilder(ValueTimestampTimeZone.MAXIMUM_PRECISION); StringBuilder builder = new StringBuilder(ValueTimestampTimeZone.MAXIMUM_PRECISION);
......
...@@ -136,6 +136,11 @@ public class ValueUuid extends Value { ...@@ -136,6 +136,11 @@ public class ValueUuid extends Value {
return TypeInfo.TYPE_UUID; return TypeInfo.TYPE_UUID;
} }
@Override
public int getMemory() {
return 32;
}
@Override @Override
public int getValueType() { public int getValueType() {
return UUID; return UUID;
......
...@@ -637,7 +637,7 @@ public class TestMVTableEngine extends TestDb { ...@@ -637,7 +637,7 @@ public class TestMVTableEngine extends TestDb {
String readCount = plan.substring(plan.indexOf("reads: ")); String readCount = plan.substring(plan.indexOf("reads: "));
readCount = readCount.substring("reads: ".length(), readCount.indexOf('\n')); readCount = readCount.substring("reads: ".length(), readCount.indexOf('\n'));
int rc = Integer.parseInt(readCount); int rc = Integer.parseInt(readCount);
assertTrue(plan, rc >= 60 && rc <= 70); assertTrue(plan, rc >= 60 && rc <= 80);
// assertTrue(plan, rc >= 1000 && rc <= 1200); // assertTrue(plan, rc >= 1000 && rc <= 1200);
conn.close(); conn.close();
} }
......
...@@ -806,4 +806,4 @@ econd irst bcef ordinality nord unnest ...@@ -806,4 +806,4 @@ econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论