aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2010-12-22 14:23:56 +0100
committerMagnus Hagander <magnus@hagander.net>2010-12-22 14:23:56 +0100
commitde9a4c27fefcc0d104bc9c97f4a93a49a25bf66d (patch)
treef35f5981172774dde3bac35c530eb9e190c6b0bb /src
parent32ba2b516066688ff56e6d62a7ff4a01c88f5700 (diff)
downloadpostgresql-de9a4c27fefcc0d104bc9c97f4a93a49a25bf66d.tar.gz
postgresql-de9a4c27fefcc0d104bc9c97f4a93a49a25bf66d.zip
Add PQlibVersion() function to libpq
This function is like the PQserverVersion() function except it returns the version of libpq, making it possible for a client program or driver to determine which version of libpq is in use at runtime, and not just at link time. Suggested by Harald Armin Massa and several others.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/exports.txt1
-rw-r--r--src/interfaces/libpq/fe-misc.c8
-rw-r--r--src/interfaces/libpq/libpq-fe.h3
3 files changed, 12 insertions, 0 deletions
diff --git a/src/interfaces/libpq/exports.txt b/src/interfaces/libpq/exports.txt
index a6c73af52e8..1af8df699ed 100644
--- a/src/interfaces/libpq/exports.txt
+++ b/src/interfaces/libpq/exports.txt
@@ -159,3 +159,4 @@ PQconnectdbParams 156
PQconnectStartParams 157
PQping 158
PQpingParams 159
+PQlibVersion 160
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 24ab7cf97a3..999f60b0d43 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -66,6 +66,14 @@ static int pqSocketCheck(PGconn *conn, int forRead, int forWrite,
time_t end_time);
static int pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time);
+/*
+ * PQlibVersion: return the libpq version number
+ */
+int
+PQlibVersion(void)
+{
+ return PG_VERSION_NUM;
+}
/*
* fputnbytes: print exactly N bytes to a file
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index 271afedb7b8..6075ea8151e 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -547,6 +547,9 @@ extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
/* === in fe-misc.c === */
+/* Get the version of the libpq library in use */
+extern int PQlibVersion(void);
+
/* Determine length of multibyte encoded char at *s */
extern int PQmblen(const char *s, int encoding);