Re: ALTER TABLE ... IF EXISTS feature?

From: Daniel Farina <drfarina(at)acm(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Noah Zoschke <noah(at)heroku(dot)com>
Subject: Re: ALTER TABLE ... IF EXISTS feature?
Date: 2010-11-07 11:42:12
Message-ID: AANLkTik5jS0cozYKzisZYW1NkxvQXuO7SxraKiqi9g8p@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 6, 2010 at 6:09 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Since we now have PL/pgsql by default, we could possibly fix pg_dump
> --clean by emitting a DO block, although the syntax for checking
> existence of a table is none too pretty, and it would make pg_dump
> --clean rely for correctness on plpgsql being installed, which might
> be none too desirable.  It would actually be sort of spiffy to be able
> to have some of the PL/pgsql control constructs available in straight
> SQL, but I'm not expecting that to happen any time in the forseeable
> future.

I have hacked up a little set of work-in-progress pg_dump patches as a
proof of concept. It uses the PGSQL and DO mechanics, thanks for
making me aware of the latter...

https://github.com/fdr/postgres/tree/pg_dump-if-exists

I will be giving it a try on some more schemas in the near future. On
my small, plain but not-entirely-a-toy schema it works great.

For some reason I cannot seem to get it to exercise the ALTER DOMAIN
check, even though I created a domain with a check constraint...hmm,
I'll have to stare at what can cause it to exercise that later.

fdr

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hitoshi Harada 2010-11-07 12:28:30 SQL2011 and writeable CTE
Previous Message Greg Stark 2010-11-07 05:04:27 Re: Protecting against unexpected zero-pages: proposal