PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ json_categorize_type()

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

Definition at line 283 of file lwgeom_out_geojson.c.

286{
287 bool typisvarlena;
288
289 /* Look through any domain */
290 typoid = getBaseType(typoid);
291
292 *outfuncoid = InvalidOid;
293
294 /*
295 * We need to get the output function for everything except date and
296 * timestamp types, array and composite types, booleans, and non-builtin
297 * types where there's a cast to json.
298 */
299
300 switch (typoid)
301 {
302 case BOOLOID:
303 *tcategory = JSONTYPE_BOOL;
304 break;
305
306 case INT2OID:
307 case INT4OID:
308 case INT8OID:
309 case FLOAT4OID:
310 case FLOAT8OID:
311 case NUMERICOID:
312 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
313 *tcategory = JSONTYPE_NUMERIC;
314 break;
315
316 case DATEOID:
317 *tcategory = JSONTYPE_DATE;
318 break;
319
320 case TIMESTAMPOID:
321 *tcategory = JSONTYPE_TIMESTAMP;
322 break;
323
324 case TIMESTAMPTZOID:
325 *tcategory = JSONTYPE_TIMESTAMPTZ;
326 break;
327
328 case JSONOID:
329 case JSONBOID:
330 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
331 *tcategory = JSONTYPE_JSON;
332 break;
333
334 default:
335 /* Check for arrays and composites */
336 if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
337 || typoid == RECORDARRAYOID)
338 *tcategory = JSONTYPE_ARRAY;
339 else if (type_is_rowtype(typoid)) /* includes RECORDOID */
340 *tcategory = JSONTYPE_COMPOSITE;
341 else
342 {
343 /* It's probably the general case ... */
344 *tcategory = JSONTYPE_OTHER;
345 /* but let's look for a cast to json, if it's not built-in */
346 if (typoid >= FirstNormalObjectId)
347 {
348 Oid castfunc;
349 CoercionPathType ctype;
350
351 ctype = find_coercion_pathway(JSONOID, typoid,
352 COERCION_EXPLICIT,
353 &castfunc);
354 if (ctype == COERCION_PATH_FUNC && OidIsValid(castfunc))
355 {
356 *tcategory = JSONTYPE_CAST;
357 *outfuncoid = castfunc;
358 }
359 else
360 {
361 /* non builtin type with no cast */
362 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
363 }
364 }
365 else
366 {
367 /* any other builtin type */
368 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
369 }
370 }
371 break;
372 }
373}
@ 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: