Re: about truncate

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Subject: Re: about truncate
Date: 2008-12-30 09:05:35
Message-ID: 4959E45F.1010604@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On Monday 22 December 2008 05:09:54 Jaime Casanova wrote:
>> just out of curiosity, why TRUNCATE doesn't support ONLY?
>
> It was probably just an omission.
>
> Note that TRUNCATE currently does not act on inheriting tables. In other
> words, the behavior is already like ONLY.
>
> FWIW, the SQL standard says that TRUNCATE should support ONLY, just like
> DELETE.
>
> Something should probably be fixed or at least documented about this.

Before I or someone goes to write code for this, note that a proper fix
would introduce a backward incompatibility when TRUNCATE is used on
inheritance hierarchies.

Currently, TRUNCATE only acts on the named table itself, not on any
children.

The behavior required by the SQL standard (and by consistency with
pretty much all other commands in PostgreSQL) is that TRUNCATE operate
on all child tables, unless ONLY is specified.

Note that there is currently no way to get a TRUNCATE not-ONLY without
writing manual loops, which is a significant gap of functionality.

Considering that TRUNCATE is a pretty dangerous operation, how can we
make adjustments to the behavior without upsetting lots of users?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-12-30 10:42:45 Re: Synchronous replication, network protocol
Previous Message Peter Eisentraut 2008-12-30 08:56:43 Re: incoherent view of serializable transactions