Alan Hodgson ahodgson
Fri Sep 9 16:46:39 PDT 2005
On Fri, Sep 09, 2005 at 11:54:34PM +1000, Philip Warner wrote:
> My question is: is there as way I can just restore the slony tables then
> make slony apply those changes to the current master? Or generate a
> script to do this? If the old master was still around, we should be able
> to apply the changes to the old slave, but the old master is gone, and
> the old slave is now a master.
> 
> Ideally, I'd like to just apply changes to a subset of the old tables:
> looking at the data in the slony schema, it seems all I need is there...


Everything you need should really be in sl_log_1 (and sl_table to get the table
names).  The only question I would have is how to get the correct ordering on
the sl_log_1 data (can you just use log_actionseq?).  

This will generate the SQL (if the ordering is right?):

SELECT CASE WHEN sl.log_cmdtype = 'I' THEN 'INSERT INTO ' || st.tab_nspname || '.' || st.tab_relname || ' ' || sl.log_cmddata  WHEN sl.log_cmdtype = 'U' THEN 'UPDATE ' || st.tab_nspname || '.' || st.tab_relname || ' SET ' || sl.log_cmddata WHEN sl.log_cmdtype = 'D' THEN 'DELETE FROM ' || st.tab_nspname || '.' || st.tab_relname || ' WHERE ' || sl.log_cmddata END || ';' FROM sl_log_1 sl JOIN sl_table st ON (sl.log_tableid=st.tab_id) ORDER BY sl.log_actionseq;

Doesn't handle DDL changes of course.

-- 
Politicians only fear one thing: peasants with guns



More information about the Slony1-general mailing list