Skip to content

[Bug]: prepared statement binary reset/cleanup is incomplete on main #23977

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

7b1a043

Other Environment Information

  • Hardware parameters:
  • OS type: Linux
  • Others:

Actual Behavior

Prepared-statement binary protocol state handling is incomplete on main:

  1. COM_STMT_RESET / reset prepare acknowledges the reset but leaves COM_STMT_SEND_LONG_DATA accumulated state on the server-side PrepareStmt.
  2. COM_STMT_CLOSE and COM_STMT_RESET continue past GetPrepareStmt failures and can dereference a nil PrepareStmt instead of returning a clean error response.
  3. After binary parameter parsing, PrepareStmt.Close() can free params through an unset prepareStmt.proc, so deallocate / close / session cleanup paths are not safely wired to the binary-param allocation context.

Expected Behavior

  • COM_STMT_RESET should clear accumulated binary prepared-statement state from COM_STMT_SEND_LONG_DATA.
  • COM_STMT_CLOSE / COM_STMT_RESET should return an error response when the statement does not exist and should not dereference nil state.
  • Prepared-statement close/deallocate/session cleanup should always free binary parameter vectors through a valid process/mempool context.

Steps to Reproduce

  1. Use a MySQL client that exposes binary prepared statements on main.
  2. Prepare a statement with at least one parameter and send parameter payload via COM_STMT_SEND_LONG_DATA.
  3. Issue COM_STMT_RESET or deallocate/close the statement.
  4. Observe that reset does not clear the accumulated binary state, and close/reset error paths are not robust when the target statement is missing.

Additional information

Relevant frontend paths:

  • pkg/frontend/mysql_protocol.go
  • pkg/frontend/mysql_cmd_executor.go
  • pkg/frontend/types.go

Activity

  1. self-assigned this
    on Mar 27, 2026
  2. added
    kind/bug
    severity/s0
    on Mar 27, 2026
  3. added theissue type on Mar 27, 2026
  4. added this to the MO-202603 milestone on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions