queriing the version of libpq

Lists: pgsql-generalpgsql-hackers
From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: queriing the version of libpq
Date: 2010-10-05 07:33:44
Message-ID: AANLkTi=q5iTGCjtMN1hv+O4bbCbeX-cWxr0Z2uyqkaUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

With 9.0 there is the new hex encoding for BYTEA, which is activated by
default.

libpq BEFORE 9.0 are not able to decode that encoding.

I am programming with Python, using psycopg2. When psycopg2 is linked with
libpq 9.0, everything works fine with hex-encoding; if psycopg2 is linked
with libpq < 9.0, decoding hex-encoded bytea fails (it stays hexencoded).

This happens because in default configuration psycopg2 calls the
libpq-decode-encoded-bytea function (which is the way it should be done).

Now I would love to have an additional check "is the used psycopg2 linked to
an advanced-enough libpq", to be able to set bytea_output to 'escape' if the
libpq is not worthy.

My question: Which way is available to query the linked libpq version?

My other option is to select 'something_that_gets_casted_to_bytea'::bytea,
and check the return value. BUT that requires a round-trip to the server....

Harald
--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-10-05 08:02:47
Message-ID: AANLkTi=cPLuPn=WDf7r9APz632Pf3qyM8BbEKt5sA0Pd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Oct 5, 2010 at 09:33, Massa, Harald Armin <chef(at)ghum(dot)de> wrote:
> With 9.0 there is the new hex encoding for BYTEA, which is activated by
> default.
> libpq BEFORE 9.0 are not able to decode that encoding.
> I am programming with Python, using psycopg2. When psycopg2 is linked with
> libpq 9.0, everything works fine with hex-encoding; if psycopg2 is linked
> with libpq < 9.0, decoding hex-encoded bytea fails (it stays hexencoded).
> This happens because in default configuration psycopg2 calls the
> libpq-decode-encoded-bytea function (which is the way it should be done).
> Now I would love to have an additional check "is the used psycopg2 linked to
> an advanced-enough libpq", to be able to set bytea_output to 'escape' if the
> libpq is not worthy.
> My question: Which way is available to query the linked libpq version?
> My other option is to select 'something_that_gets_casted_to_bytea'::bytea,
> and check the return value. BUT that requires a round-trip to the server....

You can try calling PQconninfoParse() on a connectino string that has
applicationname= in it. That will fail on anything pre-9.0. Assuming
there's a way to access that function through psycopg2.

But it does outline that fact that it wouldn't suck to have a function
in libpq returning the version so that application can check this at
runtime - clearly it would also be useful when being linked "through"
something like psycopg2.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: queriing the version of libpq
Date: 2010-10-05 14:32:11
Message-ID: f29d17cf5ceaf81fb3ae45f5151168a3@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

> My question: Which way is available to query the linked libpq version?

That's information your driver should be supplying. For example, in
Perl (DBD::Pg), you would say

if ($dbh->{pg_lib_version} >= 90000) {

I'd raise a bug with psycopg2 if it does not provide that information.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 201010051030
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyrNskACgkQvJuQZxSWSsiW7wCfYge62y175Xtsk4drGbnt7UU5
0R4Ani1gxDhNA0xdHoq+xxxROjuC4wh+
=n33y
-----END PGP SIGNATURE-----


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: queriing the version of libpq
Date: 2010-10-05 14:38:21
Message-ID: AANLkTim=tdZ5EP1BL_J=N_opzgBrZqejVk6OnfqY83BR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Oct 5, 2010 at 16:32, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>> My question: Which way is available to query the linked libpq version?
>
> That's information your driver should be supplying. For example, in
> Perl (DBD::Pg), you would say
>
> if ($dbh->{pg_lib_version} >= 90000) {
>
> I'd raise a bug with psycopg2 if it does not provide that information.

How does the driver figure it out?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 15:33:15
Message-ID: 2f4c4dd73daff9a8250254f63e70526f@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

>> if ($dbh->{pg_lib_version} >= 90000) {
>>
>> I'd raise a bug with psycopg2 if it does not provide that information.
>
> How does the driver figure it out?

DBD::Pg parses pg_config --version, then passes the information
to the C programs for directive fiddling. I certainly hope
other drivers are doing the same, as libpq varies across
major versions a good deal.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 201010051132
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyrRR8ACgkQvJuQZxSWSsgHmwCfaAPXXA1YCZ6OgOjyis6uKVmz
HvoAnj42290eDAGO+HDsGVZvOAqwEXeR
=P8XV
-----END PGP SIGNATURE-----


From: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 15:52:28
Message-ID: AANLkTinNsPfdJ+67cRQTvqrEEwGkEgH09T0A+ov86s_o@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On 5 October 2010 16:33, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
>
>>> if ($dbh->{pg_lib_version} >= 90000) {
>>>
>>> I'd raise a bug with psycopg2 if it does not provide that information.
>>
>> How does the driver figure it out?
>
> DBD::Pg parses pg_config --version, then passes the information
> to the C programs for directive fiddling. I certainly hope
> other drivers are doing the same, as libpq varies across
> major versions a good deal.

I would imagine that most libpq wrapping drivers use libpq's
PQserverVersion(), which returns an integer that looks like 90000.

--
Regards,
Peter Geoghegan


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 16:14:07
Message-ID: 0f0dc6d8694982a930e6412196effce0@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

> I would imagine that most libpq wrapping drivers use libpq's
> PQserverVersion(), which returns an integer that looks like 90000.

Yeah, I'm familiar with that (I wrote it :) but it's not useful
here for two reasons:

1) It's not available on older versions

2) It returns the *target* version, not the *compiled* version.
In other words, it requires an existing PGconn object.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201010051212
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyrTrsACgkQvJuQZxSWSsh+rACgkvzm7HFWO4X6jHy68M4lAr74
vSoAnRzG5F+pML4IQfQxCl64b3eiNbRm
=JL6x
-----END PGP SIGNATURE-----


From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 16:15:07
Message-ID: AANLkTik_o=pxq9oVUnZR9ZVYzwXJJ_v3LRyL+V8p_PO-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

>
> I would imagine that most libpq wrapping drivers use libpq's
> PQserverVersion(), which returns an integer that looks like 90000.
>
> exactly that is exposed as cn.server_version property of the psycopg2
connection object; but it does not help, as a 8.4libpq happily connects to a
9.0 server... for some values of happy :)

Harald

--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 16:41:23
Message-ID: 26161.1286296883@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com> writes:
> On 5 October 2010 16:33, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>>> How does the driver figure it out?
>>
>> DBD::Pg parses pg_config --version, then passes the information
>> to the C programs for directive fiddling. I certainly hope
>> other drivers are doing the same, as libpq varies across
>> major versions a good deal.

> I would imagine that most libpq wrapping drivers use libpq's
> PQserverVersion(), which returns an integer that looks like 90000.

The real problem is that neither of these can be trusted to tell you the
*library* version. PQserverVersion() is something else altogether,
and I wouldn't want to assume that pg_config exactly matches the library
you're linked to --- if it's even present at all.

We could add a PQlibpqVersion(), maybe, but it would be many years
before client code could rely on that being present.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 16:47:35
Message-ID: AANLkTi=JpmHkERWg8UwT8stHEwwTzPdvyY68iu+Tpn18@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Oct 5, 2010 at 18:41, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com> writes:
>> On 5 October 2010 16:33, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>>>> How does the driver figure it out?
>>>
>>> DBD::Pg parses pg_config --version, then passes the information
>>> to the C programs for directive fiddling. I certainly hope
>>> other drivers are doing the same, as libpq varies across
>>> major versions a good deal.
>
>> I would imagine that most libpq wrapping drivers use libpq's
>> PQserverVersion(), which returns an integer that looks like 90000.
>
> The real problem is that neither of these can be trusted to tell you the
> *library* version.  PQserverVersion() is something else altogether,
> and I wouldn't want to assume that pg_config exactly matches the library
> you're linked to --- if it's even present at all.
>
> We could add a PQlibpqVersion(), maybe, but it would be many years
> before client code could rely on that being present.

I think we should.

And in a small way they can already - if they check for it
dynamically, they'll know if it was 9.1 or newer at least :-) It'll be
a long time before it's *easy* to use though. But if we don't add it
now, it'll be even longer...

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: querying the version of libpq
Date: 2010-10-05 17:39:36
Message-ID: AANLkTikwde-gYqWq3WWdTXUYAfUVvf6RKhy=mVTBr1Lg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

>
>
> > We could add a PQlibpqVersion(), maybe, but it would be many years
> > before client code could rely on that being present.
>
> I think we should.
>
> And in a small way they can already - if they check for it
> dynamically, they'll know if it was 9.1 or newer at least :-) It'll be
> a long time before it's *easy* to use though. But if we don't add it
> now, it'll be even longer...

and an additional argument: Isn't it a wise decision for clients, to allways
use the newset libpq, independent of the server? As younger libpqs happily
connect to older servers AND are supposed to have less bugs.

As libpq is very small, can be statically linked into applications and there
are no license troubles, I can see no argument to use something that is not
brand new... (compared to other databases with 120megabyte clients with
longer licence restrictions than documentations...)

Or am I missing sth?

Harald

--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 20:39:41
Message-ID: e9848cc536fedfb3672aa4b5d9ff235a@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

> The real problem is that neither of these can be trusted to tell you the
> *library* version. PQserverVersion() is something else altogether,
> and I wouldn't want to assume that pg_config exactly matches the library
> you're linked to --- if it's even present at all.

Er...yes it will match exact...because we[1] get the location of the
library files from pg_config as well. :) Handy little utility that.

