postgresql - 获取 libpq 运行时版本(来自 libpqxx)

标签 postgresql libpq libpqxx

在 libpqxx 引用中,我有时可以读到仅限于底层 libpq 版本的内容(“需要 PostgreSQL 7.4 或更高版本的 libpq 版本。”) like here

现在问题:(1)如何获取当前程序使用的libpq版本(使用libpqxx)? (2) 据我所知,在升级到新的 libpq 版本时,libpqxx 不一定需要重新编译。替换旧的 libpq.dll 涵盖(通常)新技术,例如我的例子中的 ssl 压缩。这就是为什么我认为 libpq 版本应在运行时接收。

最佳答案

libpq 版本从 9.1 开始可在运行时使用 PQlibVersion :

int PQlibVersion(void);

The result of this function can be used to determine, at run time, if specific functionality is available in the currently loaded version of libpq. The function can be used, for example, to determine which connection options are available for PQconnectdb or if the hex bytea output added in PostgreSQL 9.0 is supported.

The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 9.1 will be returned as 90100, and version 9.1.2 will be returned as 90102 (leading zeroes are not shown).

libpqxx 似乎没有封装此功能,因此我们必须穿过它才能直接访问 libpq

关于postgresql - 获取 libpq 运行时版本(来自 libpqxx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29746966/

相关文章:

postgresql - 如何指定模式以在 Postgresql 命令行中针对运行 sql 文件

ruby-on-rails - Rails 3 - 无法安装 pg gem

postgresql - 如何使用 libpq 的 pgpass 连接到 postgresql,而不指定纯文本密码?

sql - 在 postgresql 中无法检查表是否存在

c++ - 处理连接对象时出现段错误

c - 识别 PostgreSQL 和 libpq 上的语句

c++ - 如何使用 C++ libpqxx API 将二进制数据插入到 PostgreSQL BYTEA 列中?

r - 使用 dplyr 过滤 postgreSQL 数据库中的多个值

postgresql - 如何在 PostgreSQL 中获取日期的开始时间?

sql - 在更新语句中加密 postgres 列