Chris Browne cbbrowne at lists.slony.info
Mon Apr 6 15:33:07 PDT 2009
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv17032/src/backend

Modified Files:
      Tag: REL_2_0_STABLE
	slony1_funcs.sql 
Log Message:
Fix bug #76 - REPAIR CONFIG could have collisions where, when we load a
schema, one entry in sl_table already has an OID value that incorrectly
matches a value that another update is trying to fix.

This would cause REPAIR CONFIG to fail.

Put in a query that updates the oids in sl_table and sl_sequence to
randomly selected values from pg_class that couldn't match (since the
values selected are from non-table/non-sequence objects)


Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.145.2.7
retrieving revision 1.145.2.8
diff -C2 -d -r1.145.2.7 -r1.145.2.8
*** slony1_funcs.sql	1 Apr 2009 17:13:38 -0000	1.145.2.7
--- slony1_funcs.sql	6 Apr 2009 22:33:04 -0000	1.145.2.8
***************
*** 5033,5036 ****
--- 5033,5037 ----
          v_no_id                 int4;
          v_set_origin            int4;
+ 	prec			record;
  begin
          -- ----
***************
*** 5066,5069 ****
--- 5067,5078 ----
                  return 0;
          end if;
+ 
+ 	-- Update OIDs for tables to values pulled from non-table objects in pg_class
+ 	-- This ensures that we won't have collisions when repairing the oids
+ 	for prec in select tab_id from @NAMESPACE at .sl_table loop
+ 		update @NAMESPACE at .sl_table set tab_reloid = (select oid from pg_class pc where relkind <> 'r' and not exists (select 1 from @NAMESPACE at .sl_table t2 where t2.tab_reloid = pc.oid) limit 1)
+ 		where tab_id = prec.tab_id;
+ 	end loop;
+ 
          update @NAMESPACE at .sl_table set
                  tab_reloid = PGC.oid
***************
*** 5073,5076 ****
--- 5082,5090 ----
  			and @NAMESPACE at .slon_quote_brute(PGN.nspname) = @NAMESPACE at .slon_quote_brute(@NAMESPACE at .sl_table.tab_nspname);
  
+ 	for prec in select seq_id from @NAMESPACE at .sl_sequence loop
+ 		update @NAMESPACE at .sl_sequence set seq_reloid = (select oid from pg_class pc where relkind <> 'S' and not exists (select 1 from @NAMESPACE at .sl_sequence t2 where t2.tab_reloid = pc.oid) limit 1)
+ 		where tab_id = prec.seq_id;
+ 	end loop;
+ 
          update @NAMESPACE at .sl_sequence set
                  seq_reloid = PGC.oid



More information about the Slony1-commit mailing list