(..)
I tried defining composite types, but get a runtime error that it isn't
available.
That is you postgresql version?
Why you need return the temporary table type? Why create a temporary table if you use a function return type "setof"?
--
William Leite Araújo