Chris Browne cbbrowne at lists.slony.info
Tue Apr 3 14:55:05 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv3668/src/backend

Modified Files:
      Tag: REL_1_2_STABLE
	slony1_funcs.sql 
Log Message:
Update to DDL handling - when a script is specified with "EXECUTE ONLY ON"
a specific node, it should be invoked, by slonik, only on that node.


Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.98.2.13
retrieving revision 1.98.2.14
diff -C2 -d -r1.98.2.13 -r1.98.2.14
*** slony1_funcs.sql	22 Mar 2007 20:41:27 -0000	1.98.2.13
--- slony1_funcs.sql	3 Apr 2007 21:55:03 -0000	1.98.2.14
***************
*** 3684,3689 ****
--- 3684,3692 ----
  	lock table @NAMESPACE at .sl_config_lock;
  
+ 	
  	-- ----
  	-- Check that the set exists and originates here
+ 	-- unless only_on_node was specified (then it can be applied to
+ 	-- that node because that is what the user wanted)
  	-- ----
  	select set_origin into v_set_origin
***************
*** 3694,3707 ****
  		raise exception ''Slony-I: set % not found'', p_set_id;
  	end if;
! 	if v_set_origin <> @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'') then
! 		raise exception ''Slony-I: set % does not originate on local node'',
  				p_set_id;
  	end if;
- 
- 	-- ----
- 	-- Create a SYNC event, run the script and generate the DDL_SCRIPT event
- 	-- ----
- 	perform @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''SYNC'', NULL);
- 	perform @NAMESPACE at .alterTableRestore(tab_id) from @NAMESPACE at .sl_table where tab_set in (select set_id from @NAMESPACE at .sl_set where set_origin = @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@''));
  	return 1;
  end;
--- 3697,3717 ----
  		raise exception ''Slony-I: set % not found'', p_set_id;
  	end if;
! 
! 	if p_only_on_node = -1 then
! 		if v_set_origin <> @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'') then
! 			raise exception ''Slony-I: set % does not originate on local node'',
  				p_set_id;
+ 		end if;
+ 		-- ----
+ 		-- Create a SYNC event, run the script and generate the DDL_SCRIPT event
+ 		-- ----
+ 		perform @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''SYNC'', NULL);
+ 		perform @NAMESPACE at .alterTableRestore(tab_id) from @NAMESPACE at .sl_table where tab_set in (select set_id from @NAMESPACE at .sl_set where set_origin = @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@''));
+ 	else
+ 		-- ----
+ 		-- If doing "only on one node" - restore ALL tables irrespective of set
+ 		-- ----
+ 		perform @NAMESPACE at .alterTableRestore(tab_id) from @NAMESPACE at .sl_table;
  	end if;
  	return 1;
  end;
***************
*** 3729,3734 ****
--- 3739,3747 ----
  	perform @NAMESPACE at .updateRelname(p_set_id, p_only_on_node);
  	perform @NAMESPACE at .alterTableForReplication(tab_id) from @NAMESPACE at .sl_table where tab_set in (select set_id from @NAMESPACE at .sl_set where set_origin = @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@''));
+ 	if p_only_on_node = -1 then
  	return  @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''DDL_SCRIPT'', 
  			p_set_id, p_script, p_only_on_node);
+ 	end if;
+ 	return NULL;
  end;
  ' language plpgsql;
***************
*** 5905,5907 ****
  
  In PG versions > 7.3, this looks like (field1,field2,...fieldn)';
- 
--- 5918,5919 ----



More information about the Slony1-commit mailing list