Bug #63027 Support $dbh->{mysql_warning_count}
Submitted: 31 Oct 2011 4:35 Modified: 15 Feb 2013 16:49
Reporter: Mike Pomraning Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S4 (Feature request)
Version:4.020 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[31 Oct 2011 4:35] Mike Pomraning
Description:
DBD-mysql-4.020 offers the `mysql_warning_count` attribute on statement handles but not on database handles themselves.

Thus, the user cannot tell whether a successful `$dbh->do(...)` statement gave rise to any warnings without laboriously issuing a SHOW WARNINGS statement.

See http://stackoverflow.com/questions/7946655/dbi-perl-logging-mysql-warnings/7949798#7949798 for a real world example of where this would be useful.

How to repeat:
#! /usr/bin/perl

use strict;
use DBI;

my $dbh = DBI->connect(@ARGV[0..2], {RaiseError => 1}); # DSN, user, pass

$dbh->do(q|set sql_mode=''|);
$dbh->do(q|CREATE TABLE t (c CHAR(1))|);

$dbh->do(q|INSERT INTO t (c) VALUES ('perl'), ('dbd'), ('mysql')|);
print "Expected warnings: 3; actual warnings: ", $dbh->{mysql_warning_count}, "\n";

Suggested fix:
Patch forthcoming
[31 Oct 2011 4:36] Mike Pomraning
Patch to implement $dbh->{mysql_warning_count}

Attachment: DBD-mysql-4.020-dbh-mysql_warning_count.patch (application/octet-stream, text), 1.92 KiB.

[31 Oct 2011 4:51] Valeriy Kravchuk
Thank you for the feature request and patch contributed.
[15 Feb 2013 16:49] Sveta Smirnova
Thank you for the report.

We don't work on DBD::mysql bugs anymore. All its bugs should go to CPAN: https://rt.cpan.org/Public/Dist/Display.html?Name=DBD-mysql

I re-submitted your report to https://rt.cpan.org/Public/Bug/Display.html?id=83352
Please subscribe to the new report on CPAN and work with DBD::mysql developers in case if they need additional details.