Aggregates - Mailing list pgsql-sql

From qd@sea.com.ua
Subject Aggregates
Date
Msg-id 199907112043.UAA00468@zamarayev.localdomain
Whole thread Raw
List pgsql-sql
Hi, All !

PostgreSQL-6.4 lacks min/max functions for character types.
As I needed one I did the following:

create function max_str(bpchar, bpchar) returns bpchar as       'select $1 where bpchargt($1, $2) union select $2
wherebpcharge($2,$1)';
 

This function seems to work fine for 'char(20)'.

Next, I define the aggregate:

create aggregate smax (basetype=bpchar, sfunc1=max_str, stype1=bpchar,   initcond1='');

and I have a table with a column 'magic char(20)'

When I try to use my smax I get such an error:

select smax(magic) from my_table;

ERROR: bpcharin: the length of char() must be less than 4096.

I have no  char type with such length. I checked if my
function max_str returns a correct length:

select length(max_str('aab' 'ab'));

It returns 2 as it should be. 

So where is the bug ?





pgsql-sql by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Next
From: Oleg Bartunov
Date:
Subject: accumulated statistics