Re: Re: Storing images in PG? - Mailing list pgsql-general

From Tod McQuillin
Subject Re: Re: Storing images in PG?
Date
Msg-id Pine.GSO.4.33.0108160339100.22208-100000@sysadmin
Whole thread Raw
In response to Re: Storing images in PG?  (Karel Zak <zakkr@zf.jcu.cz>)
Responses RE: Re: Storing images in PG?  ("Andrew SNow" <andrew@modulus.org>)
List pgsql-general
On Thu, 16 Aug 2001, Karel Zak wrote:

> On Thu, Aug 16, 2001 at 06:02:00AM -0000, Dr. Evil wrote:
>
> > CREATE TABLE imagetable (
> >        ....
> >        image BYTEA,
> >        ....
> > );
> >
> > and then I do this in PHP:
> >
> > $result = pg_exec($db, "SELECT image FROM imagetable WHERE ...");
> > $ary = pg_fetch_array($result, 0);
> > $imagedata = $ary["image"];
> >
> > Will all of the above work?
>
>  Yes, but good is encode binary data (image) to same ascii safe encoding
> like base64, else you will have problem in INSERT/UPDATE queries.

If you encode with base64 you can use use varchar or text to store the
data.  Then what is the point of the 'bytea' type?

Encoding/decoding base64 is a lot of overhead for large images (both in
cpu time and disk space) -- is there no way to store and retrieve raw
binary data for bytea columns?
--
Tod McQuillin



pgsql-general by date:

Previous
From: Kenji Sugita
Date:
Subject: The -o command line option of pg_dump for a database using foreign keys
Next
From: "Andrew SNow"
Date:
Subject: RE: Re: Storing images in PG?