pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAbout temporary table
7+ messages / 3 participants
[nested] [flat]
* About temporary table
@ 2002-03-25 03:37 jack <datactrl@tpg.com.au>
0 siblings, 1 reply; 7+ messages in thread
From: jack @ 2002-03-25 03:37 UTC (permalink / raw)
To: pgsql-sql
HI,
I installed postgreSql v7.2. There is a question about temporary tables. How
can I drop a temporary table only if it exists? Thank you!
JACK
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-03-25 03:54 Bruce Momjian <pgman@candle.pha.pa.us>
parent: jack <datactrl@tpg.com.au>
0 siblings, 1 reply; 7+ messages in thread
From: Bruce Momjian @ 2002-03-25 03:54 UTC (permalink / raw)
To: jack <datactrl@tpg.com.au>; +Cc: pgsql-sql
jack wrote:
> HI,
>
> I installed postgreSql v7.2. There is a question about temporary tables. How
> can I drop a temporary table only if it exists? Thank you!
Uh, just issue the drop and ignore the possible error.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-03-25 04:11 jack <datactrl@tpg.com.au>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 7+ messages in thread
From: jack @ 2002-03-25 04:11 UTC (permalink / raw)
To: pgsql-sql
But when I write SQL in pl/pgSQL, I can't test to drop a temporary table. If
it fails, the whole procedure will be aborted. That's my problem!
JACK
----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "jack" <datactrl@tpg.com.au>
Cc: <pgsql-sql@postgresql.org>
Sent: Monday, March 25, 2002 1:54 PM
Subject: Re: [SQL] About temporary table
> jack wrote:
> > HI,
> >
> > I installed postgreSql v7.2. There is a question about temporary tables.
How
> > can I drop a temporary table only if it exists? Thank you!
>
> Uh, just issue the drop and ignore the possible error.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-03-25 04:15 Dan Langille <dan@langille.org>
parent: jack <datactrl@tpg.com.au>
1 sibling, 0 replies; 7+ messages in thread
From: Dan Langille @ 2002-03-25 04:15 UTC (permalink / raw)
To: jack <datactrl@tpg.com.au>; +Cc: pgsql-sql
Why don't you just create it at the start of where it is needed and then
never worry about it. It is automatically deleted when the session
finishes.
On 25 Mar 2002 at 14:11, jack wrote:
> But when I write SQL in pl/pgSQL, I can't test to drop a temporary table. If
> it fails, the whole procedure will be aborted. That's my problem!
>
> JACK
>
> ----- Original Message -----
> From: "Bruce Momjian" <pgman@candle.pha.pa.us>
> To: "jack" <datactrl@tpg.com.au>
> Cc: <pgsql-sql@postgresql.org>
> Sent: Monday, March 25, 2002 1:54 PM
> Subject: Re: [SQL] About temporary table
>
>
> > jack wrote:
> > > HI,
> > >
> > > I installed postgreSql v7.2. There is a question about temporary tables.
> How
> > > can I drop a temporary table only if it exists? Thank you!
> >
> > Uh, just issue the drop and ignore the possible error.
--
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-03-25 10:17 jack <datactrl@tpg.com.au>
parent: jack <datactrl@tpg.com.au>
1 sibling, 1 reply; 7+ messages in thread
From: jack @ 2002-03-25 10:17 UTC (permalink / raw)
To: pgsql-sql
----- Original Message -----
From: "David Stanaway" <David@Stanaway.net>
To: "jack" <datactrl@tpg.com.au>
Sent: Monday, March 25, 2002 2:17 PM
Subject: Re: [SQL] About temporary table
>
> ----- Original Message -----
> From: jack <datactrl@tpg.com.au>
> To: <pgsql-sql@postgresql.org>
> Sent: Sunday, March 24, 2002 10:11 PM
> Subject: Re: [SQL] About temporary table
> You can see if its in the relevant system tables, then drop it.
But how can we find the exact name of a temporary table? Or do you know
which system table has the name mapping?
JACK
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-03-25 21:05 Bruce Momjian <pgman@candle.pha.pa.us>
parent: jack <datactrl@tpg.com.au>
0 siblings, 1 reply; 7+ messages in thread
From: Bruce Momjian @ 2002-03-25 21:05 UTC (permalink / raw)
To: jack <datactrl@tpg.com.au>; +Cc: pgsql-sql
jack wrote:
>
> ----- Original Message -----
> From: "David Stanaway" <David@Stanaway.net>
> To: "jack" <datactrl@tpg.com.au>
> Sent: Monday, March 25, 2002 2:17 PM
> Subject: Re: [SQL] About temporary table
>
>
> >
> > ----- Original Message -----
> > From: jack <datactrl@tpg.com.au>
> > To: <pgsql-sql@postgresql.org>
> > Sent: Sunday, March 24, 2002 10:11 PM
> > Subject: Re: [SQL] About temporary table
>
> > You can see if its in the relevant system tables, then drop it.
>
> But how can we find the exact name of a temporary table? Or do you know
> which system table has the name mapping?
There is actually no way to know the name from the table name, but if
there is only one temp table, pg_class will have the oid of the backend
in the table name. To get the backend pid, you can use libpq's
PQbackendPID() function or do this:
create function getpid () returns int as '/shlib/libc.so'
language 'c';
test=> select getpid();
getpid
--------
16011
(1 row)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: About temporary table
@ 2002-04-02 03:41 jack <datactrl@tpg.com.au>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 7+ messages in thread
From: jack @ 2002-04-02 03:41 UTC (permalink / raw)
To: pgsql-sql
To solve this problem, I think it's better to have "DROP TABLE xxx
ONLY-IF-EXISTING"
JACK
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2002-04-02 03:41 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-25 03:37 About temporary table jack <datactrl@tpg.com.au>
2002-03-25 03:54 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-03-25 04:11 ` jack <datactrl@tpg.com.au>
2002-03-25 04:15 ` Dan Langille <dan@langille.org>
2002-03-25 10:17 ` jack <datactrl@tpg.com.au>
2002-03-25 21:05 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-04-02 03:41 ` jack <datactrl@tpg.com.au>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox