Skip to content

fix report.daily_summary_v2.worst_query_hash sql_variant garbling - #1667

Merged
erikdarlingdata merged 1 commit into
erikdarlingdata:devfrom
argpna:fix/daily-summary-v2-worst-query-hash-sql-variant
Jul 26, 2026
Merged

fix report.daily_summary_v2.worst_query_hash sql_variant garbling#1667
erikdarlingdata merged 1 commit into
erikdarlingdata:devfrom
argpna:fix/daily-summary-v2-worst-query-hash-sql-variant

Conversation

@argpna

@argpna argpna commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #1666. The view boxes the raw binary(8) query_hash column directly into the sql_variant pivot column: CONVERT(sql_variant, wq.query_hash). Any caller that follows the view's own documented usage and converts metric_value straight to nvarchar gets the raw bytes reinterpreted as UTF-16 instead of a readable hash - every other row in the view is a scalar and converts cleanly; only this one row carries a binary payload.

Which component(s) does this affect?

  • Lite
  • Darling
  • Lite Tests
  • Darling Tests
  • SQL collection scripts
  • Documentation
  • Full Dashboard (deprecated)
  • CLI Installer (deprecated)

How was this tested?

  • Verified against a live mcr.microsoft.com/mssql/server:2022-latest container:
    • Boxed a literal binary(8) query hash into sql_variant the way the unfixed view does, then converted to nvarchar - produced garbled text (稟띿坧謈), reproducing the bug.
    • Applied the fix (CONVERT(nvarchar(20), ..., 1) before boxing) against the same literal - produced the correct hex string (0x1F7A7FB76757088B).
  • Build and SQL Validation GitHub Actions workflows triggered against this branch via a fork-internal PR.

SQL Server version(s) tested against: SQL Server 2022 (Docker, :latest tag)

Checklist

  • I have read the contributing guide
  • My code builds with zero warnings (dotnet build -c Debug)
  • I have tested my changes against at least one SQL Server version
  • I have not introduced any hardcoded credentials or server names

- boxing raw binary(8) query_hash into sql_variant makes CONVERT(nvarchar,...)
  reinterpret the bytes as UTF-16, producing garbage instead of a hash
- convert to hex nvarchar before boxing, matching the style already used
  elsewhere in the codebase for query_hash display
@erikdarlingdata
erikdarlingdata merged commit a57f352 into erikdarlingdata:dev Jul 26, 2026
8 checks passed
erikdarlingdata added a commit that referenced this pull request Jul 26, 2026
…and-view-smoke

Add the missing CHANGELOG entry for #1667
pull Bot pushed a commit to ehtick/PerformanceMonitor that referenced this pull request Jul 29, 2026
The merged fix had no [Unreleased] entry. Records the behaviour change as well
as the fix: that one row's sql_variant base type goes from binary(8) to
nvarchar(20), so anyone querying the view directly and converting to varbinary
needs to adjust -- though the old value was garbled and therefore unusable,
which is the bug being fixed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants