我想迁移到Postgresql 9.2并恢复转储,一切正常,除非我尝试检索这些图像:Postgres 9.2使用十六进制表示输出表示而不是Postgres 8.4中使用的转义.
有两种可能的解决方案:更改转义表示的Postgres 9.2设置或通过应用程序更改二进制数据中的十六进制字符串.但什么是最好的解决方案?为什么Postgresql 9.X更改为十六进制表示bytea?
这是一个简单的设置还是有技术原因?
解决方法
- Allow
bytea
values to be written in hex notation (Peter Eisentraut)The server parameter
bytea_output
controls whether hex or traditional
format is used forbytea
output. Libpq’sPQescapeByteaConn()
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.
你似乎已经意识到了bytea_output
.