[1] DBD::Pg

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201010051638
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyrjPUACgkQvJuQZxSWSsiONwCfb8t30qkOBSKmMYDz2qL0mXIp
Xp4AoM2pQIQzUOSx4r8ZPdzNp/lA2Ar3
=1Ano
-----END PGP SIGNATURE-----


From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 20:41:49
Message-ID: AANLkTinYeZd2CgRsxgdbi+aWHst5_ydXxQh-SrE8x+du@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Hey all,

Could you call it as PQlibVersion() or even PQversion() instead of
PQlibpqVersion() ?

2010/10/5 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com> writes:
> > On 5 October 2010 16:33, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
> >>> How does the driver figure it out?
> >>
> >> DBD::Pg parses pg_config --version, then passes the information
> >> to the C programs for directive fiddling. I certainly hope
> >> other drivers are doing the same, as libpq varies across
> >> major versions a good deal.
>
> > I would imagine that most libpq wrapping drivers use libpq's
> > PQserverVersion(), which returns an integer that looks like 90000.
>
> The real problem is that neither of these can be trusted to tell you the
> *library* version. PQserverVersion() is something else altogether,
> and I wouldn't want to assume that pg_config exactly matches the library
> you're linked to --- if it's even present at all.
>
> We could add a PQlibpqVersion(), maybe, but it would be many years
> before client code could rely on that being present.
>
> regards, tom lane
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
// Dmitriy.


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 20:44:48
Message-ID: AANLkTim-xsim6CVVxsS5kvWa3kffF1UTx0=tvc3P=ROF@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Oct 5, 2010 at 22:39, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>
>
>> The real problem is that neither of these can be trusted to tell you the
>> *library* version.  PQserverVersion() is something else altogether,
>> and I wouldn't want to assume that pg_config exactly matches the library
>> you're linked to --- if it's even present at all.
>
> Er...yes it will match exact...because we[1] get the location of the
> library files from pg_config as well. :) Handy little utility that.

How do you get pg_config to tell you which of the multiple versions of
libpq that may be installed on the machine you are actually linking
against?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 20:53:03
Message-ID: dee2643d13434a7545004592d37b2023@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

>> Er...yes it will match exact...because we[1] get the location of the
>> library files from pg_config as well. :) Handy little utility that.
>
> How do you get pg_config to tell you which of the multiple versions of
> libpq that may be installed on the machine you are actually linking
> against?

Not sure what you mean. pg_config *drives* the compilation and linking,
we don't blindly compile and simply take pg_config's word for it.
pg_config --libdir and pg_config --includedir.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201010051651
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyrkB0ACgkQvJuQZxSWSsh4OACglNyrdKgf1jk5op7yzBw1Mh4M
sFUAnjiWVUDjNmJbNRnsuumZxzZvxQCT
=ig1E
-----END PGP SIGNATURE-----


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 21:00:20
Message-ID: 1013.1286312420@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

