Re: Truncate if exists

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Truncate if exists
Дата
Msg-id CA+TgmobtVEpXMbPFZfL2D0yNf4VZ8Vr3uF_tPBuPunJ9P6z=3Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Truncate if exists  (Sébastien Lardière <slardiere@hi-media.com>)
Ответы Re: Truncate if exists
Re: Truncate if exists
Re: Truncate if exists
Список pgsql-hackers
On Tue, Oct 9, 2012 at 12:28 PM, Sébastien Lardière
<slardiere@hi-media.com> wrote:
>> For starters, the use-case hasn't been explained to my satisfaction.
>> In what situation is it actually helpful to TRUNCATE a table that's
>> not there yet?  Aren't you going to have to do a CREATE IF NOT EXISTS
>> to keep from failing later in the script?  If so, why not just do that
>> first?
>
> it could be useful to not rollback transactions :
>
>  - 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.

>  - if a table was dropped, for any reason

But in this case surely you could use DROP IF EXISTS.

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.

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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Detecting libpq connections improperly shared via fork()
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: Statistics and selectivity estimation for ranges