On 22.09.2011 13:51, MUHAMMAD ASIF wrote:
> You are right, _xpg_ socket functionality is not available in older systems, it is available in hp-ux 11.23 version
throughpatch HCO_35744 . HPUX 10.20 is very old machine (1996). I am using latest HPUX B.11.31 machine, I don't have
accessto older systems. -D_XOPEN_SOURCE_EXTENDED make the postgres build X/Open Socket enabled including connector's
i.elibpq. Now if system default 64bit perl (BSD Socket) try to use libpq (X/Open Socket) it will end up in unexpected
resultsor errors . HP-UX don't allow mixing of X/Open Socket objects and BSD Socket objects in the same 64bit binary,
HPtried to fix this issue through -D_HPUX_ALT_XOPEN_SOCKET_API on later version of OS. It seems nice that if postgres
adoptthis fix at least for connectors (PFA patch, minor change in src/interfaces/libpq/Makefile) and so that users on
laterhp-ux boxes don't trouble with these socket issues and connect their applications to database server with the
helpof libpq without the fear of X/Open So
cket or BSD Socket complexity. On older system defining _HPUX_ALT_XOPEN_SOCKET_API should do no effects or issues.
You're right that defining _HPUX_ALT_XOPEN_SOCKET_API should have no
effect on older systems that don't have that. But removing -lxnet and
-D_XOPEN_SOURCE_EXTENDED *is* clearly going to cause problems on older
systems.
According to
http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/xopen_networking.7.html,
-D_XOPEN_SOURCE_EXTENDED should still be defined, even if you use
-D_HPUX_ALT_XOPEN_SOCKET_API. So removing that was bogus. But -lxnet
should indeed not be used with _HPUX_ALT_XOPEN_SOCKET_API, so I think we
need a configure test to see whether that option is available, and use
it only if it is.
Looking at the headers, it seems pretty hard to detect whether
_HPUX_ALT_XOPEN_SOCKET_API is available. The best I can think of is to
check whether the _xpg_* functions exist. That's a bit ugly because a
program is not supposed to call those functions directly, but it should
work fine in practice, so attached is a patch to do that.
I did some experiments on my HP-UX box ("HP-UX guest2 B.11.31 U ia64
HP-UX", according to uname -a). I built a small test program that uses
libpq, and also calls socket() and getsockopt() on an unrelated socket.
I also tested a little perl function in the database, that calls
getsockopt(). Without this patch, the perl function fails, and the test
program fails unless compiled with "-lxnet -D_XOPEN_SOURCE_EXTENDED"
(ie. unless it uses X/Open sockets). With the patch, the perl function
works, and the test program works, whether it's compiled with X/Open or not.
In the patch, I had to move the logic into configure.in, because the
autoconf AC_* macros can't be used in the template, which is a plain
shell script.
Unforunately I don't have access to any older HP-UX boxes that don't
have _HPUX_ALT_XOPEN_SOCKET_API. Tom, can you test this on that old
HP-UX box of yours?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com