diff -P -r -u DBD-mysql-4.00-orig/dbdimp.c DBD-mysql-4.00-mine/dbdimp.c --- DBD-mysql-4.00-orig/dbdimp.c 2007-01-07 19:03:21.000000000 +0200 +++ DBD-mysql-4.00-mine/dbdimp.c 2007-01-07 18:58:21.000000000 +0200 @@ -3274,6 +3274,8 @@ } } + imp_sth->warning_count = mysql_warning_count(&imp_dbh->mysql); + if (dbis->debug >= 2) { /* @@ -4236,6 +4238,10 @@ else if (strEQ(key, "mysql_use_result")) retsv= boolSV(imp_sth->use_mysql_use_result); break; + case 19: + if (strEQ(key, "mysql_warning_count")) + retsv= sv_2mortal(newSViv((IV) imp_sth->warning_count)); + break; case 20: if (strEQ(key, "mysql_server_prepare")) #if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION diff -P -r -u DBD-mysql-4.00-orig/dbdimp.h DBD-mysql-4.00-mine/dbdimp.h --- DBD-mysql-4.00-orig/dbdimp.h 2007-01-07 18:06:00.000000000 +0200 +++ DBD-mysql-4.00-mine/dbdimp.h 2007-01-07 18:53:30.000000000 +0200 @@ -231,6 +231,7 @@ long long_buflen; /* length for long/longraw (if >0) */ bool long_trunc_ok; /* is truncating a long an error */ my_ulonglong insertid; /* ID of auto insert */ + int warning_count; /* Number of warnings after execute() */ imp_sth_ph_t* params; /* Pointer to parameter array */ AV* av_attr[AV_ATTRIB_LAST];/* For caching array attributes */ int use_mysql_use_result; /* TRUE if execute should use */ diff -P -r -u DBD-mysql-4.00-orig/lib/DBD/mysql.pm DBD-mysql-4.00-mine/lib/DBD/mysql.pm --- DBD-mysql-4.00-orig/lib/DBD/mysql.pm 2007-01-07 18:06:00.000000000 +0200 +++ DBD-mysql-4.00-mine/lib/DBD/mysql.pm 2007-01-07 19:07:35.000000000 +0200 @@ -1124,8 +1124,11 @@ Similar to mysql, but type names and not numbers are returned. Whenever possible, the ANSI SQL name is preferred. -=back +=item mysql_warning_count + +The number of warnings generated during execution of the SQL statement. +=back =head1 TRANSACTION SUPPORT diff -P -r -u DBD-mysql-4.00-orig/t/warnings.t DBD-mysql-4.00-mine/t/warnings.t --- DBD-mysql-4.00-orig/t/warnings.t 1970-01-01 02:00:00.000000000 +0200 +++ DBD-mysql-4.00-mine/t/warnings.t 2007-01-07 19:01:49.000000000 +0200 @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use strict; +use vars qw($test_dsn $test_user $test_password $mdriver $state); +use DBI; +use Carp qw(croak); +use Data::Dumper; + +$^W =1; + + +use DBI; +$mdriver = ""; +my ($row, $sth, $dbh); +foreach my $file ("lib.pl", "t/lib.pl", "DBD-mysql/t/lib.pl") { + do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n"; + exit 10; + } + if ($mdriver ne '') { + last; + } +} + +sub ServerError() { + print STDERR ("Cannot connect: ", $DBI::errstr, "\n", + "\tEither your server is not up and running or you have no\n", + "\tpermissions for acessing the DSN $test_dsn.\n", + "\tThis test requires a running server and write permissions.\n", + "\tPlease make sure your server is running and you have\n", + "\tpermissions, then retry.\n"); + exit 10; +} + +while(Testing()) +{ + my ($sth); + Test($state or $dbh = + DBI->connect($test_dsn, $test_user, $test_password, + { RaiseError => 1, AutoCommit => 1})) or ServerError() ; + + Test($state or $sth = $dbh->prepare("drop table if exists no_such_table")) or + DbiError($dbh->err, $dbh->errstr); + + Test($state or $sth->execute()) or + DbiError($dbh->err, $dbh->errstr); + + Test($state or $sth->{mysql_warning_count} == 1) or + DbiError($dbh->err, $dbh->errstr); +}