Skip to content

fix: use proper MySQL error for scalar subquery returning multiple rows#25373

Open
aunjgr wants to merge 1 commit into
matrixorigin:mainfrom
aunjgr:fix/23062-subquery-error
Open

fix: use proper MySQL error for scalar subquery returning multiple rows#25373
aunjgr wants to merge 1 commit into
matrixorigin:mainfrom
aunjgr:fix/23062-subquery-error

Conversation

@aunjgr

@aunjgr aunjgr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #23062

What this PR does / why we need it:

Scalar subquery returning multiple rows used internal error: prefix (wrong error class). MySQL uses ER_SUBQUERY_NO_1_ROW (1242, SQLSTATE 21000).

Fix

  1. Registered ErrSubqueryNo1Row in errorMsgRefer map with proper error code (1242) and SQLSTATE (21000)
  2. Added NewErrSubqueryNo1Row helper
  3. Replaced 9 NewInternalError calls in hashjoin (7) and loopjoin (2)

Error message retained the "scalar" qualifier for clarity: ERROR 1242 (21000): scalar subquery returns more than 1 row

File Change
pkg/common/moerr/error.go +5 lines
pkg/sql/colexec/hashjoin/join.go 7 locations
pkg/sql/colexec/loopjoin/join.go 2 locations
test/.../cte.result regenerated
test/.../seq_func2.result regenerated
test/.../subquery-with-in.result regenerated

🤖 Generated with Claude Code

Replace NewInternalError with NewErrSubqueryNo1Row which uses
ER_SUBQUERY_NO_1_ROW (1242, SQLSTATE 21000), matching MySQL behavior.
9 locations in hashjoin and loopjoin operators.

Co-Authored-By: Claude <noreply@anthropic.com>
@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 →

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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants