Re: Any functions to convert bit(5) to text? - Mailing list pgsql-general

From Tom Lane
Subject Re: Any functions to convert bit(5) to text?
Date
Msg-id 26851.1108049007@sss.pgh.pa.us
Whole thread Raw
In response to Re: Any functions to convert bit(5) to text?  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
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

pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: Understanding EXPLAIN ANALYZE output
Next
From: Michael Fuhr
Date:
Subject: Re: a SELECT FOR UPDATE question