Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ytU-0005EF-LQ for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Feb 2013 13:30:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5ytU-0006oO-0e for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Feb 2013 13:30:32 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ytT-0006oI-3X for pgsql-bugs@postgresql.org; Thu, 14 Feb 2013 13:30:31 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ytR-0002SF-3a for pgsql-bugs@postgresql.org; Thu, 14 Feb 2013 13:30:30 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ytP-0006EW-T8 for pgsql-bugs@postgresql.org; Thu, 14 Feb 2013 13:30:28 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1U5ytP-0006E3-KB for pgsql-bugs@postgresql.org; Thu, 14 Feb 2013 13:30:27 +0000 Date: Thu, 14 Feb 2013 13:30:27 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7881: SQL function failures in long-lived calling contexts To: pgsql-bugs@postgresql.org From: andrew@tao11.riddles.org.uk X-Pg-Spam-Score: -1.9 (-) 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 The following bug has been logged on the website: Bug reference: 7881 Logged by: Andrew Gierth Email address: andrew@tao11.riddles.org.uk PostgreSQL version: 9.2.3 Operating system: any Description:=20=20=20=20=20=20=20=20 The range type code accepts SQL functions for subtype_diff, but stores the flinfo in a long-lived context (typcache). The SQL function handler, fmgr_sql, isn't prepared to deal with the possibility that the fcache entry may be left over from a previous query that failed. The combination of these two allows a non-superuser to provoke at least an assertion failure as follows: create or replace function inet_subdiff(inet,inet) returns float8 language sql immutable as $f$ select ($2 - $1)::float8; $f$; create type inetrange as range (subtype =3D inet, subtype_diff =3D inet_subdiff); create table inetr as select format('[%s::,%s::]',to_hex(i),to_hex(i+1))::inetrange as r from generate_series(0,65534) i; postgres=3D# create index inetr_idx on inetr using gist (r); ERROR: result is out of range CONTEXT: SQL function "inet_subdiff" statement 1 postgres=3D# create index inetr_idx on inetr using gist (r); TRAP: FailedAssertion("!(snapshot->regd_count > 0)", File: "snapmgr.c", Line: 557) I'm inclined to think this is fmgr_sql's fault for apparently assuming that if an error is thrown that it'll never see the fcache entry again, but in this example that's clearly not true. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs