Re: About index for temporay table in a plpgsql function

From: Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca, pgsql-general(at)postgresql(dot)org
Subject: Re: About index for temporay table in a plpgsql function
Date: 2006-03-16 22:48:31
Message-ID: 4419EB3F.9030804@amsoftwaredesign.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Emi Lu wrote:
>
>
> The temporary table will be dropped automatically at the end of the
> function, right?
>

A temp table will be dropped at the end of the connection. You can reuse
it by adding ON COMMIT DELETE ROWS and then check
if it exists in your function with this other function:
http://www.milwaukeesoft.com/forums/viewtopic.php?t=79

You can also use ON COMMIT in a couple of different ways:

ON COMMIT

The behavior of temporary tables at the end of a transaction block
can be controlled using ON COMMIT. The three options are:

PRESERVE ROWS

No special action is taken at the ends of transactions. This is
the default behavior.

DELETE ROWS

All rows in the temporary table will be deleted at the end of
each transaction block. Essentially, an automatic TRUNCATE
<http://www.postgresql.org/docs/8.1/interactive/sql-truncate.html>
is done at each commit.

DROP

The temporary table will be dropped at the end of the current
transaction block.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-03-16 23:10:41 Re: pg_dumpall: permission denied for relation pg_shadow
Previous Message Brandon Keepers 2006-03-16 22:37:42 Re: Relation 'pg_largeobject' does not exist