Re: [HACKERS] (stupid) bug in agg_select_candidate - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] (stupid) bug in agg_select_candidate
Date
Msg-id 3680950B.6C7E98BB@alumni.caltech.edu
Whole thread Raw
In response to (stupid) bug in agg_select_candidate  (David Sauer <davids@iol.cz>)
List pgsql-hackers
>   I'm trying postgres 6.4.1 and I have problem with select command:
> > create table t( text_column text );
> > select sum( text_column ) from t;
> This command makes no sense, but causes crash in backend:

Thanks for finding this. It was in new code for automatic type matching
and coersion on aggregate functions to help implement aggregates for the
string types.

I've enclosed a simple patch which fixes the problem, and which at the
same time makes a nicer warning message as a result:

postgres=> select sum(c) from cc;
ERROR:  Unable to select an aggregate function sum(bpchar)
postgres=> select min(c) from cc;
min
----------
abc
(1 row)

Will commit to the cvs tree sometime soon; let me know if you have any
continuing problems. Good luck.

                      - Tom*** ../src/backend/parser/parse_func.c.orig    Sun Dec 20 17:35:27 1998
--- ../src/backend/parser/parse_func.c    Wed Dec 23 06:50:44 1998
***************
*** 225,231 ****
              }
          }
          /* otherwise, don't bother keeping this one around... */
!         else
          {
              last_candidate->next = NULL;
          }
--- 225,231 ----
              }
          }
          /* otherwise, don't bother keeping this one around... */
!         else if (last_candidate != NULL)
          {
              last_candidate->next = NULL;
          }
***************
*** 399,406 ****
                  }
                  else
                  {
!                     elog(ERROR,"Unable to select an aggregate function for type '%s'",
!                          typeidTypeName(basetype));
                  }
              }

--- 399,406 ----
                  }
                  else
                  {
!                     elog(ERROR,"Unable to select an aggregate function %s(%s)",
!                          funcname, typeidTypeName(basetype));
                  }
              }


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Problems on NUMERIC
Next
From: David Sauer
Date:
Subject: Re: [HACKERS] (stupid) bug in agg_select_candidate