[postgis-devel] Typmod Enforcement

Paul Ramsey pramsey at opengeo.org
Mon Aug 3 09:43:48 PDT 2009

Having now figured out the magic of typmod enforcement, there's an  
interesting "extra feature" available that old fashioned constraint  
enforcement didn't provide: if we want we can coerce bad data into  
good data during the enforcement stage.

Here's as example:

If I have a column with type POINTZ and I feed it a POINT, there's not  
much I can do -- the input is lacking sufficient information. However,  
if I have a column with type POINT and feed it a POINTZ, I have the  
option of stripping the input down to the column dimensionality. The  
PgSQL code for things like varchar() tosses errors on overlong input,  
except when the spare stuff is white space, in which case it truncates.

So, in that example, information would be discarded in the coercion  
which I probably couldn't convince you to do. But what about this?

If I have a column with SRID = 4326 and try to insert an object with  
SRID = 26910. I can coerce it into the right SRID with no data loss.  
Do I insert or complain?


More information about the postgis-devel mailing list