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 ?