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

---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to