def _release(self, space, w_connection, mode): from pypy.module.oracle.interp_connect import W_Connection connection = space.interp_w(W_Connection, w_connection) self.checkConnected(space) if connection.sessionPool is not self: raise OperationError( get(space).w_ProgrammingError, space.wrap("connection not acquired with this session pool")) # attempt a rollback status = roci.OCITransRollback(connection.handle, connection.environment.errorHandle, roci.OCI_DEFAULT) # if dropping the connection from the pool, ignore the error if mode != roci.OCI_SESSRLS_DROPSESS: self.environment.checkForError(status, "SessionPool_Release(): rollback") # release the connection status = roci.OCISessionRelease(connection.handle, connection.environment.errorHandle, None, 0, mode) self.environment.checkForError( status, "SessionPool_Release(): release session") # ensure that the connection behaves as closed connection.sessionPool = None connection.handle = lltype.nullptr(roci.OCISvcCtx.TO)
def rollback(self, space): # make sure we are actually connected self._checkConnected(space) status = roci.OCITransRollback(self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) self.environment.checkForError(status, "Connection_Rollback()")
def destructor(self): assert isinstance(self, W_Connection) if self.release: roci.OCITransRollback(self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) roci.OCISessionRelease(self.handle, self.environment.errorHandle, None, 0, roci.OCI_DEFAULT) else: if self.sessionHandle: roci.OCITransRollback(self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) roci.OCISessionEnd(self.handle, self.environment.errorHandle, self.sessionHandle, roci.OCI_DEFAULT) if self.serverHandle: roci.OCIServerDetach(self.serverHandle, self.environment.errorHandle, roci.OCI_DEFAULT)
def __del__(self): if self.release: roci.OCITransRollback( self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) roci.OCISessionRelease( self.handle, self.environment.errorHandle, None, 0, roci.OCI_DEFAULT) else: if self.sessionHandle: roci.OCITransRollback( self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) roci.OCISessionEnd( self.handle, self.environment.errorHandle, self.sessionHandle, roci.OCI_DEFAULT) if self.serverHandle: roci.OCIServerDetach( self.serverHandle, self.environment.errorHandle, roci.OCI_DEFAULT)
def close(self, space): # make sure we are actually connnected self._checkConnected(space) # perform a rollback status = roci.OCITransRollback(self.handle, self.environment.errorHandle, roci.OCI_DEFAULT) self.environment.checkForError(status, "Connection_Close(): rollback") # logoff of the server if self.sessionHandle: status = roci.OCISessionEnd(self.handle, self.environment.errorHandle, self.sessionHandle, roci.OCI_DEFAULT) self.environment.checkForError(status, "Connection_Close(): end session") roci.OCIHandleFree(self.handle, roci.OCI_HTYPE_SVCCTX) self.handle = lltype.nullptr(roci.OCISvcCtx.TO)