matrixorigin / matrixorigin/matrixone

[Bug]: COM_SET_OPTION returns OK for malformed or unsupported option values

Open
#25,743 1 comment 0 reactions 1 assignee Claimed by @daviszhen View on GitHub
deferred kind/bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.