matrixorigin / matrixorigin/matrixone
[Bug]: COM_SET_OPTION returns OK for malformed or unsupported option values
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
### Is there an existing issue for the same bug?
- [x] I have checked the existing issues.
### Branch Name
`main`-based checkout (`main`)
### Commit ID
`e538e203ad47ebf0506a424fe93aed61290c4061`
### Actual Behavior
`MysqlCmdExecutor.ExecRequest` calls `handleSetOption`, constructs an error response when it fails, and then unconditionally returns a new OK response:
```go
err = handleSetOption(ses, data)
if err != nil {
resp = NewGeneralErrorResponse(COM_SET_OPTION, err)
}
return NewGeneralOkResponse(COM_SET_OPTION), nil
```
Consequently, both a short payload and an unsupported value (anything other than 0 or 1) are acknowledged as successful.
A white-box test calling `ExecRequest(..., COM_SET_OPTION, []byte{2, 0})` expects `ErrorResponse` but receives `OkResponse`.
### Expected Behavior
Invalid `COM_SET_OPTION` payloads should return the error response produced from `handleSetOption`; valid values 0 and 1 should continue to return OK.
### Steps to Reproduce
1. Create a minimal frontend session and command executor.
2. Call `ExecRequest` with `COM_SET_OPTION` and payload `[]byte{2, 0}`.
3. Assert that the response category is `ErrorResponse`.
The assertion currently fails because the response category is `OkResponse`.
### Relevant code
- `pkg/frontend/mysql_cmd_executor.go`: `ExecRequest` COM_SET_OPTION branch
- `pkg/frontend/mysql_cmd_executor.go`: `handleSetOption`
Contributor guide
Assessment
This issue has not been assessed yet.