Re: Truncate if exists
От | Tom Lane |
---|---|
Тема | Re: Truncate if exists |
Дата | |
Msg-id | 10949.1349791611@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Truncate if exists (Simon Riggs <simon@2ndQuadrant.com>) |
Ответы |
Re: Truncate if exists
Re: Truncate if exists Re: Truncate if exists Re: Truncate if exists Re: Truncate if exists |
Список | pgsql-hackers |
Simon Riggs <simon@2ndQuadrant.com> writes: > On 9 October 2012 09:33, S�bastien Lardi�re <slardiere@hi-media.com> wrote: >> With the help of C�dric, here's a patch changing the TRUNCATE TABLE >> command, adding the IF EXISTS option to allow the presence in the list >> of tables of a missing or invisible table. > Will apply in 48 hours barring objections. I object: this doesn't deserve to be fast-tracked like that with no thought about whether the semantics are actually useful or sensible. 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? Second, to my mind the point of a multi-table TRUNCATE is to ensure that all the referenced tables get reset to empty *together*. With something like this, you'd have no such guarantee. Consider a timeline like this: Session 1 Session 2 TRUNCATE IF EXISTS a, b, c;... finds c doesn't exist ...... working on a and b ... CREATE TABLE c ( ... ); INSERT INTO c ...;... commits ... Now we have a, b, and c, but c isn't empty, violating the expectations of session 1. So even if there's a use-case for IF EXISTS on a single table, I think it's very very dubious to allow it in multi-table commands. regards, tom lane
В списке pgsql-hackers по дате отправления: