How would one go about determining the function used by postgresql to perform a type casting?
EG: If I have SELECT ‘{1,2,3}’::int4[], how do I determine which function is used by postgresql to perform the casting? Doing \dC within psql does not seem to list any casts that have the target data type being int4[].
The totally elite way is to do
SET debug_print_parse TO on;orSET debug_print_plan TO on;and then look at the parse or plan tree in the server log for which function ends up being called.In this particular example, this will tell you that what you wrote isn’t really a cast, it simply feeds the string
'{1,2,3}'to the type input function of the typeint4[]. There are other scenarios where a cast function as such won’t be called, such as binary compatible types or coercion via I/O functions.