Re: Truncate if exists

Andrew Dunstan <andrew@dunslane.net>

From: Andrew Dunstan <andrew@dunslane.net>
To: Sébastien Lardière <slardiere@hi-media.com>
Cc: Simon Riggs <simon@2ndQuadrant.com>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers@postgresql.org
Date: 2012-10-12T16:23:43Z
Lists: 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