Re: Temp table exists test??

From: William Yu <wyu(at)talisys(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Temp table exists test??
Date: 2005-02-04 19:27:58
Message-ID: cu0ic1$11j8$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> It's in reference to a post the other day "Function to blame?" I'm
> running into an issue that causes the database to get corrupted under a
> heavy load. Everytime it get corrupted, it's always in this function
> that creates a temp table, fills it, sends back the results and drops
> the table. This one function is heavily used.
> That said, we know that every thread has it's own connection. So, I
> would like to modify the function to create the temp table the first
> time its used, and truncate it every other time reducing the number of
> entries in the pg_class, pg_type,... tables that we experienced
> corruption in. This is why I need to know if the connection created the
> temp table.

1) You could query the system tables.

2) You could attempt to query the temp table -- and if an error message
occurs, assume the table does not exist.

3) You could issue the create command and ignore the "table already
exists" error. Then follow it up with the truncate command.

#2/#3 would be problematic if you commonly wrapped these commands inside
a transaction becaues the errors would kick your transaction out.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Poul Jensen 2005-02-04 21:11:28 ECPG: Structure definitions in header files
Previous Message Tom Lane 2005-02-04 18:26:39 Re: Trigger/copy issue