Bug #25457 DBI can not access mysql_warning_count() - (patch+test+docs provided)
Submitted: 7 Jan 2007 17:16 Modified: 19 Mar 2007 19:07
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S4 (Feature request)
Version:4.00 OS:Perl
Assigned to: Jim Winstead CPU Architecture:Any
Tags: Contribution

[7 Jan 2007 17:16] Philip Stoev
Description:
Hello,

It is impossible to determine from DBI if a SQL statement has generated warnings, except by calling SHOW WARNINGS repeatedly after each statement. Therefore, a Statement handle attribute was added that provides access to this information.

How to repeat:
From the SHOW WARNINGS example in the manual:

$dbh->do("DROP TABLE IF EXISTS no_such_table");

It is impossible to determine if everything went OK unless you issue SHOW WARNINGS after each and every statement.

Suggested fix:
With the patch provided, one can do:

my $sth = $dbh->prepare("DROP TABLE IF EXISTS no_such_table");
$sth->execute();
return $sth->{mysql_warning_count};
[7 Jan 2007 17:17] Philip Stoev
Provides mysql_warning_count statement handle attribute

Attachment: mysql-warnings.patch (text/plain), 3.62 KiB.

[9 Jan 2007 13:31] Valeriy Kravchuk
Thank you for a problem report and a patch.
[19 Mar 2007 19:07] Jim Winstead
I have applied this to the repository, so it will be in 4.004. Thanks for the contribution.