DBI 1.39 was released a few days ago.

Although it is mostly a bug fix version, there are three things that I would like to point out:

  1. The documentation for "InactiveDestroy" was updated, making clear what this method does.
    InactiveDestroy is a handler attribute that instructs the DBI not to call the database engine methods related to DESTROY. It is especially useful in a forked process.
    The example below shows what the docs mean. A child process inherits a database handler from its parent. The handler goes out of scope in the child process, and if we don't set InactiveDestroy (line 23), we get an error, because the database handler's DESTROY method will implicitly call disconnect().
    Notice that with some database engines, such as Oracle, this example won't work, because they don't allow passing of handlers across processes.

  2. Starting from version 1.38, as promised since February 2003, the minimum requirement for DBI is Perl 5.6.0.
    If you still are using an older version of Perl, it may be time to upgrade.

  3. <plug> Both the changelog and the docs point to an article, which is nothing more than a bit polished DBI Recipes.
    In a private message, Tim Bunce promised that the next version of Programming the Perl DBI will be very much cookbook oriented. </plug>
#!/usr/bin/perl -w use DBI; use strict; my $dbh = DBI->connect("DBI:mysql:test", "user", "pwd", { RaiseError => 1 }) or die "can't connect\n"; my $query = qq{select user(), NOW()}; my $sth = $dbh->prepare($query); my $pid ; FORK: { if ($pid = fork) { print "I am the parent (PID: $$) and $pid is my child \n"; print_result($sth); } elsif (defined $pid) { print "I am the child ($$)\n"; $dbh->{InactiveDestroy} = 1; # line 23 print_result($sth); } else { die "Can't fork: $!\n"; } } sub print_result { my $st = shift; return unless $st; print "process id: $$\n"; $st->execute() or die "can't execute (PID $$), ($DBI::errstr)\n"; while (my $row = $st->fetchrow_arrayref()) { print ">> @$row\n"; } } __END__ I am the parent (PID: 2812) and 2813 is my child I am the child (2813) process id: 2813 >> gmax@localhost 2003-11-30 18:06:20 process id: 2812 >> gmax@localhost 2003-11-30 18:06:20
 _  _ _  _  
(_|| | |(_|><
 _|   

In reply to DBI 1.39 by gmax

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.