"Greg Sabino Mullane" <greg(at)turnstep(dot)com> writes:
>> The real problem is that neither of these can be trusted to tell you the
>> *library* version. PQserverVersion() is something else altogether,
>> and I wouldn't want to assume that pg_config exactly matches the library
>> you're linked to --- if it's even present at all.

> Er...yes it will match exact...because we[1] get the location of the
> library files from pg_config as well. :) Handy little utility that.

[ shrug... ] It's not at all hard to think of scenarios where that will
give you misleading results, even granted that you're willing to fall
over when pg_config isn't present. But regardless of that, the
technique simply isn't available to ordinary C code using the standard
dynamic linker.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-05 21:10:33
Message-ID: AANLkTimnTUr17LBb4QOmsr3MaFMZRpxcBvGFDwyy4Yk7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Oct 5, 2010 at 22:53, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>
>>> Er...yes it will match exact...because we[1] get the location of the
>>> library files from pg_config as well. :) Handy little utility that.
>>
>> How do you get pg_config to tell you which of the multiple versions of
>> libpq that may be installed on the machine you are actually linking
>> against?
>
> Not sure what you mean. pg_config *drives* the compilation and linking,
> we don't blindly compile and simply take pg_config's word for it.
> pg_config --libdir and pg_config --includedir.

But that's build-time, not run-time.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-06 12:17:02
Message-ID: 342b83b76a4b52f688460b61bd606e8e@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

> Not sure what you mean. pg_config *drives* the compilation and linking,
> we don't blindly compile and simply take pg_config's word for it.
> pg_config --libdir and pg_config --includedir.

> But that's build-time, not run-time.

Correct, not sure of your point. Is this a problem? Build-time is
what we want here (determining the libpq we were built with)

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201010060816
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkysaKQACgkQvJuQZxSWSsg0uACg78/o1brlOO4RtNi6U+O6noAG
PCYAn1dgpW8A/+BIOjNkhXygc16tyB3R
=YN9u
-----END PGP SIGNATURE-----


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-06 12:25:21
Message-ID: AANLkTinc7zQCC-i9cML1H9UYzym10zt1gEjizn54sZ+6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Wed, Oct 6, 2010 at 14:17, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>
>
>> Not sure what you mean. pg_config *drives* the compilation and linking,
>> we don't blindly compile and simply take pg_config's word for it.
>> pg_config --libdir and pg_config --includedir.
>
>> But that's build-time, not run-time.
>
> Correct, not sure of your point. Is this a problem? Build-time is
> what we want here (determining the libpq we were built with)

The original question was how to find this out from python, which
means at runtime.

And the pg_lib_version of DBD::Pg clearly doesn't tell you what
version of libpq it's using, only what it was built against.

As long as you have libpq 9.0, you can decode the bytea hex thingy,
irregardless of what version of libpq your <whatever other
code/library> was linked against.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-06 13:54:22
Message-ID: 15727.1286373262@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Wed, Oct 6, 2010 at 14:17, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>>> But that's build-time, not run-time.
>>
>> Correct, not sure of your point. Is this a problem? Build-time is
>> what we want here (determining the libpq we were built with)

> The original question was how to find this out from python, which
> means at runtime.

> And the pg_lib_version of DBD::Pg clearly doesn't tell you what
> version of libpq it's using, only what it was built against.

> As long as you have libpq 9.0, you can decode the bytea hex thingy,
> irregardless of what version of libpq your <whatever other
> code/library> was linked against.

