From a6e3e9c04c535ef8124251189c4b0487baf6f00b Mon Sep 17 00:00:00 2001
From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com>
Date: Mon, 20 Apr 2026 11:30:07 -0400
Subject: [PATCH] Fix blocked process report plan lookup (#867)
Right-click > View Plan on a Blocked Process Reports row silently fell
through (no handler case) and Get Actual Plan erred with "no query text."
- Split the grid onto its own BlockedProcessContextMenu with separate
View Blocked Plan / View Blocking Plan actions; drop Get Actual Plan
(re-executing a mid-transaction blocked query is a foot-gun).
- Parse all entries from the BPR XML's executionStack, filter
the 42-byte all-zero sql_handle placeholder (dynamic SQL / system
context), default stmtstart=0 / stmtend=-1 per the dm_exec_text_query_plan
convention. Matches sp_HumanEventsBlockViewer's XPath and join shape.
- Add FetchPlanBySqlHandleAsync keyed on sql_handle + statement offsets
against sys.dm_exec_query_stats. Caller iterates frames until one
resolves; falls back to a clear "plan no longer in cache" message.
Co-Authored-By: Claude Opus 4.7 (1M context)
---
Lite/Controls/ServerTab.xaml | 28 +++++-
Lite/Controls/ServerTab.xaml.cs | 98 ++++++++++++++++++++
Lite/Services/LocalDataService.QueryStats.cs | 66 +++++++++++++
3 files changed, 191 insertions(+), 1 deletion(-)
diff --git a/Lite/Controls/ServerTab.xaml b/Lite/Controls/ServerTab.xaml
index 749a3b3..6ee7b1c 100644
--- a/Lite/Controls/ServerTab.xaml
+++ b/Lite/Controls/ServerTab.xaml
@@ -32,12 +32,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
-