Easily produced: DBD::mysql outputs to stderr and no DBI->errstr

Easily produced: DBD::mysql outputs to stderr and no DBI->errstr

am 27.03.2006 18:35:04 von Martin.Evans

The following simple script:

==========
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(
'DBI:mysql:test', 'xxx', 'yyy',
{PrintError => 0, RaiseError=>0}
) or die "DBI::errstr";

$dbh->do(q/create table mytest (a int, b char(20))/);
$dbh->do(q/delete from mytest where type = ?/, undef, 'three');

print "Error: ", $dbh->errstr, "\n";
==========

produces:

DO: Something wrong while try to prepare query Unknown column 'type' in 'where
clause'
Use of uninitialized value in print at x.pl line 13.
Error:

i.e. it is writing directly to stderr (the bit starting DO:) and not setting the
error string. The problem seems to be in DBD::mysql mysql.xs which contains a
number of fprintf(stderr,) calls without calling DBD::mysql do_error. I think
they need changing to something like this:

--- mysql.xs.orig Mon Mar 27 17:10:18 2006
+++ mysql.xs.mine Mon Mar 27 17:27:44 2006
@@ -510,8 +510,7 @@
}
else
{
- fprintf(stderr,"DO: Something wrong while try to prepare query %s\n",
- mysql_error(&imp_dbh->mysql));
+ do_error(dbh, mysql_errno(&imp_dbh->mysql),
mysql_error(&imp_dbh->mysql));

retval=-2;
mysql_stmt_close(stmt);

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com

FWD: Re: Easily produced: DBD::mysql outputs to stderr and no DBI->errstr

am 27.03.2006 18:51:32 von Martin.Evans

Could the list maintainer please remove this person - every time I post I get
one of these:

Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com


-----FW: <20060327163939.30556.qmail@zlinuxweb.zajil.net>-----

Date: 27 Mar 2006 19:39:39 +0300
From: nayeem@gulfnetksa.com
To: martin.evans@easysoft.com
Subject: Re: Easily produced: DBD::mysql outputs to stderr and no
DBI->errstr
Cc:

Please use nayeem@ksa.zajil.com instead of nayeem@gulfnetksa.com

--------------End of forwarded message-------------------------