CVS User Account cvsuser
Tue May 30 07:52:37 PDT 2006
Log Message:
-----------
Mark Stosberg contributed altperl scripts for "slonik_drop_table" and
"slonik_print_preamble."

These are hereby added to CVS, along with some documentation for the admin
guide.

Modified Files:
--------------
    slony1-engine/doc/adminguide:
        adminscripts.sgml (r1.33 -> r1.34)

Added Files:
-----------
    slony1-engine/tools/altperl:
        slonik_drop_table.pl (r1.1)
        slonik_print_preamble.pl (r1.1)

-------------- next part --------------
--- /dev/null
+++ tools/altperl/slonik_print_preamble.pl
@@ -0,0 +1,39 @@
+#!@@PERL@@
+# $Id: slonik_print_preamble.pl,v 1.1 2006/05/30 14:52:35 cbbrowne Exp $
+# Author: Mark Stosberg
+# Based on work by: Christopher Browne
+# Parts Copyright 2006 Summerault, LLC
+# Parts Copyright 2004 Afilias Canada
+
+use Getopt::Long;
+
+$CONFIG_FILE = '/usr/local/etc/slon_tools.conf';
+$SHOW_USAGE  = 0;
+
+# Read command-line options
+GetOptions("config=s" => \$CONFIG_FILE,
+	   "help"     => \$SHOW_USAGE);
+
+my $USAGE =
+"Usage: slonik_print_preamble [--config file]
+
+    print the preamble required by all slonik scripts, using the
+    details from the config file
+
+  Write the results of this command to a file, and then use a text
+  editor to complete a custom command to send to slonik.
+";
+
+if ($SHOW_USAGE) {
+    print $USAGE;
+    exit 0;
+}
+
+require '/usr/local/pgsql/lib//slon-tools.pm';
+require $CONFIG_FILE;
+
+$FILE="/tmp/print_preamble.$$";
+open (SLONIK, ">", $FILE);
+print SLONIK genheader();
+close SLONIK;
+run_slonik_script($FILE);
--- /dev/null
+++ tools/altperl/slonik_drop_table.pl
@@ -0,0 +1,59 @@
+#!@@PERL@@
+# $Id: slonik_drop_table.pl,v 1.1 2006/05/30 14:52:35 cbbrowne Exp $
+# Author: Mark Stosberg
+# Based on work by: Christopher Browne
+# Parts Copyright 2006 Summerault, LLC
+# Parts Copyright 2004 Afilias Canada
+
+use Getopt::Long;
+
+$CONFIG_FILE = '/usr/local/etc/slon_tools.conf';
+$SHOW_USAGE  = 0;
+
+# Read command-line options
+GetOptions("config=s" => \$CONFIG_FILE,
+	   "help"     => \$SHOW_USAGE);
+
+my $USAGE =
+"Usage: slonik_drop_table [--config file] table_id set
+
+    table_id  The ID of the table to be dropped from replication
+    set  The name or ID of the set to drop the table from
+
+ You can get the table_id with a query like this:  
+
+ SELECT tab_id,tab_relname from _MY_CLUSTER.sl_table where tab_relname = 'MY_TABLE';
+
+";
+
+if ($SHOW_USAGE) {
+    print $USAGE;
+    exit 0;
+}
+
+require '/usr/local/pgsql/lib//slon-tools.pm';
+require $CONFIG_FILE;
+
+my ($TABLE_ID,$set) = @ARGV;
+$SET_ID = get_set($set);
+unless ($TABLE_ID && $SET_ID) {
+    die $USAGE;
+}
+
+$FILE="/tmp/drop_table.$$";
+open (SLONIK, ">", $FILE);
+print SLONIK genheader();
+
+# DROP TABLE
+print SLONIK "\n";
+print SLONIK "# DROP TABLE \n";
+print SLONIK "  try {\n";
+print SLONIK "    SET DROP TABLE (id = $TABLE_ID, origin = $SET_ORIGIN);\n";
+print SLONIK "  } on error {\n";
+print SLONIK "    echo 'Could not drop table $TABLE_ID for $CLUSTER_NAME!';\n";
+print SLONIK "    exit -1;\n";
+print SLONIK "  }\n";
+
+
+close SLONIK;
+run_slonik_script($FILE);
Index: adminscripts.sgml
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/adminscripts.sgml,v
retrieving revision 1.33
retrieving revision 1.34
diff -Ldoc/adminguide/adminscripts.sgml -Ldoc/adminguide/adminscripts.sgml -u -w -r1.33 -r1.34
--- doc/adminguide/adminscripts.sgml
+++ doc/adminguide/adminscripts.sgml
@@ -125,12 +125,20 @@
 <envar>nvar>@SERIALT</envar>nvar>, and <envar>@SEQUENCES</envar></para></listitem>
 </itemizedlist>
 </sect2>
+<sect2><title>slonik_print_preamble</title>
+
+<para>This generates just the <quote>preamble</quote> that is required
+by all slonik scripts.  In effect, this provides a
+<quote>skeleton</quote> slonik script that does not do
+anything.</para>
+</sect2>
 <sect2><title>slonik_create_set</title>
 
 <para>This requires <envar>SLONYSET</envar> to be set as well as
-<envar>SLONYNODES</envar>; it is used to generate the <command>slonik</command> script to set up
-a replication set consisting of a set of tables and sequences that are
-to be replicated.</para>
+<envar>SLONYNODES</envar>; it is used to generate the
+<command>slonik</command> script to set up a replication set
+consisting of a set of tables and sequences that are to be
+replicated.</para>
 </sect2>
 <sect2><title>slonik_drop_node</title>
 
@@ -142,6 +150,14 @@
 (<emphasis>e.g.</emphasis> - set of tables and sequences) from a
 &slony1; cluster.</para>
 </sect2>
+
+<sect2><title>slonik_drop_table</title>
+
+<para>Generates Slonik script to drop a table from replication.
+Requires, as input, the ID number of the table (available from table
+<envar>sl_table</envar>) that is to be dropped. </para>
+</sect2>
+
 <sect2><title>slonik_execute_script</title>
 
 <para>Generates Slonik script to push DDL changes to a replication set.</para>



More information about the Slony1-commit mailing list