Example #1
0
 def __get_dbobject(self):
     obj_name = self._attributes['MON$OBJECT_NAME']
     obj_type = self._attributes['MON$OBJECT_TYPE']
     if obj_type == 5: # procedure
         return self.monitor._con.schema.get_procedure(obj_name)
     elif obj_type == 2: # trigger
         return self.monitor._con.schema.get_trigger(obj_name)
     else:
         raise fdb.ProgrammingError("Unrecognized object type '%d'" % obj_type)
Example #2
0
    def bind(self, connection):
        """Bind this instance to specified :class:`~fdb.Connection`.

        :param connection: :class:`~fdb.Connection` instance.

        :raises fdb.ProgrammingError: If Monitor object was set as internal (via
            :meth:`_set_as_internal`) or database has ODS lower than 11.1.
        """
        if self.__internal:
            raise fdb.ProgrammingError("Call to 'bind' not allowed for embedded Monitor.")
        if self._con:
            self.close()
        if connection.ods < fdb.ODS_FB_21:
            raise fdb.ProgrammingError("Monitoring tables are available only " \
                                       "for databases with ODS 11.1 and higher.")
        self._con = connection
        self._ic = self._con.trans(fdb.ISOLATION_LEVEL_READ_COMMITED_RO).cursor()
        self.clear()
Example #3
0
    def terminate(self):
        """Terminates execution of statement.

        :raises fdb.ProgrammingError: If this attachement is current session.
        """
        if self.attachment == self.monitor.this_attachment:
            raise fdb.ProgrammingError("Can't terminate statement from current session.")
        else:
            self.monitor._ic.execute('delete from mon$statements where mon$statement_id = ?',
                                     (self.id,))
Example #4
0
    def close(self):
        """Sever link to :class:`~fdb.Connection`.

        :raises fdb.ProgrammingError: If Monitor object was set as internal (via
            :meth:`_set_as_internal`).
        """
        if self.__internal:
            raise fdb.ProgrammingError("Call to 'close' not allowed for embedded Monitor.")
        self._close()
        self.clear()
Example #5
0
    def __get_owner(self):
        def find(seq):
            for x in seq:
                if x.stat_id == self.stat_id:
                    return x
            return None

        obj_type = self.group
        if obj_type == STAT_DATABASE:
            return self.monitor.db
        elif obj_type == STAT_ATTACHMENT:
            return find(self.monitor.attachments)
        elif obj_type == STAT_TRANSACTION:
            return find(self.monitor.transactions)
        elif obj_type == STAT_STATEMENT:
            return find(self.monitor.statements)
        elif obj_type == STAT_CALL:
            return find(self.monitor.callstack)
        else:
            raise fdb.ProgrammingError("Unrecognized table stat group '%d'" % obj_type)
Example #6
0
 def __fail_if_closed(self):
     if self.closed:
         raise fdb.ProgrammingError("Monitor is not binded to connection.")