Commit f594e12
Fix sp_LogHunter custom_message_only validation and canary date floor
Two related bugs in the setup path:
1. @custom_message_only = 1 with NULL/empty @custom_message produced an
empty #search. The canary and canned-search inserts are gated on
@custom_message_only = 0, so they skipped; the custom insert is
gated on @custom_message LIKE N'_%' which is UNKNOWN (treated as
FALSE) when @custom_message is NULL, so it also skipped. The outer
cursor ran over nothing and the sproc returned "no results" on
what should have been an invalid input. Added an early validation
that RAISERRORs a clear message instead.
2. Canary searches built `days_back` as a "90 days ago at minimum"
floor via CASE WHEN @days_back > -90 THEN -90 ELSE @days_back END.
When the caller passes @start_date/@end_date instead of @days_back,
the setup code NULLs @days_back — and CASE over NULL collapses to
NULL, the CONVERT→DATEADD produces NULL, and the final concatenated
literal becomes the string "NULL" (or NULLs all the way out), which
xp_readerrorlog rejects. Switched to a CASE WHEN @days_back IS NOT
NULL fallback that substitutes @start_date when date-range mode is
active.
Verified on SQL Server 2022:
@custom_message_only = 1 (no message) → expected error raised
@start_date / @end_date set, @days_back NULL → canary rows build
with a real date floor and xp_readerrorlog runs without error
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 85cc60e commit f594e12
1 file changed
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
244 | 259 | | |
245 | 260 | | |
246 | 261 | | |
| |||
412 | 427 | | |
413 | 428 | | |
414 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
415 | 440 | | |
416 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
417 | 448 | | |
418 | 449 | | |
419 | 450 | | |
| |||
0 commit comments