We all know that perl excels in all forms of communications ranging from STDIN/STDOUT/STDERR to POE. These include all methods supported by Unix, which means terminal IO, disk IO, pipes, message queues, shared memory, and lo and behold sockets.

In my working environments sockets are now used everywhere ranging from webservices to monitor programs and database communications.

Only two weeks ago, I tried to install DBD::Pg on a perl-5.10.1 tree with a freshly built postgres-8.4.5 whose test suite passed all tests so the odds looked like it would be a big success.

But DBD::Pg refused to connect to any postgres database server, neither local, nor remote. Numerous hours of debugging later, I found out that there are two kinds of sockets available on that system:

Default DSB sockets: 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 difference isn't that big, and you'll notice no difference in a 32bit environment, but in a 64bit environment, socklen_t is 64bit. You'll probably see the problems shine already. Perl itself was built with all default options, resulting in the standard BSD type sockets, whereas libpq from postgres was built with the X/Open type causing all socket calls that involve optlen to fail.

To prove that I was right, I compiled perl-5.12.2 from scratch, forcing it to use the X/Open type of socket calls. That involves one extra define and the addition of xnet to the libswanted during Configure. Perl's internal test suite passed all tests, and all my default modules (186 in total) built and installed fine.

Then came the final test: DBD::Pg, and all went well. Problem solved?

Of course not. Otherwise I wouldn't have posted here. We do not only use postgres databases, but we also use perl to connect to Unify, SQLite and CSV databases (I also test on mysql, but as we don't use it, I don't really care).

DBD::SQLite and DBD::CSV already passed in my basic setup, so that was fine. Next in line was the horrible DBD::Oracle. And that one showed the exact error that DBD::Pg showed when I started this quest: all connects failed.

If it were just for me, I wouldn't care. I hate Oracle. Not that there is a perfect database. In the end all databases suck, but Oracle and mysql suck more than the rest. But we have customers that use Oracle. A lot.

The problem now is that we also have scripts that connect to both Oracle and Postgres. That is now impossible. By now all of us probably know that you cannot use 32bit shared libraries in a 64bit environment and vice versa, but this is a completely new type of fail area.

If I have a BSD-socket type of perl, my Oracle communications work fine. I can make the Postgres scritps work by compiling DBD::Pg with the X/Open socket options and libraries and then setting export LD_PRELOAD=/usr/lib64/libxnet.so or wherever that library is located, but I cannot set that in my default environment, as the Oracle connections would fail. Neither is it possible to have script that communicate with both databases.

The life of IT people is so hard ...

(FWIW I currently have both perls installed at the customer site, and the script specifically sets the perl required. This does mean that I have to maintain both trees).


Enjoy, Have FUN! H.Merijn

In reply to The joy of socket communication by Tux

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.