pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leif B. Kristensen <leif@solumslekt.org>
To: pgsql-sql@postgresql.org
Subject: Re: Error from trigger
Date: Thu, 8 Dec 2005 00:43:18 +0100
Message-ID: <200512080043.18481.leif@solumslekt.org> (raw)
In-Reply-To: <4507.1133997785@sss.pgh.pa.us>
References: <200512080006.44606.leif@solumslekt.org>
	<4507.1133997785@sss.pgh.pa.us>

On Thursday 08 December 2005 00:23, Tom Lane wrote:
>Is there a reason you don't just mark the FK reference as ON DELETE
>CASCADE, rather than using a handwritten trigger?

I could have done that, of course. I'm still a little shaky on "best 
practice" with these things. Besides, I haven't found out yet how to 
alter the table to make the reference cascading. And I wanted to 
experiment with simple triggers.

>Offhand this looks like you might have dropped and recreated the
>event_citations table?  If so it's just the known problem that
>plpgsql caches plans and doesn't throw them away when the referenced
>objects change.

Right on target. Thank you. A few days ago, as I have already related on 
this list, I did the following to fix a bad design with inherited 
tables:

pgslekt=> create table event_cits (
pgslekt(> event_fk integer references events (event_id),
pgslekt(> source_fk integer references sources (source_id),
pgslekt(> PRIMARY KEY (event_fk, source_fk)
pgslekt(> );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 
"event_cits_pkey" for table "event_cits"
CREATE TABLE
pgslekt=> insert into event_cits (select event_fk, source_fk from 
event_citations);
INSERT 0 29139
pgslekt=> drop table event_citations cascade;
NOTICE:  drop cascades to rule _RETURN on view event_notes
NOTICE:  drop cascades to view event_notes
DROP TABLE
pgslekt=> drop table citations;
DROP TABLE
pgslekt=> alter table event_cits rename to event_citations;
ALTER TABLE
pgslekt=> \i views_and_functions.sql

I've run a VACUUM FULL ANALYZE, but that doesn't seem to cure the 
situation. Is there a way to fix it, short of a full dump, drop, and  
reload?
-- 
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE



view thread (5+ messages)  latest in thread

Message-ID: <200512080043.18481.leif@solumslekt.org>
Permalink:  ../200512080043.18481.leif@solumslekt.org/
Also on:    postgresql.org/message-id/200512080043.18481.leif@solumslekt.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: leif@solumslekt.org
  Subject: Re: Error from trigger
  In-Reply-To: <200512080043.18481.leif@solumslekt.org>

* 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