-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect SUBSTRING usage in debug section in sp_BlitzCache and sp_BlitzIndex #3406
Comments
Can you tell me a little about the problem this is causing for you on a production server?---Tiny glass keyboardTypos flowing like riversAs winter snow thawsOn Dec 11, 2023, at 3:27 AM, Per Scheffer ***@***.***> wrote:
Version of the script
8.17
What is the current behavior?
sp_BlitzCache and sp_BlitzIndex have a section like this:
IF @debug = 1
BEGIN
PRINT ***@***.***, 0, 4000);
PRINT ***@***.***, 4000, 8000);
PRINT ***@***.***, 8000, 12000);
PRINT ***@***.***, 12000, 16000);
PRINT ***@***.***, 16000, 20000);
PRINT ***@***.***, 20000, 24000);
PRINT ***@***.***, 24000, 28000);
PRINT ***@***.***, 28000, 32000);
PRINT ***@***.***, 32000, 36000);
PRINT ***@***.***, 36000, 40000);
END;
What is the expected behavior?
The syntax for SUBSTRING is
SUBSTRING ( expression, start, length )
and the numbering of start is 1-based, so the section should probably be
IF @debug = 1
BEGIN
PRINT ***@***.***, 1, 4000);
PRINT ***@***.***, 4001, 4000);
PRINT ***@***.***, 8001, 4000);
PRINT ***@***.***, 12001, 4000);
PRINT ***@***.***, 16001, 4000);
PRINT ***@***.***, 20001, 4000);
PRINT ***@***.***, 24001, 4000);
PRINT ***@***.***, 28001, 4000);
PRINT ***@***.***, 32001, 4000);
PRINT ***@***.***, 36001, 4000);
END;
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
It's causing no problems. I just stumbled upon this code while searching for something else. But the debug output would be weird. Here is an example of similar code: DECLARE @string nvarchar(10) = N'1234567890';
PRINT SUBSTRING(@string, 0, 2);
PRINT SUBSTRING(@string, 2, 4);
PRINT SUBSTRING(@string, 4, 6);
PRINT SUBSTRING(@string, 6, 8);
PRINT SUBSTRING(@string, 8, 10); which outputs
What is intended here is probably: DECLARE @string nvarchar(10) = N'1234567890';
PRINT SUBSTRING(@string, 1, 2);
PRINT SUBSTRING(@string, 3, 2);
PRINT SUBSTRING(@string, 5, 2);
PRINT SUBSTRING(@string, 7, 2);
PRINT SUBSTRING(@string, 9, 2); which outputs
|
It is possible that a pull request would have been more suitable in this instance rather than a bug report; however, my familiarity with GitHub is still limited. |
@perscheffer Thanks for the report, I added PR #3407 to fix this issue. |
…it_3406 #3406 Fixed the Substring command to respect the command syntax
Looks good! Thanks for the pull request. Merging into the dev branch, will be in the next release with credit to you in the release notes. |
Version of the script
8.17
What is the current behavior?
sp_BlitzCache and sp_BlitzIndex have a section like this:
What is the expected behavior?
The syntax for
SUBSTRING
isSUBSTRING ( expression, start, length )
and the numbering of
start
is 1-based, so the section should probably beThe text was updated successfully, but these errors were encountered: