mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 09:02:37 +00:00
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
This commit is contained in:
parent
c6db7b5748
commit
4af70020b7
|
@ -125,6 +125,36 @@ while( my $l = <INPUT> ) {
|
|||
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 = <INPUT>)
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue