From: | Sébastien Lardière <slardiere(at)hi-media(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org, cedric(at)2ndquadrant(dot)fr |
Subject: | Re: Truncate if exists |
Date: | 2012-10-11 09:22:05 |
Message-ID: | 50768FBD.4040108@hi-media.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 10/09/2012 10:04 PM, Robert Haas wrote:
>> - if a table is not yet or no more visible, because of search_path
>> modification
>
> I don't think I understand the case you are describing here.
Here's a sample :
begin;
set search_path = foo, public;
create table c ( … ) ;
commit;
begin;
set search_path = bar, public;
create table d ( … );
truncate if exists c;
commit;
>
>> - if a table was dropped, for any reason
>
> But in this case surely you could use DROP IF EXISTS.
Well, TRUNCATE and DROP TABLE are not the same, I don't see your point ?
>
> I've been a big proponent of adding "IF EXISTS" support to CREATE
> TABLE and ALTER TABLE but I'm having a hard time getting excited about
> this one. I can't imagine that many people would use it, and those
> who do can implement it in about 10 lines of PL/pgsql. The existence
> of DO blocks and the fact that PL/pgsql is now installed by default
> have made it much more convenient to solve these kinds of problems
> using those tools rather than needing dedicated syntax. That does not
> mean that the most frequently used cases shouldn't have dedicated
> syntax anyway, for convenience, but I'm doubtful that this falls into
> that category.
>
I don't think we can ask people to do DO blocks for TRUNCATE, when they
simply use IF EXISTS with DROP TABLE.
Even if TRUNCATE is not a DDL, it's often use as is
--
Sébastien Lardière
PostgreSQL DBA Team Manager
Hi-Media
From | Date | Subject | |
---|---|---|---|
Next Message | Sébastien Lardière | 2012-10-11 09:33:36 | Re: Truncate if exists |
Previous Message | Dimitri Fontaine | 2012-10-11 09:19:34 | Re: replace plugins directory with GUC |