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

From Tom Lane
Subject Re: Index expressions: how to recreate
Date
Msg-id 3186.1057071656@sss.pgh.pa.us
Whole thread Raw
In response to Index expressions: how to recreate  (Andreas Pflug <pgadmin@pse-consulting.de>)
List pgsql-hackers
Andreas Pflug <pgadmin@pse-consulting.de> writes:
> I noticed the new expression functionality of indices and while 
> implementing them in pgadmin3 was wonderingnow to extract the definition 
> from the catalog.

The best way is to use pg_get_indexdef(indexOID), same as pg_dump and
psql do.

>     CREATE INDEX foo ON bar (numcol, length(txtcol), intcol2, 
> length(txtcol2))

>     indkey will contain 1 0 4

Actually it should be read as 1 0 4 0.  The output converter for
int2vector suppresses trailing zeroes, for largely-historical reasons.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: vacuum bug
Next
From: Jan Wieck
Date:
Subject: New position and new location