Chris Browne cbbrowne at lists.slony.info
Tue Jul 21 14:15:53 PDT 2009
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv8262/backend

Modified Files:
      Tag: REL_2_0_STABLE
	Makefile slony1_base.sql slony1_base.v83.sql slony1_funcs.sql 
Added Files:
      Tag: REL_2_0_STABLE
	slony1_base.v84.sql slony1_funcs.v84.sql 
Log Message:
Addressing autovacuum change in PostgreSQL 8.4

1.  Need to have v84.sql files

2.  Need for slonik to install v84.sql files, when apropos

3.  v84.sql functions file implements alternative implementation
    which pulls the attribute from pg_class rather than the former
    pg_autovacuum table


Index: slony1_base.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_base.sql,v
retrieving revision 1.40.2.1
retrieving revision 1.40.2.2
diff -C2 -d -r1.40.2.1 -r1.40.2.2
*** slony1_base.sql	23 Feb 2009 17:23:55 -0000	1.40.2.1
--- slony1_base.sql	21 Jul 2009 21:15:51 -0000	1.40.2.2
***************
*** 470,473 ****
--- 470,474 ----
  create sequence @NAMESPACE at .sl_event_seq;
  comment on sequence @NAMESPACE at .sl_event_seq is 'The sequence for numbering events originating from this node.';
+ select setval('@NAMESPACE at .sl_event_seq', 5000000000);
  
  -- ----------------------------------------------------------------------
***************
*** 534,541 ****
  comment on column @NAMESPACE at .sl_config_lock.dummy is 'No data ever goes in this table so the contents never matter.  Indeed, this column does not really need to exist.';
  
- create type @NAMESPACE at .vactables as (nspname name, relname name);
- 
- comment on type @NAMESPACE at .vactables is 'used as return type for SRF function TablesToVacuum';
- 
  -- ----------------------------------------------------------------------
  -- TABLE sl_archive_counter
--- 535,538 ----

Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.145.2.12
retrieving revision 1.145.2.13
diff -C2 -d -r1.145.2.12 -r1.145.2.13
*** slony1_funcs.sql	14 Jul 2009 19:09:00 -0000	1.145.2.12
--- slony1_funcs.sql	21 Jul 2009 21:15:51 -0000	1.145.2.13
***************
*** 5620,5673 ****
  'Reenable index maintenance and reindex the table';
  
- 
- -- ----------------------------------------------------------------------
- -- FUNCTION ShouldSlonyVacuumTable (nspname, tabname)
- --
- --	Returns 't' if the table needs to be vacuumed by Slony-I
- --      Returns 'f' if autovac handles the table, so Slony-I should not
- --                  or if the table is not needful altogether
- -- ----------------------------------------------------------------------
- create or replace function @NAMESPACE at .ShouldSlonyVacuumTable (name, name) returns boolean as
- $$
- declare
- 	i_nspname alias for $1;
- 	i_tblname alias for $2;
- 	c_table oid;
- 	c_namespace oid;
- 	c_enabled boolean;
- 	v_dummy int4;
- begin
- 	select 1 into v_dummy from "pg_catalog".pg_settings where name = 'autovacuum' and setting = 'on';
- 	if not found then
- 		return 't'::boolean;       -- If autovac is turned off, then we gotta vacuum
- 	end if;
- 	
- 	select into c_namespace oid from "pg_catalog".pg_namespace where nspname = i_nspname;
- 	if not found then
- 		raise exception 'Slony-I: namespace % does not exist', i_nspname;
- 	end if;
- 	select into c_table oid from "pg_catalog".pg_class where relname = i_tblname and relnamespace = c_namespace;
- 	if not found then
- 		raise warning 'Slony-I: table % does not exist in namespace %/%', tblname, c_namespace, i_nspname;
- 		return 'f'::boolean;
- 	end if;
- 	
- 	-- So, the table is legit; try to look it up for autovacuum policy
- 	select enabled into c_enabled from "pg_catalog".pg_autovacuum where vacrelid = c_table;
- 
- 	if not found then
- 		return 'f'::boolean;   -- Autovac is turned on, and this table has no overriding handling
- 	end if;
- 
- 	if c_enabled then
- 		return 'f'::boolean;   -- Autovac is expressly turned on for this table
- 	end if;
- 
- 	return 't'::boolean;
- end;$$ language plpgsql;
- 
- comment on function @NAMESPACE at .ShouldSlonyVacuumTable (name, name) is 
- 'returns false if autovacuum handles vacuuming of the table, or if the table does not exist; returns true if Slony-I should manage it';
- 
  create or replace function @NAMESPACE at .setup_vactables_type () returns integer as $$
  begin
