提交 c1010fba authored 作者: Thomas Mueller's avatar Thomas Mueller

The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.

上级 9daa8ba8
...@@ -17,7 +17,8 @@ Change Log ...@@ -17,7 +17,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in <ul><li>The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
</li><li>Issue 573: Add implementation for Methods "isWrapperFor()" and "unwrap()" in
other JDBC classes. other JDBC classes.
</li><li>Issue 572: MySQL compatibility for "order by" in update statements. </li><li>Issue 572: MySQL compatibility for "order by" in update statements.
</li><li>The change in JDBC escape processing in version 1.4.181 affects both the parser </li><li>The change in JDBC escape processing in version 1.4.181 affects both the parser
......
...@@ -536,7 +536,7 @@ public class Parser { ...@@ -536,7 +536,7 @@ public class Parser {
private Prepared parseAnalyze() { private Prepared parseAnalyze() {
Analyze command = new Analyze(session); Analyze command = new Analyze(session);
if (readIf("SAMPLE_SIZE")) { if (readIf("SAMPLE_SIZE")) {
command.setTop(getPositiveInt()); command.setTop(readPositiveInt());
} }
return command; return command;
} }
...@@ -2966,15 +2966,15 @@ public class Parser { ...@@ -2966,15 +2966,15 @@ public class Parser {
return function; return function;
} }
private int getPositiveInt() { private int readPositiveInt() {
int v = getInt(); int v = readInt();
if (v < 0) { if (v < 0) {
throw DbException.getInvalidValueException("positive integer", v); throw DbException.getInvalidValueException("positive integer", v);
} }
return v; return v;
} }
private int getInt() { private int readInt() {
boolean minus = false; boolean minus = false;
if (currentTokenType == MINUS) { if (currentTokenType == MINUS) {
minus = true; minus = true;
...@@ -2982,12 +2982,16 @@ public class Parser { ...@@ -2982,12 +2982,16 @@ public class Parser {
} else if (currentTokenType == PLUS) { } else if (currentTokenType == PLUS) {
read(); read();
} }
if (currentTokenType != VALUE || currentValue.getType() != Value.INT) { if (currentTokenType != VALUE) {
throw DbException.getSyntaxError(sqlCommand, parseIndex, "integer"); throw DbException.getSyntaxError(sqlCommand, parseIndex, "integer");
} }
if (minus) {
// must do that now, otherwise Integer.MIN_VALUE wouldn't work
currentValue = currentValue.negate();
}
int i = currentValue.getInt(); int i = currentValue.getInt();
read(); read();
return minus ? -i : i; return i;
} }
private long readLong() { private long readLong() {
...@@ -2995,14 +2999,19 @@ public class Parser { ...@@ -2995,14 +2999,19 @@ public class Parser {
if (currentTokenType == MINUS) { if (currentTokenType == MINUS) {
minus = true; minus = true;
read(); read();
} else if (currentTokenType == PLUS) {
read();
} }
if (currentTokenType != VALUE || if (currentTokenType != VALUE) {
(currentValue.getType() != Value.INT && currentValue.getType() != Value.LONG)) {
throw DbException.getSyntaxError(sqlCommand, parseIndex, "long"); throw DbException.getSyntaxError(sqlCommand, parseIndex, "long");
} }
if (minus) {
// must do that now, otherwise Long.MIN_VALUE wouldn't work
currentValue = currentValue.negate();
}
long i = currentValue.getLong(); long i = currentValue.getLong();
read(); read();
return minus ? -i : i; return i;
} }
private boolean readBooleanSetting() { private boolean readBooleanSetting() {
...@@ -3901,7 +3910,7 @@ public class Parser { ...@@ -3901,7 +3910,7 @@ public class Parser {
column.setSequence(sequence); column.setSequence(sequence);
} }
if (readIf("SELECTIVITY")) { if (readIf("SELECTIVITY")) {
int value = getPositiveInt(); int value = readPositiveInt();
column.setSelectivity(value); column.setSelectivity(value);
} }
String comment = readCommentIf(); String comment = readCommentIf();
...@@ -4005,7 +4014,7 @@ public class Parser { ...@@ -4005,7 +4014,7 @@ public class Parser {
readIf("CHAR"); readIf("CHAR");
if (dataType.supportsScale) { if (dataType.supportsScale) {
if (readIf(",")) { if (readIf(",")) {
scale = getInt(); scale = readInt();
original += ", " + scale; original += ", " + scale;
} else { } else {
// special case: TIMESTAMP(5) actually means // special case: TIMESTAMP(5) actually means
...@@ -4027,7 +4036,7 @@ public class Parser { ...@@ -4027,7 +4036,7 @@ public class Parser {
} else if (readIf("(")) { } else if (readIf("(")) {
// Support for MySQL: INT(11), MEDIUMINT(8) and so on. // Support for MySQL: INT(11), MEDIUMINT(8) and so on.
// Just ignore the precision. // Just ignore the precision.
getPositiveInt(); readPositiveInt();
read(")"); read(")");
} }
if (readIf("FOR")) { if (readIf("FOR")) {
...@@ -4532,7 +4541,7 @@ public class Parser { ...@@ -4532,7 +4541,7 @@ public class Parser {
command.setRowBased(false); command.setRowBased(false);
} }
if (readIf("QUEUE")) { if (readIf("QUEUE")) {
command.setQueueSize(getPositiveInt()); command.setQueueSize(readPositiveInt());
} }
command.setNoWait(readIf("NOWAIT")); command.setNoWait(readIf("NOWAIT"));
read("CALL"); read("CALL");
...@@ -4940,7 +4949,7 @@ public class Parser { ...@@ -4940,7 +4949,7 @@ public class Parser {
} else if (readIf("NUMBERS")) { } else if (readIf("NUMBERS")) {
command.setInt(Constants.ALLOW_LITERALS_NUMBERS); command.setInt(Constants.ALLOW_LITERALS_NUMBERS);
} else { } else {
command.setInt(getPositiveInt()); command.setInt(readPositiveInt());
} }
return command; return command;
} else if (readIf("DEFAULT_TABLE_TYPE")) { } else if (readIf("DEFAULT_TABLE_TYPE")) {
...@@ -4951,7 +4960,7 @@ public class Parser { ...@@ -4951,7 +4960,7 @@ public class Parser {
} else if (readIf("CACHED")) { } else if (readIf("CACHED")) {
command.setInt(Table.TYPE_CACHED); command.setInt(Table.TYPE_CACHED);
} else { } else {
command.setInt(getPositiveInt()); command.setInt(readPositiveInt());
} }
return command; return command;
} else if (readIf("CREATE")) { } else if (readIf("CREATE")) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论