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

From Andrew SNow
Subject RE: Re: Storing images in PG?
Date
Msg-id 000801c1263a$14cb9710$fa01b5ca@avon
Whole thread Raw
In response to Re: Re: Storing images in PG?  (Karel Zak <zakkr@zf.jcu.cz>)
List pgsql-general
> > Correct me if I'm wrong, but the only thing "lztext" can't store is
> > NULLs, which could escaped somehow with other (rare) characters.
> > Still overhead, but you shouldn't be storing large pieces of binary
> > data this way, I think.
>
>  Here is not a problem with storing binary data to some
> datetype (like bytea), but problem is with other parts of PG.
> For example libpq
> functions read queries as string, other thing is query
> parsing where is needful set correct chars (like quote), etc.
>  IMHO if you want to work with queries with no problems and limits is

Right, and I'm saying you can save that space by simply escaping all
your characters in the normal way, e.g. SELECT '\377'  is the ASCII
character 0xFF.  This would work for all characters except NULL, which
you could represent by \377\377  (and you could represent a real \377 by
\377\376 or something).  Then the space wastage would be minimal
compared to using base 64.

I wrote a perl module which wraps around Pg, in which you can use
parameters in queries, and it automatically escapes extended ascii
characters as per above, however I have never tried storing binary data
using the whole 0x01 -> 0xFF range as I just described, but I think it
would work.


- Andrew


pgsql-general by date:

Previous
From: "Eric Ridge"
Date:
Subject: RE: Re: Re: Storing images in PG?
Next
From: "Ben-Nes Michael"
Date:
Subject: Roll Back dont roll back counters