Unfortunately, this method does not work. Because we cannot have more than one separated group of sl_log items within a single transaction: sl_event SYNC contain information only about xid, not about sequence of sl_log item. So, if we have
xid=123: (0) SYNC xid=123: (1) DDL_SCRIPT xid=123: (2) SYNC xid=123: (3) DDL_SCRIPT then slon cannot detect are sl_log items of (2) SYNC were performed *before*(3) DDL_SCRIPT or *after* it. And the following sequence becomes broken: (1) ALTER TABLE a ADD COLUMN id_copy INTEGER; (2) UPDATE a SET id_copy = id; (3) ALTER TABLE a RENAME COLUMN id_copy TO abcd; But, while digging the source, I have suddenly found 2 bugs. I reported them here (with solution patches attached): http://www.slony.info/bugzilla/show_bug.cgi?id=75 On Sat, Mar 7, 2009 at 1:40 AM, Dmitry Koterov <[email protected]> wrote: > 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='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 = <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 = id; > UPDATE tbl SET abc = 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. > >
_______________________________________________ Slony1-general mailing list [email protected] http://lists.slony.info/mailman/listinfo/slony1-general
