Author: jimw
Date: Mon Mar 19 12:06:52 2007
New Revision: 9276
Added:
DBD-mysql/trunk/t/warnings.t
Modified:
DBD-mysql/trunk/ChangeLog
DBD-mysql/trunk/dbdimp.c
DBD-mysql/trunk/dbdimp.h
DBD-mysql/trunk/lib/DBD/mysql.pm
Log:
Add support for mysql_warning_count statement handle attribute. (Bug #25457,
patch from Philip Stoev)
Modified: DBD-mysql/trunk/ChangeLog
==============================================================================
--- DBD-mysql/trunk/ChangeLog (original)
+++ DBD-mysql/trunk/ChangeLog Mon Mar 19 12:06:52 2007
@@ -1,4 +1,6 @@
<unreleased> Patrick Galbraith <patg@stripped> Jim Winstead
<jimw@stripped> (4.004)
+* Add support for mysql_warning_count statement handle attribute. (Bug #25457,
+ patch from Philip Stoev)
* Add support for mysql_multi_statements connection option. (RT #12322, based
on patch from Doug Morris)
Modified: DBD-mysql/trunk/dbdimp.c
==============================================================================
--- DBD-mysql/trunk/dbdimp.c (original)
+++ DBD-mysql/trunk/dbdimp.c Mon Mar 19 12:06:52 2007
@@ -2802,6 +2802,7 @@
hv_delete((HV*)SvRV(sth), "mysql_table", 11, G_DISCARD);
hv_delete((HV*)SvRV(sth), "mysql_type", 10, G_DISCARD);
hv_delete((HV*)SvRV(sth), "mysql_type_name", 15, G_DISCARD);
+ hv_delete((HV*)SvRV(sth), "mysql_warning_count", 20, G_DISCARD);
/* Adjust NUM_OF_FIELDS - which also adjusts the row buffer size */
DBIc_NUM_FIELDS(imp_sth)= 0; /* for DBI <= 1.53 */
@@ -3211,6 +3212,8 @@
}
}
+ imp_sth->warning_count = mysql_warning_count(&imp_dbh->mysql);
+
if (dbis->debug >= 2)
{
/*
@@ -4152,6 +4155,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
Modified: DBD-mysql/trunk/dbdimp.h
==============================================================================
--- DBD-mysql/trunk/dbdimp.h (original)
+++ DBD-mysql/trunk/dbdimp.h Mon Mar 19 12:06:52 2007
@@ -237,6 +237,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 */
Modified: DBD-mysql/trunk/lib/DBD/mysql.pm
==============================================================================
--- DBD-mysql/trunk/lib/DBD/mysql.pm (original)
+++ DBD-mysql/trunk/lib/DBD/mysql.pm Mon Mar 19 12:06:52 2007
@@ -1353,8 +1353,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
Added: DBD-mysql/trunk/t/warnings.t
==============================================================================
--- (empty file)
+++ DBD-mysql/trunk/t/warnings.t Mon Mar 19 12:06:52 2007
@@ -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);
+}
| Thread |
|---|
| • [svn:DBD-mysql] r9276 - in DBD-mysql/trunk: . lib/DBD t | jimw | 19 Mar |