Re: Functional index definition

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Josué Maldonado <josue(at)lamundial(dot)hn>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Functional index definition
Date: 2003-11-11 15:32:23
Message-ID: 20031111073008.Y60760@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Tue, 11 Nov 2003, [ISO-8859-1] Josué Maldonado wrote:

> Hello list,
>
> Is there a way to create indexes using functions like these:
> substring(prod_no,8,4)
> to_char(fkardex,'YYYYMM')
> substr(facnum,1,2)
>
> Help says is not possible but I would like to know if someone know an
> undocumented/tricky way to get that done.

Not directly in 7.3 and earlier. You have to make a function that wraps
the function you want to call with static arguments like:

create function substring_8_4(text) returns text as
'select substring($1, 8, 4);' language 'sql' immutable;

In 7.4, the indexes have been approved to allow indexes on expressions
which allow the above (with an extra set of parens in the definition).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2003-11-11 15:33:10 Proposal for a cascaded master-slave replication system
Previous Message Dennis Gearon 2003-11-11 15:32:16 Re: multibyte support