Dmitry Koterov dmitry at koterov.ru
Fri Mar 6 14:40:33 PST 2009
Hello.

I work with Slony for about 2 years in a heavy-loaded web site. I'd like to
mix DDL and DML code to perform them in a single transaction (in deployment
procedure it would be very handy and important).

Digging the source of slonik and _schemadoc I assumed that I possibly could
do it via slonik
(for better readability I replaced FILENAME=3D'xxx' clause by the content of
xxx itself):


-- Perform my DDL modifications.
EXECUTE SCRIPT {
  ALTER TABLE tbl ADD COLUMN id_copy INTEGER;
}

EXECUTE SCRIPT {
  -- This is needed to deny execution of this SQL in other nodes.
  EXECUTE ONLY ON =3D <my_origin_node>

  -- Temporariy turn on replication mode.
  SET session_replication_role TO origin;
  -- Perform my DML operations. They will be replicated via logTrigger as
usual.
  UPDATE tbl SET id_copy =3D id;
  UPDATE tbl SET abc =3D 123;
  -- Reset replication mode back.
  SET session_replication_role TO local;
}

-- Perform any other DDL modifications.
EXECUTE SCRIPT {
  ALTER TABLE tbl ADD COLUMN c INTEGER;
}
...

Please say would this method work without side effects or not?
Thank you!

B.r.,
  Dmitry Koterov,
  chief architect at MoiKrug.Ru, Yandex, Moscow.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.slony.info/pipermail/slony1-general/attachments/20090307/=
18d48973/attachment.htm


More information about the Slony1-general mailing list