Hmm.
I tried that before
one of my attempts had that in the same hash as raiseerror.., and now that I think on what you said -- it does seem to work.
After a bit of a re-write, I realise that my issue seems to be if the DB server is gone, and a query is attempted. Something that can happen between even a DBI PING and QUERY.
If that happens, it just hangs in a 'wait' state forever.
EG:
- I'm connected
- I run a query or two
- the MySQL server vanishes
- I do a prepare and an execute of a query
- I get an error, and raiseerror is on...
- I get 'execute failed' and it simply hangs forever
Just in case, I've also tried with 'or die' at the end of the execute statement. It still hangs.
I have a debugging like .. print "BAH"; right after the execute statement, and it is never reached.
I've tried wrapping it in an eval, without an eval around it, using connect_cached and connect, using raiseerror or not, the list goes on.
Should a query just hang, if it can't reach the server?! I'm guessing 'connect timeout' is only for connect.
Yet, I'm getting an error stating lost connection, so why aren't I getting a raisederror, or the die kicking in?!
HELP! :P
Thanks btw for the prior, at least I have a much better idea of what the issue is...
AH.
Perl version..
5.22
So... just to add to this in an edit....
I'm trying alarm right now. It works, and I'm monkeying with it.
But, all over the place I see posts about 'don't do alarm, do this', then other places 'don't do THAT, do this instead' then 'perl v$x will segfault with this and....
I guess my question is.. I can't find a complete "This is how to do completely foolproof MySQL handling under perl, for all versions, catching all errors, etc..." anywhere.
Maybe I'm Googling the wrong thing. But, any suggestions?
Is alarm OK 100% of the time, in every single case?