FirebirdSQL logo

MON$CALL_STACK

MON$CALL_STACK displays calls to the stack from queries executing in stored procedures and triggers.

Column Name Data Type Description

MON$CALL_ID

BIGINT

Call identifier

MON$STATEMENT_ID

BIGINT

The identifier of the top-level SQL statement, the one that initiated the chain of calls.Use this identifier to find the records about the active statement in the MON$STATEMENTS table

MON$CALLER_ID

BIGINT

The identifier of the calling trigger or stored procedure

MON$OBJECT_NAME

CHAR(63)

PSQL object name

MON$OBJECT_TYPE

SMALLINT

PSQL object type:

2 - trigger
5 - stored procedure
15 - stored function

MON$TIMESTAMP

TIMESTAMP WITH TIME ZONE

The date and time when the call was started

MON$SOURCE_LINE

INTEGER

The number of the source line in the SQL statement being executed at the moment of the snapshot

MON$SOURCE_COLUMN

INTEGER

The number of the source column in the SQL statement being executed at the moment of the snapshot

MON$STAT_ID

INTEGER

Statistics identifier

MON$PACKAGE_NAME

CHAR(63)

Package name for stored procedures or functions in a package

MON$COMPILED_STATEMENT_ID

BIGINT

Compiled statement id

Note

Information about calls during the execution of the EXECUTE STATEMENT statement does not get into the call stack.

Get the call stack for all connections except your own
WITH RECURSIVE
  HEAD AS (
    SELECT
      CALL.MON$STATEMENT_ID, CALL.MON$CALL_ID,
      CALL.MON$OBJECT_NAME, CALL.MON$OBJECT_TYPE
    FROM MON$CALL_STACK CALL
    WHERE CALL.MON$CALLER_ID IS NULL
    UNION ALL
    SELECT
      CALL.MON$STATEMENT_ID, CALL.MON$CALL_ID,
      CALL.MON$OBJECT_NAME, CALL.MON$OBJECT_TYPE
    FROM MON$CALL_STACK CALL
      JOIN HEAD ON CALL.MON$CALLER_ID = HEAD.MON$CALL_ID
  )
SELECT MON$ATTACHMENT_ID, MON$OBJECT_NAME, MON$OBJECT_TYPE
FROM HEAD
  JOIN MON$STATEMENTS STMT ON STMT.MON$STATEMENT_ID = HEAD.MON$STATEMENT_ID
WHERE STMT.MON$ATTACHMENT_ID <> CURRENT_CONNECTION

MON$CONTEXT_VARIABLES

MON$CONTEXT_VARIABLES displays information about custom context variables.

Column Name Data Type Description

MON$ATTACHMENT_ID

BIGINT

Connection identifier.It contains a valid value only for a connection-level context variable.For transaction-level variables it is NULL.

MON$TRANSACTION_ID

BIGINT

Transaction identifier.It contains a valid value only for transaction-level context variables.For connection-level variables it is NULL.

MON$VARIABLE_NAME

VARCHAR(80)

Context variable name

MON$VARIABLE_VALUE

VARCHAR(32765)

Context variable value

Retrieving all session context variables for the current connection
SELECT
  VAR.MON$VARIABLE_NAME,
  VAR.MON$VARIABLE_VALUE
FROM MON$CONTEXT_VARIABLES VAR
WHERE VAR.MON$ATTACHMENT_ID = CURRENT_CONNECTION