Re: Temp table exists test??

Поиск
Список
Период
Сортировка
От William Yu
Тема Re: Temp table exists test??
Дата
Msg-id cu0ic1$11j8$1@news.hub.org
обсуждение исходный текст
Ответ на Re: Temp table exists test??  (Michael Guerin <guerin@rentec.com>)
Список 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.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Trigger/copy issue
Следующее
От: "Rodolfo J. Paiz"
Дата:
Сообщение: Re: Help with subselect (first time)