From: Sandro Santilli Date: Fri, 6 Aug 2004 08:08:15 +0000 (+0000) Subject: perl detection and bug fixes. X-Git-Tag: pgis_0_9_1~128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1bc0b09d17471f67cc1d9a3dad2f9f94f868668;p=postgis perl detection and bug fixes. git-svn-id: http://svn.osgeo.org/postgis/trunk@666 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/utils/postgis_restore.pl b/utils/postgis_restore.pl index c10cee700..fac9659fd 100644 --- a/utils/postgis_restore.pl +++ b/utils/postgis_restore.pl @@ -16,12 +16,11 @@ # - operators from the dump are never restored due to # the impossibility (for current implementation) to # detect wheter or not they are from postgis -# -exec perl $0 $@ +eval "exec perl $0 $@" if (0); -(@ARGV == 3) || die "Usage: perl postgis_restore.pl \nRestore a custom dump (pg_dump -Fc) of a postgis enabled database.\n"; +(@ARGV == 3) || die "Usage: postgis_restore.pl \nRestore a custom dump (pg_dump -Fc) of a postgis enabled database.\n"; $DEBUG=0; @@ -275,6 +274,21 @@ while( my $line = ) close( INPUT ); close(OUTPUT); +print "Producing ascii dump $dumpascii\n"; +open( INPUT, "pg_restore -L $dumplist $dump |") || die "Can't run pg_restore\n"; +open( OUTPUT, ">$dumpascii") || die "Can't write to $dumpascii\n"; +while( my $line = ) +{ + $line =~ s/^(SET search_path .*);/\1, public;/; + print OUTPUT $line; + # TODO: + # skip postgis operator, checking for basetype + # when implemented operators skip must be disabled + # in the first scan of ToC +} +close(INPUT); +close(OUTPUT); + #exit(1); print "Creating db ($dbname)\n"; `createdb $dbname`; @@ -282,8 +296,9 @@ print "Adding plpgsql\n"; `createlang plpgsql $dbname`; print "Sourcing $postgissql\n"; `psql -f $postgissql $dbname`; -print "Restoring $dump\n"; -`pg_restore -L $dumplist $dump | sed 's/^\\(SET search_path .*\\);/\\1, public;/' > $dumpascii`; +print "Dropping geometry_columns and spatial_ref_sys\n"; +`psql -c "drop table geometry_columns; drop table spatial_ref_sys;" $dbname`; +print "Restoring ascii dump $dumpascii\n"; `psql -f $dumpascii $dbname`; exit;