From 4af70020b73ca05f30ab40d7ed67f040adde8848 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 12 Dec 2011 22:22:57 +0000 Subject: [PATCH] Rewrite spatial table constraints to add st_ prefix and use 0 rather than -1 for unknown git-svn-id: http://svn.osgeo.org/postgis/trunk@8366 b70326c6-7e19-0410-871a-916f4a2858ee --- utils/new_postgis_restore.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/utils/new_postgis_restore.pl b/utils/new_postgis_restore.pl index 735480adf..8295c34db 100755 --- a/utils/new_postgis_restore.pl +++ b/utils/new_postgis_restore.pl @@ -125,6 +125,36 @@ while( my $l = ) { next; } + # Rewrite spatial table constraints + # + # Example: + # CREATE TABLE geos_in ( + # id integer NOT NULL, + # g public.geometry, + # CONSTRAINT enforce_dims_g CHECK ((public.st_ndims(g) = 2)), + # CONSTRAINT enforce_geotype_g CHECK (((public.geometrytype(g) = 'MULTILINESTRING'::text) OR (g IS NULL))), + # CONSTRAINT enforce_srid_g CHECK ((public.st_srid(g) = (-1))) + # ); + # + elsif ( $l =~ /CREATE TABLE *([^ ,]*)/) + { + my @sublines = ($l); + while( my $subline = ) + { + if ( $subline =~ /CONSTRAINT enforce_dims_/i ) { + $subline =~ s/\.ndims\(/.st_ndims(/; + } + if ( $subline =~ /CONSTRAINT enforce_srid_/i ) { + $subline =~ s/\.srid\(/.st_srid(/; + $subline =~ s/\(-1\)/(0)/; + } + push(@sublines, $subline); + last if $subline =~ /;[\t ]*$/; + } + print STDOUT @sublines; + next; + } + print STDOUT $l; } -- 2.40.0