CVS User Account cvsuser
Mon Aug 14 13:38:55 PDT 2006
Log Message:
-----------
As noticed by AndyY, there was a problem with creation of extra sl_log_?
indices in the function addPartialLogIndices(); it wasn't recognizing when
indices were already in place.

Revised it to search pg_indexes better, and ran through cases where it
was expected to both create and add indices.  All's well now...

http://rafb.net/paste/results/oRWz8l49.html

Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.sql (r1.94 -> r1.95)

-------------- next part --------------
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.94
retrieving revision 1.95
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.94 -r1.95
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -5602,8 +5602,10 @@
 	v_current_status	int4;
 	v_log			int4;
 	v_dummy		record;
+	v_dummy2	record;
 	idef 		text;
 	v_count		int4;
+        v_iname         text;
 BEGIN
 	v_count := 0;
 	select last_value into v_current_status from @NAMESPACE at .sl_log_status;
@@ -5618,26 +5620,32 @@
 	else
 		v_log := 1;
 	end if;
-
+--                                       PartInd_test_db_sl_log_2-node-1
 	-- Add missing indices...
-	for v_dummy in select distinct set_origin from @NAMESPACE at .sl_set
-		where not exists 
-                     (select * from pg_catalog.pg_indexes where schemaname = ''@NAMESPACE@''
-                      and tablename = ''sl_log_'' || v_log and 
-                      indexname = ''PartInd_ at CLUSTERNAME at _sl_log_'' || v_log || ''-node-'' || set_origin) loop	   
+	for v_dummy in select distinct set_origin from @NAMESPACE at .sl_set loop
+            v_iname := ''PartInd_ at CLUSTERNAME at _sl_log_'' || v_log || ''-node-'' || v_dummy.set_origin;
+	    raise notice ''Consider adding partial index % on sl_log_%'', v_iname, v_log;
+	    raise notice ''schema: [_ at CLUSTERNAME@] tablename:[sl_log_%]'', v_log;
+            select * into v_dummy2 from pg_catalog.pg_indexes where tablename = ''sl_log_'' || v_log and  indexname = v_iname;
+            if not found then
+		raise notice ''index was not found - add it!'';
 		idef := ''create index "PartInd_ at CLUSTERNAME at _sl_log_'' || v_log || ''-node-'' || v_dummy.set_origin ||
                         ''" on @NAMESPACE at .sl_log_'' || v_log || '' USING btree(log_xid @NAMESPACE at .xxid_ops) where (log_origin = '' || v_dummy.set_origin || '');'';
 		execute idef;
 		v_count := v_count + 1;
+            else
+                raise notice ''Index % already present - skipping'', v_iname;
+            end if;
 	end loop;
 
 	-- Remove unneeded indices...
-	for v_dummy in select indexname from pg_catalog.pg_indexes i where i.schemaname = ''@NAMESPACE''
-                       and i.tablename = ''sl_log_'' || v_log and
+	for v_dummy in select indexname from pg_catalog.pg_indexes i where i.tablename = ''sl_log_'' || v_log and
+                       i.indexname like (''PartInd_ at CLUSTERNAME at _sl_log_'' || v_log || ''-node-%'') and
                        not exists (select 1 from @NAMESPACE at .sl_set where
 				i.indexname = ''PartInd_ at CLUSTERNAME at _sl_log_'' || v_log || ''-node-'' || set_origin)
 	loop
-		idef := ''drop index "@NAMESPACE@"."'' || v_dummy.indexname || ''";'';
+		raise notice ''Dropping obsolete index %d'', v_dummy.indexname;
+		idef := ''drop index @NAMESPACE at ."'' || v_dummy.indexname || ''";'';
 		execute idef;
 		v_count := v_count - 1;
 	end loop;



More information about the Slony1-commit mailing list