More problems with DBD::mysql (and resolution?)



Hi again,

I am still struggling to make DBD::mysql work with my application. The
problem I posted feb 10 in this list - "Strange
selectall_hashref/fetchall_hashref problem with DBD::mysql" got no responses so
far and I'm still stumped as to why it does not work (I've had to junk
DBD::mysql for that task at the moment and replace it with DBD::ODBC and myodbc)

However, I have a new issue (and possible resolution):

$dbh->{RaiseError} = 1;
my $sth = $dbh->prepare('fred bloggs');

obviously invalid SQL but when I run this against DBD::mysql 3.0002_4:

o I get undef back but RaiseError not called
o "DBD::mysql::db prepare warning: at x.pl line nnn."
o the trace shows:

-> prepare for DBD::mysql::db (DBI::db=HASH(0x8320cbc)~0x8322e70 'fred blogg
s')
New DBI::st (for DBD::mysql::st, parent=DBI::db=HASH(0x8322e70), id=)
dbih_setup_handle(DBI::st=HASH(0x8323014)=>DBI::st=HASH(0x8506858), DBD::mys
ql::st, 8323020, Null!)
dbih_make_com(DBI::db=HASH(0x8322e70), 8527880, DBD::mysql::st, 248, 0) thr#
0
> dbd_st_prepare MYSSQL_VERSION_ID 50015
error 0 recorded:

It would appear the code around line 2313 of dbdimp.c:

if (mysql_stmt_prepare(imp_sth->stmt, statement, strlen(statement)))
{

mysql_stmt_close(imp_sth->stmt);
imp_sth->stmt= NULL;
do_error(sth, mysql_errno(&imp_dbh->mysql), mysql_error(&imp_dbh->mysql));

/* For commands that are not supported by server side prepared statement
mechanism lets try to pass them through regular API */
if (mysql_errno(&imp_dbh->mysql) == ER_UNSUPPORTED_PS)
imp_sth->use_server_side_prepare= 0;
else
return FALSE;
}

attempts to use mysql_error AFTER closing the mysql statement and the
closing of the statement clears mysql_error on a connection handle
(I'm not too sure why as the docs say "A rule of thumb is that all
functions that have to ask the server for information reset
mysql_error() if they succeed."). If you move the call to do_error
(above) up to be the first thing in the block when mysql_stmt_prepare
fails the correct things seems to happen:

DBD::mysql::db prepare failed: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'fred bloggs' at line 1 at
x.pl line n.

I am not that familiar with MySQL's client library but it does appear
to have a mysql_stmt_error(stmt) function which the examples on the
MySQL web site use. Whether this should be used in preference to
mysql_error in this case I do not know.

If anyone has any ideas on my previous posting about a problems with DBD::mysql
and selectall_hashref I'd love to hear from you.

I am now running with at least 3 patches to DBD::mysql 3.0002_4 which I've
posted here. Patrick Galbraith posted inviting discussion 31-Jan.
Would you like me to roll all the patches in to one? Could you publish
a list of the bugs you've been mailed about so we can avoid spending time
tracking the same issues down.

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

.



Relevant Pages

  • Re: multi-master with mysql backend
    ... All DNS servers are slaves to a single, ... being assigned to loopback interface on the server. ... I'd keep two copies of the BIND config, one that has all the zones as "master", and one that has all the zones as "slave". ... No need for rsync or mysql, BIND replication does all the work for you. ...
    (comp.protocols.dns.bind)
  • Re: multi-master with mysql backend
    ... Subject: multi-master with mysql backend ... All DNS servers are slaves to a single, ... being assigned to loopback interface on the server. ... No need for rsync or mysql, BIND replication does all the work for you. ...
    (comp.protocols.dns.bind)
  • RE: MySQL/PHPMyAdmin on FC3 Connection Problem
    ... // You can disable a server config entry by setting host to ''. ... MySQL server ... MySQL control user settings ... table to describe the display fields ...
    (Fedora)
  • Re: IIS Hack : Anyone explain cause...
    ... it looks like you cleaned up the server -- if you care about security, ... Microsoft tries and mostly succeeds to release patches PRIOR to ... weeks/months/years prior to exploitation. ... > protected rant as we all know that IIS and indeed lots of software has ...
    (microsoft.public.inetserver.iis)
  • Re: KDE is now broken (Fwd: Heads-up: KDE4 hitting testing tonight (UTC) )
    ... don't want to run an akonadi server either, ... KDE 4.0 was available. ... kmail) and I do not have a mysql server installed. ...
    (Debian-User)