Re: ToDo: conditional ALTER TABLE

From: Noah Misch <noah(at)leadboat(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ToDo: conditional ALTER TABLE
Date: 2011-12-20 03:37:45
Message-ID: 20111220033745.GB26050@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 19, 2011 at 10:25:34AM +0100, Pavel Stehule wrote:
> I am working on quiet dumps now. i found a small issue.
>
> pg_dump produces a statements
>
> ALTER TABLE ONLY public.b DROP CONSTRAINT b_fk_fkey;
> ALTER TABLE ONLY public.a DROP CONSTRAINT a_pkey;
>
> DROP TABLE IF EXISTS public.b;
> DROP TABLE IF EXISTS public.a;
>
> Actually there is no a conditional ALTER. These statements must be
> before DROPs, but then it can fails when these tables are missing.
>
> So some form like ALTER TABLE IF EXISTS ... should be usefull

If ALTER TABLE is the only ALTER command you'd need to change this way, I think
your proposal is good.

nm (who has never used "pg_dump --clean")

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-12-20 04:13:57 Re: ALTER TABLE lock strength reduction patch is unsafe
Previous Message Noah Misch 2011-12-20 03:10:02 Re: ALTER TABLE lock strength reduction patch is unsafe