diff --git a/src/current/_includes/v26.1/known-limitations/routine-limitations.md b/src/current/_includes/v26.1/known-limitations/routine-limitations.md index 4718c6c7abf..f161512cb72 100644 --- a/src/current/_includes/v26.1/known-limitations/routine-limitations.md +++ b/src/current/_includes/v26.1/known-limitations/routine-limitations.md @@ -7,4 +7,5 @@ - Routines cannot be created with an `OUT` parameter of type `RECORD`. [#123448](https://github.com/cockroachdb/cockroach/issues/123448) - DDL statements (e.g., `CREATE TABLE`, `CREATE INDEX`) are not allowed within UDFs or stored procedures. [#110080](https://github.com/cockroachdb/cockroach/issues/110080) - Polymorphic types cannot be cast to other types (e.g., `TEXT`) within routine parameters. [#123536](https://github.com/cockroachdb/cockroach/issues/123536) -- Routine parameters and return types cannot be declared using the `ANYENUM` polymorphic type, which is able to match any [`ENUM`]({% link {{ page.version.version }}/enum.md %}) type. [123048](https://github.com/cockroachdb/cockroach/issues/123048) \ No newline at end of file +- Routine parameters and return types cannot be declared using the `ANYENUM` polymorphic type, which is able to match any [`ENUM`]({% link {{ page.version.version }}/enum.md %}) type. [123048](https://github.com/cockroachdb/cockroach/issues/123048) +- Statement diagnostics cannot be collected for statements executed within UDFs or stored procedures. Statement diagnostics continue to work only for top-level statement executions. [#156905](https://github.com/cockroachdb/cockroach/pull/156905) \ No newline at end of file diff --git a/src/current/_includes/v26.1/ui/statements-views.md b/src/current/_includes/v26.1/ui/statements-views.md index 607e05528f2..5550580414c 100644 --- a/src/current/_includes/v26.1/ui/statements-views.md +++ b/src/current/_includes/v26.1/ui/statements-views.md @@ -32,6 +32,10 @@ The **Statements Fingerprints** view helps you: - View SQL statement fingerprint [details](#statement-fingerprint-page). - Download SQL statement [diagnostics](#diagnostics) for troubleshooting. +{{site.data.alerts.callout_info}} +The **Statements** page displays all SQL statements, including those executed within [user-defined functions]({{ link_prefix}}user-defined-functions.html#statement-statistics) and [stored procedures]({{ link_prefix}}stored-procedures.html#statement-statistics). This allows you to monitor the performance of individual statements within your functions and procedures. +{{site.data.alerts.end}} + {% if page.cloud != true %} To view this page, click **SQL Activity** in the left-hand navigation of the DB Console. {% else %} diff --git a/src/current/v26.1/stored-procedures.md b/src/current/v26.1/stored-procedures.md index 753a650e783..1e95db3ed7e 100644 --- a/src/current/v26.1/stored-procedures.md +++ b/src/current/v26.1/stored-procedures.md @@ -28,6 +28,16 @@ CREATE PROCEDURE procedure_name(parameters) For details, see [`CREATE PROCEDURE`]({% link {{ page.version.version }}/create-procedure.md %}). +## Statement statistics + +SQL statements executed within stored procedures are tracked in the SQL statistics subsystem and will appear in the [**SQL Activity** > **Statements**]({% link {{ page.version.version }}/ui-statements-page.md %}) page and the [**Insights**]({% link {{ page.version.version }}/ui-insights-page.md %}) page in the DB Console. This allows you to monitor the performance and execution statistics of individual statements within your procedures. + +These statements will also appear in the [**Transaction details**]({% link {{ page.version.version }}/ui-transactions-page.md %}#transaction-details-page) in the **Statement Fingerprints** table when the stored procedure is invoked as part of a transaction. + +{{site.data.alerts.callout_info}} +Statement diagnostics cannot be collected for statements executed within stored procedures. Statement diagnostics continue to work only for top-level statement executions. For details, see [Known limitations](#known-limitations). +{{site.data.alerts.end}} + ## Examples {% include {{page.version.version}}/sql/movr-statements.md %} diff --git a/src/current/v26.1/transaction-diagnostics.md b/src/current/v26.1/transaction-diagnostics.md index 0fc6ab9e7fc..6b9c73c7bc4 100644 --- a/src/current/v26.1/transaction-diagnostics.md +++ b/src/current/v26.1/transaction-diagnostics.md @@ -10,6 +10,10 @@ Transaction diagnostics allow operators and support engineers to investigate iss Requesting a transaction diagnostics bundle introduces performance overhead. This feature is primarily intended for use under the guidance of [Cockroach Labs Support](https://support.cockroachlabs.com/). {{site.data.alerts.end}} +{{site.data.alerts.callout_info}} +Transaction diagnostics cannot be collected for statements executed within [user-defined functions]({% link {{ page.version.version }}/user-defined-functions.md %}) or [stored procedures]({% link {{ page.version.version }}/stored-procedures.md %}). Transaction diagnostics continue to work only for top-level statement executions. +{{site.data.alerts.end}} + ## Required privileges To use this function on a [secure cluster]({% link {{ page.version.version }}/secure-a-cluster.md %}), you must be an [`admin` user]({% link {{ page.version.version }}/security-reference/authorization.md %}#admin-role) or a SQL user with the [`VIEWACTIVITY`]({% link {{ page.version.version }}/security-reference/authorization.md %}#viewactivity) or [`VIEWACTIVITYREDACTED`]({% link {{ page.version.version }}/security-reference/authorization.md %}#viewactivityredacted) [system privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#supported-privileges). If the user has only `VIEWACTIVITYREDACTED`, they can request only redacted bundles. diff --git a/src/current/v26.1/user-defined-functions.md b/src/current/v26.1/user-defined-functions.md index c525ac6a5ea..671d181cd0f 100644 --- a/src/current/v26.1/user-defined-functions.md +++ b/src/current/v26.1/user-defined-functions.md @@ -31,6 +31,16 @@ The basic components of a user-defined function are a name, list of arguments, r - Can reference tables. - Can reference only the `SELECT` statement. +## Statement statistics + +SQL statements executed within user-defined functions are tracked in the SQL statistics subsystem and will appear in the [**SQL Activity** > **Statements**]({% link {{ page.version.version }}/ui-statements-page.md %}) page and the [**Insights**]({% link {{ page.version.version }}/ui-insights-page.md %}) page in the DB Console. This allows you to monitor the performance and execution statistics of individual statements within your functions. + +These statements will also appear in the [**Transaction details**]({% link {{ page.version.version }}/ui-transactions-page.md %}#transaction-details-page) in the **Statement Fingerprints** table when the UDF is invoked as part of a transaction. + +{{site.data.alerts.callout_info}} +Statement diagnostics cannot be collected for statements executed within UDFs. Statement diagnostics continue to work only for top-level statement executions. For details, see [Known limitations](#known-limitations). +{{site.data.alerts.end}} + ## Examples ### Create a UDF