libpq compatibility policy across versions

From: Sebastien FLAESCH <sf(at)4js(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: libpq compatibility policy across versions
Date: 2013-09-10 12:07:07
Message-ID: 522F0B6B.1040006@4js.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Joe 2013-09-10 13:13:23 Re: Can not compile libpq version 9.3
Previous Message Denis 2013-09-09 18:01:10 Can not compile libpq version 9.3