Chris Browne cbbrowne at lists.slony.info
Thu Feb 8 14:56:00 PST 2007
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main:/tmp/cvs-serv10636/src/backend

Modified Files:
      Tag: REL_1_2_STABLE
	Makefile slony1_funcs.sql slony1_funcs.v73.sql 
	slony1_funcs.v74.sql slony1_funcs.v80.sql 
Added Files:
      Tag: REL_1_2_STABLE
	slony1_base.v81.sql slony1_funcs.v81.sql 
Log Message:
1_2_STABLE updates:

- Release notes
- Change version to 1.2.7
- Need to install v81.sql files
- Fix expansion of cluster name in generate_sync_event()
- update functions now includes a call to make_function_strict() for xxidin()


Index: slony1_funcs.v73.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.v73.sql,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** slony1_funcs.v73.sql	11 Nov 2005 13:53:24 -0000	1.9
--- slony1_funcs.v73.sql	8 Feb 2007 22:55:58 -0000	1.9.2.1
***************
*** 103,104 ****
--- 103,113 ----
  'Returns 1 or 0 based on whether or not the DB is running a
  version earlier than 7.4';
+ 
+ create or replace function @NAMESPACE at .make_function_strict (text, text) returns void as
+ '
+    update "pg_catalog"."pg_proc" set proisstrict = ''t'' where 
+            proname = $1 and pronamespace = (select oid from "pg_catalog"."pg_namespace" where nspname = '_ at CLUSTERNAME@') and prolang = (select oid from "pg_catalog"."pg_language" where lanname = ''c'');
+ ' language sql;
+ 
+ comment on function @NAMESPACE at .make_function_strict (text, text) is
+ 'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';

Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.98.2.8
retrieving revision 1.98.2.9
diff -C2 -d -r1.98.2.8 -r1.98.2.9
*** slony1_funcs.sql	8 Jan 2007 17:31:40 -0000	1.98.2.8
--- slony1_funcs.sql	8 Feb 2007 22:55:58 -0000	1.98.2.9
***************
*** 431,435 ****
  as '
  begin
! 	return 6;
  end;
  ' language plpgsql;
--- 431,435 ----
  as '
  begin
! 	return 7;
  end;
  ' language plpgsql;
***************
*** 5219,5227 ****
  BEGIN
  	select 1 into v_node_row from @NAMESPACE at .sl_event 
!        	  where ev_type = ''SYNC'' and ev_origin = @NAMESPACE at .getLocalNodeId(''@NAMESPACE@'')
            and ev_timestamp > now() - p_interval limit 1;
  	if not found then
  		-- If there has been no SYNC in the last interval, then push one
! 		perform @NAMESPACE at .createEvent(''@NAMESPACE@'', ''SYNC'', NULL);
  		return 1;
  	else
--- 5219,5227 ----
  BEGIN
  	select 1 into v_node_row from @NAMESPACE at .sl_event 
!        	  where ev_type = ''SYNC'' and ev_origin = @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'')
            and ev_timestamp > now() - p_interval limit 1;
  	if not found then
  		-- If there has been no SYNC in the last interval, then push one
! 		perform @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''SYNC'', NULL);
  		return 1;
  	else
***************
*** 5830,5833 ****
--- 5830,5835 ----
  	end if;
  
+ 	-- In any version, make sure that the xxidin() functions are defined STRICT
+ 	perform @NAMESPACE at .make_function_strict (''xxidin'', ''(cstring)'');
  	return p_old;
  end;
***************
*** 5903,5904 ****
--- 5905,5907 ----
  
  In PG versions > 7.3, this looks like (field1,field2,...fieldn)';
+ 

Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/Makefile,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -C2 -d -r1.22.2.1 -r1.22.2.2
*** Makefile	14 Dec 2006 22:30:25 -0000	1.22.2.1
--- Makefile	8 Feb 2007 22:55:58 -0000	1.22.2.2
***************
*** 29,32 ****
--- 29,35 ----
  FUNCS_80		= slony1_funcs.v80.sql
  
+ BASE_81			= slony1_base.v81.sql
+ FUNCS_81		= slony1_funcs.v81.sql
+ 
  SQL_NAMES =				\
  	$(BASE_COMMON)		\
***************
*** 35,39 ****
  	$(FUNCS_74)			\
  	$(BASE_80)			\
! 	$(FUNCS_80)
  
  DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)
--- 38,44 ----
  	$(FUNCS_74)			\
  	$(BASE_80)			\
! 	$(FUNCS_80)			\
! 	$(BASE_81)			\
! 	$(FUNCS_81)
  
  DISTFILES = Makefile README README.events $(wildcard *.sql) $(wildcard *.in) $(wildcard *.c)

Index: slony1_funcs.v80.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.v80.sql,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** slony1_funcs.v80.sql	5 Dec 2006 18:04:46 -0000	1.2.2.1
--- slony1_funcs.v80.sql	8 Feb 2007 22:55:58 -0000	1.2.2.2
***************
*** 4,8 ****
  --    Version 8.0 specific part of the replication support functions.
  --
! --	Copyright (c) 2003-2004, PostgreSQL Global Development Group
  --	Author: Jan Wieck, Afilias USA INC.
  --
--- 4,8 ----
  --    Version 8.0 specific part of the replication support functions.
  --
! --	Copyright (c) 2003-2006, PostgreSQL Global Development Group
  --	Author: Jan Wieck, Afilias USA INC.
  --
***************
*** 25,29 ****
  begin
  	-- ----
! 	-- Get the OID and fully qualified name for the table
  	-- ---
  	select	PGC.oid,
--- 25,29 ----
  begin
  	-- ----
! 	-- Get the tables OID and fully qualified name
  	-- ---
  	select	PGC.oid,
***************
*** 57,61 ****
  	exception when others then
  		raise notice ''truncate of % failed - doing delete'', v_tab_fqname;
- 		update pg_class set relhasindex = ''f'' where oid = v_tab_oid;
  		execute ''delete from only '' || @NAMESPACE at .slon_quote_input(v_tab_fqname);
  		return 0;
--- 57,60 ----
***************
*** 115,116 ****
--- 114,127 ----
  'Returns 1/0 based on whether or not the DB is running a
  version earlier than 7.4';
+ 
+ create or replace function @NAMESPACE at .make_function_strict (text, text) returns integer as
+ '
+ begin
+    update "pg_catalog"."pg_proc" set proisstrict = ''t'' where 
+      proname = $1 and pronamespace = (select oid from "pg_catalog"."pg_namespace" where nspname = ''_ at CLUSTERNAME@'') and prolang = (select oid from "pg_catalog"."pg_language" where lanname = ''c'');
+    return 1 ;
+ end
+ ' language plpgsql;
+ 
+ comment on function @NAMESPACE at .make_table_strict (text, text) is
+ 'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';

Index: slony1_funcs.v74.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.v74.sql,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -d -r1.8 -r1.8.2.1
*** slony1_funcs.v74.sql	11 Nov 2005 13:53:24 -0000	1.8
--- slony1_funcs.v74.sql	8 Feb 2007 22:55:58 -0000	1.8.2.1
***************
*** 4,8 ****
  --    Version 7.4 specific part of the replication support functions.
  --
! --	Copyright (c) 2003-2004, PostgreSQL Global Development Group
  --	Author: Jan Wieck, Afilias USA INC.
  --
--- 4,8 ----
  --    Version 7.4 specific part of the replication support functions.
  --
! --	Copyright (c) 2003-2006, PostgreSQL Global Development Group
  --	Author: Jan Wieck, Afilias USA INC.
  --
***************
*** 98,104 ****
  create or replace function @NAMESPACE at .pre74()
  returns integer
! as 'select 0;' language sql;
  
  comment on function @NAMESPACE at .pre74() is 
! 'Returns 1 or 0 based on whether or not the DB is running a
! version earlier than 7.4';
--- 98,115 ----
  create or replace function @NAMESPACE at .pre74()
  returns integer
! as 'select 0' language sql;
  
  comment on function @NAMESPACE at .pre74() is 
! 'Returns 1/0 based on whether or not the DB is running a version earlier than 7.4';
! 
! create or replace function @NAMESPACE at .make_function_strict (text, text) returns void as
! '
! begin
!    update "pg_catalog"."pg_proc" set proisstrict = ''t'' where 
!      proname = $1 and pronamespace = (select oid from "pg_catalog"."pg_namespace" where nspname = ''_ at CLUSTERNAME@'') and prolang = (select oid from "pg_catalog"."pg_language" where lanname = ''c'');
!    return 1 ;
! end
! ' language plpgsql;
! 
! comment on function @NAMESPACE at .make_function_strict (text, text) is
! 'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';

--- NEW FILE: slony1_base.v81.sql ---
-- ----------------------------------------------------------------------
-- slony1_base.v81.sql
--
--    Version 8.1 specific parts of the basic replication schema.
--
--	Copyright (c) 2003-2004, PostgreSQL Global Development Group
--	Author: Jan Wieck, Afilias USA INC.
--
-- $Id: slony1_base.v81.sql,v 1.1.2.1 2007-02-08 22:55:58 cbbrowne Exp $
-- ----------------------------------------------------------------------



--- NEW FILE: slony1_funcs.v81.sql ---
-- ----------------------------------------------------------------------
-- slony1_funcs.v81.sql
--
--    Version 8.1 specific part of the replication support functions.
--
--	Copyright (c) 2003-2004, PostgreSQL Global Development Group
--	Author: Jan Wieck, Afilias USA INC.
--
-- $Id: slony1_funcs.v81.sql,v 1.1.2.1 2007-02-08 22:55:58 cbbrowne Exp $
-- ----------------------------------------------------------------------

-- ----------------------------------------------------------------------
-- FUNCTION prepareTableForCopy(tab_id)
--
--	Remove all content from a table before the subscription
--	content is loaded via COPY and disable index maintenance.
-- ----------------------------------------------------------------------
create or replace function @NAMESPACE at .prepareTableForCopy(int4)
returns int4
as '
declare
	p_tab_id		alias for $1;
	v_tab_oid		oid;
	v_tab_fqname	text;
begin
	-- ----
	-- Get the OID and fully qualified name for the table
	-- ---
	select	PGC.oid,
			@NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' ||
			@NAMESPACE at .slon_quote_brute(PGC.relname) as tab_fqname
		into v_tab_oid, v_tab_fqname
			from @NAMESPACE at .sl_table T,   
				"pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN
				where T.tab_id = p_tab_id
				and T.tab_reloid = PGC.oid
				and PGC.relnamespace = PGN.oid;
	if not found then
		raise exception ''Table with ID % not found in sl_table'', p_tab_id;
	end if;

	-- ----
	-- Setting pg_class.relhasindex to false will cause copy not to
	-- maintain any indexes. At the end of the copy we will reenable
	-- them and reindex the table. This bulk creating of indexes is
	-- faster.
	-- ----
	update pg_class set relhasindex = ''f'' where oid = v_tab_oid;

	-- ----
	-- Try using truncate to empty the table and fallback to
	-- delete on error.
	-- ----
	execute ''truncate '' || @NAMESPACE at .slon_quote_input(v_tab_fqname);
	raise notice ''truncate of % succeeded'', v_tab_fqname;
	return 1;
	exception when others then
		raise notice ''truncate of % failed - doing delete'', v_tab_fqname;
		update pg_class set relhasindex = ''f'' where oid = v_tab_oid;
		execute ''delete from only '' || @NAMESPACE at .slon_quote_input(v_tab_fqname);
		return 0;
end;
' language plpgsql;

comment on function @NAMESPACE at .prepareTableForCopy(int4) is
'Delete all data and suppress index maintenance';

-- ----------------------------------------------------------------------
-- FUNCTION finishTableAfterCopy(tab_id)
--
--	Reenable index maintenance and reindex the table after COPY.
-- ----------------------------------------------------------------------
create or replace function @NAMESPACE at .finishTableAfterCopy(int4)
returns int4
as '
declare
	p_tab_id		alias for $1;
	v_tab_oid		oid;
	v_tab_fqname	text;
begin
	-- ----
	-- Get the tables OID and fully qualified name
	-- ---
	select	PGC.oid,
			@NAMESPACE at .slon_quote_brute(PGN.nspname) || ''.'' ||
			@NAMESPACE at .slon_quote_brute(PGC.relname) as tab_fqname
		into v_tab_oid, v_tab_fqname
			from @NAMESPACE at .sl_table T,   
				"pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN
				where T.tab_id = p_tab_id
				and T.tab_reloid = PGC.oid
				and PGC.relnamespace = PGN.oid;
	if not found then
		raise exception ''Table with ID % not found in sl_table'', p_tab_id;
	end if;

	-- ----
	-- Reenable indexes and reindex the table.
	-- ----
	update pg_class set relhasindex = ''t'' where oid = v_tab_oid;
	execute ''reindex table '' || @NAMESPACE at .slon_quote_input(v_tab_fqname);

	return 1;
end;
' language plpgsql;

comment on function @NAMESPACE at .finishTableAfterCopy(int4) is
'Reenable index maintenance and reindex the table';

create or replace function @NAMESPACE at .pre74()
returns integer
as 'select 0' language sql;

comment on function @NAMESPACE at .pre74() is 
'Returns 1/0 based on whether or not the DB is running a
version earlier than 7.4';

create or replace function @NAMESPACE at .make_function_strict (text, text) returns void as
'
declare
   fun alias for $1;
   parms alias for $2;
   stmt text;
begin
   stmt := ''ALTER FUNCTION "_ at CLUSTERNAME@".'' || fun || '' '' || parms || '' STRICT;'';
   execute stmt;
   return;
end
' language plpgsql;

comment on function @NAMESPACE at .make_function_strict (text, text) is
'Equivalent to 8.1+ ALTER FUNCTION ... STRICT';




More information about the Slony1-commit mailing list