Thread: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

[Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Simon Riggs
Date:
FW

-------- Forwarded Message --------
From: H.Merijn Brand <h.m.brand@xs4all.nl>
To: DBI Developers Mailing List <dbi-dev@perl.org>, Simon Riggs
<simon@2ndquadrant.com>
Subject: DBD::Pg on HP-UX 11.31 64bit
Date: Tue, 14 Dec 2010 13:35:49 +0100

I have postgres running on most my HP-UX varieties, ranging from HP-UX
10.20/32bit through 11.31/64bit. It works fine everywhere, except on
HP-UX 11.31-ipf in 64bit mode. Note that this is Itanium architecture.

postgres' own test suite passes, but all connects fail with DBD::Pg.
The compiled psql works fine. Same for 8.4.5 and 9.0.1. I'm working
with 8.4.5 now to make it as stable as possible to compare to my other
architectures.

Everything is a success when I use the same perl built in 32bit mode

I've run truss (HP-UX' version of trace, and narrowed the fail part to
141 lines by being as explicit as possible (e.g setting PGHOST to an IP
address to prevent calls to the resolver). Or to 56 lines for the
version ran with gcc compiled perl5.12.

I now need guidance or help to nail down where things actually cause
these failures.

Here are two traces. The first for perl-5.10.1 compiled with HP's
C-ANSI-C, the second for perl-5.12.2 compiled with gcc-4.2.4

This is perl, v5.10.1 (*) built for IA64.ARCHREV_0-LP64

open ("/pro/pgsql/lib/libpq.so.5", O_RDONLY|0x800, 0)                                      = 3
fstat (3, 0x9fffffffffffdd70)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd3d0)                                           = 0
open ("/usr/lib/hpux64/dpd/libpq.so.5.bpd", O_RDONLY|0x800, 0)                             ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 428816, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                       = 0xc000000009d28000
mmap (NULL, 9860, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 458752)                  = 0x9fffffffbf764000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf76c000
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
open ("/pro/local/lib/libcrypto.so", O_RDONLY|0x800, 0)                                    ERR#2 ENOENT
open ("/usr/local/ssl/lib/libcrypto.so", O_RDONLY|0x800, 0)                                = 3
fstat (3, 0x9fffffffffffdd20)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd380)                                           = 0
open ("/usr/lib/hpux64/dpd/libcrypto.so.bpd", O_RDONLY|0x800, 0)                           ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 3530960, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                      = 0xc000000006fe8000
mmap (NULL, 11552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_SHLIB, -1, 0)       = 0x9fffffffbf760000
mmap (0x9fffffffbf731000, 191296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 3538944) = 0x9fffffffbf731000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 32768, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)       = 0x9fffffffbf728000
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
open ("/pro/local/lib/libssl.so", O_RDONLY|0x800, 0)                                       ERR#2 ENOENT
open ("/usr/local/ssl/lib/libssl.so", O_RDONLY|0x800, 0)                                   = 3
fstat (3, 0x9fffffffffffdd20)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd380)                                           = 0
open ("/usr/lib/hpux64/dpd/libssl.so.bpd", O_RDONLY|0x800, 0)                              ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 659104, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                       = 0xc000000008bc0000
mmap (NULL, 29584, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 720896)                 = 0x9fffffffbf720000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf71e000
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf71c000
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf71a000
brk (0x6000000000940000)                                                                   = 0
getpid ()                                                                                  = 28317 (28316)
getpid ()                                                                                  = 28317 (28316)
getuid ()                                                                                  = 203 (203)
open ("/var/spool/pwgr/status", O_RDONLY|0x800, 0)                                         = 3
mmap (NULL, 532, PROT_READ, MAP_SHARED|MAP_VARIABLE|MAP_FILE|MAP_ADDR32, 3, 0)             = 0xc0001000
close (3)                                                                                  = 0
socket (AF_UNIX, SOCK_DGRAM, 0)                                                            = 3
getpid ()                                                                                  = 28317 (28316)
unlink ("/var/spool/sockets/pwgr/client28317")                                             ERR#2 ENOENT
bind (3, 0x9fffffffbf7b1510, 38)                                                           ERR#2 ENOENT
munmap (0xc0001000, 532)                                                                   = 0
close (3)                                                                                  = 0
open ("/etc/nsswitch.conf", O_RDONLY|0x800, 0666)                                          = 3
ioctl (3, TCGETA, 0x9fffffffffffcee0)                                                      ERR#25 ENOTTY
read (3, "230a23202f6574632f6e | # # /etc/n".., 8192)                                      = 500
read (3, 0x600000000093a218, 8192)                                                         = 0
close (3)                                                                                  = 0
open ("/usr/lib/hpux64/libnss_files.so.1", O_RDONLY|0x800, 0)                              = 3
fstat (3, 0x9fffffffffffc950)                                                              = 0
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffbf10)                                           = 0
open ("/usr/lib/hpux64/dpd/libnss_files.so.1.bpd", O_RDONLY|0x800, 0)                      ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 85872, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                        = 0xc0000000001e0000
mmap (NULL, 3159, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 131072)                  = 0x9fffffffbf767000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
open ("/etc/passwd", O_RDONLY|0x800, 0666)                                                 = 3
ioctl (3, TCGETA, 0x9fffffffffffcf10)                                                      ERR#25 ENOTTY
read (3, "726f6f743a3250465250 | root:2PFRP".., 8192)                                      = 1495
lseek (3, 18446744073709551032, SEEK_CUR)                                                  = 911
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
open ("/var/spool/pwgr/status", O_RDONLY|0x800, 0)                                         = 3
mmap (NULL, 532, PROT_READ, MAP_SHARED|MAP_VARIABLE|MAP_FILE|MAP_ADDR32, 3, 0)             = 0xc0001000
close (3)                                                                                  = 0
socket (AF_UNIX, SOCK_DGRAM, 0)                                                            = 3
getpid ()                                                                                  = 28317 (28316)
unlink ("/var/spool/sockets/pwgr/client28317")                                             ERR#2 ENOENT
bind (3, 0x9fffffffbf7b1510, 38)                                                           ERR#2 ENOENT
munmap (0xc0001000, 532)                                                                   = 0
close (3)                                                                                  = 0
open ("/etc/passwd", O_RDONLY|0x800, 0666)                                                 = 3
ioctl (3, TCGETA, 0x9fffffffffffc540)                                                      ERR#25 ENOTTY
read (3, "726f6f743a3250465250 | root:2PFRP".., 8192)                                      = 1495
lseek (3, 18446744073709551032, SEEK_CUR)                                                  = 911
close (3)                                                                                  = 0
stat ("/u/usr/merijn/.pgpass", 0x9fffffffffffd2c0)                                         ERR#2 ENOENT
socket (AF_INET, SOCK_STREAM, 0)                                                           = 3
setsockopt (3, 0x6, TCP_NODELAY, 0x9fffffffffffd9b0, 4)                                    = 0
fcntl (3, F_SETFL, 65536)                                                                  = 0
fcntl (3, F_SETFD, 1)                                                                      = 0
connect (3, 0x6000000000849290, 16)                                                        ERR#245 EINPROGRESS
poll (0x9fffffffffffdb90, 1, -1)                                                           = 1
getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb84, 0x9fffffffffffdb98)               ERR#22 EINVAL
getpid ()                                                                                  = 28317 (28316)
pstat (PSTAT_PROC, 0x9fffffffffffca10, 720, 0, 28317)                                      = 1
getpid ()                                                                                  = 28317 (28316)
pstat (PSTAT_PROC, 0x9fffffffffffca10, 720, 0, 28317)                                      = 1
open ("/usr/share/locale/C/LC_MESSAGES/strerror.cat", O_RDONLY|0x800, 02415)               ERR#2 ENOENT
open ("/usr/lib/nls/msg/C/strerror.cat", O_RDONLY|0x800, 02415)                            = 4
fstat (4, 0x9fffffffffffce30)                                                              = 0
fcntl (4, F_SETFD, 1)                                                                      = 0
lseek (4, 0, SEEK_SET)                                                                     = 0
read (4, "6d736763617430310000 | msgcat01  ".., 1212)                                      = 1212
lseek (4, 3383, SEEK_SET)                                                                  = 3383
read (4, "496e76616c6964206172 | Invalid ar".., 16)                                        = 16
close (4)                                                                                  = 0
close (3)                                                                                  = 0
sigsetstatemask (0x17, NULL, -6917529027641091920)                                         = 0
sigsetstatemask (0x17, NULL, -6917529027641091920)                                         = 0
sigsetstatemask (0x17, NULL, -6917529027641091920)                                         = 0
getpid ()                                                                                  = 28317 (28316)
pstat (PSTAT_PROC, 0x9fffffffffffd310, 720, 0, 28317)                                      = 1
getpid ()                                                                                  = 28317 (28316)
pstat (PSTAT_PROC, 0x9fffffffffffd310, 720, 0, 28317)                                      = 1
open ("/usr/share/locale/C/LC_MESSAGES/strerror.cat", O_RDONLY|0x800, 02415)               ERR#2 ENOENT
open ("/usr/lib/nls/msg/C/strerror.cat", O_RDONLY|0x800, 02415)                            = 3
fstat (3, 0x9fffffffffffd730)                                                              = 0
fcntl (3, F_SETFD, 1)                                                                      = 0
lseek (3, 0, SEEK_SET)                                                                     = 0
read (3, "6d736763617430310000 | msgcat01  ".., 1212)                                      = 1212
lseek (3, 3383, SEEK_SET)                                                                  = 3383
read (3, "496e76616c6964206172 | Invalid ar".., 16)                                        = 16
close (3)                                                                                  = 0
DBI connect ('','',...) failed: could not get socket error status: Invalid argument at
/pro/lib/perl5/site_perl/5.10.1/IA64.ARCHREV_0-LP64/PROCURA/DBD.pmline 339 
write (2, "44424920636f6e6e6563 | DBI connec".., 162)                                      = 162

