Re: Query to retrieve the index columns when a function is used.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Sterpu Victor <victor(at)caido(dot)ro>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Query to retrieve the index columns when a function is used.
Date: 2020-03-11 22:29:00
Message-ID: 5284.1583965740@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> On Tue, 10 Mar 2020 at 02:16, Sterpu Victor <victor(at)caido(dot)ro> wrote:
>> How can I retrieve this detail?

> Those details are in the indexprs column. There's an item there for
> each 0 valued indkey. It's not going to be particularly easy for you
> to parse that from SQL. Internally in PostgreSQL, we have functions
> that could give you that information easily, but to access those from
> SQL you'd need to write something in C.

You could use pg_get_indexdef(). I agree that parsing indexprs from
SQL is not to be recommended --- aside from being very complex, it
would break on a regular basis, because we change those structs often.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Brannen 2020-03-11 23:11:49 RE: pg_restore restores out of order
Previous Message Adrian Klaver 2020-03-11 22:13:17 Re: Streaming replication - 11.5