Perl’s *DBM_File packages: what the heck are you people thinking?

Among many other things, my day-job involves working on a web-based system, written in Perl, for administrating our MasterKey metasearching system.  We call the admin system MKAdmin.  It was developed on Debian GNU/Linux, since that’s our usual production platform, but I also work on it from my Mac laptop.

Excuse me if I rant for a moment.

MKAdmin, until recently, used the NDBM_File module to implement a simple persistent session store — just an on-disk hashtable that maps cookie values to session structures.  NDBM_File is part of the core Perl distribution.

But when one of our partners wanted to run it on Fedora Linux, it became apparent that in their infinite wisdom the Fedora packagers have removed the NDBM_File module from their Perl package, so MKAdmin wouldn’t run. Understand: it isn’t that they didn’t provide an RPM package for the NDBM_File module, it’s that they removed that module from the Perl package, even though it’s part of the Perl core distribution.

So I changed MKAdmin to use the functionally equivalent GDBM_File module, which is also part of the core Perl distribution but hasn’t been sabotaged by the Fedora people.  And so all was well.

Except that now all the MKAdmin applications I have running on my Mac laptop no longer work.

It turns out that in their infinite wisdom the MacPorts packagers have removed the GDBM_File module from their Perl package, so MKAdmin won’t run. Understand: it isn’t that they didn’t provide a port package for the GDBM_File module, it’s that they removed that module from the Perl package, even though it’s part of the Perl core distribution.

Holy crap, people! Can you all please just stop pooping all over the Perl distribution? Would you please refrain from doing additional work in order to remove functionality? Would you please just LEAVE WELL ENOUGH ALONE?!

So now I am going to modify MKAdmin again, so that instead it uses the (also functionally equivalent) SDBM_File module — which, I’ve checked, does exist on Debian, Red Hat and MacPorts.

But, really, folks.  It’s so avoidable.

Just stop it.

15 responses to “Perl’s *DBM_File packages: what the heck are you people thinking?

  1. I guess you can install in Fedora the offending package using CPAN.

    May be you could try AnyDBM_File too.

    use warnings;
    use strict;
    use AnyDBM_File;
    my %hash;
    tie %hash, 'AnyDBM_File', 'test.db';
    	print "Look out! $hash{'stored'}\n";
    	$hash{'stored'} = 'Store this, no matter what *DBM_File is used';
    untie %hash;

    In my case (Fedora 12), file says “test.db: Berkeley DB (Hash, version 9, native byte-order)”.

  2. You can’t (easily) install either GDBM or NDBM from CPAN, precisely because they are both part of the core Perl distribution. They have no distributions of their own. No doubt it would be possible to download the whole Perl distribution and extract the relevant bits, but I can easily imagine that getting messy very quickly, and I don’t want to go there.

    … but I do wonder whether AnyDBM_File might have been a better solution.

    Well, the next time I have to move MKAdmin to a different persistent session-store back-end, I’ll try that. *sigh*

  3. The point of AnyDBM_File is it’ll try to use any *DBM_File in the system.

    If there’s one installed, you’re done as long as you’re using an interface that it’s common to all *DBM_File packages.

  4. I think that the problem you’ve had is part of a larger one within free software. Many distributions make changes from the upstream projects, unnecessarily.

    It /shouldn’t matter/ in most cases what distribution you use, because it is the same programs that are being installed on all of them. I have often had the experience of searching the Web to see if anyone has had the same problem with a particular program, and have gotten forums specific to a distribution (e.g. Ubuntu) where people are suggesting solutions (installing distribution specific packages) that are irrelevant to people using a different distribution method, and in these cases there will always be a distribution-nonspecific solution but because the world of free software is split up like this it can be hard to find anyone discussing it.

    One reason I have installed Slackware is that it tends to provide unmodified upstream packages, and is unobtrusive as a package management system.

  5. Not being a perl guy, I have to ask: why are there three functionally equivalent modules?

  6. Aric, you can probably guess that the answer is: Historical Reasons.

  7. Ah, yes, the perennial answer to “why is this the way it is?”

    I’ve used that one many times. Especially when I don’t want to have to explain the actual reasoning behind how it ended up that way. Especially when the new manager isn’t going to understand that reasoning, and is going to want to go back and change it all to be “proper” even though thats going to break existing stuff built on top of it and will cause the project to run overtime with no practical benefit to anyone.

    But I digress…

  8. So why on earth there are three core packages that do the same thing exactly?

  9. Omer Katz asked:

    So why on earth there are three core packages that do the same thing exactly?

    Since Aric Caley asked the same thing, I guess an actual answer might be in order. First there was DBM, the original hash-table-on-disk library provided by Unix. That was superceded by NDBM (New DBM) which was better in various ways, including a diferent on-disk representation (and IIRC a wider and less modal API, introducing for the first time the concept of a descriptor for an open NDBM file, so that you could have two or more of them open at once). Then came GDBM (GNU DBM) and SDBM (no idea) which also offered additional functionality and/or performance and had different on-disk formats.

    If you are writing a Perl program that needs access to a *DBM file generated by another packages, then of course you need to use the correct *DBM_File module — I can’t read your NDBM files with my GDBM-based Perl program — which is why Perl comes with modules for all the different *DBM packages. Except of course when it’s sabotaged by a packager.

  10. When I search around trying to find out why Fedora might have wanted to remove NDBM_File, I find references to BUG: 84671 “perl: should something obsolete perl-NDBM_File?”

    But no discussion of why, only of whether. I see one comment claiming that it was obsoleted in rhl 8, and then unobsoleted in rhl 9, but still nothing about why.

  11. Thanks for the pointer, Jeff. This led me to the email archived at which contains the least uniformative comment I’ve seen on the subject:

    It was removed because it really isn’t necessary; there is DB_File
    which does the same, and on Linux, NDBM is just GDBM anyway, which is
    part of perl. This reduced the confusion and magic of the NDBM module
    since ndbm varies from platform to platform, making portable files

    I can understand what the thinking was here; it was wrong, but it wasn’t incomprehensible. They just didn’t think through the consequences.

  12. Nathan Myers

    What it doesn’t explain is why Apple removed GDBM from their Perl. Of course we will never get an official answer to that, but we know the answer already: if you remove NDBM to drive toward maximizing portability, you remove GDBM to sabotage portability. It is clearly in Apple’s interest to make porting away from Apple harder. That it made porting to Apple harder in this case is something Apple is evidently willing to live with.

  13. This is extermely strange. Usually you just change the version number. Well Perl says that there is more than one way to do it. There is a reason why I like python so much :)

  14. Vanilla packages are ftw. (I use Arch, thanks for asking!)

  15. Benjamin Franz

    GDBM probably went away forthe same reason I don’t use it anymore (and haven’t for several years). It’s buggy, undocumented, and unmaintained. The last release of the underlying library was eight years ago for goodness sake.

    Really, if you are going to use a local key/value store just use BerkeleyDB.

    DBM/NDBM/GDBM are all really just bad ideas nowadays.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s