Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#117 self not NULL but closed in _mysql_string_literal

MySQLdb-1.1
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2004-12-30
Mike Verdone
No

Hi,

we're trying to track down a particularily icky bug
that seems to be somewhere between our application code
and MySQL-python-test 1.1.7. I'll give as much detail
as possible and continue to leave comments as I find
things.

Our setup is as follows:

MySQL 4.1.8
MySQL-Python 1.1.7
Python 2.2.3

Arch is i386 and we've seen this issue on Red Hat 7.3
and Red Hat ES 3.0 systems. I know that Python 2.2
isn't supported but unfortunately we're stuck with it
at the moment.

Our application caches MySQLdb connections to many
different database servers and some connections are
opened and closed while others remain intact. The issue
only happens on connection 'A' if a connection 'B' has
been closed before the query is issued on 'A'.
Unfortunately I haven't been able to make a test case
to demonstrate it.

The problem happens in _mysql_string_literal. On line
826 of _mysql.c is the check "if (self)" followed on
line 827 by "check_connection(self)". It seems that in
some cases self is set but check_connection fails. On
the Python side an exception InterfaceError: (0, '') is
raised.

I can work around the problem by changing line 826 to
"if (self && self->open)" however I'm not sure if
that's just working around a bigger problem. Is it
acceptable for self to be set and be closed in this
function? If so, could you make the change to _mysql.c
to handle this case?

Thank you,

Mike.

Discussion

  • Andy Dustman
    Andy Dustman
    2004-12-30

    Logged In: YES
    user_id=71372

    This has been fixed in the current CVS tree.

     
  • Mike Verdone
    Mike Verdone
    2004-12-30

    Logged In: YES
    user_id=1186966

    I checked out MySQLdb from the trunk and installed it but
    the issue still exists. The workaround still works.

     
  • Andy Dustman
    Andy Dustman
    2004-12-30

    Logged In: YES
    user_id=71372

    I fixed _mysql_string_literal, but I also need to fix
    _mysql_escape_string, which has the same problem.

    Make sure you have at least revision 1.61 of _mysql.c; the
    anonymous CVS mirrors are not updated live, and sometimes it
    takes awhile for changes to propogate.

     
  • Mike Verdone
    Mike Verdone
    2004-12-30

    Logged In: YES
    user_id=1186966

    Ah... I didn't know the anon CVS servers were delayed. I'll
    wait for 1.61 to show up and give it a try. Thank you.

     
  • Mike Verdone
    Mike Verdone
    2004-12-31

    Logged In: YES
    user_id=1186966

    Just pulled out MySQLdb with _mysql.c 1.62 from cvs and it
    works fine. Sweet.