提交 137a50dc authored 作者: Noel Grandin's avatar Noel Grandin

Improve error message when specifying incorrect scale/precision

上级 a09fa0fc
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
90048=Unsupported database file version or invalid file header in file {0} 90048=Unsupported database file version or invalid file header in file {0}
90049=Encryption error in file {0} 90049=Encryption error in file {0}
90050=Wrong password format, must be: file password <space> user password 90050=Wrong password format, must be: file password <space> user password
90051=Scale(${0}) must be <= precision({1})
90052=Subquery is not a single column query 90052=Subquery is not a single column query
90053=Scalar subquery contains more than one row 90053=Scalar subquery contains more than one row
90054=Invalid use of aggregate function {0} 90054=Invalid use of aggregate function {0}
......
...@@ -491,6 +491,16 @@ public class ErrorCode { ...@@ -491,6 +491,16 @@ public class ErrorCode {
*/ */
public static final int INVALID_VALUE_2 = 90008; public static final int INVALID_VALUE_2 = 90008;
/**
* The error with code <code>90051</code> is thrown when
* trying to use a scale that is > precision.
* Example:
* <pre>
* CREATE TABLE TABLE1 ( FAIL NUMBER(6,24) );
* </pre>
*/
public static final int INVALID_VALUE_SCALE_PRECISION = 90051;
/** /**
* The error with code <code>90009</code> is thrown when * The error with code <code>90009</code> is thrown when
* trying to create a sequence with an invalid combination * trying to create a sequence with an invalid combination
...@@ -1914,7 +1924,7 @@ public class ErrorCode { ...@@ -1914,7 +1924,7 @@ public class ErrorCode {
public static final int STEP_SIZE_MUST_NOT_BE_ZERO = 90142; public static final int STEP_SIZE_MUST_NOT_BE_ZERO = 90142;
// next are 90051, 90056, 90110, 90122, 90143 // next are 90056, 90110, 90122, 90143
private ErrorCode() { private ErrorCode() {
// utility class // utility class
......
...@@ -129,8 +129,8 @@ import org.h2.table.IndexColumn; ...@@ -129,8 +129,8 @@ import org.h2.table.IndexColumn;
import org.h2.table.RangeTable; import org.h2.table.RangeTable;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.table.TableView;
import org.h2.table.TableFilter.TableFilterVisitor; import org.h2.table.TableFilter.TableFilterVisitor;
import org.h2.table.TableView;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.New; import org.h2.util.New;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
...@@ -4068,9 +4068,8 @@ public class Parser { ...@@ -4068,9 +4068,8 @@ public class Parser {
readIf("UNSIGNED"); readIf("UNSIGNED");
int type = dataType.type; int type = dataType.type;
if (scale > precision) { if (scale > precision) {
throw DbException.get(ErrorCode.INVALID_VALUE_2, throw DbException.get(ErrorCode.INVALID_VALUE_SCALE_PRECISION,
Integer.toString(scale), "scale (precision = " + precision + Integer.toString(scale), Long.toString(precision));
")");
} }
Column column = new Column(columnName, type, precision, scale, Column column = new Column(columnName, type, precision, scale,
displaySize); displaySize);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论