Re: Index expressions: how to recreate - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Index expressions: how to recreate
Date
Msg-id 22541.1057098336@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index expressions: how to recreate  (Andreas Pflug <pgadmin@pse-consulting.de>)
Responses Re: Index expressions: how to recreate  (Andreas Pflug <pgadmin@pse-consulting.de>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: cvs build failure
Next
From: Alvaro Herrera
Date:
Subject: Re: cvs build failure