From 632a5e2678e08656d490caf6f83e3c844153691d Mon Sep 17 00:00:00 2001 From: Florence Morris Date: Fri, 12 Dec 2025 17:54:02 -0500 Subject: [PATCH 1/2] In user-defined-function.md and stored-procedures.md, added Statement statistics section. In routine-limitations.md, added limitation for statement diagnostics. In statements-views.md, added callout that statements include those executed in UDF/SPs. In transaction-diagnostics.md, added callout about limitation for statement diagnostics. --- .../v26.1/known-limitations/routine-limitations.md | 3 ++- src/current/_includes/v26.1/ui/statements-views.md | 4 ++++ src/current/v26.1/stored-procedures.md | 10 ++++++++++ src/current/v26.1/transaction-diagnostics.md | 4 ++++ src/current/v26.1/user-defined-functions.md | 10 ++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) 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..8e634db7930 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..eb6039f3185 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 From 110e5f3c018f5760f36a6baf8faf56dbd655a5a5 Mon Sep 17 00:00:00 2001 From: Florence Morris Date: Fri, 12 Dec 2025 17:59:57 -0500 Subject: [PATCH 2/2] Removed unnecessary spaces. --- src/current/v26.1/stored-procedures.md | 2 +- src/current/v26.1/user-defined-functions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/current/v26.1/stored-procedures.md b/src/current/v26.1/stored-procedures.md index 8e634db7930..1e95db3ed7e 100644 --- a/src/current/v26.1/stored-procedures.md +++ b/src/current/v26.1/stored-procedures.md @@ -32,7 +32,7 @@ For details, see [`CREATE PROCEDURE`]({% link {{ page.version.version }}/create- 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. +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). diff --git a/src/current/v26.1/user-defined-functions.md b/src/current/v26.1/user-defined-functions.md index eb6039f3185..671d181cd0f 100644 --- a/src/current/v26.1/user-defined-functions.md +++ b/src/current/v26.1/user-defined-functions.md @@ -35,7 +35,7 @@ The basic components of a user-defined function are a name, list of arguments, r 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. +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).