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
# 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 {
}
# 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"};
# 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";
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";
$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";