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

Get libpq runtime version (from libpqxx)

在 libpqxx 参考资料中,我有时可以阅读仅限于底层 libpq 版本 ("Requires libpq version from PostgreSQL 7.4 or better. ") 的内容 like here.

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

从 9.1 到 PQlibVersion

,libpq 版本在运行时可用

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.