MCPcopy Create free account
hub / github.com/apache/cloudberry / find_typmod_coercion_function

Function find_typmod_coercion_function

src/backend/parser/parse_coerce.c:3303–3344  ·  view source on GitHub ↗

* find_typmod_coercion_function -- does the given type need length coercion? * * If the target type possesses a pg_cast function from itself to itself, * it must need length coercion. * * "bpchar" (ie, char(N)) and "numeric" are examples of such types. * * If the given type is a varlena array type, we do not look for a coercion * function associated directly with the array type, but instea

Source from the content-addressed store, hash-verified

3301 * COERCION_PATH_ARRAYCOERCE: apply the function using ArrayCoerceExpr
3302 */
3303CoercionPathType
3304find_typmod_coercion_function(Oid typeId,
3305 Oid *funcid)
3306{
3307 CoercionPathType result;
3308 Type targetType;
3309 Form_pg_type typeForm;
3310 HeapTuple tuple;
3311
3312 *funcid = InvalidOid;
3313 result = COERCION_PATH_FUNC;
3314
3315 targetType = typeidType(typeId);
3316 typeForm = (Form_pg_type) GETSTRUCT(targetType);
3317
3318 /* Check for a "true" array type */
3319 if (IsTrueArrayType(typeForm))
3320 {
3321 /* Yes, switch our attention to the element type */
3322 typeId = typeForm->typelem;
3323 result = COERCION_PATH_ARRAYCOERCE;
3324 }
3325 ReleaseSysCache(targetType);
3326
3327 /* Look in pg_cast */
3328 tuple = SearchSysCache2(CASTSOURCETARGET,
3329 ObjectIdGetDatum(typeId),
3330 ObjectIdGetDatum(typeId));
3331
3332 if (HeapTupleIsValid(tuple))
3333 {
3334 Form_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);
3335
3336 *funcid = castForm->castfunc;
3337 ReleaseSysCache(tuple);
3338 }
3339
3340 if (!OidIsValid(*funcid))
3341 result = COERCION_PATH_NONE;
3342
3343 return result;
3344}
3345
3346/*
3347 * is_complex_array

Callers 2

coerce_type_typmodFunction · 0.85
init_cast_cache_entryFunction · 0.85

Calls 4

typeidTypeFunction · 0.85
ReleaseSysCacheFunction · 0.85
SearchSysCache2Function · 0.85
ObjectIdGetDatumFunction · 0.85

Tested by

no test coverage detected