--- 5620,5623 ----

--- NEW FILE: slony1_base.v84.sql ---
-- ----------------------------------------------------------------------
-- slony1_base.v83.sql
--
--    Version 8.3 specific parts of the basic replication schema.
--
--	Copyright (c) 2007, PostgreSQL Global Development Group
--	Author: Jan Wieck, Afilias USA INC.
--
-- $Id: slony1_base.v84.sql,v 1.1.2.1 2009-07-21 21:15:51 cbbrowne Exp $
-- ----------------------------------------------------------------------

create type @NAMESPACE at .vactables as (nspname name, relname name);

comment on type @NAMESPACE at .vactables is 'used as return type for SRF function TablesToVacuum';



--- NEW FILE: slony1_funcs.v84.sql ---
-- ----------------------------------------------------------------------
-- slony1_funcs.v83.sql
--
--    Version 8.3 specific part of the replication support functions.
--
--	Copyright (c) 2007, PostgreSQL Global Development Group
--	Author: Jan Wieck, Afilias USA INC.
--
-- $Id: slony1_funcs.v84.sql,v 1.1.2.1 2009-07-21 21:15:51 cbbrowne Exp $
-- ----------------------------------------------------------------------

-- ----------------------------------------------------------------------
-- FUNCTION ShouldSlonyVacuumTable (nspname, tabname)
--
--	Returns 't' if the table needs to be vacuumed by Slony-I
--      Returns 'f' if autovac handles the table, so Slony-I should not
--                  or if the table is not needful altogether
-- ----------------------------------------------------------------------
create or replace function @NAMESPACE at .ShouldSlonyVacuumTable (name, name) returns boolean as
$$
declare
	i_nspname alias for $1;
	i_tblname alias for $2;
	c_table oid;
	c_namespace oid;
	c_enabled boolean;
	v_dummy int4;
begin
	select 1 into v_dummy from "pg_catalog".pg_settings where name = 'autovacuum' and setting = 'on';
	if not found then
		return 't'::boolean;       -- If autovac is turned off, then we gotta vacuum
	end if;
	
	select into c_namespace oid from "pg_catalog".pg_namespace where nspname = i_nspname;
	if not found then
		raise exception 'Slony-I: namespace % does not exist', i_nspname;
	end if;
	select into c_table oid from "pg_catalog".pg_class where relname = i_tblname and relnamespace = c_namespace;
	if not found then
		raise warning 'Slony-I: table % does not exist in namespace %/%', tblname, c_namespace, i_nspname;
		return 'f'::boolean;
	end if;
	
	-- So, the table is legit; try to look it up for autovacuum policy
	if exists (select 1 from pg_class where 'autovacuum_enabled=off' = any (reloptions) and oid = c_table) then
		return 't'::boolean;   -- Autovac is turned on, but this table is disabled
	end if;

	return 'f'::boolean;

end;$$ language plpgsql;

comment on function @NAMESPACE at .ShouldSlonyVacuumTable (name, name) is 
'returns false if autovacuum handles vacuuming of the table, or if the table does not exist; returns true if Slony-I should manage it';


Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/Makefile,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -C2 -d -r1.26 -r1.26.2.1
*** Makefile	7 Jun 2007 13:01:10 -0000	1.26
--- Makefile	21 Jul 2009 21:15:51 -0000	1.26.2.1
***************
*** 25,28 ****
--- 25,30 ----
  BASE_83			= slony1_base.v83.sql
  FUNCS_83		= slony1_funcs.v83.sql
+ BASE_84			= slony1_base.v84.sql
+ FUNCS_84		= slony1_funcs.v84.sql
  
  SQL_NAMES =				\
***************
*** 30,34 ****
  	$(FUNCS_COMMON)		\
  	$(BASE_83)			\
! 	$(FUNCS_83)
  
  DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)
--- 32,38 ----
  	$(FUNCS_COMMON)		\
  	$(BASE_83)			\
! 	$(BASE_84)			\
! 	$(FUNCS_83)			\
! 	$(FUNCS_84)
  
  DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)

Index: slony1_base.v83.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_base.v83.sql,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** slony1_base.v83.sql	31 May 2007 18:55:28 -0000	1.1
--- slony1_base.v83.sql	21 Jul 2009 21:15:51 -0000	1.1.2.1
***************
*** 10,12 ****
--- 10,16 ----
  -- ----------------------------------------------------------------------
  
+ create type @NAMESPACE at .vactables as (nspname name, relname name);
+ 
+ comment on type @NAMESPACE at .vactables is 'used as return type for SRF function TablesToVacuum';
+ 
  



More information about the Slony1-commit mailing list