[HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Moran.Michael
Hello all, I have a table with a VARCHAR column that I need to convert to a BYTEA. How do I cast VARCHAR to BYTEA? The following doesn't seem to work as it yields the 'cannot cast varchar to bytea' error message: varchar_data::bytea On the same topic, how do I do the reverse, that

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Moran.Michael
Thank you, Tom. Yes, the exact bytes in the varchar datum (without encoding) is what I would like to become the bytes in the BYTEA. So, how do I create a cast WITHOUT FUNCTION as you mention below? I assume plpgsql is required, right? Is there anyway this can be done in a VIEW without having

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Alvaro Herrera
On Tue, Mar 08, 2005 at 02:16:52PM -0800, Moran.Michael wrote: Yes, the exact bytes in the varchar datum (without encoding) is what I would like to become the bytes in the BYTEA. So, how do I create a cast WITHOUT FUNCTION as you mention below? I assume plpgsql is required, right? Did you

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Christopher Kings-Lynne
How do I cast VARCHAR to BYTEA? I think it would work to create a cast WITHOUT FUNCTION, assuming that the semantics you want is that the exact bytes in the varchar datum become the bytes in the bytea (no encoding or backslashing conversions). Are pg_escape_bytea and pg_unescape_bytea available