Re: Saving a jpg into Postgresql table - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Saving a jpg into Postgresql table
Date
Msg-id 20060825204925.GS6550@merkur.hilbert.loc
Whole thread Raw
In response to Re: Saving a jpg into Postgresql table  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Saving a jpg into Postgresql table  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
On Fri, Aug 25, 2006 at 10:17:34AM -0700, Jeff Davis wrote:

> > It takes aproximately 25-30% more disk space but is much easier for me
> > to operate with it.
> > When I read the object from the database I decode it and I have the file
> > in the original format.
>
> Why not go a step further and do this:
>
> (1) encode the image as base64
> (2) insert into mytable(image) values(decode('<base64 encoding of
> image>','base64'));
>
> Then, to get it back:
>
> (1) select encode(image,'base64') from mytable;
> (2) decode the base64 into your image

Should that jumping through the base64 loops even be
necessary ? I thought that I could just send the raw data
when it ends up in a bytea field. However, your advice and
previous suggestions make me have a sneaking suspicion that
it still depends on how my PG library puts the data on the
wire:

a) as a string inside the query itself (in which case it
should not be touched by encoding conversions as its headed
towards a bytea field but still needs to be quoted properly
which, again, the library should do)

b) in raw binary if bound parameters are used (values
transmitted separate from the query)

Am I correct ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

pgsql-general by date:

Previous
From: Marc Munro
Date:
Subject: Re: Something blocking in libpq_gettext?
Next
From: Jeff Davis
Date:
Subject: Re: Saving a jpg into Postgresql table