CVS User Account cvsuser
Mon Dec 13 22:08:54 PST 2004
Log Message:
-----------
Due to lots of SIC regarding the pg_dump safe patches, I'll commit them.

New functionality allows you to REPAIR CONFIG() a node(s) after you have used pg_dump/restore on them.
slonik has a new statement REPAIR CONFIG(),  and a new event class has been created REPAIR_CONFIG.

Modified Files:
--------------
    slony1-engine/doc/howto:
        slonik_commands.html (r1.13 -> r1.14)
    slony1-engine/src/backend:
        slony1_base.sql (r1.24 -> r1.25)
        slony1_funcs.sql (r1.49 -> r1.50)
    slony1-engine/src/slon:
        misc.c (r1.14 -> r1.15)
        remote_worker.c (r1.67 -> r1.68)
        slon.c (r1.38 -> r1.39)
    slony1-engine/src/slonik:
        parser.y (r1.21 -> r1.22)
        scan.l (r1.21 -> r1.22)
        slonik.c (r1.37 -> r1.38)
        slonik.h (r1.21 -> r1.22)

-------------- next part --------------
Index: slonik_commands.html
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/howto/slonik_commands.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -Ldoc/howto/slonik_commands.html -Ldoc/howto/slonik_commands.html -u -w -r1.13 -r1.14
--- doc/howto/slonik_commands.html
+++ doc/howto/slonik_commands.html
@@ -51,6 +51,7 @@
 		<li><a href="#stmt_failover">FAILOVER</a>
 		<li><a href="#stmt_ddl_script">EXECUTE SCRIPT</a>
 		<li><a href="#stmt_wait_event">WAIT FOR EVENT</a>
+		<li><a href="#stmt_repair_config">REPAIR CONFIG</a>
 	</ul>
 </ul>
 </div>
@@ -1747,6 +1748,54 @@
 </table>
 <h3>Example:</h3>
 <p>
+
+<!-- **************************************** -->
+<a name="stmt_repair_config">
+<h3>REINIT NODE</h3>
+</a>
+<div style="margin-left:40px; margin-right:0px;">
+<h3>Synopsis:</h3>
+        REPAIR CONFIG ( &lt;options&gt; );
+<h3>Description:</h3>
+<p>
+        Resets the name to oid mapping, usefull for restoring after a pg_dump. 
+</p>
+<p>
+<table border="0" cellpadding="10">
+<tr>
+        <td align="left" valign="top" nowrap><b>SET ID = &lt;ival&gt;</b></td>
+        <td align="left" valign="top"><p>
+                The unique, numeric ID number of the set affected by the script.
+        </p></td>
+</tr>
+<tr>
+        <td align="left" valign="top" nowrap><b>EVENT NODE = &lt;ival&gt;</b></td>
+        <td align="left" valign="top"><p>
+                <b>(Optional)</b>
+                The ID of the current origin of the set.
+                The default value is 1.
+        </p></td>
+</tr>
+<tr>
+        <td align="left" valign="top" nowrap><b>EXECUTE ONLY ON = &lt;ival&gt;</b></td>
+        <td align="left" valign="top"><p>
+                <b>(Optional)</b>
+                The ID of the only node to actually update the mapping on.
+                The default is to execute this on all nodes that are
+                subscribed to the set.
+        </p></td>
+</tr>
+</table>
+<h3>Example:</h3>
+<p>
+        REPAIR CONFIG (
+        <br>&nbsp;&nbsp;&nbsp;&nbsp;SET ID = 1,
+        <br>&nbsp;&nbsp;&nbsp;&nbsp;EVENT NODE = 2
+        <br>);
+</p>
+</div>
+<p align="right">Back to <a href="#index">Index</a></p>
+
 	WAIT FOR EVENT (
 	<br>&nbsp;&nbsp;&nbsp;&nbsp;ORIGIN = ALL,
 	<br>&nbsp;&nbsp;&nbsp;&nbsp;CONFIRMED = ALL,
Index: slony1_base.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_base.sql,v
retrieving revision 1.24
retrieving revision 1.25
diff -Lsrc/backend/slony1_base.sql -Lsrc/backend/slony1_base.sql -u -w -r1.24 -r1.25
--- src/backend/slony1_base.sql
+++ src/backend/slony1_base.sql
@@ -93,6 +93,8 @@
 create table @NAMESPACE at .sl_table (
 	tab_id				int4,
 	tab_reloid			oid UNIQUE NOT NULL,
+	tab_relname			name NOT NULL,
+	tab_nspname			name NOT NULL,
 	tab_set				int4,
 	tab_idxname			name NOT NULL,
 	tab_altered			boolean NOT NULL,
@@ -107,6 +109,8 @@
 comment on table @NAMESPACE at .sl_table is 'Holds information about the tables being replicated.';
 comment on column @NAMESPACE at .sl_table.tab_id is 'Unique key for Slony-I to use to identify the table';
 comment on column @NAMESPACE at .sl_table.tab_reloid is 'The OID of the table in pg_catalog.pg_class.oid';
+comment on column @NAMESPACE at .sl_table.tab_relname is 'The name of the table in pg_catalog.pg_class.relname used to recover from a dump/restore cycle'; 
+comment on column @NAMESPACE at .sl_table.tab_nspname is 'The name of the schema in pg_catalog.pg_namespace.nspname used to recover from a dump/restore cycle'; 
 comment on column @NAMESPACE at .sl_table.tab_set is 'ID of the replication set the table is in';
 comment on column @NAMESPACE at .sl_table.tab_idxname is 'The name of the primary index of the table';
 comment on column @NAMESPACE at .sl_table.tab_altered is 'Has the table been modified for replication?';
@@ -138,6 +142,8 @@
 create table @NAMESPACE at .sl_sequence (
 	seq_id				int4,
 	seq_reloid			oid UNIQUE NOT NULL,
+	seq_relname			name NOT NULL,
+	seq_nspname			name NOT NULL,
 	seq_set				int4,
 	seq_comment			text,
 
@@ -150,6 +156,8 @@
 comment on table @NAMESPACE at .sl_sequence is 'Similar to sl_table, each entry identifies a sequence being replicated.';
 comment on column @NAMESPACE at .sl_sequence.seq_id is 'An internally-used ID for Slony-I to use in its sequencing of updates';
 comment on column @NAMESPACE at .sl_sequence.seq_reloid is 'The OID of the sequence object';
+comment on column @NAMESPACE at .sl_sequence.seq_relname is 'The name of the sdequence in pg_catalog.pg_class.relname used to recover from a dump/restore cycle'; 
+comment on column @NAMESPACE at .sl_sequence.seq_nspname is 'The name of the schema in pg_catalog.pg_namespace.nspname used to recover from a dump/restore cycle'; 
 comment on column @NAMESPACE at .sl_sequence.seq_set is 'Indicates which replication set the object is in';
 comment on column @NAMESPACE at .sl_sequence.seq_comment is 'A human-oriented comment';
 
@@ -287,6 +295,7 @@
 				UNSUBSCRIBE_SET		=
 				DDL_SCRIPT			=
 				ADJUST_SEQ			=
+				RESET_CONFIG		=
 ';
 comment on column @NAMESPACE at .sl_event.ev_data1 is 'Data field containing an argument needed to process the event';
 comment on column @NAMESPACE at .sl_event.ev_data2 is 'Data field containing an argument needed to process the event';
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.49 -r1.50
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -2298,6 +2298,8 @@
 create or replace function @NAMESPACE at .setAddTable_int(int4, int4, text, name, text)
 returns int4
 as '
+	v_tab_relname		name;
+	v_tab_nspname		name;
 declare
 	p_set_id			alias for $1;
 	p_tab_id			alias for $2;
@@ -2341,7 +2343,7 @@
 	-- ----
 	-- Get the tables OID and check that it is a real table
 	-- ----
-	select PGC.oid, PGC.relkind into v_tab_reloid, v_relkind
+	select PGC.oid, PGC.relkind, PGC.relname, PGN.nspname into v_tab_reloid, v_relkind, v_tab_relname, v_tab_nspname
 			from "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN
 			where PGC.relnamespace = PGN.oid
 			and p_fqname = "pg_catalog".quote_ident(PGN.nspname) ||
@@ -2369,10 +2371,11 @@
 	-- Add the table to sl_table and create the trigger on it.
 	-- ----
 	insert into @NAMESPACE at .sl_table
-			(tab_id, tab_reloid, tab_set, tab_idxname, 
-			tab_altered, tab_comment) values
-			(p_tab_id, v_tab_reloid, p_set_id, p_tab_idxname,
-			false, p_tab_comment);
+			(tab_id, tab_reloid, tab_relname, tab_nspname, 
+			tab_set, tab_idxname, tab_altered, tab_comment) 
+			values
+			(p_tab_id, v_tab_reloid, v_tab_relname, v_tab_nspname,
+			p_set_id, p_tab_idxname, false, p_tab_comment);
 	perform @NAMESPACE at .alterTableForReplication(p_tab_id);
 
 	return p_tab_id;
@@ -2580,6 +2583,8 @@
 	v_sub_provider		int4;
 	v_relkind			char;
 	v_seq_reloid		oid;
+	v_seq_relname		name;
+	v_seq_nspname		name;
 	v_sync_row			record;
 begin
 	-- ----
@@ -2613,7 +2618,8 @@
 	-- ----
 	-- Get the sequences OID and check that it is a sequence
 	-- ----
-	select PGC.oid, PGC.relkind into v_seq_reloid, v_relkind
+	select PGC.oid, PGC.relkind, PGC.relname, PGN.nspname 
+		into v_seq_reloid, v_relkind, v_seq_relname, v_seq_nspname
 			from "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN
 			where PGC.relnamespace = PGN.oid
 			and p_fqname = "pg_catalog".quote_ident(PGN.nspname) ||
@@ -2631,8 +2637,9 @@
 	-- Add the sequence to sl_sequence
 	-- ----
 	insert into @NAMESPACE at .sl_sequence
-			(seq_id, seq_reloid, seq_set, seq_comment) values
-			(p_seq_id, v_seq_reloid, p_set_id, p_seq_comment);
+		(seq_id, seq_reloid, seq_relname, seq_nspname, seq_set, seq_comment) 
+		values
+		(p_seq_id, v_seq_reloid, v_seq_relname, v_seq_nspname,  p_set_id, p_seq_comment);
 
 	-- ----
 	-- On the set origin, fake a sl_seqlog row for the last sync event
@@ -3278,6 +3285,7 @@
 	-- ----
 	perform @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''SYNC'', NULL);
 	perform @NAMESPACE at .ddlScript_int(p_set_id, p_script, p_only_on_node);
+	perform @NAMESPACE at .updateRelname(p_set_id, p_only_on_node);
 	return  @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''DDL_SCRIPT'', 
 			p_set_id, p_script, p_only_on_node);
 end;
@@ -4683,7 +4691,7 @@
 	else
 		return 0;
 	end if;
-END;
+end;
 ' language plpgsql;
 
 comment on function @NAMESPACE at .generate_sync_event(interval) is
@@ -4713,6 +4721,138 @@
 				and PGA.attname = ''_Slony-I_ at CLUSTERNAME@_rowID''
 				and not PGA.attisdropped;
 	return found;
+-- FUNCTION updateRelname (set_id, only_on_node)
+--
+--      Reset the relnames          
+-- ----------------------------------------------------------------------
+create or replace function @NAMESPACE at .updateRelname (int4, int4)
+returns int4
+as '
+declare
+        p_set_id                alias for $1;
+        p_only_on_node          alias for $2;
+        v_no_id                 int4;
+        v_set_origin            int4;
+begin
+        -- ----
+        -- Grab the central configuration lock
+        -- ----
+        lock table @NAMESPACE at .sl_config_lock;
+
+        -- ----
+        -- Check that we either are the set origin or a current
+        -- subscriber of the set.
+        -- ----
+        v_no_id := @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'');
+        select set_origin into v_set_origin
+                        from @NAMESPACE at .sl_set
+                        where set_id = p_set_id
+                        for update;
+        if not found then
+                raise exception ''Slony-I: set % not found'', p_set_id;
+        end if;
+        if v_set_origin <> v_no_id
+                and not exists (select 1 from @NAMESPACE at .sl_subscribe
+                        where sub_set = p_set_id
+                        and sub_receiver = v_no_id)
+        then
+                return 0;
+        end if;
+    
+        -- ----
+        -- If execution on only one node is requested, check that
+        -- we are that node.
+        -- ----
+        if p_only_on_node > 0 and p_only_on_node <> v_no_id then
+                return 0;
+        end if;
+        update @NAMESPACE at .sl_table set 
+                tab_relname = PGC.relname, tab_nspname = PGN.nspname
+                from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN 
+                where @NAMESPACE at .sl_table.tab_reloid = PGC.oid
+                        and PGC.relnamespace = PGN.oid;
+        update @NAMESPACE at .sl_sequence set
+                seq_relname = PGC.relname, seq_nspname = PGN.nspname
+                from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN
+                where @NAMESPACE at .sl_sequence.seq_reloid = PGC.oid
+                and PGC.relnamespace = PGN.oid;
+        return p_set_id;
+end;
+' language plpgsql;
+comment on function @NAMESPACE at .updateRelname(int4, int4) is
+'updateRelname(set_id, only_on_node)';
+
+-- ----------------------------------------------------------------------
+-- FUNCTION updateReloid (set_id, only_on_node)
+--
+--      Reset the relnames
+-- ----------------------------------------------------------------------
+create or replace function @NAMESPACE at .updateReloid (int4, int4)
+returns int4
+as '
+declare
+        p_set_id                alias for $1;
+        p_only_on_node          alias for $2;
+        v_no_id                 int4;
+        v_set_origin            int4;
+begin
+        -- ----
+        -- Grab the central configuration lock
+        -- ----
+        lock table @NAMESPACE at .sl_config_lock;
+
+        -- ----
+        -- Check that we either are the set origin or a current
+        -- subscriber of the set.
+        -- ----
+        v_no_id := @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'');
+        select set_origin into v_set_origin
+                        from @NAMESPACE at .sl_set
+                        where set_id = p_set_id
+                        for update;
+        if not found then
+                raise exception ''Slony-I: set % not found'', p_set_id;
+        end if;
+        if v_set_origin <> v_no_id
+                and not exists (select 1 from @NAMESPACE at .sl_subscribe
+                        where sub_set = p_set_id
+                        and sub_receiver = v_no_id)
+        then
+                return 0;
+        end if;
+
+        -- ----
+        -- If execution on only one node is requested, check that
+        -- we are that node.
+        -- ----
+        if p_only_on_node > 0 and p_only_on_node <> v_no_id then
+                return 0;
+        end if;
+        update @NAMESPACE at .sl_table set
+                tab_reloid = PGC.oid
+                from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN
+                where pg_catalog.quote_ident(@NAMESPACE at .sl_table.tab_relname) = pg_catalog.quote_ident(PGC.relname)
+                        and PGC.relnamespace = PGN.oid
+			and pg_catalog.quote_ident(PGN.nspname) = pg_catalog.quote_ident(@NAMESPACE at .sl_table.tab_nspname);
+
+        update @NAMESPACE at .sl_sequence set
+                seq_reloid = PGC.oid
+                from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN
+                where pg_catalog.quote_ident(@NAMESPACE at .sl_sequence.seq_relname) = pg_catalog.quote_ident(PGC.relname)
+                	and PGC.relnamespace = PGN.oid
+			and pg_catalog.quote_ident(PGN.nspname) = pg_catalog.quote_ident(@NAMESPACE at .sl_sequence.seq_nspname);
+
+        return  @NAMESPACE at .createEvent(''_ at CLUSTERNAME@'', ''RESET_CONFIG'',
+                        p_set_id, p_only_on_node);
+end;
+' language plpgsql;
+comment on function @NAMESPACE at .updateReloid(int4, int4) is
+'updateReloid(set_id, only_on_node)
+
+Updates the respective reloids in sl_table and sl_seqeunce based on
+their respective FQN';
+
+-- ----------------------------------------------------------------------
 end;
 ' language plpgsql;
 
