slonik_create_set : adding set name on comment of set
authorLuiz K. Matsumura <luiz.matsumura@gmail.com>
Wed, 24 Oct 2012 20:53:09 +0000 (18:53 -0200)
committerLuiz K. Matsumura <luiz.matsumura@gmail.com>
Thu, 8 Nov 2012 22:03:25 +0000 (20:03 -0200)
Added the unique name of set on the comment of create set comand
to help when inspecting the sets under postgres

tools/altperl/slon-tools.pm
tools/altperl/slonik_create_set.pl

index 86c7ea24f05eb7b59216e632fac0f78f12a0476d..4fedd2e2f3c2b1aefb7db37f5567a55ba796edc3 100644 (file)
@@ -236,6 +236,7 @@ limit 1)
 sub get_set {
     my $set = shift();
     my $match;
+    my $name;
 
     # If the variables are already set through $ENV{SLONYSET}, just
     # make sure we have an integer for $SET_ID
@@ -254,10 +255,11 @@ sub get_set {
     # Is this a set name or number?
     if ($SLONY_SETS->{$set}) {
        $match = $SLONY_SETS->{$set};
+       $name  = $set;
     }
     elsif ($set =~ /^(?:set)?(\d+)$/) {
        $set = $1;
-       my ($name) = grep { $SLONY_SETS->{$_}->{"set_id"} == $set } keys %{$SLONY_SETS};
+       ($name) = grep { $SLONY_SETS->{$_}->{"set_id"} == $set } keys %{$SLONY_SETS};
        $match = $SLONY_SETS->{$name};
     }
     else {
@@ -265,6 +267,7 @@ sub get_set {
     }
 
     # Set the variables for this set.
+    $SET_NAME     = $name;
     $SET_ORIGIN   = ($match->{"origin"} or $MASTERNODE);
     $TABLE_ID     = $match->{"table_id"};
     $SEQUENCE_ID  = $match->{"sequence_id"};
index b7a08b0d99763e1a95fb64c3878a60f0b4cf8912..70204dde0afef027d8878f0f899594a5c75d3133 100644 (file)
@@ -51,21 +51,19 @@ $slonik .= "# TABLE ADD KEY\n";
 # CREATE SET
 $slonik .= "\n";
 $slonik .= "# CREATE SET\n";
-$slonik .= "    create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID for $CLUSTER_NAME');\n";
+$slonik .= "    create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID ($SET_NAME) for $CLUSTER_NAME');\n";
 
 # SET ADD TABLE
 $slonik .= "\n";
 $slonik .= "# SET ADD TABLE\n";
-$slonik .= "  echo 'Subscription set $SET_ID created';\n";
+$slonik .= "  echo 'Subscription set $SET_ID ($SET_NAME) created';\n";
 $slonik .= "  echo 'Adding tables to the subscription set';\n";
 
 $TABLE_ID = 1 if $TABLE_ID < 1;
 
-
-
 foreach my $table (@PKEYEDTABLES) {
     $table = ensure_namespace($table);
-       $table = lc($table) if $FOLD_CASE;
+    $table = lc($table) if $FOLD_CASE;
     $slonik .= "  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
     $slonik .= "                 full qualified name = '$table',\n";
     $slonik .= "                 comment = 'Table $table with primary key');\n";
@@ -76,7 +74,7 @@ foreach my $table (@PKEYEDTABLES) {
 foreach my $table (keys %KEYEDTABLES) {
     my $key = $KEYEDTABLES{$table};
     $table = ensure_namespace($table);
-       $table = lc($table) if $FOLD_CASE;
+    $table = lc($table) if $FOLD_CASE;
     $slonik .= "  set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
     $slonik .= "                 full qualified name = '$table', key='$key',\n";
     $slonik .= "                 comment = 'Table $table with candidate primary key $key');\n";
@@ -92,7 +90,7 @@ $slonik .= "  echo 'Adding sequences to the subscription set';\n";
 $SEQUENCE_ID = 1 if $SEQUENCE_ID < 1;
 foreach my $seq (@SEQUENCES) {
     $seq = ensure_namespace($seq);
-       $seq = lc($seq) if $FOLD_CASE;
+    $seq = lc($seq) if $FOLD_CASE;
     $slonik .= "  set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
     $slonik .= "                    full qualified name = '$seq',\n";
     $slonik .= "                    comment = 'Sequence $seq');\n";