[postgis-devel] Typmod Enforcement
Chris Hodgson
chodgson at refractions.net
Mon Aug 3 10:59:17 PDT 2009
Paul, I think you're right that this is a great opportunity to add some
automagic features. I'd love to see features automatically reprojected,
but I think we need to throw at least a notice. I don't see why we
couldn't just zero additional fields when stuffing a point into a pointz
column, and the same for 2d into a 3d column... but again at least a
notice, probably a warning, should be raised. Really, as long as we
raise a warning, automagically stripping additional data when stuffing
3d geometries into 2d columns, or pointz into a point column seems like
a handy feature. Although I could understand if we want to force people
to explicitly use available functions to do these data manipulations
instead of hiding it in an auto cast. Perhaps we could even tell them
what function(s) to use in the warning or error message.
All easy for me to say since you're doing the work ;)
Chris
Paul Ramsey wrote:
> 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?
>
> P.
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
More information about the postgis-devel
mailing list