Re: Examples of using bytea type - Mailing list pgsql-general

From lbayuk@mindspring.com (ljb)
Subject Re: Examples of using bytea type
Date
Msg-id 9j82t9$9ts$1@news.tht.net
Whole thread Raw
In response to Examples of using bytea type  ("Richard Church" <rfchurch@hotmail.com>)
Responses Re: Re: Examples of using bytea type
List pgsql-general
rfchurch@hotmail.com wrote:
>
>The current PostgreSQL documentation is does not discuss the bytea type at
>all.
>
>Does anyone have indepth examples of using this type in SQL?
>
>I know expressing BLOb data in SQL is awkward and would generate huge text
>files, but is there a standard method of using escape sequences to express
>blobs or something similar to MIME?
>
>There surely must be something like that.

The bytea type is undocumented, so I suppose you should use it at your
own risk, since it may vanish (like lztext did at 7.1).

Keep in mind that unless you use binary cursors, what you get back from a
query on a bytea type is a string with "\nnn" sequences mixed with text in
it, which your application would then need to decode to get the actual
data.  For inserting, you must convert your data to \nnn sequences (\\000
for 0), all in one string, to use in an insert on a bytea (there are no
binary cursors for insert). So it's a lot of trouble, and might not be
worth the effort. If you have to encode/decode in your application anyway,
I wonder if it wouldn't be be easier to do Base64 or Ascii85 coding and use
the "text" type in PostgreSQL instead of bytea?

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: many tables in db
Next
From: Justin Clift
Date:
Subject: Re: Interesting discussion