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

Re: Truncate if exists

From: Sébastien Lardière <slardiere(at)hi-media(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Cc: cedric(at)2ndquadrant(dot)fr
Subject: Re: Truncate if exists
Date: 2012-10-09 09:28:53
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On 10/09/2012 11:09 AM, Simon Riggs wrote:
> On 9 October 2012 09:33, Sébastien Lardière <slardiere(at)hi-media(dot)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.
>> This meets the needs of scripts that should be run in different stages,
>> and do not always have the same visibility on the tables, as well as
>> DROP TABLE. Rather than rollback the entire TRUNCATE or transaction, we
>> prefer to ignore the absence of the table.
>> It is a small patch which changes very little code, but that could be
>> quite useful.
> Agreed.
> Patch looks fine, but please observe the coding standards wrt nested brackets.
> Will apply in 48 hours barring objections.
> Anyone want to check for any other missing IF EXISTS capability in other DDL?

Indeed, brackets was not correct, it's better now (I think), and correct
some comments.


Sébastien Lardière
PostgreSQL DBA Team Manager

Attachment: truncateifexists-2.diff
Description: text/x-patch (5.2 KB)

In response to


pgsql-hackers by date

Next:From: Vik ReykjaDate: 2012-10-09 09:51:15
Subject: Re: Truncate if exists
Previous:From: Simon RiggsDate: 2012-10-09 09:11:13

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