CVS User Account cvsuser
Wed Aug 4 16:36:43 PDT 2004
Log Message:
-----------
Use function to ensure all objects without specified namespaces get
namespace "public" prepended to them.

Modified Files:
--------------
    slony1-engine/tools/altperl:
        create_set.pl (r1.2 -> r1.3)

-------------- next part --------------
Index: create_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/create_set.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltools/altperl/create_set.pl -Ltools/altperl/create_set.pl -u -w -r1.2 -r1.3
--- tools/altperl/create_set.pl
+++ tools/altperl/create_set.pl
@@ -2,6 +2,7 @@
 # $Id$
 # Author: Christopher Browne
 # Copyright 2004 Afilias Canada
+
 require 'slon-tools.pm';
 require 'slon.env';
 my ($set) = @ARGV;
@@ -18,6 +19,7 @@
 print OUTFILE genheader();
 
 foreach my $table (@SERIALTABLES) {
+  $table = ensure_namespace($table);
  print OUTFILE "
 		echo '  Adding unique key to table $table...';
 		table add key (
@@ -55,11 +57,7 @@
 
 $TABLE_ID=1;
 foreach my $table (@SERIALTABLES) {
-  if ($table =~ /^(.*\..*)$/) {
-    # Table has a namespace specified
-  } else {
-    $table = "$table";
-  }
+  $table = ensure_namespace($table);
     print OUTFILE "
 		set add table (set id = $set, origin = 1, id = $TABLE_ID, full qualified name = '$table', comment = 'Table $table', key=serial);
                 echo 'Add unkeyed table $table';
@@ -68,11 +66,7 @@
 }
 
 foreach my $table (@KEYEDTABLES) {
-  if ($table =~ /^(.*\..*)$/) {
-    # Table has a namespace specified
-  } else {
-    $table = "public.$table";
-  }
+  $table = ensure_namespace($table);
   print OUTFILE "
 		set add table (set id = $set, origin = 1, id = $TABLE_ID, full qualified name = '$table', comment = 'Table $table');
                 echo 'Add keyed table $table';
@@ -92,11 +86,7 @@
 
 $SEQID=1;
 foreach my $seq (@SEQUENCES) {
-  if ($seq =~ /^(.*\..*)$/) {
-    # Table has a namespace specified
-  } else {
-    $seq = "public.$seq";
-  }
+  $seq = ensure_namespace($seq);
   print OUTFILE "
                 set add sequence (set id = $set, origin = 1, id = $SEQID, full qualified name = '$seq', comment = 'Sequence $seq');
                 echo 'Add sequence $seq';
@@ -109,3 +99,14 @@
 
 print `slonik < $OUTPUTFILE`;
 unlink($OUTPUTFILE);
+
+### If object hasn't a namespace specified, assume it's in "public", and make it so...
+sub ensure_namespace {
+  my ($object) = @_;
+    if ($object =~ /^(.*\..*)$/) {
+    # Table has a namespace specified
+  } else {
+    $object = "public.$object";
+  }
+  return $object;
+}


More information about the Slony1-commit mailing list