File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -125,10 +125,26 @@ export function extractPlan(result: any, calculateTotalDbHits = false) {
125125 if ( result . summary && ( result . summary . plan || result . summary . profile ) ) {
126126 const rawPlan = result . summary . profile || result . summary . plan
127127 const boltPlanToRESTPlanShared = ( plan : any ) => {
128+ // `dbHits` and `Rows` are available both on the plan object and on plan.arguments
129+ // there is a bug numbers that are larger than signed 32 bit integers overflow and become negative
130+ // if we find that the value on arguments is available and above the max signed 32 bit integer
131+ // we do a workaround and use that instead. Otherwise we prefer the original value
132+
133+ // sidenote: It is called "dbHits" in the plan object and "DbHits" in plan.arguments,
134+ // it's not a typo, just a little confusing
135+ const SIGNED_INT32_MAX = 2147483647
128136 return {
129137 operatorType : plan . operatorType ,
130- DbHits : plan . dbHits ,
131- Rows : plan . rows ,
138+ DbHits :
139+ plan ?. arguments ?. DbHits ?. toNumber ( ) > SIGNED_INT32_MAX
140+ ? plan ?. arguments ?. DbHits ?. toNumber ( )
141+ : plan . dbHits ,
142+
143+ Rows :
144+ plan ?. arguments ?. Rows ?. toNumber ( ) > SIGNED_INT32_MAX
145+ ? plan ?. arguments ?. Rows ?. toNumber ( )
146+ : plan . rows ,
147+
132148 identifiers : plan . identifiers ,
133149 children : plan . children . map ( ( _ : any ) => ( {
134150 ...transformPlanArguments ( _ . arguments ) ,
You can’t perform that action at this time.
0 commit comments