Check the consistency of the metadata we want to enforce in the typmod: srid, type and dimensionality.
If things are inconsistent, shut down the query.
130 POSTGIS_DEBUG(2,
"Entered function");
133 if (typmod < 0)
return gser;
135 POSTGIS_DEBUGF(3,
"Got geom(type = %d, srid = %d, hasz = %d, hasm = %d)", geom_type, geom_srid, geom_z, geom_m);
136 POSTGIS_DEBUGF(3,
"Got typmod(type = %d, srid = %d, hasz = %d, hasm = %d)", typmod_type, typmod_srid, typmod_z, typmod_m);
160 if ( typmod_srid > 0 && typmod_srid != geom_srid )
163 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
164 errmsg(
"Geometry SRID (%d) does not match column SRID (%d)", geom_srid, typmod_srid) ));
168 if ( typmod_type > 0 &&
175 (typmod_type != geom_type)) )
178 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
179 errmsg(
"Geometry type (%s) does not match column type (%s)",
lwtype_name(geom_type),
lwtype_name(typmod_type)) ));
183 if ( typmod_z && ! geom_z )
186 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
187 errmsg(
"Column has Z dimension but geometry does not" )));
191 if ( geom_z && ! typmod_z )
194 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
195 errmsg(
"Geometry has Z dimension but column does not" )));
199 if ( typmod_m && ! geom_m )
202 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
203 errmsg(
"Column has M dimension but geometry does not" )));
207 if ( geom_m && ! typmod_m )
210 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
211 errmsg(
"Geometry has M dimension but column does not" )));
#define TYPMOD_GET_TYPE(typmod)
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
#define TYPMOD_GET_M(typmod)
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
#define TYPMOD_GET_SRID(typmod)
Macros for manipulating the 'typemod' int.
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
int gserialized_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
#define TYPMOD_GET_Z(typmod)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...