This is perl 5, version 12, subversion 2 (v5.12.2) built for IA64.ARCHREV_0-LP64-ld

open ("/pro/pgsql/lib/libpq.so.5", O_RDONLY|0x800, 0)                                      = 3
fstat (3, 0x9fffffffffffdd80)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd3e0)                                           = 0
open ("/usr/lib/hpux64/dpd/libpq.so.5.bpd", O_RDONLY|0x800, 0)                             ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 428816, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                       = 0xc000000009e68000
mmap (NULL, 9860, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 458752)                  = 0x9fffffffbf764000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf762000
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
open ("/pro/local/lib/libcrypto.so", O_RDONLY|0x800, 0)                                    ERR#2 ENOENT
open ("/usr/local/ssl/lib/libcrypto.so", O_RDONLY|0x800, 0)                                = 3
fstat (3, 0x9fffffffffffdd30)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd390)                                           = 0
open ("/usr/lib/hpux64/dpd/libcrypto.so.bpd", O_RDONLY|0x800, 0)                           ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 3530960, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                      = 0xc000000006fe8000
mmap (NULL, 11552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_SHLIB, -1, 0)       = 0x9fffffffbf75e000
mmap (0x9fffffffbf72f000, 191296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 3538944) = 0x9fffffffbf72f000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 32768, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)       = 0x9fffffffbf724000
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
open ("/pro/local/lib/libssl.so", O_RDONLY|0x800, 0)                                       ERR#2 ENOENT
open ("/usr/local/ssl/lib/libssl.so", O_RDONLY|0x800, 0)                                   = 3
fstat (3, 0x9fffffffffffdd30)                                                              = 0
read (3, "7f454c46020201010100 |  ELF      ".., 64)                                        = 64
pread (3, "7f454c46020201010100 |  ELF      ".., 1024, 0)                                  = 1024
stat ("/usr/lib/hpux64/dpd", 0x9fffffffffffd390)                                           = 0
open ("/usr/lib/hpux64/dpd/libssl.so.bpd", O_RDONLY|0x800, 0)                              ERR#2 ENOENT
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 659104, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_SHLIB, 3, 0)                       = 0xc000000008bc0000
mmap (NULL, 29584, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_SHLIB, 3, 720896)                 = 0x9fffffffbf71c000
close (3)                                                                                  = 0
getuid ()                                                                                  = 203 (203)
getgid ()                                                                                  = 200 (200)
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf72c000
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf71a000
mmap (NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)        = 0x9fffffffbf718000
brk (0x6000000000940000)                                                                   = 0
  Received signal 4, SIGILL, in user mode, [SIG_DFL], partial siginfo
    Siginfo: si_code: ILL_ILLOPC, faulting address: 0x60000000000ab620, si_errno: 0
     PC: 00000001000000a0.0
