Skip to content

Commit ff9e575

Browse files
Merge fix/humanevents-seconds-sample-validation into dev
2 parents 92f4e3b + 0a453c3 commit ff9e575

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

sp_HumanEvents/sp_HumanEvents.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,25 @@ BEGIN
890890
RETURN;
891891
END;
892892

893+
/*
894+
@seconds_sample drives the WAITFOR DELAY that controls how long the XE session
895+
samples before we shred results. When NULL it's treated as unset. When
896+
explicitly 0 the user is asking for no sampling, which would hit the
897+
unconditional WAITFOR below with an empty @waitfor string and raise a
898+
syntax error. Coerce NULL and 0 to 1 second — the minimum meaningful
899+
value — and warn if 0 was explicit.
900+
*/
901+
IF @debug = 1 BEGIN RAISERROR(N'Checking seconds_sample parameter', 0, 1) WITH NOWAIT; END;
902+
IF @seconds_sample IS NULL
903+
BEGIN
904+
SET @seconds_sample = 1;
905+
END;
906+
ELSE IF @seconds_sample = 0
907+
BEGIN
908+
RAISERROR(N'@seconds_sample = 0 is not meaningful (nothing would be sampled). Using 1 second instead. Pass a larger value for real sampling.', 0, 1) WITH NOWAIT;
909+
SET @seconds_sample = 1;
910+
END;
911+
893912

894913
IF @debug = 1 BEGIN RAISERROR(N'Checking query sort order', 0, 1) WITH NOWAIT; END;
895914
IF @query_sort_order NOT IN

0 commit comments

Comments
 (0)