提交 17fac4b5 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Reject negative precision

上级 d6cebc3f
...@@ -4146,6 +4146,14 @@ public class Parser { ...@@ -4146,6 +4146,14 @@ public class Parser {
return i; return i;
} }
private long readNonNegativeLong() {
long v = readLong();
if (v < 0) {
throw DbException.getInvalidValueException("non-negative long", v);
}
return v;
}
private long readLong() { private long readLong() {
boolean minus = false; boolean minus = false;
if (currentTokenType == MINUS_SIGN) { if (currentTokenType == MINUS_SIGN) {
...@@ -5302,7 +5310,7 @@ public class Parser { ...@@ -5302,7 +5310,7 @@ public class Parser {
} }
} else if (readIf(OPEN_PAREN)) { } else if (readIf(OPEN_PAREN)) {
if (!readIf("MAX")) { if (!readIf("MAX")) {
long p = readLong(); long p = readNonNegativeLong();
if (readIf("K")) { if (readIf("K")) {
p *= 1024; p *= 1024;
} else if (readIf("M")) { } else if (readIf("M")) {
......
...@@ -2,3 +2,9 @@ ...@@ -2,3 +2,9 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
CREATE TABLE TEST(I NUMERIC(-1));
> exception INVALID_VALUE_2
CREATE TABLE TEST(I NUMERIC(-1, -1));
> exception INVALID_VALUE_2
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论