[postgis-users] Difference on check constraints on colum type between Pgis 1.5 and 2.0 ?

Nicolas Ribot nicolas.ribot at gmail.com
Thu Nov 21 02:43:35 PST 2013


Hi David,

Yes: the new geometry type definition now allows contraints to be
carried by the column itself. The typmod "geometry(MultiPolygon,4326)"
forces the column to respect the object type (Multipolygon) and a
SRID. Its like using varchar(30), for instance.

You will also notice that geometry_columns is not a table anymore, but
a view, automatically registering geometry metadata thanks to the
typmod feature.

Nicolas.

On 20 November 2013 15:26, David PEYRIERES <david.peyrieres at meteo.fr> wrote:
> Hye.
> I have a question about the check constraints on the PostGIS columns type
> Can you explain me why we got check constraints on old version (here 1.5.2)
> of PostGIS and now we don't see such constraints with 2.0 when we ask a
> describe of such relation.
> I precise that the 2 objects have been created with same query (same
> function) on two servers.
>
>>>> select AddGeometryColumn('d1','contour',4326,'MULTIPOLYGON',2);
>
> POSTGIS 1.5
> ___________________
> bd=> \d d1
>   Column  |   Type   | Modifiers
> ----------+----------+-----------
>  idmenage | integer  | not null
>  contour  | geometry |
> Indexes:
>     "idx1_d1" btree (idmenage), tablespace "bde_data"
> Check constraints:
>     "enforce_dims_contour" CHECK (st_ndims(contour) = 2)
>     "enforce_geotype_contour" CHECK (geometrytype(contour) =
> 'MULTIPOLYGON'::text OR contour IS NULL)
>     "enforce_srid_contour" CHECK (st_srid(contour) = 4326)
>
>
> POSTGIS 2.0
> ___________________
> bde=> \d d1
>   Column  |            Type             | Modifiers
> ----------+-----------------------------+-----------
>  idmenage | integer                     | not null
>  contour  | geometry(MultiPolygon,4326) |
> Indexes:
>     "idx1_d1" btree (idmenage)
>
>
> The difference is that the type added by function is not really the same.
> Are constraints not visible but internal ?
> Thanks.
>
> ________________________________
>
> David PEYRIERES
> Direction des Sytèmes d'Information
> Division Etudes et Développements
> Administration et Support Bases de Données
>
> Tel :   +33 (0)5.61.07.83.36
> Fax :  +33 (0)5.61.07.81.09
> david.peyrieres at meteo.fr
>
> METEO FRANCE
> www.meteo.fr
> 42 avenue Gustave Coriolis
> 31057 TOULOUSE Cédex
>
> ________________________________
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


More information about the postgis-users mailing list