Huh, so in the other cases where the function works fine, it's likely that the data all just fits within the regular table and doesn't have to be TOAST'ed?
So this is something that isn't changed in PG10, and I could have encountered in 9.6, and just by chance didn't?
This is a pattern I've used in quite a few (at least 50) functions, so it's surprising I've not seen this issue until now.
Thanks,
-Adam