[postgis-users] Typmod and triggers

Jose Carlos Martinez jomarlla at cgf.upv.es
Tue Nov 22 10:53:16 PST 2011


Hi all,
Im using PostgreSQL 9.1 and PG 2.0 under MS Windows.

Lets say I have a tabla A with a geometry column 'geom' of type 
geometry(MultiPolygon, 23030).
then I wrote a trigger (BEFORE INSERT ON, FOR EACH ROW) that changes: 
New.geom:= ST_GeometryN (New.geom, 1).

After inserting a row:
insert into A (geom) values ('SRID=23030;MULTIPOLYGON (((0 0, 10 0, 10 
10, 0 0)))'::geometry);

I got a row inserted in this table with a POLYGON type!!


And Viceversa:
I wrote a trigger that change: New.geom:= ST_Multi(geom);
then I insert:
insert into A (geom) values ('SRID=23030; POLYGON ((0 0, 10 0, 10 10, 0 
0))'::geometry);

and then PostgreSQL checks again the typmod geometry before the trigger 
and it is not possible to insert such a row.

In PG8.4 without typmod everything worked fine.

If this is the expected behaviour then I think typmod is adding some 
important limitations that PostGIS didnt have before.
If not then what Im doing wrong? can i fix it?

PD: Sorry if this problem was already post in the email list..i couldnt 
find it though.

Thanks in advance,
Best,
Jose








More information about the postgis-users mailing list