Re: Temporary table already exists - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Temporary table already exists
Date
Msg-id A737B7A37273E048B164557ADEF4A58B17CA1446@ntex2010i.host.magwien.gv.at
Whole thread Raw
In response to Temporary table already exists  (mephysto <mephystoonhell@gmail.com>)
Responses Re: Temporary table already exists  (mephysto <mephystoonhell@gmail.com>)
List pgsql-general
mephysto wrote:
> in my database I'm using several stored_functions that take advantage of
> temporary table. The application that is connected to Postgres is a Java Web
> Application in a Glassfish Application Server: it is connected by a JDBC
> Connection Pool provided by Glassfish with this settings:
> 
> Resource type -> javax.sql.ConnectionPoolDataSouce
> Dataset Classname -> org.postgresql.ds.PGConnectionPoolDataSource
> Transaction Isolation -> read-uncommitted
> 
> 
> The problem is that in a concurrent execution of a function, I received
> error of relation already exists. The relation that caused issue is exactly
> my temporary table.
> 
> My question is: what is the reason for which I take this type of error? Is
> there a way to follow to avoid this situation?

You probably have a connection pool that reuses a connection in which
you already created the temporary table.

I see two options:
- Explicitly drop the temporary table when you are done.
- Create the table with ON COMMIT DROP and put your work into a transaction.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: alexandros_e
Date:
Subject: Re: Reindexing and tablespaces
Next
From: mephysto
Date:
Subject: Re: Temporary table already exists