Attached is a revised version of my previous
ON COMMIT DROP
patch. This patch implements:
ON COMMIT { DROP | PRESERVE ROWS | DELETE ROWS }
The latter two are SQL99.
Sample usage:
---
template1=# begin;
BEGIN
template1=# create temp table a (a int) on commit drop;
CREATE
template1=# create temp table b (a int) on commit preserve rows;
CREATE
template1=# create temp table c (a int) on commit delete rows;
CREATE
template1=# insert into a values(1);
INSERT 24793 1
template1=# insert into b values(1);
INSERT 24794 1
template1=# insert into c values(1);
INSERT 24795 1
template1=# commit;
COMMIT
template1=# select * from a;
ERROR: Relation "a" does not exist
template1=# select * from b;
a
---
1
(1 row)
template1=# select * from c;
a
---
(0 rows)
template1=# create temp table a (a int) on commit drop;
ERROR: You must be inside a transaction to use ON COMMIT
---
Gavin