Filip Rembiałkowski plk.zuber
Mon Dec 11 08:22:58 PST 2006
2006/12/11, Brad Nicholson <bnichols at ca.afilias.info>:
> > Add column can always be done without slony help.
>
> This is false.

I think this is true, at least if you take some extra measures to
avoid remote worker errors.
First of all, you should always enable any restrictions (checks, not
null constraints, foreign keys) on master nodes first.

Let's assume that you have simple master-slave setup, and you want to
ALTER TABLE prod ADD price numeric not null default 0.
To be completely safe you can take following steps (make sure that
replication lag goes to zero after each step):

1. slave# alter table prod add price numeric
2. master# alter table prod add price numeric
3. master# alter table prod alter price set default 0
4. slave# alter table prod alter price set default 0
5. master# update prod set price=0 where price is null
6. master# alter table prod alter price set not null
7. slave# alter table prod alter price set not null

that's all :) remote writers are happy.

>  It may work sometimes, or even most of the time, but it
> doesn't work all the time.
Maybe you have some example?

Of course this does not work for some sick situations, like
replication sets which have external foreign key references. But
they're broken anyway.

F.



More information about the Slony1-general mailing list