Re: Using a lock to avoid: could not open relation with OID

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Francisco Reyes <lists(at)stringsutils(dot)com>
Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using a lock to avoid: could not open relation with OID
Date: 2010-01-11 23:25:44
Message-ID: 4B4BB378.4040003@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/01/2010 2:04 AM, Francisco Reyes wrote:
> I need to replace a table with a new one.
> Example..
> I create a script that continously does selects like
> select count(*) from tmp_deleteme_francisco;
> .... enough selects to last the duration of second script
> select count(*) from tmp_deleteme_francisco;
>
>
> Another script then does
> begin;
> select * into tmp_deleteme_francisco_2 from xxx;
> alter table tmp_deleteme_francisco rename to tmp_deleteme_francisco_old;
> alter table tmp_deleteme_francisco_2 rename to tmp_deleteme_francisco;
> drop table tmp_deleteme_francisco_old;
> commit;
>
> That results in the script doing the selects getting could not open
> relation with OID ####.

Possible workaround: Instead of your table creation, renaming and
dropping, use TRUNCATE.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2010-01-11 23:27:38 Re: Database size
Previous Message Craig Ringer 2010-01-11 23:18:58 Re: How to get DATE in server locale format