exit (4) [implicit]
WIFSIGNALED(SIGILL)|WCOREDUMP



--
 Simon Riggs           http://www.2ndQuadrant.com/books/
 PostgreSQL Development, 24x7 Support, Training and Services

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Tom Lane
Date:
Simon Riggs <simon@2ndQuadrant.com> writes:
> FW
> From: H.Merijn Brand <h.m.brand@xs4all.nl>
> I have postgres running on most my HP-UX varieties, ranging from HP-UX
> 10.20/32bit through 11.31/64bit. It works fine everywhere, except on
> HP-UX 11.31-ipf in 64bit mode. Note that this is Itanium architecture.

> postgres' own test suite passes, but all connects fail with DBD::Pg.

That's pretty odd.  What seems to be failing here:

> This is perl, v5.10.1 (*) built for IA64.ARCHREV_0-LP64
> getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb84, 0x9fffffffffffdb98)               ERR#22 EINVAL

is this bit of code in libpq:

                int            optval;
                ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
                ...
                if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
                               (char *) &optval, &optlen) == -1)
                {
                    appendPQExpBuffer(&conn->errorMessage,
                    libpq_gettext("could not get socket error status: %s\n"),
                            SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
                    goto error_return;
                }

It's not clear at all how that would fail in the Perl environment if it
works standalone.  I could believe getting EINVAL if we had determined
the wrong datatype for ACCEPT_TYPE_ARG3, but that ought to fail
standalone too, I should think.  Anyway it would be worth checking what
configure identified as ACCEPT_TYPE_ARG3 and comparing that to the docs
for getsockopt.

Meanwhile, this one:

> This is perl 5, version 12, subversion 2 (v5.12.2) built for IA64.ARCHREV_0-LP64-ld
>   Received signal 4, SIGILL, in user mode, [SIG_DFL], partial siginfo
>     Siginfo: si_code: ILL_ILLOPC, faulting address: 0x60000000000ab620, si_errno: 0
>      PC: 00000001000000a0.0

seems like it's just a flat-out library incompatibility --- it looks to
me like it's probably failing immediately upon passing control to libpq.
I'm wondering about issues like word width and endianness.  IA64 can do
either endianness IIRC, so maybe your toolchain is confused about which
it should use?

            regards, tom lane

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Tom Lane
Date:
"H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> This is what the docs on HP-UX say:

>       int getsockopt (
>           int         s,
>           int         level,
>           int         optname,
>           void       *optval,
>           int        *optlen
>           );

>     UNIX 03 Only (X/Open Sockets)

>       int getsockopt (
>           int                    s,
>           int                    level,
>           int                    optname,
>           void       *__restrict optval,
>           socklen_t  *__restrict optlen
>           );

Mmm, fun.  And what is socklen_t defined as?

> the includes tell me
> src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t

Hmm, that suggests that configure was already seeing the socklen_t
variant ...

> To use X/Open sockets, which seems to me the better option for
> postgresql, I changed scr/Makefile.global =>

> CC = cc
> CFLAGS = -O2 -g -Ae -z +Z +DD64 -D_XOPEN_SOURCE=600
> LIBS = -lssl -lcrypto -lxnet -lz -lm
> LDFLAGS = -Wl,+vnocompatwarnings +DD64  -L/usr/local/ia64/lib \
>     -L/usr/lib/hpux64 -L/usr/contrib/X11R6/lib/hpux64 -s \
>     -L/usr/local/lib -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib

Screwing around with CFLAGS in an already-generated Makefile.global
is definitely *not* the way to approach this; you need configure to
have seen the same switches, else it will have selected the wrong
ACCEPT_TYPE_ARG3.  Try it with
    configure CPPFLAGS="-D_XOPEN_SOURCE=600"
or something like that.

> To ensure optimal alignment, I also added
> #pragma pack 16
> to all header files

And please do not inject random other ways of breaking things at the
same time --- there's no good reason to believe that that will even
work, and it's surely complicating trying to solve the immediate
problem.

> # PostgreSQL (reported)       PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.4.1
[gcc-4_4-branchrevision 150839], 64-bit 

Where'd that come from?  Seems a bit weird that this is referring to
something other than your HPUX build.

> As, at this point, there is no control over the library that perl itself is linked with:

Hmm.  I wonder whether perl is built with libraries that expect the
"int" definition instead of the "socklen_t" definition, or vice versa
(whichever way is not what libpq expects).  Do you know exactly how HP
is managing to support both of those ABIs?

            regards, tom lane

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Tom Lane
Date:
I wrote:
> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
>> the includes tell me
>> src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t

> Hmm, that suggests that configure was already seeing the socklen_t
> variant ...

Actually, the reason that happens is probably that src/template/hpux
forcibly adds -D_XOPEN_SOURCE_EXTENDED to CPPFLAGS.  At least on my
old HPUX box, that's sufficient to select the more modern prototype
for accept and getsockopt; probably the same on yours.

So what I'm thinking is happening is that libpq expects size_t as
the argument type, but it's getting linked against a libc that
expects int as the argument type, and whatever HP is doing under
the hood fails to cope with that case.  You might try removing
-D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
that will have any bad side-effects, but it's worth a try to build
libpq that way.

            regards, tom lane

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Thu, 16 Dec 2010 12:31:21 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> I wrote:
> > "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> >> the includes tell me
> >> src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t
>
> > Hmm, that suggests that configure was already seeing the socklen_t
> > variant ...
>
> Actually, the reason that happens is probably that src/template/hpux
> forcibly adds -D_XOPEN_SOURCE_EXTENDED to CPPFLAGS.  At least on my
> old HPUX box, that's sufficient to select the more modern prototype
> for accept and getsockopt; probably the same on yours.
>
> So what I'm thinking is happening is that libpq expects size_t as
> the argument type, but it's getting linked against a libc that
> expects int as the argument type, and whatever HP is doing under
> the hood fails to cope with that case.  You might try removing
> -D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
> that will have any bad side-effects, but it's worth a try to build
> libpq that way.

I'll try that first after cleaning up my environment.

I always compile with -Ae:

      -Ae            In aC++, invokes aCC as an ANSI-C compiler, with
                     additional support for HP-C language extensions.  Refer
                     to the HP-C compiler documentation for details of the
                     HP-C language extensions.
                     In C, this is the default, Extended ANSI C99 mode.
                     Which is almost the same as -Aa -D_HPUX_SOURCE -ext.
                     This would define the names (macros and typedefs)
                     provided by the HP-UX Operating System and, in
                     addition, allows extensions such as C99 features in
                     this release (complex and imaginary data types, STDC
                     pragmas), $ characters in identifier names, sized
                     enums, and sized bit-fields, and 64-bit integral types.
                     Additional extensions may be added to this option in
                     the future.

-
      -Aa            For aC++, turns on newly supported ANSI C++ Standard
                     features like Koenig lookup and correct scoping for
                     variables declared in conditional statements like for-
                     loops.  Additional features may be enabled by this
                     option in the future.
                     For C, compile under strict ANSI mode (ANSI programming
                     language C standard ISO 9899:1990).  When compiling
                     under ANSI mode, the header files would define only
                     those names (macros and typedefs) specified by the
                     Standard.  To access macros and typedefs that are not
                     defined by the ANSI Standard but are provided by the
                     HP-UX Operating System, define the symbol _HPUX_SOURCE;
                     or use the extension option, -Ae described below.
      -ext           Allow various C/C++ extensions.  Currently -ext enables
                     the 64 bit integer (long long) data type.  This is a
                     synonym for the +e option.

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Thu, 16 Dec 2010 12:24:01 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> > This is what the docs on HP-UX say:
>
> >       int getsockopt (
> >           int         s,
> >           int         level,
> >           int         optname,
> >           void       *optval,
> >           int        *optlen
> >           );
>
> >     UNIX 03 Only (X/Open Sockets)
>
> >       int getsockopt (
> >           int                    s,
> >           int                    level,
> >           int                    optname,
> >           void       *__restrict optval,
> >           socklen_t  *__restrict optlen
> >           );
>
> Mmm, fun.  And what is socklen_t defined as?

sys/types.h
473:typedef size_t              socklen_t;

> > the includes tell me
> > src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t
>
> Hmm, that suggests that configure was already seeing the socklen_t
> variant ...

That was my conclusion too

> > To use X/Open sockets, which seems to me the better option for
> > postgresql, I changed scr/Makefile.global =>
>
> > CC = cc
> > CFLAGS = -O2 -g -Ae -z +Z +DD64 -D_XOPEN_SOURCE=600
> > LIBS = -lssl -lcrypto -lxnet -lz -lm
> > LDFLAGS = -Wl,+vnocompatwarnings +DD64  -L/usr/local/ia64/lib \
> >     -L/usr/lib/hpux64 -L/usr/contrib/X11R6/lib/hpux64 -s \
> >     -L/usr/local/lib -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib
>
> Screwing around with CFLAGS in an already-generated Makefile.global
> is definitely *not* the way to approach this; you need configure to
> have seen the same switches, else it will have selected the wrong
> ACCEPT_TYPE_ARG3.  Try it with
>     configure CPPFLAGS="-D_XOPEN_SOURCE=600"
> or something like that.

I know, but I first wanted to nail down the real cause of failure

> > To ensure optimal alignment, I also added
> > #pragma pack 16
> > to all header files
>
> And please do not inject random other ways of breaking things at the
> same time --- there's no good reason to believe that that will even
> work, and it's surely complicating trying to solve the immediate
> problem.

I did this because of the truckload of warnings I got. I'll do a fresh
checkout on my next attempt

> > # PostgreSQL (reported)       PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.4.1
[gcc-4_4-branchrevision 150839], 64-bit 
>
> Where'd that come from?  Seems a bit weird that this is referring to
> something other than your HPUX build.

$PGHOST is set to our postgres server

One of the reasons is that *that* is what I eventually have to get
working: 64bit perl on HP-UX 11.31 talking through DBD::Pg to a remote
postgres server.

> > As, at this point, there is no control over the library that perl
> > itself is linked with:
>
> Hmm.  I wonder whether perl is built with libraries that expect the
> "int" definition instead of the "socklen_t" definition, or vice versa
> (whichever way is not what libpq expects).  Do you know exactly how HP
> is managing to support both of those ABIs?

It is, as getsockopt () is in libc. All executables - of course - are
linked to libc, so unless they were *also* linked to libxnet, the libc
variant will be chosen.

I might find some time to rebuild perl from scratch with the -D option
and the addition of libxnet and see it that causes a different result

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Tue, 14 Dec 2010 15:16:36 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Thanks for the answer. I think all of this makes sense in reading
further into the HP-UX 11.31 socket docs. Please read on as I found a
workaround, but that is probably NOT *the* solution.

> Simon Riggs <simon@2ndQuadrant.com> writes:
> > FW
> > From: H.Merijn Brand <h.m.brand@xs4all.nl>
> > I have postgres running on most my HP-UX varieties, ranging from HP-UX
> > 10.20/32bit through 11.31/64bit. It works fine everywhere, except on
> > HP-UX 11.31-ipf in 64bit mode. Note that this is Itanium architecture.
>
> > postgres' own test suite passes, but all connects fail with DBD::Pg.
>
> That's pretty odd.  What seems to be failing here:
>
> > This is perl, v5.10.1 (*) built for IA64.ARCHREV_0-LP64
> > getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb84, 0x9fffffffffffdb98)               ERR#22 EINVAL
>
> is this bit of code in libpq:
>
>                 int            optval;
>                 ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
>                 ...
>                 if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
>                                (char *) &optval, &optlen) == -1)
>                 {
>                     appendPQExpBuffer(&conn->errorMessage,
>                     libpq_gettext("could not get socket error status: %s\n"),
>                             SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
>                     goto error_return;
>                 }

This is what the docs on HP-UX say:

      int getsockopt (
          int         s,
          int         level,
          int         optname,
          void       *optval,
          int        *optlen
          );

    UNIX 03 Only (X/Open Sockets)

      int getsockopt (
          int                    s,
          int                    level,
          int                    optname,
          void       *__restrict optval,
          socklen_t  *__restrict optlen
          );

the includes tell me

src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t

That is already some sort of inconsistency

    AF_CCITT only
      #include <x25/x25addrstr.h>

      int accept (int s, void *addr, int *addrlen);

    UNIX 03 only (X/Open Sockets)
           int accept (
               int                         s,
               struct sockaddr *__restrict addr,
               socklen_t       *__restrict addrlen
               );

To use X/Open sockets, which seems to me the better option for
postgresql, I changed scr/Makefile.global =>

CC = cc
CFLAGS = -O2 -g -Ae -z +Z +DD64 -D_XOPEN_SOURCE=600
LIBS = -lssl -lcrypto -lxnet -lz -lm
LDFLAGS = -Wl,+vnocompatwarnings +DD64  -L/usr/local/ia64/lib \
    -L/usr/lib/hpux64 -L/usr/contrib/X11R6/lib/hpux64 -s \
    -L/usr/local/lib -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib

To ensure optimal alignment, I also added

#pragma pack 16

to all header files

However that made no difference in the end-result:

connect (3, 0x6000000000849280, 16)                                          ERR#245 EINPROGRESS
poll (0x9fffffffffffdba0, 1, -1)                                             = 1
getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb94, 0x9fffffffffffdba8) ERR#22 EINVAL

HOWEVER

With

tcsh> setenv LD_PRELOAD /usr/lib/hpux64/libxnet.so.1
bash> export LD_PRELOAD=/usr/lib/hpux64/libxnet.so.1

DBD-Pg-2.17.1 559 > make test
PGINITDB="/pro/pgsql-8.4.5/bin/initdb" PERL_DL_NONLAZY=1 /pro/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib','blib/arch')" t/*.t 
t/00-signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ......... ok
t/01connect.t ....... 4/13 #
# DBI                         Version 1.615
# DBD::Pg                     Version 2.17.1
# Perl                        Version 5.10.1
# OS                          hpux
# PostgreSQL (compiled)       80405
# PostgreSQL (target)         80404
# PostgreSQL (reported)       PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.4.1
[gcc-4_4-branchrevision 150839], 64-bit 
# Default port                5432
# DBI_DSN                     dbi:Pg:
# DBI_USER                    postgres
# Test schema                 dbd_pg_testschema
# PGDATABASE                  testdb
# PGHOST                      12.13.14.15
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings off
t/01connect.t ....... ok
t/01constants.t ..... ok
t/02attribs.t ....... 48/249
#   Failed test 'Failed ping returns a SQLSTATE code of 08000'
#   at t/02attribs.t line 1597.
#          got: '22000'
#     expected: '08000'
t/02attribs.t ....... 247/249 # Looks like you failed 1 test of 249.
t/02attribs.t ....... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/249 subtests
        (less 1 skipped subtest: 247 okay)
t/03dbmethod.t ...... ok
t/03smethod.t ....... ok
t/04misc.t .......... ok
t/06bytea.t ......... ok
t/07copy.t .......... ok
t/08async.t ......... ok
t/09arrays.t ........ ok
t/12placeholders.t .. ok
t/20savepoints.t .... ok
t/99cleanup.t ....... 1/1 Removing test database directory
t/99cleanup.t ....... ok

Test Summary Report
-------------------
t/02attribs.t     (Wstat: 256 Tests: 249 Failed: 1)
  Failed test:  244
  Non-zero exit status: 1
Files=15, Tests=1707, 21 wallclock secs ( 0.39 usr  0.09 sys +  2.62 cusr  0.90 csys =  4.00 CPU)
Result: FAIL
Failed 1/15 test programs. 1/1707 subtests failed.

As, at this point, there is no control over the library that perl itself is linked with:

Lib                                  Real path                            Size      Date                Refs
------------------------------------ ------------------------------------ --------- ------------------- ----
/pro/bin/perl                        /pro/bin/perl                          4419056 2009-10-05 09:30:15   13
/usr/lib/hpux64/libcl.so.1           /usr/lib/hpux64/libcl.so.1               69336 2007-02-15 22:47:27    3
/usr/lib/hpux64/libIO77.so.1         /usr/lib/hpux64/libIO77.so.1           3099480 2007-01-12 21:03:25    0
/usr/lib/hpux64/libunwind.so.1       /usr/lib/hpux64/libunwind.so.1          558120 2007-02-15 22:47:31    1
/usr/lib/hpux64/libuca.so.1          /usr/lib/hpux64/libuca.so.1              85680 2007-02-15 22:36:36    0
/usr/lib/hpux64/libpthread.so.1      /usr/lib/hpux64/libpthread.so.1        1528360 2008-07-09 23:24:48    0
/usr/lib/hpux64/libnsl.so.1          /usr/lib/hpux64/libnsl.so.1            1510840 2008-07-03 19:16:00    3
/usr/lib/hpux64/libc.so.1            /usr/lib/hpux64/libc.so.1              4898520 2009-06-06 01:23:40    1
/usr/lib/hpux64/libdl.so.1           /usr/lib/hpux64/libdl.so.1               78168 2010-06-24 20:02:37    0
/usr/lib/hpux64/libxti.so.1          /usr/lib/hpux64/libxti.so.1             298840 2008-06-28 11:59:19    0
/usr/lib/hpux64/libnm.so             /usr/lib/hpux64/libnm.so.1              244296 2007-02-15 22:32:55    0
/usr/lib/hpux64/libm.so.1            /usr/lib/hpux64/libm.so.1              2026976 2007-02-15 22:47:28    0
/usr/lib/hpux64/libsec.so.1          /usr/lib/hpux64/libsec.so.1             580112 2008-04-25 17:29:35    1

As getsockopt () is defined in libc.so.1, that one is used before it uses
the libxnet one as required/used by libpq.

> It's not clear at all how that would fail in the Perl environment if it
> works standalone.  I could believe getting EINVAL if we had determined
> the wrong datatype for ACCEPT_TYPE_ARG3, but that ought to fail
> standalone too, I should think.  Anyway it would be worth checking what
> configure identified as ACCEPT_TYPE_ARG3 and comparing that to the docs
> for getsockopt.

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Tom Lane
Date:
"H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> On Thu, 16 Dec 2010 12:31:21 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> So what I'm thinking is happening is that libpq expects size_t as
>> the argument type, but it's getting linked against a libc that
>> expects int as the argument type, and whatever HP is doing under
>> the hood fails to cope with that case.  You might try removing
>> -D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
>> that will have any bad side-effects, but it's worth a try to build
>> libpq that way.

> I'll try that first after cleaning up my environment.

I looked in the git history and found that I added
-D_XOPEN_SOURCE_EXTENDED in a patch that made getaddrinfo work
correctly:
http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=1da6eb7fdaa79a93972c290174bd7136672a894f
So taking it out may indeed have unpleasant side-effects.

            regards, tom lane

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Thu, 16 Dec 2010 12:56:12 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> > On Thu, 16 Dec 2010 12:31:21 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> So what I'm thinking is happening is that libpq expects size_t as
> >> the argument type, but it's getting linked against a libc that
> >> expects int as the argument type, and whatever HP is doing under
> >> the hood fails to cope with that case.  You might try removing
> >> -D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
> >> that will have any bad side-effects, but it's worth a try to build
> >> libpq that way.
>
> > I'll try that first after cleaning up my environment.
>
> I looked in the git history and found that I added
> -D_XOPEN_SOURCE_EXTENDED in a patch that made getaddrinfo work
> correctly:
> http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=1da6eb7fdaa79a93972c290174bd7136672a894f
> So taking it out may indeed have unpleasant side-effects.

I rebuilt perl from scratch with xnet as required lib and cpp option
-D_XOPEN_SOURCE_EXTENDED predefined in the hint file

All my other required modules passed, and DBD::Pg now connects!

With localhost postgres

t/01connect.t ....... 1/13 #
# DBI                         Version 1.615
# DBD::Pg                     Version 2.17.1
# Perl                        Version 5.12.2
# OS                          hpux
# PostgreSQL (compiled)       80405
# PostgreSQL (target)         80405
# PostgreSQL (reported)       PostgreSQL 8.4.5 on ia64-hp-hpux11.31, compiled by cc -Ae, 64-bit
# Default port                5432
# DBI_DSN                     dbi:Pg:db="postgres";port=5440;host=<pwd>/dbdpg_test_database/data/socket
# DBI_USER                    merijn
# Test schema                 dbd_pg_testschema
# LANG                        C
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings off
# Adjusted:                   initdb
t/01connect.t ....... ok
t/01constants.t ..... ok
t/02attribs.t ....... ok
t/03dbmethod.t ...... ok
t/03smethod.t ....... ok
t/04misc.t .......... ok
t/06bytea.t ......... ok
t/07copy.t .......... ok
t/08async.t ......... ok
t/09arrays.t ........ ok
t/12placeholders.t .. ok
t/20savepoints.t .... ok
t/99cleanup.t ....... 1/1 Removing test database directory
t/99cleanup.t ....... ok
All tests successful.
Files=15, Tests=1707, 29 wallclock secs ( 0.39 usr  0.09 sys +  4.35 cusr  1.32 csys =  6.15 CPU)
Result: PASS

With remote host postgres

t/00-signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ......... ok
t/01connect.t ....... 1/13 #
# DBI                         Version 1.615
# DBD::Pg                     Version 2.17.1
# Perl                        Version 5.12.2
# OS                          hpux
# PostgreSQL (compiled)       80405
# PostgreSQL (target)         80404
# PostgreSQL (reported)       PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.4.1
[gcc-4_4-branchrevision 150839], 64-bit 
# Default port                5432
# DBI_DSN                     dbi:Pg:
# DBI_USER                    postgres
# Test schema                 dbd_pg_testschema
# PGDATABASE                  lep1699
# PGHOST                      192.0.1.192
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings off
t/01connect.t ....... ok
t/01constants.t ..... ok
t/02attribs.t ....... 231/249
#   Failed test 'Failed ping returns a SQLSTATE code of 08000'
#   at t/02attribs.t line 1597.
#          got: '22000'
#     expected: '08000'
# Looks like you failed 1 test of 249.
t/02attribs.t ....... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/249 subtests
        (less 1 skipped subtest: 247 okay)
t/03dbmethod.t ...... ok
t/03smethod.t ....... ok
t/04misc.t .......... ok
t/06bytea.t ......... ok
t/07copy.t .......... ok
t/08async.t ......... ok
t/09arrays.t ........ ok
t/12placeholders.t .. ok
t/20savepoints.t .... ok
t/99cleanup.t ....... 1/1 Removing test database directory
t/99cleanup.t ....... ok

Test Summary Report
-------------------
t/02attribs.t     (Wstat: 256 Tests: 249 Failed: 1)
  Failed test:  244
  Non-zero exit status: 1
Files=15, Tests=1707, 20 wallclock secs ( 0.38 usr  0.07 sys +  2.72 cusr  0.74 csys =  3.91 CPU)
Result: FAIL
Failed 1/15 test programs. 1/1707 subtests failed.
make: *** [test_dynamic] Error 255


--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Thu, 16 Dec 2010 12:56:12 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> > On Thu, 16 Dec 2010 12:31:21 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> So what I'm thinking is happening is that libpq expects size_t as
> >> the argument type, but it's getting linked against a libc that
> >> expects int as the argument type, and whatever HP is doing under
> >> the hood fails to cope with that case.  You might try removing
> >> -D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
> >> that will have any bad side-effects, but it's worth a try to build
> >> libpq that way.
>
> > I'll try that first after cleaning up my environment.
>
> I looked in the git history and found that I added
> -D_XOPEN_SOURCE_EXTENDED in a patch that made getaddrinfo work
> correctly:
> http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=1da6eb7fdaa79a93972c290174bd7136672a894f
> So taking it out may indeed have unpleasant side-effects.

Which brings me to a rather awkward position.

A fresh built perl, using the same sockets that postgres uses (X/Open)
works perfectly fine with postgres, but now Oracle, DBD::Oracle also
freshly compiled with the same options however now doesn't work anymore
because of exactly the same reasons why DBD::Pg refused to work when I
started this quest.

As I use perl with DBD::Oracle and DBD::Pg at the same time to convert
between these two databases, there doesn't seem to be a way out.

My hopes in getting Oracle to change their policy is higher than IBM
changing user support, but still very close to zero.

How much are the postgres people willing to find a solution that would
force postgres to optional use BSD type sockets?

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"Greg Sabino Mullane"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> How much are the postgres people willing to find a solution that would
> force postgres to optional use BSD type sockets?
      

FWIW, my long-term plan is to have DBD::Pg provide its own libpq. Not
sure if this would enable you to solve the problem or not, but
I suspect it might. Actually removing the libpq dependency is awaiting
copious amounts of free time on my part, or funding from a sponsor.
But it's on the todo list. :)

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

iEYEAREDAAYFAk0N/Z0ACgkQvJuQZxSWSsjXtwCg6wb/Z+ws/3Rzs1rwkwjW8Awt
CSAAoLsyz0atsNS3Hi+9f16NlxAC1dtE
=GqaK
-----END PGP SIGNATURE-----

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
Magnus Hagander
Date:
On Sun, Dec 19, 2010 at 13:42, Greg Sabino Mullane <greg@turnstep.com> wrot=
e:
>
>> How much are the postgres people willing to find a solution that would
>> force postgres to optional use BSD type sockets?
>
> FWIW, my long-term plan is to have DBD::Pg provide its own libpq. Not
> sure if this would enable you to solve the problem or not, but
> I suspect it might. Actually removing the libpq dependency is awaiting
> copious amounts of free time on my part, or funding from a sponsor.
> But it's on the todo list. :)

Spinning off into the off-topic based on the question - if you do
this, please make it *optional*. Unless you plan to actually implement
all the libpq functionality and also shoulder the burden to release a
new version whenever a new version of libpq is out. Things like
kerberos/gssapi and cert authentication that actually work the same
way as others...

Might be worth looking at what the ODBC folks did though - they run
the actual protocol for the queries, but they use libipq for
connection setup and authentication (if found - they'll fallback on
doing simple auth etc if libpq isn't there)

--=20
=A0Magnus Hagander
=A0Me: http://www.hagander.net/
=A0Work: http://www.redpill-linpro.com/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Thu, 16 Dec 2010 12:56:12 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> > On Thu, 16 Dec 2010 12:31:21 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> So what I'm thinking is happening is that libpq expects size_t as
> >> the argument type, but it's getting linked against a libc that
> >> expects int as the argument type, and whatever HP is doing under
> >> the hood fails to cope with that case.  You might try removing
> >> -D_XOPEN_SOURCE_EXTENDED from the template file --- I don't know if
> >> that will have any bad side-effects, but it's worth a try to build
> >> libpq that way.
>
> > I'll try that first after cleaning up my environment.
>
> I looked in the git history and found that I added
> -D_XOPEN_SOURCE_EXTENDED in a patch that made getaddrinfo work
> correctly:
> http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=1da6eb7fdaa79a93972c290174bd7136672a894f
> So taking it out may indeed have unpleasant side-effects.

I have read that patch, and it may well be that this might only be
needed on PA-RISC. I at least see that the comment written in
src/makefiles/Makefile.hpux is not completely correct. Probably true
for LP64, but not for IA64.

I hav now taken out the -D_XOPEN_SOURCE_EXTENDED and -lxnet requirements
and compiled postgres against BSD sockets. Now it passes both its
internal test suite *AND* the DBD::Pg test suite.

Side notes

env CC=cc CFLAGS="-Ae -z +Z +DD64 -O2" configure --prefix=/pro/pgsql \
     --without-readline --without-ldap --with-openssl

currently doesn't work, as src/template/hpux and
src/makefiles/Makefile.hpux overrule these env vars, which means that
I still have to modify src/Makefile.global

Note again that I am on HP-UX 11.31 on Itanium (not PA-RISC) and that I
am compiling a 64bitall environment.

 HP-UX 11.31/64 U  rx2660/64 Itanium 2 9100/1710(2) ia64  4075 Mb
 This is perl, v5.10.1 (*) built for IA64.ARCHREV_0-LP64
 /pro/pgsql/bin/psql:    ELF-64 executable object file - IA64
 psql (PostgreSQL) 8.4.5

Below is the diff between what was generated by default on 8.4.5 and
after what I changed to make it work. Note that I did not alter either
the template not the specific original makefile to do so automatically.
I can (try to) do so if you would like to see how I would do that

After make, these are the essential diffs:
--8<---
diff -purd postgresql-8.4.5-org/config.status postgresql-8.4.5/config.status
--- postgresql-8.4.5-org/config.status  2010-12-20 11:52:19 +0100
+++ postgresql-8.4.5/config.status      2010-12-20 12:04:26 +0100
@@ -567,7 +567,7 @@ s,@enable_dtrace@,|#_!!_#|no,g
 s,@CC@,|#_!!_#|cc -Ae,g
 s,@CFLAGS@,|#_!!_#|-Ae -z +Z +DD64 -O2,g
 s,@LDFLAGS@,|#_!!_#| -L/usr/local/ia64/lib -L/usr/lib/hpux64 -L/usr/contrib/X11R6/lib/hpux64 -s -L/usr/local/lib
-L/usr/lib/X11R6-L/usr/contrib/X11R6/lib ,g 
-s,@CPPFLAGS@,|#_!!_#| -D_XOPEN_SOURCE_EXTENDED ,g
+s,@CPPFLAGS@,|#_!!_#| ,g
 s,@ac_ct_CC@,|#_!!_#|,g
 s,@EXEEXT@,|#_!!_#|,g
 s,@OBJEXT@,|#_!!_#|o,g
@@ -981,8 +981,8 @@ s,^\([       #]*\)[^         ]*\([   ]*SIZEOF_OFF_T\)
 s,^\([  #]*\)[^         ]*\([   ]*HAVE_INT_TIMEZONE\)[  (].*,\1define\2  ,
 s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_RETURN\)[         (].*,\1define\2 int ,
 s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_ARG1\)[   (].*,\1define\2 int ,
-s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_ARG2\)[   (].*,\1define\2 struct sockaddr * ,
-s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_ARG3\)[   (].*,\1define\2 size_t ,
+s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_ARG2\)[   (].*,\1define\2 void * ,
+s,^\([  #]*\)[^         ]*\([   ]*ACCEPT_TYPE_ARG3\)[   (].*,\1define\2 int ,
 s,^\([  #]*\)[^         ]*\([   ]*HAVE_CBRT\)[  (].*,\1define\2 1 ,
 s,^\([  #]*\)[^         ]*\([   ]*HAVE_DLOPEN\)[        (].*,\1define\2 1 ,
 s,^\([  #]*\)[^         ]*\([   ]*HAVE_FCVT\)[  (].*,\1define\2 1 ,
diff -purd postgresql-8.4.5-org/src/Makefile.global postgresql-8.4.5/src/Makefile.global
--- postgresql-8.4.5-org/src/Makefile.global    2010-12-20 11:52:19 +0100
+++ postgresql-8.4.5/src/Makefile.global        2010-12-20 12:05:17 +0100
@@ -199,8 +199,8 @@ DOCBOOK2MAN =

 # Compilers

-CPP = cc -Ae -E
-CPPFLAGS =  -D_XOPEN_SOURCE_EXTENDED
+CPP = cc -E
+CPPFLAGS =

 ifdef PGXS
 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
@@ -211,7 +211,7 @@ override CPPFLAGS := -I$(top_builddir)/s
 endif
 endif # not PGXS

-CC = cc -Ae
+CC = cc
 GCC =
 SUN_STUDIO_CC = no
 CFLAGS = -Ae -z +Z +DD64 -O2
diff -purd postgresql-8.4.5-org/src/Makefile.port postgresql-8.4.5/src/Makefile.port
--- postgresql-8.4.5-org/src/Makefile.port      2010-10-01 15:35:31 +0200
+++ postgresql-8.4.5/src/Makefile.port  2010-12-20 11:58:53 +0100
@@ -8,7 +8,7 @@ endif
 # Using X/Open Networking Interfaces requires to link with libxnet.
 # Without specifying this, bind(), getpeername() and so on don't work
 # correctly in the LP64 data model.
-LIBS := -lxnet $(LIBS)
+#LIBS := -lxnet $(LIBS)

 # Set up rpath so that the executables don't need SHLIB_PATH to be set.
 # (Note: --disable-rpath is a really bad idea on this platform...)
diff -purd postgresql-8.4.5-org/src/include/pg_config.h postgresql-8.4.5/src/include/pg_config.h
--- postgresql-8.4.5-org/src/include/pg_config.h        2010-12-20 11:52:19 +0100
+++ postgresql-8.4.5/src/include/pg_config.h    2010-12-20 12:04:27 +0100
@@ -5,10 +5,10 @@
 #define ACCEPT_TYPE_ARG1 int

 /* Define to the type of arg 2 of 'accept' */
-#define ACCEPT_TYPE_ARG2 struct sockaddr *
+#define ACCEPT_TYPE_ARG2 void *

 /* Define to the type of arg 3 of 'accept' */
-#define ACCEPT_TYPE_ARG3 size_t
+#define ACCEPT_TYPE_ARG3 int

 /* Define to the return type of 'accept' */
 #define ACCEPT_TYPE_RETURN int
diff -purd postgresql-8.4.5-org/src/makefiles/Makefile.hpux postgresql-8.4.5/src/makefiles/Makefile.hpux
--- postgresql-8.4.5-org/src/makefiles/Makefile.hpux    2010-10-01 15:35:31 +0200
+++ postgresql-8.4.5/src/makefiles/Makefile.hpux        2010-12-20 11:58:53 +0100
@@ -8,7 +8,7 @@ endif
 # Using X/Open Networking Interfaces requires to link with libxnet.
 # Without specifying this, bind(), getpeername() and so on don't work
 # correctly in the LP64 data model.
-LIBS := -lxnet $(LIBS)
+#LIBS := -lxnet $(LIBS)

 # Set up rpath so that the executables don't need SHLIB_PATH to be set.
 # (Note: --disable-rpath is a really bad idea on this platform...)
diff -purd postgresql-8.4.5-org/src/template/hpux postgresql-8.4.5/src/template/hpux
--- postgresql-8.4.5-org/src/template/hpux      2010-10-01 15:35:31 +0200
+++ postgresql-8.4.5/src/template/hpux  2010-12-20 11:58:20 +0100
@@ -1,6 +1,6 @@
 # $PostgreSQL: pgsql/src/template/hpux,v 1.16 2006/12/12 19:43:19 petere Exp $

-CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+#CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"

 if test "$GCC" != yes ; then
   CC="$CC -Ae"
-->8---

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"Greg Sabino Mullane"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


(yes, I'm going through old emails tonight)

> Spinning off into the off-topic based on the question - if you do
> this, please make it *optional*. Unless you plan to actually implement
> all the libpq functionality and also shoulder the burden to release a
> new version whenever a new version of libpq is out. Things like
> kerberos/gssapi and cert authentication that actually work the same
> way as others...

Er, no, it certainly will not be optional, that kind of ruins the
point. But yes, we will certainly not remove any functionality
and keep up with any libpq changes. Not sure why you would think
a new version would be released when a new version of libpq is
released - currently we are linked to any old random libpq that
happens to be on the user's box, and it almost always is not
the latest one. :) Once this is in place, I expect we'll be making
changes that will be picked up *by* libpq, because it frankly
hasn't seen much love lately.

> Might be worth looking at what the ODBC folks did though - they run
> the actual protocol for the queries, but they use libipq for
> connection setup and authentication (if found - they'll fallback on
> doing simple auth etc if libpq isn't there)

Yeah, we might end up doing something like that, but it seems
easier from this distance to simply subsume a good copy of
libpq into the DBD::Pg tree. Thanks for the feedback and idea.

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

iEYEAREDAAYFAk1SBEEACgkQvJuQZxSWSsiZcwCg7nRBwTnQ9bmVUMPXtk3cZShV
70sAnijn2nbWaRVMgljnKz4mqZDqVklk
=m89q
-----END PGP SIGNATURE-----

Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From
"H.Merijn Brand"
Date:
On Mon, 14 Mar 2011 10:31:26 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> > Maybe not the most ideal follow up, but I was trying to get a 64bit
> > postgresql running on HP-UX 11.23 Itanium2 64bit following the same
> > mantra that lead to success on my previous quest on 11.31, but whatever
> > I try I run into:
> > loading system objects' descriptions ... ok
> > creating conversions ... FATAL:  incompatible library
"/pro/3gl/postgresql-8.4.7/src/test/regress/tmp_check/install/pro/pgsql/lib/ascii_and_mic.so":missing magic block 
> > HINT:  Extension libraries are required to use the PG_MODULE_MAGIC macro.
>
> Hmm.  That file certainly does contain a magic block, so for some reason
> the backend is failing to find it.  I'd guess something going wrong with
> pg_dlsym() (look into src/backend/port/dynloader/hpux.c) but no idea
> exactly what.

To add to the confusion:

When I just copy the build from HP-UX 11.31 over to 11.23, all seems to
work fine. I *DO* expect that to work the other way around, but this
experiment just worked which is a huge surprise to me.

I tried to build 8.4.7, because 9.0.3 failed soon after start, because
11.23 doesn't have  HP-UX 11.23 doesn't seem to have "struct lifconf"
defined anywhere, so starting with 8.4.7 sounded like a more sane idea

FWIW I also tried with 9.0.3 and SIOCGLIFCONF undefined and IPV6
disabled, but that ended up with the same FATAL incompatible library

>             regards, tom lane
>
> PS: please don't send these types of questions to individuals.  You're
> much more likely to get a timely/helpful response on the pgsql-bugs
> list.

--
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/