@@ -4725,12 +4865,49 @@
 
 -- ----------------------------------------------------------------------
 -- FUNCTION upgradeSchema(old_version)
+        -- upgrade sl_node
 --
 --	Called by slonik during the function upgrade process. 
 -- ----------------------------------------------------------------------
 create or replace function @NAMESPACE at .upgradeSchema(text)
 returns text as '
 declare
+	-- upgrade sl_table
+	if p_old = ''1.0.2'' or p_old = ''1.0.5'' then
+		-- Add new column(s) sl_table.tab_relname, sl_table.tab_nspname
+		execute ''alter table @NAMESPACE at .sl_table add column tab_relname name'';
+		execute ''alter table @NAMESPACE at .sl_table add column tab_nspname name'';
+
+		-- populate the colums with data
+		update @NAMESPACE at .sl_table set
+			tab_relname = PGC.relname, tab_nspname = PGN.nspname
+			from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN
+			where @NAMESPACE at .sl_table.tab_reloid = PGC.oid
+			and PGC.relnamespace = PGN.oid;
+
+		-- constrain the colums
+		execute ''alter table @NAMESPACE at .sl_table alter column tab_relname set NOT NULL'';
+		execute ''alter table @NAMESPACE at .sl_table alter column tab_nspname set NOT NULL'';
+
+	end if;
+
+	-- upgrade sl_sequence
+	if p_old = ''1.0.2'' or p_old = ''1.0.5'' then
+		-- Add new column(s) sl_sequence.seq_relname, sl_sequence.seq_nspname
+		execute ''alter table @NAMESPACE at .sl_sequence add column seq_relname name'';
+		execute ''alter table @NAMESPACE at .sl_sequence add column seq_nspname name'';
+
+		-- populate the columns with data
+		update @NAMESPACE at .sl_sequence set
+			seq_relname = PGC.relname, seq_nspname = PGN.nspname
+			from pg_catalog.pg_class PGC, pg_catalog.pg_namespace PGN
+			where @NAMESPACE at .sl_sequence.seq_reloid = PGC.oid
+			and PGC.relnamespace = PGN.oid;
+
+		-- constrain the data
+		execute ''alter table @NAMESPACE at .sl_sequence alter column seq_relname set NOT NULL'';
+		execute ''alter table @NAMESPACE at .sl_sequence alter column seq_nspname set NOT NULL'';
+	end if;
 	p_old	alias for $1;
 begin
 	-- ----