The problem here is that you might actually be *running* with a
different version of libpq than you built against. This is actually
highly likely if you distribute an executable that dynamically links
to a shared library at runtime. And the dynamic linker will take any
version of libpq.so that has the same major number, meaning that you
cannot assume that it's not 8.4 just because you built against 9.0.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-06 14:05:35
Message-ID: AANLkTi=o_2SukguiuUoRw0gPOQFdgVCP5srXhSjkzoyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Wed, Oct 6, 2010 at 15:54, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Wed, Oct 6, 2010 at 14:17, Greg Sabino Mullane <greg(at)turnstep(dot)com> wrote:
>>>> But that's build-time, not run-time.
>>>
>>> Correct, not sure of your point. Is this a problem? Build-time is
>>> what we want here (determining the libpq we were built with)
>
>> The original question was how to find this out from python, which
>> means at runtime.
>
>> And the pg_lib_version of DBD::Pg clearly doesn't tell you what
>> version of libpq it's using, only what it was built against.
>
>> As long as you have libpq 9.0, you can decode the bytea hex thingy,
>> irregardless of what version of libpq your <whatever other
>> code/library> was linked against.
>
> The problem here is that you might actually be *running* with a
> different version of libpq than you built against.  This is actually
> highly likely if you distribute an executable that dynamically links
> to a shared library at runtime.  And the dynamic linker will take any
> version of libpq.so that has the same major number, meaning that you
> cannot assume that it's not 8.4 just because you built against 9.0.

Uh, that's what I was saying. The build version is quite irrelevant for that.

Not to mention when you're on windows (and I dunno if any other
platforms are like *that*), where they're all libpq.dll and we'll
happily take *any* other libpq.dll (even an older one, but that will
give you an error if you're actually using any functions not present
in it).

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-10-07 09:23:10
Message-ID: 1286443390.25221.4.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On tis, 2010-10-05 at 09:33 +0200, Massa, Harald Armin wrote:
> Now I would love to have an additional check "is the used psycopg2
> linked to an advanced-enough libpq", to be able to set bytea_output to
> 'escape' if the libpq is not worthy.

This is really something that psycopg2 should work out for you. I
suggest you take up a discussion on this on their mailing list.


From: Devrim GÜNDÜZ <devrim(at)gunduz(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-10-07 09:34:55
Message-ID: 1286444095.2426.18.camel@hp-laptop02.gunduz.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Thu, 2010-10-07 at 12:23 +0300, Peter Eisentraut wrote:
> This is really something that psycopg2 should work out for you. I
> suggest you take up a discussion on this on their mailing list.

...which is down over the last 3 weeks or so:

http://www.initd.org/

--
Devrim GÜNDÜZ
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
PostgreSQL RPM Repository: http://yum.pgrpms.org
Community: devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org Twitter: http://twitter.com/devrimgunduz


From: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-10-07 15:07:33
Message-ID: F694F3B3-BAD2-49A4-8D60-C13115F37903@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


On Oct 7, 2010, at 5:34 AM, Devrim GÜNDÜZ wrote:

> On Thu, 2010-10-07 at 12:23 +0300, Peter Eisentraut wrote:
>> This is really something that psycopg2 should work out for you. I
>> suggest you take up a discussion on this on their mailing list.
>
> ...which is down over the last 3 weeks or so:
>
> http://www.initd.org/

In addition, I posted a patch for 9.0 support which was supposed to be rolled in to psycopg2 weeks ago. Now I am stuck pushing my own psycopg2 egg around. The psycopg2 project is too reliant on one person (who has trouble managing his servers)- I wish he would move the project to a public project management service.

I also remember a discussion on the poor state of postgresql drivers for python and which driver the PostgreSQL project should endorse- it looks like the situation has not improved. Here's the thread: http://archives.postgresql.org/pgsql-hackers/2010-02/msg00351.php

Cheers,
M


From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-14 10:02:13
Message-ID: AANLkTinAmypvGZNcg+cPhrfr4eYeGEQ9SajQ6J0c0e91@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

>
> And the dynamic linker will take any version of libpq.so that has the same
> major number, meaning that you
> cannot assume that it's not 8.4 just because you built against 9.0.
>
> [...]

> Not to mention when you're on windows (and I dunno if any other
> platforms are like *that*), where they're all libpq.dll and we'll
> happily take *any* other libpq.dll (even an older one, but that will give
> you an error if you're actually using any functions not present in it).
>
> So there are quite many arguments for adding a

PQlibpqVersion()

to libpq, yeah? Do you think you will do it, Magnus?

[updates: the other "got bitten by the BYTEA-encoding-change"-thread is
connected to this....]

Best wishes,

Harald

--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Sabino Mullane <greg(at)turnstep(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-14 12:00:41
Message-ID: AANLkTi=6NXMtckxXKeqmFegN7cZ-CcBtp_qDPxiyFyA-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Hey Massa,

Again, I suggest PQlibVersion() or PQversion() instead of PQlibpqVersion().

Why this "pq" redundancy in name? Waste of bytes.

2010/10/14 Massa, Harald Armin <chef(at)ghum(dot)de>

> And the dynamic linker will take any version of libpq.so that has the same
>> major number, meaning that you
>> cannot assume that it's not 8.4 just because you built against 9.0.
>>
>> [...]
>
>> Not to mention when you're on windows (and I dunno if any other
>> platforms are like *that*), where they're all libpq.dll and we'll
>> happily take *any* other libpq.dll (even an older one, but that will give
>> you an error if you're actually using any functions not present in it).
>>
>> So there are quite many arguments for adding a
>
> PQlibpqVersion()
>
> to libpq, yeah? Do you think you will do it, Magnus?
>
> [updates: the other "got bitten by the BYTEA-encoding-change"-thread is
> connected to this....]
>
> Best wishes,
>
> Harald
>
> --
> GHUM GmbH
> Harald Armin Massa
> Spielberger Straße 49
> 70435 Stuttgart
> 0173/9409607
>
> Amtsgericht Stuttgart, HRB 734971
> -
> persuadere.
> et programmare
>

--
// Dmitriy.


From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-14 12:08:56
Message-ID: AANLkTiks2FL37fwsToZ-qYj4BAiWG_NnOo5NBmHpjUPj@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Dmitriy,

>
> Again, I suggest PQlibVersion() or PQversion() instead of PQlibpqVersion().
>
> Why this "pq" redundancy in name? Waste of bytes.
>
> the first PQ qualifies the name-space "those are PostgresQl functions".
the library is called libpq, and we are explicitly asking for the version of
libpq; not of any other library that may or may not be connected with libpq

(in some compilations there is linkage to some system libraries, which have
versions of their own. in other implementations there are wrappers around
the libpq-libraray, which have their own version to. Oh, and there is
open-ssl which may be mixed into the whole party)

So 2 bytes of source-code / linker redundancy in times where smartphones
sport 12Gigabyte should be payed....

Harald
--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: querying the version of libpq
Date: 2010-10-14 12:14:04
Message-ID: AANLkTikA9e7_JWszj8Y6g580e6RGnPCi97RVUhHvW0wD@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

2010/10/14 Massa, Harald Armin <chef(at)ghum(dot)de>

> Dmitriy,
>
>>
>> Again, I suggest PQlibVersion() or PQversion() instead of
>> PQlibpqVersion().
>>
>> Why this "pq" redundancy in name? Waste of bytes.
>>
>> the first PQ qualifies the name-space "those are PostgresQl functions".
> the library is called libpq, and we are explicitly asking for the version
> of libpq; not of any other library that may or may not be connected with
> libpq
>
If "PQ" is "namespace", so PQlibVersion() will never conflict with other
libraries.

>
> (in some compilations there is linkage to some system libraries, which have
> versions of their own. in other implementations there are wrappers around
> the libpq-libraray, which have their own version to. Oh, and there is
> open-ssl which may be mixed into the whole party)
>
> So 2 bytes of source-code / linker redundancy in times where smartphones
> sport 12Gigabyte should be payed....
>
> I don't worry about source-code or linker. I want correctness.
Why libpq does not have PQlibpqConnect() ? How about other libraries linked
to libpq ?
Waste of bytes.

Harald
> --
> GHUM GmbH
> Harald Armin Massa
> Spielberger Straße 49
> 70435 Stuttgart
> 0173/9409607
>
> Amtsgericht Stuttgart, HRB 734971
> -
> persuadere.
> et programmare
>

--
// Dmitriy.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-10-20 23:26:39
Message-ID: 201010202326.o9KNQdi19420@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

A.M. wrote:
>
> On Oct 7, 2010, at 5:34 AM, Devrim G?ND?Z wrote:
>
> > On Thu, 2010-10-07 at 12:23 +0300, Peter Eisentraut wrote:
> >> This is really something that psycopg2 should work out for you. I
> >> suggest you take up a discussion on this on their mailing list.
> >
> > ...which is down over the last 3 weeks or so:
> >
> > http://www.initd.org/
>
> In addition, I posted a patch for 9.0 support which was supposed to be
> rolled in to psycopg2 weeks ago. Now I am stuck pushing my own psycopg2
> egg around. The psycopg2 project is too reliant on one person (who has
> trouble managing his servers)- I wish he would move the project to a
> public project management service.
>
> I also remember a discussion on the poor state of postgresql drivers
> for python and which driver the PostgreSQL project should endorse- it
> looks like the situation has not improved. Here's the thread:
> http://archives.postgresql.org/pgsql-hackers/2010-02/msg00351.php

The python driver situation did improve, for a while. :-|

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: "Massa, Harald Armin" <chef(at)ghum(dot)de>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: queriing the version of libpq
Date: 2010-12-14 16:56:15
Message-ID: AANLkTimKHBifr+9a3Nj5A0vbF01oUVfiUxAPPE8U01m_@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

>> My question: Which way is available to query the linked libpq version?

> But it does outline that fact that it wouldn't suck to have a >function in libpq returning the version so that application can >check this at runtime - clearly it would also be useful when >being linked "through" something like psycopg2.

did there something happen?

happen as in "an addition of a function to libpq to query its version
without a server roundtrip AFTER libpq has been linked into sth has
been decided for / against"

Harald

--
GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971
-
persuadere.
et programmare


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 15:56:32
Message-ID: AANLkTinf_2G3V5cvfx2o1VNDYtvr0u_ntf7c7RH0Gufq@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Tue, Dec 14, 2010 at 17:56, Massa, Harald Armin <chef(at)ghum(dot)de> wrote:
>>> My question: Which way is available to query the linked libpq version?
>
>> But it does outline that fact that it wouldn't suck to have a >function  in libpq returning the version so that application can >check this at  runtime - clearly it would also be useful when >being linked "through" something like psycopg2.
>
> did there something happen?

Stuck in a local git branch. I've rebased on current and added docs,
see attachment.

(moving to hackers as well)

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
pqlibversion.patch text/x-patch 3.3 KB

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 16:00:39
Message-ID: AANLkTi=my1ecYcAFb8-uPDEw9+piJaSRseJejx+on5Mm@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Magnus, thats great ! And name PQlibVersion is correct ! Thanks.

2010/12/16 Magnus Hagander <magnus(at)hagander(dot)net>

> On Tue, Dec 14, 2010 at 17:56, Massa, Harald Armin <chef(at)ghum(dot)de> wrote:
> >>> My question: Which way is available to query the linked libpq version?
> >
> >> But it does outline that fact that it wouldn't suck to have a >function
> in libpq returning the version so that application can >check this at
> runtime - clearly it would also be useful when >being linked "through"
> something like psycopg2.
> >
> > did there something happen?
>
> Stuck in a local git branch. I've rebased on current and added docs,
> see attachment.
>
> (moving to hackers as well)
>
> --
> Magnus Hagander
> Me: http://www.hagander.net/
> Work: http://www.redpill-linpro.com/
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

--
// Dmitriy.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 16:07:56
Message-ID: 22010.1292515676@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> But it does outline that fact that it wouldn't suck to have a >function in libpq returning the version so that application can >check this at runtime - clearly it would also be useful when >being linked "through" something like psycopg2.

> Stuck in a local git branch. I've rebased on current and added docs,
> see attachment.

Ick. Please get rid of that extra version number. There is no reason
not to use PG_VERSION_NUM. The documentation needs further thought too:
grammar needs work, and the format of the result value is unspecified.

But perhaps we should first recheck the premise. Exactly how will this
function be useful? I don't believe it's usable in the form implied by
the documentation, namely

if (PQlibVersion() >= something)
... call PQspiffyNewFunction() ...
else
... do something else ...

because if you're trying to link against an older libpq, the link will
fail before you ever get to execute. So let's have a less implausible
use-case please.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 16:12:13
Message-ID: AANLkTinep-oeG-ct9v2Zg+OMsKY04CrdOt9qvLH72qPY@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Thu, Dec 16, 2010 at 17:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> But it does outline that fact that it wouldn't suck to have a >function  in libpq returning the version so that application can >check this at  runtime - clearly it would also be useful when >being linked "through" something like psycopg2.
>
>> Stuck in a local git branch. I've rebased on current and added docs,
>> see attachment.
>
> Ick.  Please get rid of that extra version number.  There is no reason
> not to use PG_VERSION_NUM.  The documentation needs further thought too:
> grammar needs work, and the format of the result value is unspecified.

Gah. i was thinking "need to avoid pulling in pg_config.h since it's
exposed to clients".. But that's only the header. D'uh. Will fix.

> But perhaps we should first recheck the premise.  Exactly how will this
> function be useful?  I don't believe it's usable in the form implied by
> the documentation, namely
>
>        if (PQlibVersion() >= something)
>                ... call PQspiffyNewFunction() ...
>        else
>                ... do something else ...
>
> because if you're trying to link against an older libpq, the link will
> fail before you ever get to execute.  So let's have a less implausible
> use-case please.

Look back at the very start of the thread.

Detecting behavior changes (in this case with bytea encoding).

The other one would be if there are options to a call that can be
different. For example, knowing which options you can pass to
PQconnect() without getting an error. (Yes, you can manually call
PQconninfoParse() and check it out, but that's a lot uglier IMO).

And it *could* be used in exactly the case you're outlining as long as
you load the function dynamically. Which could most definitely be
useful for a *driver* to be able to do - and I'm sure some programs as
well.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 16:13:37
Message-ID: 22128.1292516017@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Thu, Dec 16, 2010 at 17:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> because if you're trying to link against an older libpq, the link will
>> fail before you ever get to execute. So let's have a less implausible
>> use-case please.

> Look back at the very start of the thread.

OK, but let's document those examples instead.

regards, tom lane


From: Andrew Chernow <ac(at)esilo(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-16 16:22:53
Message-ID: 4D0A3CDD.4070302@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers


>
> And it *could* be used in exactly the case you're outlining as long as
> you load the function dynamically.

Detecting the presence of a function does not require a version number.
If the symbol is in the library, use it.

The only reason the version number would come into play is if you were
attempting to detect behavior differences.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-20 15:48:21
Message-ID: AANLkTi==9HMtVK3e6voH0-wzHxnbUqW33yyGK2SWymv-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Thu, Dec 16, 2010 at 17:13, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> On Thu, Dec 16, 2010 at 17:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> because if you're trying to link against an older libpq, the link will
>>> fail before you ever get to execute.  So let's have a less implausible
>>> use-case please.
>
>> Look back at the very start of the thread.
>
> OK, but let's document those examples instead.

Something like this better?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
libpq_version.diff text/x-patch 3.1 KB

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Massa, Harald Armin" <chef(at)ghum(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] queriing the version of libpq
Date: 2010-12-22 13:26:26
Message-ID: AANLkTi=3nE+=ELMJpOOSChdKPDaCfdCR3LD3=y_nAcEB@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Mon, Dec 20, 2010 at 16:48, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Thu, Dec 16, 2010 at 17:13, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> On Thu, Dec 16, 2010 at 17:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>>> because if you're trying to link against an older libpq, the link will
>>>> fail before you ever get to execute.  So let's have a less implausible
>>>> use-case please.
>>
>>> Look back at the very start of the thread.
>>
>> OK, but let's document those examples instead.
>
> Something like this better?

I got some help from Bruce to look over the grammar in the docs (and
fix the broken ones), and have now applied and pushed this.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: crbenesch <chris(at)beneschtech(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: queriing the version of libpq
Date: 2018-06-10 19:53:02
Message-ID: 1528660382160-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

#include <pg_config.h>

/usr/include/pg_config-x86_64.h:#define PG_VERSION "9.6.9"
/usr/include/pg_config-x86_64.h:#define PG_VERSION_NUM 90609
/usr/include/pg_config-x86_64.h:#define PG_VERSION_STR "PostgreSQL 9.6.9 on
x86_64-redhat-linux-gnu, compiled by gcc (GCC) 7.3.1 20180303 (Red Hat
7.3.1-5), 64-bit"

I also have source for 8.4 and its there too.

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html