Re: Index expressions: how to recreate

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Index expressions: how to recreate
Дата
Msg-id 22541.1057098336@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Index expressions: how to recreate  (Andreas Pflug <pgadmin@pse-consulting.de>)
Ответы Re: Index expressions: how to recreate  (Andreas Pflug <pgadmin@pse-consulting.de>)
Список pgsql-hackers
Andreas Pflug <pgadmin@pse-consulting.de> writes:
> Tom Lane wrote:
>> The best way is to use pg_get_indexdef(indexOID), same as pg_dump and
>> psql do.

> [ doesn't want to parse the pg_get_indexdef output... ]

Well, I guess if you just want one column it's kind of a pain.

> pg_get_indexdef converts that string to a list of nodes (not 
> surprising), while pg_get_expr whill join these list elements with an 
> explicit and (according to a comment, needed for partial index). Do I 
> need to retrieve indexprs and split it myself (counting brackets) or is 
> there a pg_xxx function that could help me (pg_get_element(indexprs, 
> 0...n)) ?

There isn't any real good way to do it, and I'd discourage you from
writing client-side code that roots around in those fields anyway.
It's much too likely to break in future versions.

Does anyone else think it's reasonable to define a backend function
along the lines of pg_get_indexdef(indexoid, columnnumber) that
retrieves just the column-name-or-expression for the indicated column
of the index?  I'm not eager to do it if just one person wants it,
but if there's more than one potential user...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: cvs build failure
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: cvs build failure