Need help importing dump with bytea into db

Поиск
Список
Период
Сортировка
От Philippe Dirkse
Тема Need help importing dump with bytea into db
Дата
Msg-id ebb0569e-2940-4612-a006-6a4b4e052439@alten.nl
обсуждение исходный текст
Ответы Re: Need help importing dump with bytea into db  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice

Hi,

 

I have the strangest problem. Scenario: Server running postgresql 8.4.10, 32-bit Ubuntu, local machine running postgresql 9.1.4, 64-bit OSX Snow Leopard. I want to create a local copy of the database running on the server for development purposes, as the server database is ‘live’.

 

So, on my Mac I use pg_dump to create a dump from the server database. This database contains one table that has a bytea column which stores pictures (png,jpg). Examining the dump, I see this data is ‘escaped’ as octects for all ‘non-readable’ characters. Now, when I use psql (or pg_restore for that matter) to import the dump into my local database, the bytea data is not ‘unescaped’ properly. It appears as if the characters for the string representation of the actual bytes are returned.

 

To clarify, suppose the server contained the bytea ‘AB BC 10’hex, then my query from the local db will return ‘4142 4243 3130’hex, so basically what I must do is convert the bytes to their ASCII values, group them by 2 and convert that string back to the actual byte value (41=A, 42=B, so together I again have ‘AB’).

 

I noticed that if I try and restore the dump into a new database on the server this issue does not occur. I tried dumping as plain text, custom format, I tried using inserts instead of copy, I tried psql and pg_restore but it all failed.

 

What am I missing or doing wrong? Any help will be greatly appreciated!

 

Met vriendelijke groeten,

 

Ir. Philippe Dirkse

 

Project Manager Alten PTS Development Center

Tel: +31-(0)40-2563080

Mob: +31-(0)6-23401846

 

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

Предыдущее
От: M Q
Дата:
Сообщение: Re: "where x between y and z" for timestamp data types
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Need help importing dump with bytea into db