Hello 2012/1/2 Tomas Vondra <t...@fuzzy.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 > -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers