Chris Browne cbbrowne at lists.slony.info
Thu Dec 18 13:27:07 PST 2008
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv20287/src/backend

Modified Files:
	slony1_funcs.sql 
Log Message:
Fix to bug #69

http://www.slony.info/bugzilla/show_bug.cgi?id=69

The problem is that one of the new functions expects the type, "vactables", to
exist.

The "upgrade functions" function has code that *would* create it, but that
function is not run until *after* the whole slony1_functions.sql file has been
loaded, and that is way too late.

The attached patch creates, runs, and drops, a temporary function that adds the
type should it be missing.

I have run this through regression test #1 on the HEAD branch, which includes a
run of slonik "UPDATE FUNCTIONS."



Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** slony1_funcs.sql	17 Nov 2008 22:39:47 -0000	1.145
--- slony1_funcs.sql	18 Dec 2008 21:27:05 -0000	1.146
***************
*** 5425,5432 ****
  		execute 'alter table @NAMESPACE at .sl_node drop column no_spool;';
  
- 		-- ----
- 		-- create new type - vactables - used by TablesToVacuum()
- 		-- ----
- 		execute 'create type @NAMESPACE at .vactables as (nspname name, relname name);';
  	end if;
  
--- 5425,5428 ----
***************
*** 5670,5673 ****
--- 5666,5686 ----
  '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
+ 	if not exists (select 1 from pg_catalog.pg_type t, pg_catalog.pg_namespace n
+ 			where n.nspname = '_ at CLUSTERNAME@' and t.typnamespace = n.oid and
+ 			t.typname = 'vactables') then
+ 		execute 'create type @NAMESPACE at .vactables as (nspname name, relname name);';
+ 	end if;
+ 	return 1;
+ end
+ $$ language plpgsql;
+ 
+ comment on function @NAMESPACE at .setup_vactables_type () is 
+ 'Function to be run as part of loading slony1_funcs.sql that creates the vactables type if it is missing';
+ 
+ select @NAMESPACE at .setup_vactables_type();
+ 
+ drop function @NAMESPACE at .setup_vactables_type ();
  
  -- ----------------------------------------------------------------------



More information about the Slony1-commit mailing list