Re: ERROR: relation xxx is still open (Re: Use Trigger to Remove Table ... )

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: relation xxx is still open (Re: Use Trigger to Remove Table ... )
Date: 2010-02-02 16:11:20
Message-ID: 6384.1265127080@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Josh Kupershmidt <schmiddy(at)gmail(dot)com> writes:
> For the record, I think having a trigger drop a table automatically when
> it's empty is probably a bad idea. But I tried it out anyways, and got a
> surprising:
> ERROR: relation 16400 is still open
> when the trigger function attempted to drop the table.

> Can anyone say whether the error message I'm seeing is valid?

It's unsurprising, anyway. The code firing the trigger would be holding
the relation open. I'm not sure whether there's a good reason for
referring to the table by OID instead of name there, but this is a
pretty low-level failure anyway.

There are any number of reasons why we'd not be likely to try to support
this. What if the trigger tries to refer to NEW or OLD afterwards, when
the information about the table's rowtype is already gone? What if
there are more trigger firings pending for the table?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2010-02-02 16:23:38 Re: Questions on PostGreSQL Authentication mechanism...
Previous Message Tom Lane 2010-02-02 15:55:04 Re: Problem with partition tables and schemas