Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyNP8-0007Zc-M6 for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Jan 2013 14:03:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TyNP7-0001av-K0 for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Jan 2013 14:03:45 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyNP6-0001aq-UV for pgsql-bugs@postgresql.org; Thu, 24 Jan 2013 14:03:45 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyNP3-0002kL-T6 for pgsql-bugs@postgresql.org; Thu, 24 Jan 2013 14:03:44 +0000 Received: by mail-wg0-f47.google.com with SMTP id dq11so3043422wgb.14 for ; Thu, 24 Jan 2013 06:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=o21tMowwbovXiorq5HFNh6DNQUM8T59axmVsBKgtBzo=; b=qBUXKUK0uE+HIs4y3SUog9lG/SBcUtQv1cAeqblFaALEIAUZwG1AGtWo9oxZNwKw2G HzM1h7qWlImtP1jVC0Tp8ZlofhEwm+ge5WJ3/elFuQOJsKPobCfPGktId78pCnBr+06I t2/ozK2gyyYfLYgVZaNZm9QUDBxe2/NC27Li77aHUQnak5iFRlF/8YLKhl6vEzahS+0i w3yetkL+/n6nagpTkklseBCjXum+T+Xi4mV1HfCqhzSDsoCXC58l2xdGtOrgHnvFZ43x Hm8iuJn05LuhsCANjfaEH5io5OXMj0Kqgi8VmNEG+eb/GbNnICkg5DXFQEYgF9WlcCuv 4gLA== X-Received: by 10.180.77.35 with SMTP id p3mr3408051wiw.18.1359036220941; Thu, 24 Jan 2013 06:03:40 -0800 (PST) Received: from gnash (ip-46-232-148-34.static.adsl.cheapnet.it. [46.232.148.34]) by mx.google.com with ESMTPS id fv2sm2448173wib.4.2013.01.24.06.03.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Jan 2013 06:03:39 -0800 (PST) Date: Thu, 24 Jan 2013 15:03:36 +0100 From: Sandro Santilli To: pgsql-bugs@postgresql.org Cc: andres@2ndquadrant.com Subject: cache lookup failed from empty plpythonu function Message-ID: <20130124140336.GJ3157@gnash> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.6 (--) 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 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: hm, I think I see the problem. The caching there looks pretty broken to me. 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. 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