From: Tom Lane <tgl@sss.pgh.pa.us>
To: ia.shumilova@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #9175: REINDEX on functional index fails
Date: Mon, 10 Feb 2014 10:50:56 -0500
Message-ID: <10815.1392047456@sss.pgh.pa.us> (raw)
In-Reply-To: <20140210121620.2717.2555@wrigleys.postgresql.org>
References: <20140210121620.2717.2555@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
ia.shumilova@gmail.com writes:
> -- function for tree structure assembling
> -- outputs something like 'level0/level1/level2/leaf'
> CREATE OR REPLACE FUNCTION taxonomy_string(tree_detail)
> RETURNS text AS
> $BODY$
> SELECT
> COALESCE(string_agg(tax_entry, '/'), '')
> FROM
> (
> SELECT
> tax_entry
> FROM
> tree_detail
> WHERE
> _left <= $1._left
> AND _right >= $1._right
> AND tree_master_id = $1.tree_master_id
> ORDER BY _level
> ) u
> $BODY$
> LANGUAGE sql IMMUTABLE;
I don't have a whole lot of sympathy for a bug report that involves
a function claimed to be IMMUTABLE when that marking is a lie.
This function selects from tree_detail, so it can at best be claimed
to be STABLE; which means you cannot use it in an index.
I think the proximate cause of the reported error is that once the
index exists, the query in the function tries to use it; and then
that usage will fail when the index is in mid-rewrite. It might
be worth trying to make that fail more cleanly, if index functions
that depend on selecting from their table were a supported thing;
but they aren't and never will be.
You might be able to get the results you want by including the
taxonomy_string() function in a materialized view over the table.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, ia.shumilova@gmail.com
Subject: Re: BUG #9175: REINDEX on functional index fails
In-Reply-To: <10815.1392047456@sss.pgh.pa.us>
References: <20140210121620.2717.2555@wrigleys.postgresql.org> <10815.1392047456@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox