235{
237 Datum *elem_values;
238 int n = 0;
239 int i = 0;
240
241 if (ARR_ELEMTYPE(arr) != CSTRINGOID)
242 ereport(ERROR,
243 (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
244 errmsg("typmod array must be type cstring[]")));
245
246 if (ARR_NDIM(arr) != 1)
247 ereport(ERROR,
248 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
249 errmsg("typmod array must be one-dimensional")));
250
251 if (ARR_HASNULL(arr))
252 ereport(ERROR,
253 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
254 errmsg("typmod array must not contain nulls")));
255
256 deconstruct_array(arr,
257 CSTRINGOID, -2, false, 'c',
258 &elem_values, NULL, &n);
259
260
261 if (is_geography)
263 else
265
266 for (i = 0; i < n; i++)
267 {
268 if ( i == 0 )
269 {
270 char *
s = DatumGetCString(elem_values[i]);
272 int z = 0;
273 int m = 0;
274
276 {
277 ereport(ERROR,
278 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
279 errmsg(
"Invalid geometry type modifier: %s",
s)));
280 }
281 else
282 {
284 if ( z )
286 if ( m )
288 }
289 }
290 if ( i == 1 )
291 {
292 char *int_string = DatumGetCString(elem_values[i]);
293 char *endp;
294 long l;
295 int32_t srid;
296
297 errno = 0;
298 l = strtol(int_string, &endp, 10);
299
300 if (int_string == endp)
301 ereport(ERROR,
302 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
303 errmsg("invalid input syntax for type %s: \"%s\"",
304 "integer", int_string)));
305
306 if (errno == ERANGE || l < INT_MIN || l > INT_MAX)
307 ereport(ERROR,
308 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
309 errmsg("value \"%s\" is out of range for type %s", int_string,
310 "integer")));
311
312 if (*endp != '\0')
313 ereport(ERROR,
314 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
315 errmsg("invalid input syntax for type %s: \"%s\"",
316 "integer", int_string)));
317
319 POSTGIS_DEBUGF(3, "srid: %d", srid);
321 {
323 }
324 }
325 }
326
327 pfree(elem_values);
328
329 return typmod;
330}
#define TYPMOD_SET_SRID(typmod, srid)
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Utility function to get type number from string.
#define TYPMOD_SET_TYPE(typmod, type)
#define TYPMOD_SET_M(typmod)
#define SRID_UNKNOWN
Unknown SRID value.
#define TYPMOD_SET_Z(typmod)
int32_t clamp_srid(int32_t srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...