On Wed, Nov 7, 2012 at 5:34 PM, Simon Riggs <simon@2ndquadrant.com> wrote:
> I was unhappy with changing the behaviour of TRUNCATE, and still am.
> So the proposal here is to have a specific modifier on TRUNCATE
> command that makes it MVCC safe by throwing a serialization error.
> That new behaviour should be requestable by adding the SERIALIZABLE
> keyword.
> i.e. TRUNCATE foo SERIALIZABLE;
> This then allows a new style of TRUNCATE, yet without modiying
> behaviour of earlier programs (ugh!).
Personally I think the behavior should be dictated by the *reader*.
The one doing the truncation may not know about the consistency
requirements of particular readers. Especially when you do the
truncate via pg_restore or some other generic tool. And indeed
different readers may have different consistency requirements.
So I'd prefer if it were a GUC variable; readers that accept relaxed
consistency can set truncate_conflict=off
Granted, making this part of the TRUNCATE statement does give you
table-level granularity. But if a reader can already handle
serialization conflicts, it doesn't really matter which table they
came from.
But making TRUNCATE behave in a MVCC-safe way, like proposed by Hannu,
would be much better.
Regards,
Marti