PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ json_categorize_type()

static void json_categorize_type ( Oid  typoid,
JsonTypeCategory tcategory,
Oid *  outfuncoid 
)
static

Definition at line 249 of file lwgeom_out_geojson.c.

252 {
253  bool typisvarlena;
254 
255  /* Look through any domain */
256  typoid = getBaseType(typoid);
257 
258  *outfuncoid = InvalidOid;
259 
260  /*
261  * We need to get the output function for everything except date and
262  * timestamp types, array and composite types, booleans, and non-builtin
263  * types where there's a cast to json.
264  */
265 
266  switch (typoid)
267  {
268  case BOOLOID:
269  *tcategory = JSONTYPE_BOOL;
270  break;
271 
272  case INT2OID:
273  case INT4OID:
274  case INT8OID:
275  case FLOAT4OID:
276  case FLOAT8OID:
277  case NUMERICOID:
278  getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
279  *tcategory = JSONTYPE_NUMERIC;
280  break;
281 
282  case DATEOID:
283  *tcategory = JSONTYPE_DATE;
284  break;
285 
286  case TIMESTAMPOID:
287  *tcategory = JSONTYPE_TIMESTAMP;
288  break;
289 
290  case TIMESTAMPTZOID:
291  *tcategory = JSONTYPE_TIMESTAMPTZ;
292  break;
293 
294  case JSONOID:
295  case JSONBOID:
296  getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
297  *tcategory = JSONTYPE_JSON;
298  break;
299 
300  default:
301  /* Check for arrays and composites */
302  if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
303  || typoid == RECORDARRAYOID)
304  *tcategory = JSONTYPE_ARRAY;
305  else if (type_is_rowtype(typoid)) /* includes RECORDOID */
306  *tcategory = JSONTYPE_COMPOSITE;
307  else
308  {
309  /* It's probably the general case ... */
310  *tcategory = JSONTYPE_OTHER;
311  /* but let's look for a cast to json, if it's not built-in */
312  if (typoid >= FirstNormalObjectId)
313  {
314  Oid castfunc;
315  CoercionPathType ctype;
316 
317  ctype = find_coercion_pathway(JSONOID, typoid,
318  COERCION_EXPLICIT,
319  &castfunc);
320  if (ctype == COERCION_PATH_FUNC && OidIsValid(castfunc))
321  {
322  *tcategory = JSONTYPE_CAST;
323  *outfuncoid = castfunc;
324  }
325  else
326  {
327  /* non builtin type with no cast */
328  getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
329  }
330  }
331  else
332  {
333  /* any other builtin type */
334  getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
335  }
336  }
337  break;
338  }
339 }
@ JSONTYPE_JSON
@ JSONTYPE_TIMESTAMP
@ JSONTYPE_NUMERIC
@ JSONTYPE_DATE
@ JSONTYPE_BOOL
@ JSONTYPE_OTHER
@ JSONTYPE_CAST
@ JSONTYPE_COMPOSITE
@ JSONTYPE_ARRAY
@ JSONTYPE_TIMESTAMPTZ

References JSONTYPE_ARRAY, JSONTYPE_BOOL, JSONTYPE_CAST, JSONTYPE_COMPOSITE, JSONTYPE_DATE, JSONTYPE_JSON, JSONTYPE_NUMERIC, JSONTYPE_OTHER, JSONTYPE_TIMESTAMP, and JSONTYPE_TIMESTAMPTZ.

Referenced by array_to_json_internal(), composite_to_geojson(), and composite_to_json().

Here is the caller graph for this function: