Subject: | ->err ->errstr not set RaiseError does not work |
->err, ->errstr not set on error in many cases (for database and
statement handles)
RaiseError does not work in many cases
Strange ERROR 2000 when trace(1)
----------
use strict;
use DBI;
my $dbh;
$dbh = DBI->connect("dbi:mysql:dbname=mydatabase", "user", "password", {
RaiseError => 1 } )
or die "cannot connect".$dbh->errstr;
my $hr = $dbh->selectall_hashref('completelly screwed SQL statement',
'anything');
# never dies !
print "hello, I shoulld be dead! [".$dbh->err."] - [".$dbh->errstr."]";
# prints: hello, I shoulld be dead! [] - []
print "hello, I shoulld be dead! [".$DBI::err."] - [".$DBI::errstr."]";
# also prints: hello, I shoulld be dead! [] - []
# also without RaiseError => 1 no errors are reported
# the same behavior for all select*_* functions
# for selectrow_arrayref there is no way to distinguish error from empty
set
----------
In above example (no matter whch select*_* function we use), if proper
query is submmited and results are returned successfuly
you may notice strange errors on trace(1)
DBI::db=HASH(0x25a2994) trace level set to 0x0/1 (DBI @ 0x0/0) in
DBI 1.616-ithread (pid 8264)
!! ERROR: 2000 CLEARED by call to bind_columns method
<- selectall_hashref('select * from bookformat', 'Name')= (
HASH(0x259f94c)1keys ) [1 items] at testbugs.pl line 9
<- DESTROY(DBI::db=HASH(0x25a2994))= ( undef ) [1 items] at
testbugs.pl line 13
and even stranger on trace(2)
<- dbd_st_execute returning imp_sth->row_num 1
--> do_error
Async support was not built into this version of DBD::mysql error 2000
recorded: Async support was not built into this v
ersion of DBD::mysql
<-- do_error
-> dbd_st_FETCH_attrib for 02553d5c, key NAME_hash
-> dbd_st_FETCH_attrib for 0254caa4, key NAME
-> dbd_st_FETCH_attrib for 02553d5c, key NUM_OF_FIELDS
-> dbd_st_FETCH_attrib for 02553d5c, key NAME
!! ERROR: 2000 CLEARED by call to bind_columns method
Notice - I do not try to use { async => 1 } in my code - what you see
above is exact code I used to reproduce bugs. Tried to set { async => 0
} manually but it did not help
------------------------------
No ->errstr or DBI::errstr is set when do() fails; undef is returned
fortunately.
------------------------------
There is no way in configuration I use to detect / report / raise errors
other then detecting undef, which may be expected output from some
functions (does not always mean error)
------------------------------
DBI 1.616
DBD-Mysql 4.019 (last available via ppm from activestate, but I see
probably the same bug reported from version 4.020)
Active State perl5.14.1 MSWin32-x86-multi-thread (standard installer)
build 294969
Windows 7 Professional 64 (ver 6.1 build 7601, service pack 1)