From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: patch: ALTER TABLE IF EXISTS |
Date: | 2012-01-02 14:14:57 |
Message-ID: | CAFj8pRBUhLM31nDX8oYWTTk8RSiXCqeJrymEB6Zoph+qjn1kZQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
2012/1/2 Tomas Vondra <tv(at)fuzzy(dot)cz>:
> On 2 Leden 2012, 14:11, Pavel Stehule wrote:
>> Hello
>>
>> this is relative simple patch that add possibility to skip noexisting
>> tables. It is necessary for silent cleaning when dump is loaded.
>
> Just a curious question - what use case is solved by this? Under what
> circumstances you get an ALTER TABLE without a preceding CREATE TABLE? I
> can't think of such scenario ...
>
> Or is this meant for scripts written manually so that it's possible to do
> alter if the table already exists and create if it does not exist?
this is necessary for "silent" cleaning in pg_dump
this is fragment of dump with -c option
ALTER TABLE ONLY public.b DROP CONSTRAINT b_b_fkey;
DROP INDEX public.a_a_idx;
ALTER TABLE ONLY public.a DROP CONSTRAINT a_pkey;
DROP TABLE public.b;
DROP TABLE public.a;
DROP EXTENSION plpgsql;
DROP SCHEMA public;
I am working on "silent cleaning" and I am able generate a sequence of
statements:
ALTER TABLE IF EXISTS ONLY public.b DROP CONSTRAINT b_b_fkey;
DROP INDEX IF EXISTS public.a_a_idx;
ALTER TABLE IF EXISTS ONLY public.a DROP CONSTRAINT a_pkey;
DROP TABLE IF EXISTS public.b;
DROP TABLE IF EXISTS public.a;
DROP EXTENSION IF EXISTS plpgsql;
DROP SCHEMA IF EXISTS public;
constraint b_b_fkey should be removed before dropping index a_a_idx
Now we have DROP .. IF EXISTS statements, but ALTER TABLE .. IF EXISTS missing
Regards
Pavel
>
> Tomas
>
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2012-01-02 14:47:09 | Re: controlling the location of server-side SSL files |
Previous Message | Tomas Vondra | 2012-01-02 13:59:24 | Re: patch: ALTER TABLE IF EXISTS |