Creating a table with NUMERIC(precision) results in error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Stado |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
The following command results in an error:
lss=> create table blahfive (prim NUMERIC(20));
ERROR: NUMERIC scale -1 must be between 0 and precision 20
On further investigation it was discovered that what is actually passed to a node is the following:
2011-10-07 15:33:40 IST STATEMENT: CREATE TABLE "blahfive" ("prim" NUMERIC (20, -1))
2011-10-07 15:35:07 IST ERROR: NUMERIC scale -1 must be between 0 and precision 20 at character 33
The scale parameter is being passed as -1, which is invalid.
On further investigation, I created a new NUMERIC TEMPLATE called NUMERIC_
Index: src/org/
=======
--- src/org/
+++ src/org/
@@ -61,6 +61,10 @@
public static final String NUMERIC_TEMPLATE = Property.get(
+// mike debug added for case when precision is non-zero but scale not specified
+ public static final String NUMERIC_
+ "xdb.sqltype.
+
public static final String NUMERIC_
This was added to the data type handler like so:
Index: src/org/
=======
--- src/org/
+++ src/org/
@@ -796,10 +796,17 @@
break;
case Types.NUMERIC:
- if (precision == -1) {
- typeString = NUMERIC_
- } else {
- typeString = NUMERIC_TEMPLATE;
+ if (precision == -1)
+ {
+ typeString = NUMERIC_
+ }
+ else if (scale == -1)
+ {
+ typeString = NUMERIC_
+ }
+ else
+ {
+ typeString = NUMERIC_TEMPLATE;
}
break;
case Types.TIMESTAMP:
Hoping the above is correct, thought it might be useful to report.
Mike
Thanks for the patch. I just committed it to the trunk.