I've started working with transactions in mysql and I believe I've run across a 
bug in libdbi's mysql driver.

When you get a lock timeout on a select, it is reported by mysql by returning
a null from mysql_store_result.  This currently isn't noticed by the driver.

In dbd_query (and dbd_query_null) in dbd_mysql.c there should be 3 cases:

mysql_store_result() != null                              good select
mysql_store_result() = null & mysql_field_count() = 0     good insert ...
mysql_store_result() = null & mysql_field_count() > 0     error on select

I'm not sure if a patch would be as simple as:

---

        res = mysql_store_result((MYSQL *)conn->connection);
        
+       if(!res && !mysql_field_count((MYSQL *)conn->connection))
+          return NULL;

        /* if res is null, the query was something that doesn't return rows 
(like an INSERT) */
        result = _dbd_result_create(conn, (void *)res, (res ? 
mysql_num_rows(res) : 0), 
                                                                
mysql_affected_rows((MYSQL *)conn->connection));

---

I hope I've explained this so you can understand it.

I have a couple of test programs if it would help.

Feel free to let me know if you have any questions or if you would like 
additional information.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel

Reply via email to