When I call a function and pass it an argument, is that argument's value actually copied in memory so that the called function receives a copy of the value, or it is passed a reference/pointer?
I guess in some cases it's obvious - I'd expect an integer to be copied, for example, but what if I have a large string or array or table row?
From my own observations it appears the value is always copied, because I can edit the value in the called function without changing the value in the calling function. In fact I can't think of any case where I've been able to modify something passed in as an argument, and have the calling function pick up the change without returning the changed data from the called function.
I'm always uneasy about passing large amounts of data from one function to another for this reason. I haven't been able to find any documentation on how postgres handles arguments, hence this question. The function types I use are SQL and plpgsql.