Using ST_Geometry to store subtype geometries

Some spatial functions only work with geometries of a specific subtype, for example, ST_ExteriorRing can only be used with geometries of type ST_Polygon. If a geometry is stored in an ST_Geometry type, such a geometry-type specific function can be applied as long as the geometry type associated with the specific geometry value matches the expected geometry type, otherwise the function will fail.

Functions may also be defined for a specific supertype. Such functions can be used for the supertype and any of its subtypes. For example, ST_GeometryN is defined for the geometry type ST_GeomCollection. It can be applied to geometries of type ST_MultiPoint, St_MultiLinestring and ST_MultiPolygon.