Bug #23935 DBD::MySQL does not set sqlstate (patch provded)
Submitted: 3 Nov 2006 12:26 Modified: 23 Dec 2006 20:51
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S3 (Non-critical)
Version:3.0008_1 OS:Linux (Linux)
Assigned to: Bugs System CPU Architecture:Any
Tags: Contribution

[3 Nov 2006 12:26] Philip Stoev
Description:
Hello,

DBD::Mysql does not communicate the sqlstate value returned from the server to the client application. While this is not a big deal, since for many errors the server returns a default, and this default is no better than the DBI default, there are already applications that examine and require sqlstate.

How to repeat:
What I did is construct a fake MySQL server that forwards (via DBI) all queries to a real MySQL server. I noticed that in that setup the mysql test suite fails because the real server returns a HY100 sqlstate on certain errors, where the DBI returns its own default, which my fake server passes to the test sute and mysqltest detects the discrepancy.

Suggested fix:
I will upload a crude patch along with this bug report.
[3 Nov 2006 12:27] Philip Stoev
DBD::MySQL patch implementing sqlstate

Attachment: sqlstate.patch (text/plain), 14.75 KiB.

[5 Nov 2006 20:19] MySQL Verification Team
Thank you for the bug report and suggested patch.
[11 Dec 2006 18:40] Patrick Galbraith
I will take a look at this patch
[12 Dec 2006 18:14] Patrick Galbraith
Philip,

Thanks for the patch!

Added to latest dev 3.0009 branch, soon to release.
[12 Dec 2006 20:51] Philip Stoev
Thank you very much. Just a quick note though -- the patch only sets sqlstate upon errors. Maybe sqlstate should also be set during normal operations as well?
[23 Dec 2006 20:51] Patrick Galbraith
Nothing to document, in version 4.0.0 in current svn tree for DBD::mysql