Index expressions: how to recreate

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Index expressions: how to recreate
Date: 2003-07-01 12:08:53
Message-ID: 3F0179D5.7080804@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers 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

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Adam H. Pendleton 2003-07-01 14:14:03 Edit data dialog
Previous Message Behdad Esfahbod 2003-07-01 12:02:04 Re: Persian PostgreSQL efforts

Browse pgsql-hackers by date

  From Date Subject
Next Message Mendola Gaetano 2003-07-01 12:09:22 Re: Dllist public/private part
Previous Message Christopher Kings-Lynne 2003-07-01 07:44:41 vacuum bug