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

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

Consider an index that looks like this:
   CREATE INDEX foo ON bar (numcol, length(txtcol), intcol2, 
length(txtcol2))

Looking at pg_index:
   indkey will contain 1 0 4   indclass contains 1988 1978 1978 1978 (numeric, int, int, int)   pg_get_expr(indexprs,
indrelid)will deliver (length((txtcol)::text) 
 
AND (length(((txtcol2)::text)))

indclass contains what I'd expect, but indkey shows only 3 columns 
and/or expressions.
So I'd recreate the index as being defined as
   CREATE INDEX foo ON bar (numcol, (length(txtcol) AND 
length(txtcol2)), intcol2)

which obviously isn't correct (and wouldn't execute either, AND with int 
operands)

Why is indexprs not a text array containing "", "length(txtcol)", "", 
"length(txtcol2)" ?


Regards,
Andreas



pgsql-hackers by date:

Previous
From: "Mendola Gaetano"
Date:
Subject: Re: Dllist public/private part
Next
From: Stuart
Date:
Subject: Re: Is Patch Ok for deferred trigger disk queue?