I recently started using DBD::AnyData to query some flat files and it works great - except for the warnings it spits out. If I run the basic example from the DBD::AnyData docs, it prints the result set, followed by:
DBI st handle 0x9bd6468 cleared whilst still active. dbih_clearcom (sth 0x9bd6468, com 0x9bd83b8, imp DBD::AnyData::st) +: FLAGS 0x88005: COMSET Active HandleError PARENT DBI::db=HASH(0x9bd6384) KIDS 0 (0 Active) NUM_OF_FIELDS 2 NUM_OF_PARAMS 0
I did add $sth->finish and $dbh->disconnect to my test script but I still get that output.

I thought I could just add a __WARN__ handler to ignore this particular warning, but that only solves part of the problem. It appears that only the first line of the above output is the warning, the part starting with dbih_clearcom still gets printed.

I also tried using $dbh->{HandleError} but my handler isn't being called. Here's what I've tried so far:

#!/usr/bin/env perl use strict; use warnings; $| = 1; use DBI; $SIG{__WARN__} = \&handle_warnings; my $dbh = DBI->connect('dbi:AnyData:'); $dbh->{HandleError} = \&handle_errors; $dbh->{RaiseError} = 0; $dbh->{PrintError} = 0; $dbh->{PrintWarn} = 0; $dbh->{ShowErrorStatement} = 0; $dbh->{Warn} = 0; $dbh->func( 'cars', 'CSV', 'cars.csv', 'ad_catalog'); my $sth = $dbh->prepare('select make, model from cars'); $sth->execute(); while (my $row = $sth->fetch) { print "@$row\n"; } $sth->finish; $dbh->disconnect; sub handle_warnings { print Data::Dumper->Dump([\@_], ['*_']); my $warning = shift; print "Handling WARNING:\n$warning\n"; return if $warning =~ /handle .*? cleared whilst still active/ms; } sub handle_errors { print Data::Dumper->Dump([\@_], ['*_']); my $error = shift; print "Handling ERROR:$error\n"; 1; }
There is a bug report for this issue but it's been open for about a year. I've seen several recommendations here for DBD::AnyData, but no mention of this problem. Am I missing something obvious, or is there a workaround?


In reply to DBD::AnyData and 'handle cleared whilst still active' warning by iguanodon

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.