[postgis-users] Help with spatial query (bug??)

Markus Schaber schabi at logix-tt.com
Wed Apr 6 23:14:38 PDT 2005

Hi, Brent,

Brent Wood schrieb:
> Not quite, what I'm assuming is that _if_ a zero length linestring is accepted
> as a valid value, then it _is_ treated as such. If the geometry is NOT valid
> (ie: rejected on data insertion) as a linestring, then it can't be mistreated.

=# select isvalid('LINESTRING(0 0,0 0)'::geometry);
(1 Zeile)

As you can see, a zero-lenght linestring actually _is not_ a valid geometry.

By default, PostGIS does not do validity checks on data insertion,
because this is a relatively expensive operation on complex geometries,
but you cannot rely on anything if you insert geometries that are not valid.

You can add this check at data insertion time by using a statement like
the following:

ALTER TABLE mytable ADD CONSTRAINT geometry_valid_check CHECK


More information about the postgis-users mailing list