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

dropdb and dropuser: IF EXISTS

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: dropdb and dropuser: IF EXISTS
Date: 2011-08-26 04:08:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
I noticed a few places where it would be handy if dropdb took a flag
like "--if-exists" which would basically just add in the 'IF EXISTS'
clause to the DROP DATABASE statement. For example, scripts like
find_static or use dropdb && createdb, but they generate
noisy errors from dropdb when run for the first time since there's no
--if-exists flag. (They could just pipe 'DROP DATABASE IF EXISTS ...'
to psql, but what's the point of having dropdb if it's not used?)

Attached is a very quick patch implementing the "--if-exists" or "-X"
option for dropdb and dropuser. I didn't bother adding in a check to
make sure the server version was 8.2+ since we're not even supporting
8.1 nowadays, though that'd be easy enough to add in.


Attachment: dropdb_user_ifexists.v1.patch
Description: text/x-patch (6.1 KB)


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2011-08-26 04:18:55
Subject: Re: [GENERAL] pg_upgrade problem
Previous:From: Tom LaneDate: 2011-08-26 03:28:03
Subject: Re: tsvector concatenation - backend crash

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