Repository navigation
fix: prevent unary minus signed integer overflow - #28499
Conversation
ff52d38 to
5f1156d
Compare
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head b157baff87d9d375887ca92fb9f65a1afaeabe56 (base 2a6fe7f61358e846a20aafba3b50903a61608682). I read the complete review, inline-comment, issue-comment, reply, and thread state; both earlier threads remain unresolved and there are no author replies, so I verified the fixes from code rather than relying on thread state. I compared the increment after reviewed head 3b44ea4cd526b3ce9eada703da58c5d0977f3464 and reconciled it with the full nine-file PR diff.
The prior execution-ABI blocker is now closed in both directions: the narrow-result fallback keeps old plans executable on a new worker, and the new v60 feature detection fences widened plans at both remote encode and decode boundaries while the cluster protocol is older. The requested SQL boundary/NULL/CTAS/BIGINT-error coverage is also present. Local exact-head validation passed pkg/sql/plan/function, the unary binder tests in pkg/sql/plan, pkg/pb/plan, and TestRemoteExpressionProtocolValidation; git diff --check is clean. One blocking golden-result inconsistency remains, detailed inline.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head c6e2695e47b3174c62cd1bf115a7cde02f945b33 (base 24f2f6ce247cd677f81da0ca69f2aadccbc050f9). I read the full review and inline-comment history, checked every resolved thread against the code, compared the increment after my prior reviewed head b157baff87d9d375887ca92fb9f65a1afaeabe56, and reconciled it with the complete 11-file diff.
The remaining golden-result blocker is closed: the earlier select -c1 from t2 oracle now records BIGINT metadata, and the other existing affected result oracle was updated as well. The earlier mixed-version executor mismatch remains closed by both the legacy narrow-wrapper fallback and the v60 sender/receiver protocol fence. The full implementation still preserves selection/NULL behavior, widens TINYINT/SMALLINT/INT before negation, and returns a range error for evaluated BIGINT minimum values; the SQL regression covers boundary values, result metadata, CTAS, NULL controls, and the BIGINT error.
Exact-head validation passed:
TestUnaryRegisteredTypeAndSelectionandTestUnaryMinusInt64Overflowinpkg/sql/plan/functionTestRemoteExpressionProtocolValidationinpkg/sql/compileTestRefreshSessionAuthRequiresCurrentProtocolVersioninpkg/queryservice/clientgit diff --check
The current-head CI also reports successful UT coverage and targeted standalone/compose BVT jobs. No blocking issues remain.
# Conflicts: # pkg/defines/const.go
# Conflicts: # pkg/defines/const.go # pkg/queryservice/client/query_client_test.go
# Conflicts: # pkg/defines/const.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed full current change at a1413db against base 065a675, including prior reviews and fixes. Narrow signed values widen before negation, evaluated BIGINT minimum returns a range error, and NULL/selection controls and the previously inconsistent SQL metadata goldens are addressed. The legacy narrow-result fallback also fixes old-plan execution on a new worker.
One mixed-version blocker remains in the reverse direction, detailed inline. This corrects the earlier review's assumption that the local protocol-version check alone closes both execution-ABI directions: it requires an externally maintained oldest-peer invariant that is not enforced by the new check or the default runtime initialization.
Evidence: inspected current/base registrations, result-wrapper construction, remote expression scanning and encode/decode validation, runtime version initialization/setter, and new UT/BVT controls. This follow-up is source-based; no fresh SQL, two-version cluster, UT or benchmark execution is claimed, and CI was not awaited. No additional arithmetic, shared-state, resource-lifecycle or normal-path asymptotic blocker found.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed the full current change and prior requested changes at b52d616 (base main, 2cecab5). No remaining concrete blocker found.
The previous mixed-version physical type conflict is resolved by lowering new TINYINT/SMALLINT/INT negations to an explicit BIGINT cast and the historical BIGINT overload 3, while preserving overloads 0/1/2 for serialized legacy plans. This avoids relying on a sender-local protocol-version variable to establish peer compatibility. Reviewed the binder cast path, signed-minimum overflow detection, NULL/selection masking, float and ordinary-value controls, and unchanged unsigned/decimal paths.
The added SQL boundary/CTAS assertions and corrected existing metadata goldens address the earlier public-result oracle finding. The focused Go tests cover new dispatch, legacy result wrappers, BIGINT minimum (including constant input), NULL/masked rows, and unrelated controls. The widening adds a bounded cast/vector cost for narrow operands; no new state ownership or unbounded allocation is introduced.
Validation: exact-head source/diff and review-history inspection; no fresh native UT/BVT or mixed-version deployment was executed in this review, and CI was not awaited. Legacy workers naturally retain their old BIGINT-overflow behavior until upgraded; the serialized argument/result contract is now compatible.
Merge Queue Status
This pull request spent 9 minutes 38 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #28499 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #28491
What this PR does / why we need it:
Prevent unary minus from silently wrapping signed integer minimum values. Narrow signed integer operands now produce an int64 result, while BIGINT minimum negation returns a range error.