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

Rename Parser.readPositiveInt() to correct readNonNegativeInt()

上级 f8dfcd0d
...@@ -575,7 +575,7 @@ public class Parser { ...@@ -575,7 +575,7 @@ public class Parser {
command.setTable(table); command.setTable(table);
} }
if (readIf("SAMPLE_SIZE")) { if (readIf("SAMPLE_SIZE")) {
command.setTop(readPositiveInt()); command.setTop(readNonNegativeInt());
} }
return command; return command;
} }
...@@ -3408,10 +3408,10 @@ public class Parser { ...@@ -3408,10 +3408,10 @@ public class Parser {
return function; return function;
} }
private int readPositiveInt() { private int readNonNegativeInt() {
int v = readInt(); int v = readInt();
if (v < 0) { if (v < 0) {
throw DbException.getInvalidValueException("positive integer", v); throw DbException.getInvalidValueException("non-negative integer", v);
} }
return v; return v;
} }
...@@ -4314,7 +4314,7 @@ public class Parser { ...@@ -4314,7 +4314,7 @@ public class Parser {
column.setSequence(sequence); column.setSequence(sequence);
} }
if (readIf("SELECTIVITY")) { if (readIf("SELECTIVITY")) {
int value = readPositiveInt(); int value = readNonNegativeInt();
column.setSelectivity(value); column.setSelectivity(value);
} }
String comment = readCommentIf(); String comment = readCommentIf();
...@@ -4362,7 +4362,7 @@ public class Parser { ...@@ -4362,7 +4362,7 @@ public class Parser {
} }
} else if (readIf("TIME")) { } else if (readIf("TIME")) {
if (readIf("(")) { if (readIf("(")) {
originalScale = readPositiveInt(); originalScale = readNonNegativeInt();
if (originalScale > ValueTime.MAXIMUM_SCALE) { if (originalScale > ValueTime.MAXIMUM_SCALE) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(originalScale)); throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(originalScale));
} }
...@@ -4375,10 +4375,10 @@ public class Parser { ...@@ -4375,10 +4375,10 @@ public class Parser {
} }
} else if (readIf("TIMESTAMP")) { } else if (readIf("TIMESTAMP")) {
if (readIf("(")) { if (readIf("(")) {
originalScale = readPositiveInt(); originalScale = readNonNegativeInt();
// Allow non-standard TIMESTAMP(..., ...) syntax // Allow non-standard TIMESTAMP(..., ...) syntax
if (readIf(",")) { if (readIf(",")) {
originalScale = readPositiveInt(); originalScale = readNonNegativeInt();
} }
if (originalScale > ValueTimestamp.MAXIMUM_SCALE) { if (originalScale > ValueTimestamp.MAXIMUM_SCALE) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(originalScale)); throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(originalScale));
...@@ -4466,7 +4466,7 @@ public class Parser { ...@@ -4466,7 +4466,7 @@ public class Parser {
} }
} else if (original.equals("DATETIME") || original.equals("DATETIME2")) { } else if (original.equals("DATETIME") || original.equals("DATETIME2")) {
if (readIf("(")) { if (readIf("(")) {
originalScale = readPositiveInt(); originalScale = readNonNegativeInt();
if (originalScale > ValueTime.MAXIMUM_SCALE) { if (originalScale > ValueTime.MAXIMUM_SCALE) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION,
Integer.toString(originalScale)); Integer.toString(originalScale));
...@@ -4514,7 +4514,7 @@ public class Parser { ...@@ -4514,7 +4514,7 @@ public class Parser {
} }
} else if (dataType.type == Value.DOUBLE && original.equals("FLOAT")) { } else if (dataType.type == Value.DOUBLE && original.equals("FLOAT")) {
if (readIf("(")) { if (readIf("(")) {
int p = readPositiveInt(); int p = readNonNegativeInt();
read(")"); read(")");
if (p > 53) { if (p > 53) {
throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(p)); throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION, Integer.toString(p));
...@@ -4548,7 +4548,7 @@ public class Parser { ...@@ -4548,7 +4548,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.
readPositiveInt(); readNonNegativeInt();
read(")"); read(")");
} }
if (readIf("FOR")) { if (readIf("FOR")) {
...@@ -5095,7 +5095,7 @@ public class Parser { ...@@ -5095,7 +5095,7 @@ public class Parser {
command.setRowBased(false); command.setRowBased(false);
} }
if (readIf("QUEUE")) { if (readIf("QUEUE")) {
command.setQueueSize(readPositiveInt()); command.setQueueSize(readNonNegativeInt());
} }
command.setNoWait(readIf("NOWAIT")); command.setNoWait(readIf("NOWAIT"));
if (readIf("AS")) { if (readIf("AS")) {
...@@ -5661,7 +5661,7 @@ public class Parser { ...@@ -5661,7 +5661,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(readPositiveInt()); command.setInt(readNonNegativeInt());
} }
return command; return command;
} else if (readIf("DEFAULT_TABLE_TYPE")) { } else if (readIf("DEFAULT_TABLE_TYPE")) {
...@@ -5672,7 +5672,7 @@ public class Parser { ...@@ -5672,7 +5672,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(readPositiveInt()); command.setInt(readNonNegativeInt());
} }
return command; return command;
} else if (readIf("CREATE")) { } else if (readIf("CREATE")) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论