pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sandro Santilli <strk@keybit.net>
To: pgsql-bugs@postgresql.org
Cc: andres@2ndquadrant.com
Subject: cache lookup failed from empty plpythonu function
Date: Thu, 24 Jan 2013 15:03:36 +0100
Message-ID: <20130124140336.GJ3157@gnash> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

I've found a bug in plpythonu resulting in a "cache lookup" failure.
Here's the SQL to reproduce (thanks Andres):

 CREATE EXTENSION plpythonu;
 CREATE OR REPLACE FUNCTION t() RETURNS trigger AS 'pass' LANGUAGE 'plpythonu';
 CREATE TABLE a();
 CREATE TABLE b();
 CREATE TRIGGER check_quota AFTER INSERT ON a FOR EACH ROW EXECUTE PROCEDURE t();
 INSERT INTO a DEFAULT VALUES;
 DROP TABLE a;
 CREATE TRIGGER check_quota
  AFTER INSERT ON b FOR EACH ROW EXECUTE PROCEDURE t();
 INSERT INTO b DEFAULT VALUES;
 --ERROR: cache lookup failed for relation 20200
 --Time: 0.570 ms
 -- cleanup with DROP TABLE b; DROP FUNCTION t();

Logs show:

 ERROR:  XX000: cache lookup failed for relation 3694414
 LOCATION:  PLy_procedure_argument_valid, plpython.c:1469

Andres (in IRC #postgresql) said:

  <andres> hm, I think I see the problem. The caching there looks pretty
           broken to me.
  <andres> i.e. the caching doesn't work *at all* if a function is used
           as a trigger for more than one table and this is just fallout
           of that.
  <andres> Looks like a typo to me, procedure_get should use the table's
           oid instead of fn_oid when doing lookups in PLy_trigger_cache.

Tested on:

 PostgreSQL 9.1.7 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit

It was probably also present in the stable version as of one year
ago ( see https://github.com/Vizzuality/cartodb/issues/173 )

--strk; 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (15+ messages)  latest in thread

Message-ID: <20130124140336.GJ3157@gnash>
Permalink:  ../20130124140336.GJ3157@gnash/
Also on:    postgresql.org/message-id/20130124140336.GJ3157@gnash

 · 

reply

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: strk@keybit.net, andres@2ndquadrant.com
  Subject: Re: cache lookup failed from empty plpythonu function
  In-Reply-To: <20130124140336.GJ3157@gnash>
  References: <20130124140336.GJ3157@gnash>

* 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