Chris Browne cbbrowne at lists.slony.info
Thu Nov 29 13:29:05 PST 2007
Update of /home/cvsd/slony1/slony1-engine/src/backend
In directory main.slony.info:/tmp/cvs-serv6919/src/backend

Modified Files:
	slony1_funcs.sql 
Log Message:
Fix to bug #15
http://www.slony.info/bugzilla/show_bug.cgi?id=15

  Fix to bug #15 - where long cluster name (>40 chars) leads to
  things breaking when an index name is created that contains
  the cluster name.

  -> Warn upon creating a long cluster name.
  -> Give a useful exception that explains the cause rather
     than merely watching index creation fail.


Index: slony1_funcs.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.123
retrieving revision 1.124
diff -C2 -d -r1.123 -r1.124
*** slony1_funcs.sql	23 Oct 2007 17:00:27 -0000	1.123
--- slony1_funcs.sql	29 Nov 2007 21:29:03 -0000	1.124
***************
*** 697,700 ****
--- 697,706 ----
  	perform setval(''@NAMESPACE at .sl_local_node_id'', p_local_node_id);
  	perform @NAMESPACE at .storeNode_int (p_local_node_id, p_comment, false);
+ 
+ 	if (pg_catalog.current_setting(''max_identifier_length'')::integer - pg_catalog.length(''@NAMESPACE@'')) < 5 then
+ 		raise notice ''Slony-I: Cluster name length [%] versus system max_identifier_length [%] '', pg_catalog.length(''@NAMESPACE@''), pg_catalog.current_setting(''max_identifier_length'');
+ 		raise notice ''leaves narrow/no room for some Slony-I-generated objects (such as indexes).'';
+ 		raise notice ''You may run into problems later!'';
+ 	end if;
  	
  	return p_local_node_id;
***************
*** 5172,5175 ****
--- 5178,5183 ----
  	v_count		int4;
          v_iname         text;
+ 	v_ilen int4;
+ 	v_maxlen int4;
  BEGIN
  	v_count := 0;
***************
*** 5195,5199 ****
              if not found then
  		-- raise notice ''index was not found - add it!'';
! 		idef := ''create index "PartInd_ at CLUSTERNAME@_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;
--- 5203,5214 ----
              if not found then
  		-- raise notice ''index was not found - add it!'';
!                 v_iname := ''PartInd_ at CLUSTERNAME@_sl_log_'' || v_log || ''-node-'' || v_dummy.set_origin;
! 		v_ilen := pg_catalog.length(v_iname);
! 		v_maxlen := pg_catalog.current_setting(''max_identifier_length''::text)::int4;
!                 if v_ilen > v_maxlen then
! 		   raise exception ''Length of proposed index name [%] > max_identifier_length [%] - cluster name probably too long'', v_ilen, v_maxlen;
! 		end if;
! 
! 		idef := ''create index "'' || v_iname || 
                          ''" on @NAMESPACE at .sl_log_'' || v_log || '' USING btree(log_xid @NAMESPACE at .xxid_ops) where (log_origin = '' || v_dummy.set_origin || '');'';
  		execute idef;



More information about the Slony1-commit mailing list