Re: Drop temporary table only if it exists - Mailing list pgsql-sql

From Jan Wieck
Subject Re: Drop temporary table only if it exists
Date
Msg-id 3E529BF0.D373AA9C@Yahoo.com
Whole thread Raw
In response to Drop temporary table only if it exists  (Mintoo Lall <tlqmail@yahoo.com>)
Responses Re: Drop temporary table only if it exists
List pgsql-sql
Josh Berkus wrote:
> 
> Jan,
> 
> > > How do I drop a temporary table ( or for that matter a sequence) only
> > > if it exists  or create them if they donot exist ? I want to do this
> > > to avoid any errors
> >
> > I wonder what type of application cannot remember if it created a temp
> > object or not during the lifetime of it's database connection.
> 
> A real one, Jan.
> 
> This sort of test is particularly necessary for Exception handling routines.
> One wants the exception handler to drop all temporary obejcts for a clean
> slate, but since an exception has occurred, one cannot be sure which objects
> were created successfully.

All temporary objects that need to persist across transactions should be
created at session start. Everything else is created inside the
transaction that needs it and is therefore automatically cleaned up.

If there are gazillions of those session level temporary objects, I
doubt that the database is really the right place to "cache" this sort
of data. 

> 
> I've personally written several such routines.

I never needed to. I might when I come around and create the next
generation of PL that supports packages with package initialization
functions and the like. Let's see ...


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #


pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Trigger that will execute external program
Next
From: JBJ
Date:
Subject: once again, sorting with Unicode