Re: Truncate if exists - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Truncate if exists
Date
Msg-id CA+TgmoYBwfg6HhHXZYg3h0oVSNOv5Q+ccjL2_4v4PZ9bGvb=Kg@mail.gmail.com
Whole thread Raw
In response to Re: Truncate if exists  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
Responses Re: Truncate if exists  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
List pgsql-hackers
On Mon, Oct 15, 2012 at 3:14 PM, Dimitri Fontaine
<dimitri@2ndquadrant.fr> wrote:
> What about continuing to extend on that incredibly useful WITH syntax we
> already have:
>
>    WITH target AS (
>       SELECT oid::regclass AS t
>         FROM pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid
>        WHERE pg_table_is_visible(oid)
>          AND nspname = 'public' AND NOT relname ~ 'exclude-pattern'
>    )
>    TRUNCATE TABLE t FROM target;

I'm not exactly sure what that is supposed to do, but it doesn't seem
like an easy-to-use substitute for truncate-if-exists...

>> my view the goal ought to be to refine that mechanism to remove the
>> clunkiness and awkwardness, rather than to invent something completely
>> new.
>
> So, what do you think? Smells like empowered SQL this time, right?

I like the idea of making our SQL dialect capable of working with DDL
in more powerful ways; I'm not sold on the concrete proposal.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Deprecating RULES
Next
From: Bruce Momjian
Date:
Subject: Re: Deprecating RULES