Re: Index expressions: how to recreate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Index expressions: how to recreate
Date: 2003-07-01 22:25:36
Message-ID: 22541.1057098336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andreas Pflug <pgadmin(at)pse-consulting(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2003-07-01 22:29:27 Re: cvs build failure
Previous Message Tom Lane 2003-07-01 22:12:31 Re: cvs build failure