Michael Fuhr <mike@fuhr.org> writes:
> On Thu, Feb 10, 2005 at 12:16:53AM -0700, Michael Fuhr wrote:
>> SELECT textin(bit_out(b)) FROM foo;
> Is it generally true that you can convert between types using the
> above method, assuming compatible syntax?
IIRC, this has been reasonably safe since we made cstring into an actual
datatype, which was 7.3 or so. Before that it was real easy to crash
the backend by trying to invoke I/O functions directly (mainly because
the old convention involving OPAQUE didn't afford any opportunity to do
type checking).
> Is that how the PL/pgSQL RETURN trick works?
plpgsql has always done this under-the-hood for assignment across
disparate data types. I'd recommend using a plpgsql function rather
than messing with the I/O functions directly. For one thing, you don't
have to look up the function names/signatures that way ;-)
regards, tom lane