Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCt8S-0000gq-Ky for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Feb 2014 15:51:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WCt8S-0007gp-1k for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Feb 2014 15:51:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCt8R-0007gf-DO for pgsql-bugs@postgresql.org; Mon, 10 Feb 2014 15:51:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCt8P-0002EI-9S for pgsql-bugs@postgresql.org; Mon, 10 Feb 2014 15:51:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1AFouqr010816; Mon, 10 Feb 2014 10:50:56 -0500 From: Tom Lane To: ia.shumilova@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #9175: REINDEX on functional index fails In-reply-to: <20140210121620.2717.2555@wrigleys.postgresql.org> References: <20140210121620.2717.2555@wrigleys.postgresql.org> Comments: In-reply-to ia.shumilova@gmail.com message dated "Mon, 10 Feb 2014 12:16:20 +0000" Date: Mon, 10 Feb 2014 10:50:56 -0500 Message-ID: <10815.1392047456@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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