Re: Truncate if exists - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Truncate if exists
Date
Msg-id CA+Tgmobi9Off4CXzkd-y14Qj5xOThCd-9Y_tvWi9S6srK9kDNQ@mail.gmail.com
Whole thread Raw
In response to Re: Truncate if exists  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Truncate if exists  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Truncate if exists  (Noah Misch <noah@leadboat.com>)
Re: Truncate if exists  (Simon Riggs <simon@2ndQuadrant.com>)
Re: Truncate if exists  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
On Tue, Oct 9, 2012 at 4:18 PM, Josh Berkus <josh@agliodbs.com> wrote:
> The second is for making deployment scripts idempotent.  For example,
> say you have script A which creates table "josh", and script B which
> needs table "josh" to be empty, if present.  Since the two scripts are
> tied to different database features, and you don't know which one will
> be deployed first, it's useful to have TRUNCATE IF EXISTS.  Yes, you can
> solve that problem with DO, but why make users go to the extra effort?

Hmm.  That's an interesting point.  I think we're currently in
somewhat of a limbo zone about where we ought to have IF EXISTS and IF
NOT EXISTS options, and where we should not.  Really, I'd like to
figure out what policy we want to have, and then go make everything
work that way.  I don't exactly know what the policy should be, but if
we don't have one then we're going to have to argue about every patch
individually, which is already getting to be more than tedious.  At
the one extreme, you have Tom, who probably would not have added any
of these given his druthers; at the other extreme, there are probably
some people who would say we ought to have this for every command in
the book, right down to INSERT IF EXISTS (and, hey, why not INSERT OR
CREATE for good measure?).  I'm not sure what the right thing to do
is... but we should probably come up with some consensus position we
can all live with, and then go make this uniform[1].

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[1] And yes, I will volunteer to do some or all of the required
implementation work, if that's helpful.  Or else somebody else can do
it.  That's good, too.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] pgxs problem...
Next
From: Tom Lane
Date:
Subject: Re: Truncate if exists