Subclassing DBI, and PrintError messages
From: David Viner (dviner_at_yahoo-inc.com)
Date: 11/18/04
- Next message: Tim Bunce: "Re: DBD::Oracle question"
- Previous message: Tim Bunce: "Re: No Values (in $sth->execute call)"
- Next in thread: Tim Bunce: "Re: Subclassing DBI, and PrintError messages"
- Reply: Tim Bunce: "Re: Subclassing DBI, and PrintError messages"
- Maybe reply: Ian Harisay: "Re: Subclassing DBI, and PrintError messages"
- Maybe reply: Ian Harisay: "Re: Subclassing DBI, and PrintError messages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "'dbi-users@perl.org'" <dbi-users@perl.org> Date: Wed, 17 Nov 2004 18:46:49 -0800
Hi,
I am attempting to write a simple subclass of DBI which will handle some
auto-reconnect behavior. In this case, I am connecting to a MySQL server,
and I can properly reconnect. However, if the user sets 'PrintError' to
true, then DBI will print out:
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at C:/Perl/site/lib/Harvester/DBI.pm line 177, <> line 1.
Immediately after that, it will reconnect, and re-execute the statement
handle successfully. I would like to print a message after the "lost
connection" message so that the user knows that the class is attempting to
reconnect. Since I can already detect when the connection is lost, I can
just use something like warn to handle this. However, I'd like to use the
same mechanism that DBI and DBD::mysql::st are using.
In order to discover how (or where exactly) DBI or DBD::mysql::st emits the
warning statement, I set DBI->trace(15) to see exactly what was happening.
Here's that output:
>> execute DISPATCH (Harvester::DBI::st=HASH(0x1d7dac0) rc1/2 @1 g0
ima1041 pid#5864)at C:/Perl/site/lib/Harvester/DBI.pm line 177
-> execute for DBD::mysql::st
(Harvester::DBI::st=HASH(0x1d7dac0)~0x1d7a230) thr#224374
-> dbd_st_execute for 01d7a158
Lost connection to MySQL server during query error 2013 recorded: Lost
connection to MySQL server during query
<- dbd_st_execute -2 rows
!! ERROR: 2013 'Lost connection to MySQL server during query' (err#0)
<- execute= undef at C:/Perl/site/lib/Harvester/DBI.pm line 177
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at C:/Perl/site/lib/Harvester/DBI.pm line 177, <> line 1.
I can't seem to find anything that emits this warning. From slow debugging,
I can tell that this occurs when $sth->execute() is invoked. However, I
can't seem to pinpoint the code which actually emits the message.
Can anyone point me in the right direction?
thanks
dave
- Next message: Tim Bunce: "Re: DBD::Oracle question"
- Previous message: Tim Bunce: "Re: No Values (in $sth->execute call)"
- Next in thread: Tim Bunce: "Re: Subclassing DBI, and PrintError messages"
- Reply: Tim Bunce: "Re: Subclassing DBI, and PrintError messages"
- Maybe reply: Ian Harisay: "Re: Subclassing DBI, and PrintError messages"
- Maybe reply: Ian Harisay: "Re: Subclassing DBI, and PrintError messages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|