Re: Truncate if exists - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Truncate if exists
Date
Msg-id 5078440F.4090906@dunslane.net
Whole thread Raw
In response to Re: Truncate if exists  (Sébastien Lardière <slardiere@hi-media.com>)
Responses Re: Truncate if exists  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
List pgsql-hackers
On 10/12/2012 12:03 PM, Sébastien Lardière wrote:
>
> If we can do something like :
>
> SELECT pg_if_table_exists('bar' , pg_if_table_exists('foo', 'TRUNCATE
> TABLE foo, bar, foobar')) ;
>
> or
>
> SELECT pg_if_tables_exists('TRUNCATE TABLE foo, bar, foobar', 'foo',
> 'bar') ;
>
> I say yes !
>
>



This strikes me as just highly un-SQL-like.

Someone could fairly easily write it for themselves in Plpgsql or C, but
it doesn't seem to me like something we should be doing.

I tend to agree with Noah's comment upthread:

> But the syntax is a bandage for raw psql input remaining a hostile
> environment for implementing the full range of schema changes.  Switch to
> submitting your SQL from a richer programming environment, and these additions
> to core syntax cease to add much.


I think this goes a fortiori for Heath Robinson-like devices such as this.


cheers

andrew




pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: velog + vereport?
Next
From: Pavel Stehule
Date:
Subject: Re: Truncate if exists