CREATE TEMP TABLE t1 ON COMMIT AS SELECT TRUE::BOOL LIMIT 0;

Lists: pgsql-bugs
From: Sean Chittenden <sean(at)chittenden(dot)org>
To: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: CREATE TEMP TABLE t1 ON COMMIT AS SELECT TRUE::BOOL LIMIT 0;
Date: 2004-03-29 23:23:05
Message-ID: 07FD1AF0-81D8-11D8-8EC1-000A95C705DC@chittenden.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

In a follow up to my post from two days ago about creating TEMP TABLES,
I noticed what I think is kind of a glaring omission: CREATE TEMP TABLE
AS doesn't support ON COMMIT. Nothing Earth shattering, but it did
catch me by surprise. There's also no ALTER TABLE statement that I can
issue to tweak a TEMP table to have it include ON COMMIT behavior after
its been created. If this isn't low hanging fruit, can someone add it
to the TODO list? -sc

-- This works
CREATE TEMP TABLE t1 AS SELECT TRUE::BOOL LIMIT 0;

-- This does not
CREATE TEMP TABLE t1 ON COMMIT DROP AS SELECT TRUE::BOOL LIMIT 0;

--
Sean Chittenden


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Sean Chittenden <sean(at)chittenden(dot)org>
Cc: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: CREATE TEMP TABLE t1 ON COMMIT AS SELECT TRUE::BOOL LIMIT
Date: 2004-06-09 03:15:45
Message-ID: 200406090315.i593FjN25122@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Sean Chittenden wrote:
> In a follow up to my post from two days ago about creating TEMP TABLES,
> I noticed what I think is kind of a glaring omission: CREATE TEMP TABLE
> AS doesn't support ON COMMIT. Nothing Earth shattering, but it did
> catch me by surprise. There's also no ALTER TABLE statement that I can
> issue to tweak a TEMP table to have it include ON COMMIT behavior after
> its been created. If this isn't low hanging fruit, can someone add it
> to the TODO list? -sc
>
>
> -- This works
> CREATE TEMP TABLE t1 AS SELECT TRUE::BOOL LIMIT 0;
>
> -- This does not
> CREATE TEMP TABLE t1 ON COMMIT DROP AS SELECT TRUE::BOOL LIMIT 0;

The problem is that CREATE TABLE ... AS SELECT is actually SELECT INTO
internally, and SELECT doesn't have any on commit behavior.

Added to TODO:

* Add ON COMMIT capability to CREATE TABLE AS SELECT

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073