Functions don't work with NUMERIC type

Bug #872213 reported by Mike
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stado
Fix Committed
Undecided
Unassigned

Bug Description

Discovered a bug relating to functions taking a numeric type as an argument:
Example:

select sum(count) from testtable;

results in:
ERROR: Can not prepare request: Unable To Determine Type For (SQLEXPRESSION):sum( "testtable"."count")

I suspect this error also relates to max and various other functions.

This was found to be related to a type getTypeString issue for NUMERIC, and the following was applied to fix the problem:

[lpmike@dredd stado]$ svn diff src/org/postgresql/stado/parser/ExpressionType.java
Index: src/org/postgresql/stado/parser/ExpressionType.java
===================================================================
--- src/org/postgresql/stado/parser/ExpressionType.java (revision 6482)
+++ src/org/postgresql/stado/parser/ExpressionType.java (working copy)
@@ -334,7 +334,6 @@
      */
     public String getTypeString() {
         String typeString = "";
-
         HashMap<String, String> params = new HashMap<String, String>();
         params.put("length", new String(length + ""));
         params.put("scale", new String(scale + ""));
@@ -394,9 +393,19 @@
             break;

         case java.sql.Types.NUMERIC:
- if (scale != 0) {
+ if (scale != 0)
+ {
                 typeString = TypeConstants.NUMERIC_TEMPLATE;
             }
+// mike added 2 more cases to NUMERIC template
+ else if (precision > 0)
+ {
+ typeString = TypeConstants.NUMERIC_TEMPLATE_WITHOUT_SCALE;
+ }
+ else
+ {
+ typeString = TypeConstants.NUMERIC_TEMPLATE_WITHOUT_PRECISION;
+ }
             typeString = ParseCmdLine.substitute(typeString, params);
             break;

Hope this helps :)

Mike

Revision history for this message
Jim Mlodgenski (jim-cirrusql) wrote :

This fix has been committed. Thanks for the patch

Changed in stado:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.