Chris Browne cbbrowne at lists.slony.info
Mon Feb 25 07:42:34 PST 2008
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv2834

Modified Files:
	slony1_funcs.sql 
Log Message:
remove function logswitch_weekly() as we are now switching logs more or
less as often as possible


Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.131
retrieving revision 1.132
diff -C2 -d -r1.131 -r1.132
*** slony1_funcs.sql	14 Feb 2008 22:21:42 -0000	1.131
--- slony1_funcs.sql	25 Feb 2008 15:42:32 -0000	1.132
***************
*** 5130,5208 ****
  Initiate a log table switch if none is in progress';
  
- 
- -- ----------------------------------------------------------------------
- -- FUNCTION logswitch_weekly()
- --
- --	Called by slonik to ensure that a logswitch is done at least
- --  once a week. The default time is Sunday 2am.
- -- ----------------------------------------------------------------------
- create or replace function @NAMESPACE at .logswitch_weekly()
- returns int4 as '
- DECLARE
- 	v_now			timestamp;
- 	v_now_dow		int4;
- 	v_auto_dow		int4;
- 	v_auto_time		time;
- 	v_auto_ts		timestamp;
- 	v_lastrun		timestamp;
- 	v_laststart		timestamp;
- 	v_days_since	int4;
- BEGIN
- 	-- ----
- 	-- Check that today is the day to run at all
- 	-- ----
- 	v_auto_dow := @NAMESPACE at .registry_get_int4(
- 			''logswitch_weekly.dow'', 0);
- 	v_now := "pg_catalog".now();
- 	v_now_dow := extract (DOW from v_now);
- 	if v_now_dow <> v_auto_dow then
- 		perform @NAMESPACE at .registry_set_timestamp(
- 				''logswitch_weekly.lastrun'', v_now);
- 		return 0;
- 	end if;
- 
- 	-- ----
- 	-- Check that the last run of this procedure was before and now is
- 	-- after the time we should automatically switch logs.
- 	-- ----
- 	v_auto_time := @NAMESPACE at .registry_get_text(
- 			''logswitch_weekly.time'', ''02:00'');
- 	v_auto_ts := current_date + v_auto_time;
- 	v_lastrun := @NAMESPACE at .registry_get_timestamp(
- 			''logswitch_weekly.lastrun'', ''epoch'');
- 	if v_lastrun >= v_auto_ts or v_now < v_auto_ts then
- 		perform @NAMESPACE at .registry_set_timestamp(
- 				''logswitch_weekly.lastrun'', v_now);
- 		return 0;
- 	end if;
- 
- 	-- ----
- 	-- This is the moment configured in dow+time. Check that the
- 	-- last logswitch was done more than 2 days ago.
- 	-- ----
- 	v_laststart := @NAMESPACE at .registry_get_timestamp(
- 			''logswitch.laststart'', ''epoch'');
- 	v_days_since := extract (days from (v_now - v_laststart));
- 	if v_days_since < 2 then
- 		perform @NAMESPACE at .registry_set_timestamp(
- 				''logswitch_weekly.lastrun'', v_now);
- 		return 0;
- 	end if;
- 
- 	-- ----
- 	-- Fire off an automatic logswitch
- 	-- ----
- 	perform @NAMESPACE at .logswitch_start();
- 	perform @NAMESPACE at .registry_set_timestamp(
- 			''logswitch_weekly.lastrun'', v_now);
- 	return 1;
- END;
- ' language plpgsql;
- comment on function @NAMESPACE at .logswitch_weekly() is
- 'logswitch_weekly()
- 
- Ensure a logswitch is done at least weekly';
- 
- 
  -- ----------------------------------------------------------------------
  -- FUNCTION logswitch_finish()
--- 5130,5133 ----



More information about the Slony1-commit mailing list