nakagami / pyfirebirdsql

Python DBAPI module for FirebirdSQL
BSD 2-Clause "Simplified" License
71 stars 29 forks source link

fbcore.Connection.close() bug or not? #79

Closed gzip4 closed 1 year ago

gzip4 commented 5 years ago

fbcore.Connection.close()

    def close(self):
        DEBUG_OUTPUT("Connection::close()")
        if self.sock is None:
            return
        if self.db_handle:           # <= this condition
            if self.is_services:
                self._op_service_detach()
            else:
                self._op_detach()
            (h, oid, buf) = self._op_response()
        self.sock.close()
        self.sock = None
        self.db_handle = None

maybe there should be:

        if not self.db_handle is None:

In later case exception is raising when open transactions are left. But when self.db_handle is zero, self._op_detach() is skipped quiet. I don't know is that a bug or not?

nakagami commented 5 years ago

Umm, It's seems a bug. But probablry socket close by server because socket closed.

I fix close() method, and explicit close, thanks.

nakagami commented 5 years ago

Sorry, It does not work good. revert now.

gzip4 commented 5 years ago

Sorry, It does not work good. revert now.

I don't understand why it does not work good? We check db_handle to be None or number, that's right, but zero is not None. What if server gives us db_handle other than zero? Why should we op_detach() at all, just shut the socket up and good by ;-)

nakagami commented 5 years ago

I'm going to develop django firebird backend https://github.com/nakagami/djfirebirdsql I think somethong wrong about djfirebirdsql, But broken django tests with 5b35698dd3c10fca8d3b0749437553f32538a34d modification.

I hope to fix dfjfirebirdsql at first

gzip4 commented 5 years ago

Ok, good luck. Thank you for this library, it helps me a lot to understand internals of protocol. I'm writing some kind of port of it to Common Lisp.

nakagami commented 1 year ago

It's been a while since I thought about it, figured out the problem with the issue, and fixed it.