Re: passing constant parameters to functional indices - Mailing list pgsql-hackers

From Tom Lane
Subject Re: passing constant parameters to functional indices
Date
Msg-id 24959.1052929874@sss.pgh.pa.us
Whole thread Raw
In response to passing constant parameters to functional indices  (Abhijit Menon-Sen <ams@wiw.org>)
List pgsql-hackers
Abhijit Menon-Sen <ams@wiw.org> writes:
> I'd like to add support for specifying constant parameters when creating
> a functional index, e.g. create index foo on bar (substr(baz, 1, 32));
> Is this a good idea?

I think you are thinking of it the wrong way.  Rather than restricting
yourself to a single function call, replace the entire "functional
index" facility with an "expressional index" facility --- ie you can
index on the result of any scalar expression, of which a function call
is just a special case.  Since you'll have to change the contents of
pg_index anyway, you may as well implement the more general solution.

The mechanisms associated with CHECK constraints already do everything
needed for this; it's just that they only allow expressions delivering
boolean results.  So you shouldn't have a great deal of trouble finding
prototype code to follow.

This has been discussed before.  Try searching the archives for
"expressional index" to see if there's anything useful.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Zeugswetter Andreas SB SD"
Date:
Subject: Re: Client encoding conversion for binary data (was Re: GUC and postgresql.conf docs)
Next
From: ohp@pyrenet.fr
Date:
Subject: DNS problem,