Repository navigation
Commit 0364c73
sp_BlitzWho: Fix bugs found in full code review
Bug fixes:
- AND/OR precedence in >50GB memory check: The AND 50000000 < (...)
condition only bound to the last OR branch (@ProductVersionMajor >= 13)
due to operator precedence. SQL Server 2012 SP3+ and 2014 SP2+ always
got MAX_GRANT_PERCENT = 1 regardless of server memory. Wrapped the
version OR chain in parentheses so the memory check applies to all
supported versions.
- AND/OR precedence in @ShowSleepingSPIDs=1: The bare OR clause
short-circuited all preceding AND conditions (@@spid exclusion,
host_name IS NOT NULL, AG read-only replica exclusion). Any session
with an open transaction was returned unfiltered. Changed to
AND (db_name IS NOT NULL OR open_tran >= 1) so base filters always
apply.
- NOT IN with NULL r.database_id on AG servers: When r is NULL (sleeping
sessions with no active request), NULL NOT IN (set) evaluates to
UNKNOWN, silently excluding all sleeping sessions on servers with
Always On read-only replicas. Added r.database_id IS NULL OR guard.
- Session waits TOP 5 ordered alphabetically: The @SessionWaitsSQL
subquery used ORDER BY 1 which sorts by the concatenated string
(alphabetically), not by wait time. Changed to
ORDER BY SUM(waitwait.wait_time_ms) DESC to return the 5 longest
waits, matching the dm_os_waiting_tasks subquery pattern.
Code quality:
- Removed unused variable @StringToSelect (declared but never referenced).
- Removed 4 redundant @ObjectFullName assignments (same value set 5
consecutive times with no changes to inputs between them).
Tested: 12 execution scenarios on SQL2022 including default, Help,
ExpertMode, ShowSleepingSPIDs (0/1/2), Debug, MinElapsedSeconds filter,
SortOrder, GetOuterCommand, GetLiveQueryPlan, and ShowActualParameters.
All passed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 2422c4b commit 0364c73
1 file changed
Lines changed: 10 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
291 | 290 | | |
292 | 291 | | |
293 | 292 | | |
294 | | - | |
295 | 293 | | |
296 | 294 | | |
297 | 295 | | |
298 | 296 | | |
299 | 297 | | |
300 | 298 | | |
301 | | - | |
302 | 299 | | |
303 | 300 | | |
304 | 301 | | |
305 | 302 | | |
306 | 303 | | |
307 | 304 | | |
308 | | - | |
309 | 305 | | |
310 | 306 | | |
311 | 307 | | |
312 | 308 | | |
313 | 309 | | |
314 | 310 | | |
315 | | - | |
316 | 311 | | |
317 | 312 | | |
318 | 313 | | |
| |||
894 | 889 | | |
895 | 890 | | |
896 | 891 | | |
897 | | - | |
| 892 | + | |
898 | 893 | | |
899 | 894 | | |
900 | 895 | | |
| |||
1195 | 1190 | | |
1196 | 1191 | | |
1197 | 1192 | | |
1198 | | - | |
| 1193 | + | |
1199 | 1194 | | |
1200 | 1195 | | |
1201 | 1196 | | |
1202 | 1197 | | |
1203 | | - | |
| 1198 | + | |
1204 | 1199 | | |
1205 | 1200 | | |
1206 | 1201 | | |
| |||
1378 | 1373 | | |
1379 | 1374 | | |
1380 | 1375 | | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
1386 | 1382 | | |
1387 | 1383 | | |
1388 | 1384 | | |
| |||
0 commit comments