Need help importing dump with bytea into db

From: Philippe Dirkse <philippe(dot)dirkse(at)alten(dot)nl>
To: pgsql-novice(at)postgresql(dot)org
Subject: Need help importing dump with bytea into db
Date: 2012-08-13 07:56:37
Message-ID: ebb0569e-2940-4612-a006-6a4b4e052439@alten.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2012-08-13 14:23:29 Re: Need help importing dump with bytea into db
Previous Message M Q 2012-08-13 06:27:52 Re: "where x between y and z" for timestamp data types