Skip to content

fix(function): reject out-of-range power results#25464

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-25308-main
Jul 6, 2026
Merged

fix(function): reject out-of-range power results#25464
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-25308-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #25308

What this PR does / why we need it:

Reject non-finite results from POW and POWER with an out-of-range error instead of returning NaN or infinity.

The root cause was that the shared Power implementation appended the result of Go's math.Pow without checking for NaN or infinity. The implementation now returns ErrOutOfRange for non-finite results while preserving finite values and NULL handling.

Regression coverage includes negative bases with fractional exponents, zero raised to a negative exponent, mixed valid/invalid vectors, and distributed SQL cases for both aliases.

Validation:

  • go test -count=1 -timeout 120s ./pkg/sql/plan/function
  • go test -race -count=1 -timeout 120s -run '^TestPower(OutOfRange)?$' ./pkg/sql/plan/function
  • go vet ./pkg/sql/plan/function
  • go build ./pkg/sql/plan/function
  • mo-tester: 53/53 statements passed for func_math_power.test

@ck89119 ck89119 marked this pull request as ready for review July 6, 2026 06:37
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find a blocker in this fix.

The change now rejects non-finite POW/POWER results as out-of-range while preserving normal finite values, NULL propagation, and alias behavior. The added select-list guard also matches the existing FunctionSelectList semantics, so filtered rows no longer evaluate the invalid branch.

@XuPeng-SH XuPeng-SH merged commit a5cb217 into matrixorigin:main Jul 6, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: POW with negative base and fractional exponent returns NaN instead of MySQL error

4 participants