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

Truncate if exists

From: Sébastien Lardière <slardiere(at)hi-media(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: cedric(at)2ndquadrant(dot)fr
Subject: Truncate if exists
Date: 2012-10-09 08:33:23
Message-ID: 5073E153.102@hi-media.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

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.

Regards,

-- 
Sébastien Lardière
PostgreSQL DBA Team Manager
Hi-Media

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

Responses

pgsql-hackers by date

Next:From: Shigeru HANADADate: 2012-10-09 08:56:44
Subject: Re: Move postgresql_fdw_validator into dblink
Previous:From: Dimitri FontaineDate: 2012-10-09 07:57:07
Subject: Re: Deparsing DDL command strings

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