[postgis-users] Updating geometry_column

Regina Obe lr at pcorp.us
Sat Sep 15 09:23:23 PDT 2018


Some functions?  No functions return "appropriate definitions".  

one reason is that PostgreSQL ignores precision/scaling /typmod even if you were to define a function as outputting that.

For example if perchance you ever tried to define a function as outputting  varchar(50), you're just going to get varchar back and in fact I believe your function def would be changed to just varchar.

So all functions in PostGIS that output a geometry/geography just output an unadorned geometry.geography.

The second reason is even if we were to output typmod details thru a function, it would have to be exactly the same for each call of the function (part of the definition).

This is not possible for a lot of functions.  Take for example ST_Transform --> its new SRID is not even what you started out with granted it's type would be the same, but the type output would rely on the type of the input geometry.

So the work around for this is when you build your table or view, you need to cast it as such like below and PostgreSQL will throw an error if you were wrong.

E.g. if your output is LINESTRING but you say it's POLYGON, it will fail the typmod change.

CREATE TABLE new_table AS 
SELECT gid, ST_Transform(geom, 2163)::geometry(POLYGON,2163) As geom
FROM old_table;

> -----Original Message-----
> From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On
> Behalf Of Paolo Cavallini
> Sent: Saturday, September 15, 2018 2:47 AM
> To: postgis-users at lists.osgeo.org
> Subject: [postgis-users] Updating geometry_column
> 
> Hi all,
> 
> why some functions (e.g. st_minline) create geometries without the
> appropriate definitions, so that the geometry_column view iss not updated
> correctly (missing geometrytype and srid)?
> 
> Thanks.
> 
> --
> Paolo Cavallini - www.faunalia.eu
> QGIS.ORG Chair:
> http://planet.qgis.org/planet/user/28/tag/qgis%20board/
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users



More information about the postgis-users mailing list