Re: Re: Examples of using bytea type

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: ljb <lbayuk(at)mindspring(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Examples of using bytea type
Date: 2001-07-20 03:12:58
Message-ID: Pine.BSO.4.10.10107192310450.7004-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 20 Jul 2001, ljb wrote:

> rfchurch(at)hotmail(dot)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?

Bytea IS documented in 7.2-devel and is definitely not going away. Major
benefit of bytea over base64/whatever encoding is storage space. Need to
escape/unescape input data depends on your frontend client. Perl DBD::Pg
will do it transparently without needing to do \\ escapes.

In 7.2, there will also be functions base64_encode/base64_decode for bytea
types. In 7.1, they exist under contrib/pg_crypto

-alex

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-07-20 04:29:29 Re: Postgres Certification/training
Previous Message Bruce Momjian 2001-07-20 03:09:53 Good software takes 10 years