Skip to content

Commit 70009e6

Browse files
Fix arithmetic overflow in query_stats collector (#547)
DMV sys.dm_exec_query_stats returns min_dop, max_dop, and thread columns as bigint, but our temp table and permanent table used smallint/integer — causing overflow on INSERT. Widened to match actual DMV types: - min_dop, max_dop: smallint -> bigint - min/max_reserved_threads, min/max_used_threads: integer -> bigint Includes upgrade script for existing 2.2.0 installations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0b1dec commit 70009e6

5 files changed

Lines changed: 1410 additions & 12 deletions

File tree

install/02_create_tables.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ BEGIN
119119
max_rows bigint NOT NULL,
120120
statement_sql_handle varbinary(64) NULL,
121121
statement_context_id bigint NULL,
122-
min_dop smallint NOT NULL,
123-
max_dop smallint NOT NULL,
122+
min_dop bigint NOT NULL,
123+
max_dop bigint NOT NULL,
124124
min_grant_kb bigint NOT NULL,
125125
max_grant_kb bigint NOT NULL,
126126
min_used_grant_kb bigint NOT NULL,
127127
max_used_grant_kb bigint NOT NULL,
128128
min_ideal_grant_kb bigint NOT NULL,
129129
max_ideal_grant_kb bigint NOT NULL,
130-
min_reserved_threads integer NOT NULL,
131-
max_reserved_threads integer NOT NULL,
132-
min_used_threads integer NOT NULL,
133-
max_used_threads integer NOT NULL,
130+
min_reserved_threads bigint NOT NULL,
131+
max_reserved_threads bigint NOT NULL,
132+
min_used_threads bigint NOT NULL,
133+
max_used_threads bigint NOT NULL,
134134
total_spills bigint NOT NULL,
135135
min_spills bigint NOT NULL,
136136
max_spills bigint NOT NULL,

install/08_collect_query_stats.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,18 @@ BEGIN
202202
max_rows bigint NOT NULL,
203203
statement_sql_handle varbinary(64) NULL,
204204
statement_context_id bigint NULL,
205-
min_dop smallint NOT NULL,
206-
max_dop smallint NOT NULL,
205+
min_dop bigint NOT NULL,
206+
max_dop bigint NOT NULL,
207207
min_grant_kb bigint NOT NULL,
208208
max_grant_kb bigint NOT NULL,
209209
min_used_grant_kb bigint NOT NULL,
210210
max_used_grant_kb bigint NOT NULL,
211211
min_ideal_grant_kb bigint NOT NULL,
212212
max_ideal_grant_kb bigint NOT NULL,
213-
min_reserved_threads integer NOT NULL,
214-
max_reserved_threads integer NOT NULL,
215-
min_used_threads integer NOT NULL,
216-
max_used_threads integer NOT NULL,
213+
min_reserved_threads bigint NOT NULL,
214+
max_reserved_threads bigint NOT NULL,
215+
min_used_threads bigint NOT NULL,
216+
max_used_threads bigint NOT NULL,
217217
total_spills bigint NOT NULL,
218218
min_spills bigint NOT NULL,
219219
max_spills bigint NOT NULL,

0 commit comments

Comments
 (0)