Index: remote_worker.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/remote_worker.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -Lsrc/slon/remote_worker.c -Lsrc/slon/remote_worker.c -u -w -r1.67 -r1.68
--- src/slon/remote_worker.c
+++ src/slon/remote_worker.c
@@ -963,6 +963,15 @@
 				  "select %s.ddlScript_int(%d, '%q', %d); ",
 						 rtcfg_namespace,
 				   ddl_setid, ddl_script, ddl_only_on_node);
+			} else if (strcmp(event->ev_type, "RESET_CONFIG") == 0)
+			{
+				int	reset_config_setid = (int)strtol(event->ev_data1, NULL, 10);
+				int	reset_configonly_on_node = (int)strtol(event->ev_data2, NULL, 10);
+
+				slon_appendquery(&query1,
+				  "select %s.updateReloid(%d, '%q', %d); ",
+						rtcfg_namespace,
+				  reset_config_setid, reset_configonly_on_node);
 			} else
 			{
 				printf("TODO: ********** remoteWorkerThread: node %d - EVENT %d," INT64_FORMAT " %s - unknown event type\n",
Index: slon.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lsrc/slon/slon.c -Lsrc/slon/slon.c -u -w -r1.38 -r1.39
--- src/slon/slon.c
+++ src/slon/slon.c
@@ -165,7 +165,6 @@
 	/*
 	 * Remember the connection information for the local node.
 	 */
-
 	if (rtcfg_conninfo == NULL)
 	{
 		errors++;
Index: misc.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/misc.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -Lsrc/slon/misc.c -Lsrc/slon/misc.c -u -w -r1.14 -r1.15
--- src/slon/misc.c
+++ src/slon/misc.c
@@ -146,6 +146,7 @@
 			slon_abort();
 		}
 	}
+
 	sprintf(outbuf, "");
 
 	if (logtimestamp == true && (Use_syslog != 1))
Index: scan.l
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/scan.l,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/slonik/scan.l -Lsrc/slonik/scan.l -u -w -r1.21 -r1.22
--- src/slonik/scan.l
+++ src/slonik/scan.l
@@ -44,6 +44,7 @@
 client			{ return K_CLIENT;				}
 cluster			{ return K_CLUSTER;				}
 comment			{ return K_COMMENT;				}
+config			{ return K_CONFIG;			}
 confirmed		{ return K_CONFIRMED;			}
 conninfo		{ return K_CONNINFO;			}
 connretry		{ return K_CONNRETRY;			}
@@ -82,6 +83,7 @@
 provider		{ return K_PROVIDER;			}
 qualified		{ return K_QUALIFIED;			}
 receiver		{ return K_RECEIVER;			}
+repair			{ return K_REPAIR;			}
 restart			{ return K_RESTART;				}
 script			{ return K_SCRIPT;				}
 sequence		{ return K_SEQUENCE;			}
Index: slonik.h
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/slonik/slonik.h -Lsrc/slonik/slonik.h -u -w -r1.21 -r1.22
--- src/slonik/slonik.h
+++ src/slonik/slonik.h
@@ -17,6 +17,7 @@
 typedef struct SlonikStmt_try_s					SlonikStmt_try;
 typedef struct SlonikStmt_echo_s				SlonikStmt_echo;
 typedef struct SlonikStmt_exit_s				SlonikStmt_exit;
+typedef struct SlonikStmt_repair_config_s		SlonikStmt_repair_config;
 typedef struct SlonikStmt_restart_node_s		SlonikStmt_restart_node;
 typedef struct SlonikStmt_init_cluster_s		SlonikStmt_init_cluster;
 typedef struct SlonikStmt_store_node_s			SlonikStmt_store_node;
@@ -65,6 +66,7 @@
 	STMT_MERGE_SET,
 	STMT_MOVE_SET,
 	STMT_RESTART_NODE,
+	STMT_REPAIR_CONFIG,
 	STMT_SET_ADD_SEQUENCE,
 	STMT_SET_ADD_TABLE,
 	STMT_SET_DROP_SEQUENCE,
@@ -145,6 +147,13 @@
 	int					no_id;
 };
 
+struct SlonikStmt_repair_config_s {
+        SlonikStmt                      hdr;
+        int                                     set_id;
+        int                                     ev_origin;
+        int                                     only_on_node;
+};
+
 
 struct SlonikStmt_init_cluster_s {
 	SlonikStmt			hdr;
Index: parser.y
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/parser.y,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/slonik/parser.y -Lsrc/slonik/parser.y -u -w -r1.21 -r1.22
--- src/slonik/parser.y
+++ src/slonik/parser.y
@@ -157,6 +157,7 @@
 %type <statement>	stmt_move_set
 %type <statement>	stmt_ddl_script
 %type <statement>	stmt_update_functions
+%type <statement>	stmt_repair_config
 %type <statement>	stmt_wait_event
 %type <opt_list>	option_list
 %type <opt_list>	option_list_item
@@ -178,6 +179,7 @@
 %token	K_CLUSTERNAME
 %token	K_COMMENT
 %token	K_CONFIRMED
+%token	K_CONFIG
 %token	K_CONNINFO
 %token	K_CONNRETRY
 %token	K_CREATE
@@ -214,6 +216,7 @@
 %token	K_PROVIDER
 %token	K_QUALIFIED
 %token	K_RECEIVER
+%token  K_REPAIR
 %token	K_RESTART
 %token	K_SCRIPT
 %token	K_SEQUENCE
@@ -467,6 +470,8 @@
 					| stmt_ddl_script
 						{ $$ = $1; }
 					| stmt_update_functions
+					| stmt_repair_config
+						{ $$ = $1; }
 						{ $$ = $1; }
 					| stmt_wait_event
 						{ $$ = $1; }
@@ -1375,6 +1380,36 @@
 						$$ = (SlonikStmt *)new;
 					}
 					;
+stmt_repair_config		: lno K_REPAIR K_CONFIG option_list
+					{
+						SlonikStmt_repair_config *new;
+						statement_option opt[] = {
+							STMT_OPTION_INT( O_SET_ID, -1 ),
+							STMT_OPTION_INT( O_EVENT_NODE, 1 ),
+							STMT_OPTION_INT( O_EXECUTE_ONLY_ON, -1 ),
+							STMT_OPTION_END
+						};
+
+						new = (SlonikStmt_repair_config *)
+							malloc(sizeof(SlonikStmt_repair_config));
+						memset(new, 0, sizeof(SlonikStmt_repair_config));
+                                                new->hdr.stmt_type              = STMT_REPAIR_CONFIG;
+                                                new->hdr.stmt_filename  = current_file;
+                                                new->hdr.stmt_lno               = $1;
+
+                                                if (assign_options(opt, $4) == 0)
+						{
+							new->set_id		= opt[0].ival;
+							new->ev_origin		= opt[1].ival;
+							new->only_on_node	= opt[2].ival;
+						}
+						else
+						{
+							parser_errors++;
+						}
+                                                $$ = (SlonikStmt *)new;
+                                        }
+                                        ;
 
 stmt_wait_event		: lno K_WAIT K_FOR K_EVENT option_list
 					{
Index: slonik.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lsrc/slonik/slonik.c -Lsrc/slonik/slonik.c -u -w -r1.37 -r1.38
--- src/slonik/slonik.c
+++ src/slonik/slonik.c
@@ -245,6 +245,21 @@
 				}
 				break;
 
+			case STMT_REPAIR_CONFIG:
+				{
+					SlonikStmt_repair_config *stmt = 
+							(SlonikStmt_repair_config *)hdr;
+					if (stmt->ev_origin < 0)
+					{
+						stmt->ev_origin = 1;
+					}
+					if (script_check_adminfo(hdr, stmt->ev_origin) < 0)
+					{
+						errors++;
+					}
+				}
+				break;
+
 			case STMT_ERROR:
 				break;
 
@@ -1157,6 +1172,15 @@
 							(SlonikStmt_init_cluster *)hdr;
 
 					if (slonik_init_cluster(stmt) < 0)
+			case STMT_REPAIR_CONFIG:
+				{
+					SlonikStmt_repair_config *stmt =
+						(SlonikStmt_repair_config *)hdr;
+
+					if (slonik_repair_config(stmt) < 0)
+						errors++;
+				}
+				break;
 						errors++;
 				}
 				break;
@@ -1919,6 +1943,31 @@
 	}
 
 	dstring_free(&query);
+}
+
+int
+slonik_repair_config(SlonikStmt_repair_config *stmt)
+{
+        SlonikAdmInfo  *adminfo1;        
+        SlonDString             query;
+
+        adminfo1 = get_active_adminfo((SlonikStmt *)stmt, stmt->ev_origin);
+        if (adminfo1 == NULL)
+                return -1;
+
+        dstring_init(&query);
+                                 
+        slon_mkquery(&query,
+                        "select \"_%s\".updateReloid(%d, %d); ",
+                        stmt->hdr.script->clustername,
+			stmt->set_id, stmt->only_on_node);
+        if (db_exec_command((SlonikStmt *)stmt, adminfo1, &query) < 0)
+        {
+                dstring_free(&query);
+                return -1;
+        }
+
+        dstring_free(&query);
 	return 0;
 }
 
@@ -3814,17 +3863,8 @@
 	/*
 	 * Finally restart the node.
 	 */
-	slon_mkquery(&query,
-			"notify \"_%s_Restart\"; ",
-			stmt->hdr.script->clustername);
-	if (db_exec_command((SlonikStmt *)stmt, adminfo, &query) < 0)
-	{
-		dstring_free(&query);
-		return -1;
-	}
 
-	dstring_free(&query);
-	return 0;
+	return slonik_restart_node((SlonikStmt_restart_node *)stmt);
 }
 
 


More information about the Slony1-commit mailing list