diff --git a/h2/src/main/org/h2/value/DataType.java b/h2/src/main/org/h2/value/DataType.java index 89520feee0..3d84029afe 100644 --- a/h2/src/main/org/h2/value/DataType.java +++ b/h2/src/main/org/h2/value/DataType.java @@ -312,8 +312,8 @@ private static DataType createGeometry() { dataType.prefix = "'"; dataType.suffix = "'"; dataType.params = "TYPE,SRID"; - dataType.maxPrecision = Constants.MAX_STRING_LENGTH; - dataType.defaultPrecision = Constants.MAX_STRING_LENGTH; + dataType.maxPrecision = Long.MAX_VALUE; + dataType.defaultPrecision = Long.MAX_VALUE; return dataType; } diff --git a/h2/src/main/org/h2/value/ValueBinary.java b/h2/src/main/org/h2/value/ValueBinary.java index 8dd921b620..aa0ea9e258 100644 --- a/h2/src/main/org/h2/value/ValueBinary.java +++ b/h2/src/main/org/h2/value/ValueBinary.java @@ -6,8 +6,10 @@ package org.h2.value; import java.nio.charset.StandardCharsets; - +import org.h2.engine.Constants; import org.h2.engine.SysProperties; +import org.h2.message.DbException; +import org.h2.util.StringUtils; import org.h2.util.Utils; /** @@ -22,6 +24,11 @@ public final class ValueBinary extends ValueBytesBase { protected ValueBinary(byte[] value) { super(value); + int length = value.length; + if (length > Constants.MAX_STRING_LENGTH) { + throw DbException.getValueTooLongException(getTypeName(getValueType()), + StringUtils.convertBytesToHex(value, 41), length); + } } /** diff --git a/h2/src/main/org/h2/value/ValueBytesBase.java b/h2/src/main/org/h2/value/ValueBytesBase.java index e06a338142..288cab1675 100644 --- a/h2/src/main/org/h2/value/ValueBytesBase.java +++ b/h2/src/main/org/h2/value/ValueBytesBase.java @@ -30,11 +30,6 @@ abstract class ValueBytesBase extends Value { int hash; ValueBytesBase(byte[] value) { - int length = value.length; - if (length > Constants.MAX_STRING_LENGTH) { - throw DbException.getValueTooLongException(getTypeName(getValueType()), - StringUtils.convertBytesToHex(value, 41), length); - } this.value = value; } diff --git a/h2/src/main/org/h2/value/ValueJavaObject.java b/h2/src/main/org/h2/value/ValueJavaObject.java index f6eb6f3773..f1a1cad4d6 100644 --- a/h2/src/main/org/h2/value/ValueJavaObject.java +++ b/h2/src/main/org/h2/value/ValueJavaObject.java @@ -6,8 +6,10 @@ package org.h2.value; import org.h2.api.ErrorCode; +import org.h2.engine.Constants; import org.h2.engine.SysProperties; import org.h2.message.DbException; +import org.h2.util.StringUtils; import org.h2.util.Utils; /** @@ -19,6 +21,11 @@ public final class ValueJavaObject extends ValueBytesBase { protected ValueJavaObject(byte[] v) { super(v); + int length = value.length; + if (length > Constants.MAX_STRING_LENGTH) { + throw DbException.getValueTooLongException(getTypeName(getValueType()), + StringUtils.convertBytesToHex(value, 41), length); + } } /** diff --git a/h2/src/main/org/h2/value/ValueJson.java b/h2/src/main/org/h2/value/ValueJson.java index 7d913855fd..7e615647f0 100644 --- a/h2/src/main/org/h2/value/ValueJson.java +++ b/h2/src/main/org/h2/value/ValueJson.java @@ -11,6 +11,7 @@ import java.util.Arrays; import org.h2.api.ErrorCode; +import org.h2.engine.Constants; import org.h2.message.DbException; import org.h2.util.StringUtils; import org.h2.util.json.JSONByteArrayTarget; @@ -50,6 +51,11 @@ public final class ValueJson extends ValueBytesBase { private ValueJson(byte[] value) { super(value); + int length = value.length; + if (length > Constants.MAX_STRING_LENGTH) { + throw DbException.getValueTooLongException(getTypeName(getValueType()), + StringUtils.convertBytesToHex(value, 41), length); + } } @Override diff --git a/h2/src/main/org/h2/value/ValueVarbinary.java b/h2/src/main/org/h2/value/ValueVarbinary.java index 163bc76bc9..77d6ee1aed 100644 --- a/h2/src/main/org/h2/value/ValueVarbinary.java +++ b/h2/src/main/org/h2/value/ValueVarbinary.java @@ -6,8 +6,10 @@ package org.h2.value; import java.nio.charset.StandardCharsets; - +import org.h2.engine.Constants; import org.h2.engine.SysProperties; +import org.h2.message.DbException; +import org.h2.util.StringUtils; import org.h2.util.Utils; /** @@ -27,6 +29,11 @@ public final class ValueVarbinary extends ValueBytesBase { protected ValueVarbinary(byte[] value) { super(value); + int length = value.length; + if (length > Constants.MAX_STRING_LENGTH) { + throw DbException.getValueTooLongException(getTypeName(getValueType()), + StringUtils.convertBytesToHex(value, 41), length); + } } /**