firebird.lib.trace¶
Enums¶
- class firebird.lib.trace.Status(value)[source]¶
Bases:
EnumRepresents the outcome status of a traced operation.
- FAILED = 'F'¶
- OK = ' '¶
- UNAUTHORIZED = 'U'¶
- UNKNOWN = '?'¶
- class firebird.lib.trace.Event(value)[source]¶
Bases:
IntEnumEnumerates the different types of events captured in a trace log.
- ATTACH_DATABASE = 7¶
- ATTACH_SERVICE = 26¶
- CLOSE_CURSOR = 18¶
- COMMIT_RETAINING = 12¶
- COMMIT_TRANSACTION = 10¶
- COMPILE_BLR = 36¶
- CREATE_DATABASE = 5¶
- DETACH_DATABASE = 8¶
- DETACH_SERVICE = 27¶
- DROP_DATABASE = 6¶
- ERROR = 30¶
- EXECUTE_BLR = 37¶
- EXECUTE_DYN = 38¶
- EXECUTE_FUNCTION_FINISH = 22¶
- EXECUTE_FUNCTION_START = 21¶
- EXECUTE_PROCEDURE_FINISH = 24¶
- EXECUTE_PROCEDURE_START = 23¶
- EXECUTE_STATEMENT_FINISH = 16¶
- EXECUTE_STATEMENT_START = 15¶
- EXECUTE_TRIGGER_FINISH = 20¶
- EXECUTE_TRIGGER_START = 19¶
- FREE_STATEMENT = 17¶
- PREPARE_STATEMENT = 14¶
- QUERY_SERVICE = 28¶
- ROLLBACK_RETAINING = 13¶
- ROLLBACK_TRANSACTION = 11¶
- SET_CONTEXT = 29¶
- START_SERVICE = 25¶
- START_TRANSACTION = 9¶
- SWEEP_FAILED = 35¶
- SWEEP_FINISH = 34¶
- SWEEP_PROGRESS = 33¶
- SWEEP_START = 32¶
- TRACE_FINI = 4¶
- TRACE_INIT = 2¶
- TRACE_SUSPENDED = 3¶
- UNKNOWN = 1¶
- WARNING = 31¶
Dataclasses¶
- class firebird.lib.trace.AttachmentInfo(attachment_id: int, database: str, charset: str, protocol: str, address: str, user: str, role: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceInfoInformation about database attachment.
- Parameters:
- class firebird.lib.trace.TransactionInfo(attachment_id: int, transaction_id: int, initial_id: int, options: list[str])[source]¶
Bases:
TraceInfoInformation about transaction.
- class firebird.lib.trace.ServiceInfo(service_id: int, user: str, protocol: str, address: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceInfoInformation about service attachment.
- Parameters:
- class firebird.lib.trace.SQLInfo(sql_id: int, sql: str, plan: str)[source]¶
Bases:
TraceInfoInformation about SQL statement.
- class firebird.lib.trace.ParamSet(par_id: int, params: list[tuple[str, Any]])[source]¶
Bases:
TraceInfoInformation about set of parameters.
- class firebird.lib.trace.AccessStats(table: str, natural: int, index: int, update: int, insert: int, delete: int, backout: int, purge: int, expunge: int)[source]¶
Bases:
TraceInfoTable access statistics.
- Parameters:
- backout: int¶
Number of rows where a new primary record version or a change to an existing primary record version is backed out due to rollback or savepoint undo
- expunge: int¶
Number of rows where record version chain is being deleted due to deletions by transactions older than OAT
- class firebird.lib.trace.EventTraceInit(event_id: int, timestamp: datetime, session_name: str)[source]¶
Bases:
TraceEventTrace session initialized trace event
- class firebird.lib.trace.EventTraceSuspend(event_id: int, timestamp: datetime, session_name: str)[source]¶
Bases:
TraceEventTrace session suspended trace event
- class firebird.lib.trace.EventTraceFinish(event_id: int, timestamp: datetime, session_name: str)[source]¶
Bases:
TraceEventTrace session finished trace event
- class firebird.lib.trace.EventCreate(event_id: int, timestamp: datetime, status: Status, attachment_id: int, database: str, charset: str, protocol: str, address: str, user: str, role: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceEventCreate database trace event
- Parameters:
- class firebird.lib.trace.EventDrop(event_id: int, timestamp: datetime, status: Status, attachment_id: int, database: str, charset: str, protocol: str, address: str, user: str, role: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceEventDrop database trace event
- Parameters:
- class firebird.lib.trace.EventAttach(event_id: int, timestamp: datetime, status: Status, attachment_id: int, database: str, charset: str, protocol: str, address: str, user: str, role: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceEventDatabase attach trace event
- Parameters:
- class firebird.lib.trace.EventDetach(event_id: int, timestamp: datetime, status: Status, attachment_id: int, database: str, charset: str, protocol: str, address: str, user: str, role: str, remote_process: str, remote_pid: int)[source]¶
Bases:
TraceEventDatabase detach trace event
- Parameters:
- class firebird.lib.trace.EventTransactionStart(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, options: list[str])[source]¶
Bases:
TraceEventTransaction start trace event
- Parameters:
- class firebird.lib.trace.EventCommit(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, options: list[str], run_time: int, reads: int, writes: int, fetches: int, marks: int)[source]¶
Bases:
TraceEventCommit trace event
- Parameters:
- class firebird.lib.trace.EventRollback(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, options: list[str], run_time: int, reads: int, writes: int, fetches: int, marks: int)[source]¶
Bases:
TraceEventRollback trace event
- Parameters:
- class firebird.lib.trace.EventCommitRetaining(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, options: list[str], new_transaction_id: int, run_time: int, reads: int, writes: int, fetches: int, marks: int)[source]¶
Bases:
TraceEventCommit retaining trace event
- Parameters:
- class firebird.lib.trace.EventRollbackRetaining(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, options: list[str], new_transaction_id: int, run_time: int, reads: int, writes: int, fetches: int, marks: int)[source]¶
Bases:
TraceEventRollback retaining trace event
- Parameters:
- class firebird.lib.trace.EventPrepareStatement(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, statement_id: int, sql_id: int, prepare_time: int)[source]¶
Bases:
TraceEventPrepare statement trace event
- Parameters:
- class firebird.lib.trace.EventStatementStart(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, statement_id: int, sql_id: int, param_id: int)[source]¶
Bases:
TraceEventStatement start trace event
- Parameters:
- class firebird.lib.trace.EventStatementFinish(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, statement_id: int, sql_id: int, param_id: int, records: int, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventStatement finish trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventFreeStatement(event_id: int, timestamp: datetime, attachment_id: int, statement_id: int, sql_id: int)[source]¶
Bases:
TraceEventFree statement trace event
- class firebird.lib.trace.EventCloseCursor(event_id: int, timestamp: datetime, attachment_id: int, statement_id: int, sql_id: int)[source]¶
Bases:
TraceEventClose cursor trace event
- class firebird.lib.trace.EventTriggerStart(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, trigger: str, table: str, event: str)[source]¶
Bases:
TraceEventTrigger start trace event
- Parameters:
- class firebird.lib.trace.EventTriggerFinish(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, trigger: str, table: str, event: str, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventTrigger finish trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventProcedureStart(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, procedure: str, param_id: int)[source]¶
Bases:
TraceEventProcedure start trace event
- Parameters:
- class firebird.lib.trace.EventProcedureFinish(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, procedure: str, param_id: int, records: int, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventProcedure finish trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventFunctionStart(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, function: str, param_id: int)[source]¶
Bases:
TraceEventFunction start trace event
- Parameters:
- class firebird.lib.trace.EventFunctionFinish(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, function: str, param_id: int, returns: tuple[str, Any], run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventFunction finish trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventServiceAttach(event_id: int, timestamp: datetime, status: Status, service_id: int)[source]¶
Bases:
TraceEventService attach trace event
- class firebird.lib.trace.EventServiceDetach(event_id: int, timestamp: datetime, status: Status, service_id: int)[source]¶
Bases:
TraceEventService detach trace event
- class firebird.lib.trace.EventServiceStart(event_id: int, timestamp: datetime, status: Status, service_id: int, action: str, parameters: list[str])[source]¶
Bases:
TraceEventService start trace event
- Parameters:
- class firebird.lib.trace.EventServiceQuery(event_id: int, timestamp: datetime, status: Status, service_id: int, action: str, sent: list[str], received: list[str])[source]¶
Bases:
TraceEventService query trace event
- Parameters:
- class firebird.lib.trace.EventSetContext(event_id: int, timestamp: datetime, attachment_id: int, transaction_id: int, context: str, key: str, value: str)[source]¶
Bases:
TraceEventset context variable trace event
- Parameters:
- class firebird.lib.trace.EventError(event_id: int, timestamp: datetime, attachment_id: int, place: str, details: list[str])[source]¶
Bases:
TraceEventError trace event
- class firebird.lib.trace.EventWarning(event_id: int, timestamp: datetime, attachment_id: int, place: str, details: list[str])[source]¶
Bases:
TraceEventWarning trace event
- class firebird.lib.trace.EventServiceError(event_id: int, timestamp: datetime, service_id: int, place: str, details: list[str])[source]¶
Bases:
TraceEventService error trace event
- class firebird.lib.trace.EventServiceWarning(event_id: int, timestamp: datetime, service_id: int, place: str, details: list[str])[source]¶
Bases:
TraceEventService warning trace event
- class firebird.lib.trace.EventSweepStart(event_id: int, timestamp: datetime, attachment_id: int, oit: int, oat: int, ost: int, next: int)[source]¶
Bases:
TraceEventSweep start trace event
- Parameters:
- class firebird.lib.trace.EventSweepProgress(event_id: int, timestamp: datetime, attachment_id: int, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventSweep progress trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventSweepFinish(event_id: int, timestamp: datetime, attachment_id: int, oit: int, oat: int, ost: int, next: int, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventSweep finished trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
- class firebird.lib.trace.EventSweepFailed(event_id: int, timestamp: datetime, attachment_id: int)[source]¶
Bases:
TraceEventSweep failed trace event
- class firebird.lib.trace.EventBLRCompile(event_id: int, timestamp: datetime, status: Status, attachment_id: int, statement_id: int, content: str, prepare_time: int)[source]¶
Bases:
TraceEventBLR compile trace event
- Parameters:
- class firebird.lib.trace.EventBLRExecute(event_id: int, timestamp: datetime, status: Status, attachment_id: int, transaction_id: int, statement_id: int, content: str, run_time: int, reads: int, writes: int, fetches: int, marks: int, access: list[AccessStats])[source]¶
Bases:
TraceEventBLR execution trace event
- Parameters:
- access: list[AccessStats]¶
list with table access statistics
Classes¶
- class firebird.lib.trace.TraceInfo[source]¶
Bases:
objectBase class for informational blocks extracted from the trace log (e.g., attachment details, SQL text).
- class firebird.lib.trace.TraceEvent[source]¶
Bases:
objectBase class for specific events recorded in the trace log (e.g., attach database, start transaction).
- class firebird.lib.trace.TraceParser[source]¶
Bases:
objectParses the textual output of a Firebird trace session.
This class processes lines from a trace log, identifying individual events and associated information blocks. It maintains internal state to track database attachments, transactions, services, unique SQL statements, and parameter sets, assigning unique IDs where appropriate.
It can be used in two ways:
Iteratively via
parse(lines): Processes an entire iterable of log lines and yields parsedTraceEventandTraceInfoobjects.Incrementally via
push(line): Processes one line at a time, returning a list of parsed objects when a complete event block is detected.
Parsed
TraceInfoobjects related to an event are typically yielded/returned before the correspondingTraceEventobject.- parse(lines: Iterable)[source]¶
Parse output from Firebird trace session.
- Parameters:
lines (Iterable) – Iterable that return lines produced by Firebird trace session.
- Yields:
TraceEventandTraceInfodataclasses describing individual trace log entries/events.- Raises:
firebird.base.types.Error – When any problem is found in input stream.
- parse_event(trace_block: list[str]) TraceEvent[source]¶
Parse single trace event.
- push(line: str | STOP) list[TraceEvent | TraceInfo] | None[source]¶
Push parser.
- Parameters:
line (str | STOP) – Single trace output line, or
STOPsentinel.- Returns:
None, or list with parsed elements (single event preceded by any info blocks related to it).
- Raises:
Error – When pushed line is not recognized as part of trace event.
- Return type:
list[TraceEvent | TraceInfo] | None
- retrieve_info() list[TraceInfo][source]¶
Returns list of
TraceInfoinstances produced by lastparse_event()call.The list could be empty.
Important
The internal buffer for info instances is cleared after call to this method, so all produced info instances are returned only once.
- has_statement_free: bool¶
Parsing option indicating that parsed trace contains
FREE_STATEMENTevents. This has impact on cleanup ofSQLInfoID cache. When True, the SQLInfo is discarded when its FREE_STATEMENT event is processed. When False, the SQLInfo is discarded when its EXECUTE_STATEMENT_FINISH is processed.
- next_param_id: int¶
Sequence id that would be assigned to next parsed unique parameter (starts with 1)
- next_sql_id: int¶
Sequence id that would be assigned to next parsed unique SQL command (starts with 1)
- param_map¶
Dictionary that maps parameters (statement or procedure) keys to internal ids