PostGIS 3.0.6dev-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 228 of file lwgeom_out_geojson.c.

231{
232 bool typisvarlena;
233
234 /* Look through any domain */
235 typoid = getBaseType(typoid);
236
237 *outfuncoid = InvalidOid;
238
239 /*
240 * We need to get the output function for everything except date and
241 * timestamp types, array and composite types, booleans, and non-builtin
242 * types where there's a cast to json.
243 */
244
245 switch (typoid)
246 {
247 case BOOLOID:
248 *tcategory = JSONTYPE_BOOL;
249 break;
250
251 case INT2OID:
252 case INT4OID:
253 case INT8OID:
254 case FLOAT4OID:
255 case FLOAT8OID:
256 case NUMERICOID:
257 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
258 *tcategory = JSONTYPE_NUMERIC;
259 break;
260
261 case DATEOID:
262 *tcategory = JSONTYPE_DATE;
263 break;
264
265 case TIMESTAMPOID:
266 *tcategory = JSONTYPE_TIMESTAMP;
267 break;
268
269 case TIMESTAMPTZOID:
270 *tcategory = JSONTYPE_TIMESTAMPTZ;
271 break;
272
273 case JSONOID:
274 case JSONBOID:
275 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
276 *tcategory = JSONTYPE_JSON;
277 break;
278
279 default:
280 /* Check for arrays and composites */
281 if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
282 || typoid == RECORDARRAYOID)
283 *tcategory = JSONTYPE_ARRAY;
284 else if (type_is_rowtype(typoid)) /* includes RECORDOID */
285 *tcategory = JSONTYPE_COMPOSITE;
286 else
287 {
288 /* It's probably the general case ... */
289 *tcategory = JSONTYPE_OTHER;
290 /* but let's look for a cast to json, if it's not built-in */
291 if (typoid >= FirstNormalObjectId)
292 {
293 Oid castfunc;
294 CoercionPathType ctype;
295
296 ctype = find_coercion_pathway(JSONOID, typoid,
297 COERCION_EXPLICIT,
298 &castfunc);
299 if (ctype == COERCION_PATH_FUNC && OidIsValid(castfunc))
300 {
301 *tcategory = JSONTYPE_CAST;
302 *outfuncoid = castfunc;
303 }
304 else
305 {
306 /* non builtin type with no cast */
307 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
308 }
309 }
310 else
311 {
312 /* any other builtin type */
313 getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
314 }
315 }
316 break;
317 }
318}
@ 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: