Using functions with indexes - Mailing list pgsql-general

From Alain TESIO
Subject Using functions with indexes
Date
Msg-id 008c01bf2fc8$cd5c34c0$f65f72c3@atesio
Whole thread Raw
List pgsql-general
Hello,

I want to use an index for comparisons on strings which are
not case-sensitive (I'm currently using col2=lower(col1))

The type of the column is char(30), it looks like I can't
use the function lower directly as it's not working on
the right type :

dip=> create index idx_tmpplayer_add_low on TMPPLAYER ( lower ( EM_ADDRESS )
text_ops );
ERROR:  BuildFuncTupleDesc: function 'lower(bpchar)' does not exist

But I can't manage to define such a function I need for the index, what's
the trick ?

dip=> create function mylower(char) returns char as 'select lower($1)'
language 'sql';
ERROR:  return type mismatch in function: declared to return char, returns
text
dip=> create function mylower(char) returns char as 'select
char(lower(char_text($1)))' language 'sql';
ERROR:  parser: parse error at or near "lower"


Thanks
Alain



pgsql-general by date:

Previous
From: "Alain TESIO"
Date:
Subject: Basic question about indexes (6.5.2)
Next
From: "Aaron J. Seigo"
Date:
Subject: Re: [GENERAL] Basic question about indexes (6.5.2)