Re: Store base64 in database. Use bytea or text?

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: Store base64 in database. Use bytea or text?
Дата
Msg-id 20110125174612.153a1f51.wmoran@potentialtech.com
обсуждение исходный текст
Ответ на Re: Store base64 in database. Use bytea or text?  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
Ответы Re: Store base64 in database. Use bytea or text?
Список pgsql-general
In response to Peter Geoghegan <peter.geoghegan86@gmail.com>:

> On 25 January 2011 22:27, Andre Lopes <lopes80andre@gmail.com> wrote:
> > Hi,
> >
> > I need to put some images on Base64 in a PostgreSQL database. Wich
> > type should I use and what is the difference between using bytea or
> > text to store Base64?
>
> I really don't think you want to do that. Base64 is used to make
> binary data 7-bit safe for compatibility with legacy systems (i.e. to
> embed arbitrary binary data within ASCII). Sometimes people escape
> binary data as base64 to store it in their DB, but they typically
> store it as bytea. Base64 probably isn't even a particularly good
> choice for escaping binary, let alone storing it.
>
> You should just use a generic escaping function. libpq has
> PQescapeByteaConn(), for example.

A warning: last I checked, PHP's pg_escape_bytea() was broken, so be
cautious if you're using PHP.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

В списке pgsql-general по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Store base64 in database. Use bytea or text?
Следующее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: Store base64 in database. Use bytea or text?