Skip site navigation (1) Skip section navigation (2)

Re: about truncate

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Subject: Re: about truncate
Date: 2008-12-30 16:23:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Peter Eisentraut wrote:
> 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 
> > 
> > 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?

Well, it is one of those, "Either we fix it or live with the
inconsistency forever".  Historically we have opted to fix it with a
clear warning in the major release notes.

  Bruce Momjian  <bruce(at)momjian(dot)us>

  + If your life is a hard drive, Christ can be your backup. +

In response to


pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2008-12-30 16:24:48
Subject: Re: LP_DELETE
Previous:From: Robert HaasDate: 2008-12-30 15:58:45
Subject: Re: Documenting serializable vs snapshot isolation levels

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group