* 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
| 3301 | * COERCION_PATH_ARRAYCOERCE: apply the function using ArrayCoerceExpr |
| 3302 | */ |
| 3303 | CoercionPathType |
| 3304 | find_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 |
no test coverage detected