Re: Passing arguments to and INDEX function.
От | Tom Lane |
---|---|
Тема | Re: Passing arguments to and INDEX function. |
Дата | |
Msg-id | 23510.958663471@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Passing arguments to and INDEX function. (Jeffery Collins <collins@onyx-technologies.com>) |
Список | pgsql-general |
Jeffery Collins <collins@onyx-technologies.com> writes: > So, with that prefix, is there a way to pass an argument to a > CREATE INDEX function? If not, is this something that would be possible > to add? If it is possible, is it desireable? If it is possible and > desireable, where would I start if I were to add it? It'd be a nontrivial bit of work (possibly not the best thing to do as your first backend project ;-)). Currently the keys for an index have a hard-wired representation in pg_index: there's a list of attribute numbers, which are either N separate keys of a multi-column index or the N arguments of a function, depending on whether indproc has a value or not. There's noplace to put a constant value, unless you can squeeze it into the int2 slot where the attribute number would go. Rather than kluging this up still further, the right approach would be to blow it all away in favor of a list of N arbitrary expressions to be evaluated to produce the index key values. The expressions would be stored as nodetrees, same as we do for column default values (for example). Doable, I think, but not too easy. You'd have to touch a bunch of code, not only in the backend but in programs like pg_dump. Whether or not Jeff wants to tackle it, I think the existing TODO item for this is badly phrased: * Allow CREATE INDEX zman_index ON test (date_trunc( 'day', zman ) datetime_ops) fails index can't store constant parameters It ought to read * Allow arbitrary expressions as index keys regards, tom lane
В списке pgsql-general по дате отправления: