Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2023-04-01 10:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found