문제

My application (developed in Delphi and ZEOS components) uses PostgreSQL 8.4 and stores some thumbnail images into a bytea column.

I want to migrate to PostgreSQL 9.2 and have restored the dump and everything works fine except when I try to retrieve those images: Postgres 9.2 uses hex for output representation instead of escape used in Postgres 8.4.

There are two possible solutions: Change the Postgres 9.2 settings for escape representation or change the hex string in binary data via application. But what is the best solution? Why did PostgreSQL 9.X change to hex for bytea representation?
It is a simple setup or are there technical reasons?

도움이 되었습니까?

해결책

A rationale was given in the release notes of Postgres 9.0:

  • Allow bytea values to be written in hex notation (Peter Eisentraut)

The server parameter bytea_output controls whether hex or traditional format is used for bytea output. Libpq's PQescapeByteaConn() function automatically uses the hex format when connected to PostgreSQL 9.0 or newer servers. However, pre-9.0 libpq versions will not correctly process hex format from newer servers.

The new hex format will be directly compatible with more applications that use binary data, allowing them to store and retrieve it without extra conversion. It is also significantly faster to read and write than the traditional format.

You already seem to be aware of bytea_output.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top