PostgreSQL 9.X bytea表示形式,以“十六进制”或“转义”形式显示缩略图 [英] PostgreSQL 9.X bytea representation in 'hex' or 'escape' for thumbnail images

查看:519
本文介绍了PostgreSQL 9.X bytea表示形式,以“十六进制”或“转义”形式显示缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序(在Delphi和ZEOS组件中开发)使用PostgreSQL 8.4,并将一些缩略图存储在 bytea 列中。

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

我想迁移到PostgreSQL 9.2并恢复了转储,并且一切正常,除非我尝试检索那些图像:Postgres 9.2使用 hex 代替输出表示Postgres 8.4中使用的转义

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.

有两种可能的解决方案:更改<$ c的Postgres 9.2设置通过应用程序在二进制数据中使用$ c> escape 表示形式或更改 hex 字符串。但是最好的解决方案是什么?为什么PostgreSQL 9.X更改为 bytea 表示形式的 hex

这很简单设置还是有技术原因?

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?

推荐答案

Postgres 9.0的发行说明



  • 允许 bytea 值以十六进制表示(Peter Eisentraut)

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

服务器参数 bytea_output 控制是否将十六进制或传统
格式用于 bytea 输出。 Libpq的 PQescapeByteaConn()函数
在连接到PostgreSQL 9.0或
的新服务器时会自动使用十六进制格式。但是,低于9.0的libpq版本将无法正确地
从较新的服务器处理十六进制格式。

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.

您似乎已经知道 bytea_output

You already seem to be aware of bytea_output.

这篇关于PostgreSQL 9.X bytea表示形式,以“十六进制”或“转义”形式显示缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