libpq compatibility policy across versions - Mailing list pgsql-interfaces

From Sebastien FLAESCH
Subject libpq compatibility policy across versions
Date
Msg-id 522F0B6B.1040006@4js.com
Whole thread Raw
Responses Re: libpq compatibility policy across versions  (Pavel Golub <pavel@microolap.com>)
List pgsql-interfaces
Hi all,

We have a libpq client application written in C.

We want to deliver the software so that can it be used with different
PostgreSQL client versions, from 8.3 to 9.3 (and future versions).

So far, we build (compile and link) a binary with each major version
of PostgreSQL (8.3, 8.4, 9.0, 9.1, 9.2, 9.3) - in fact we have shared
libraries (database driver) for each PostgreSQL version.

Is this the proper way, or could we just compile/link with a given
version (9.3) and assume that it's backward compatible with any
prior version such as 8.3 ?

Assuming that we could dynamically load the libpq.so client, search
for existing API symbols and only use them if present?

Is this risky? Do the C headers define C structures that are compatible
between newer and older versions?

I would expect some note about libpq compatibility policy here:

http://www.postgresql.org/docs/9.3/static/libpq-build.html

I can see that the lib version number of libpq.so.x.y changes
for each major version:

/opt3/dbs/pgs/9.2/lib/libpq.so -> libpq.so.5.5
/opt3/dbs/pgs/9.2/lib/libpq.so.5 -> libpq.so.5.5
/opt3/dbs/pgs/9.2/lib/libpq.so.5.5
/opt3/dbs/pgs/9.3.0/lib/libpq.so -> libpq.so.5.6
/opt3/dbs/pgs/9.3.0/lib/libpq.so.5 -> libpq.so.5.6
/opt3/dbs/pgs/9.3.0/lib/libpq.so.5.6

The binaries are dependent from libpq.so.5:

$ ldd -r dbmpgs92x.so...libpq.so.5 => /opt3/dbs/pgs/9.2.3/lib/libpq.so.5 (0xb77bb000)...

What does this mean?

Theoritically, a binary linked in a 9.3 env can use le libpq.so version
of a prior version down to 8.2 ... (8.1 has libpq.so.4)

The main question is about C header compatibility:

- Compile + link with PostgreSQL client version X.Y.?
- What PostgreSQL client version can be used at runtime?

Thanks.
Seb



pgsql-interfaces by date:

Previous
From: Denis
Date:
Subject: Can not compile libpq version 9.3
Next
From: Joe
Date:
Subject: Re: Can not compile libpq version 9.3