]> granicus.if.org Git - postgis/commitdiff
postgis_restore.pl support for dump with postgis in custom schema
authorSandro Santilli <strk@keybit.net>
Fri, 12 Apr 2013 16:10:28 +0000 (16:10 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 12 Apr 2013 16:10:28 +0000 (16:10 +0000)
See #2264 -- thanks Thomas (frost242)

git-svn-id: http://svn.osgeo.org/postgis/trunk@11285 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
utils/postgis_restore.pl.in

diff --git a/NEWS b/NEWS
index 6d93fa369ef35a0c69561d20167be957c51baa02..ba9f57b8cbc3ab3c59ff530703ae8c50b26959aa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,7 @@ PostGIS 2.1.0
   - #2123, ST_FromGDALRaster
 
 * Enhancements *
+
   - #823,  tiger geocoder: Make loader_generate_script download portion 
            less greedy
   - #826,  raster2pgsql no longer defaults to padding tiles. Flag -P
@@ -127,6 +128,7 @@ PostGIS 2.1.0
   - #2202, Make libjson-c optional (--without-json configure switch)
   - #2231, raster2pgsql supports user naming of filename column with -n
   - #2200, ST_Union(raster, uniontype) unions all bands of all rasters
+  - #2264, postgis_restore.pl support for dump with postgis in custom schema
 
 * Fixes *
 
index 4315c126bfbcf09cb8ece55cb4326fcbb9a880ed..be31f22c6a652aac930cc8ade8d67dfefc195156 100755 (executable)
@@ -34,7 +34,7 @@ use strict;
 my $me = $0;
 
 my $usage = qq{
-Usage: $me [-v] <dumpfile>
+Usage: $me [-v] [-s schema] <dumpfile>
         Restore a custom dump (pg_dump -Fc) of a PostGIS-enabled database.
         First dump the old database: pg_dump -Fc MYDB > MYDB.dmp
         Then create a new database: createdb NEWDB
@@ -50,15 +50,22 @@ Usage:      $me [-v] <dumpfile>
 };
 
 my $DEBUG = 0;
+my $POSTGIS_SCHEMA;
 
 # NOTE: the SRID limits here are being discussed:
 # http://postgis.refractions.net/pipermail/postgis-devel/2012-February/018463.html
 my $SRID_MAXIMUM = @SRID_MAXIMUM@;
 my $SRID_USER_MAXIMUM = @SRID_USER_MAXIMUM@; 
 
-if ( @ARGV && $ARGV[0] eq '-v' ) {
-  $DEBUG = 1;
-  shift(@ARGV);
+while (@ARGV && $ARGV[0] =~ /-/) {
+  if ( $ARGV[0] eq '-v' ) {
+    $DEBUG = 1;
+    shift(@ARGV);
+  }
+  elsif ( $ARGV[0] eq '-s' ) {
+    shift(@ARGV);
+    $POSTGIS_SCHEMA = shift(@ARGV);
+  }
 }
 
 die $usage if (@ARGV < 1);
@@ -120,6 +127,10 @@ close(DUMP) || die "$me: pg_restore returned an error\n";
 print STDERR "  Writing ASCII to stdout...\n";
 open( INPUT, "pg_restore -L $manifest $dumpfile |") || die "$me:\tCan't run pg_restore\n";
 
+if ( defined $POSTGIS_SCHEMA ) {
+  print STDOUT "SET search_path = \"" . $POSTGIS_SCHEMA . "\";\n";
+}
+
 #
 # Disable topology metadata tables triggers to allow for population
 # in arbitrary order.
@@ -280,6 +291,10 @@ while( my $l = <INPUT> ) {
 
 }
 
+if ( defined $POSTGIS_SCHEMA ) {
+  print STDOUT "SET search_path = \"" . $POSTGIS_SCHEMA . "\";\n";
+}
+
 if ( $hasTopology ) {
 
   # Re-enable topology.layer table triggers