Skip to content

Commit 3d484fc

Browse files
committed
improve the comment of mysqlConn.Reset()
1 parent 527b0ab commit 3d484fc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

connection.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,16 @@ func (mc *mysqlConn) startWatcher() {
685685
}()
686686
}
687687

688-
// Reset resets the MySQL connection.
688+
// Reset resets the server-side session state using COM_RESET_CONNECTION.
689+
// It clears most per-session state (e.g., user variables, prepared statements)
690+
// without re-authenticating.
691+
// Usage hint: call via database/sql.Conn.Raw using a method assertion:
692+
// conn.Raw(func(c any) error {
693+
// if r, ok := c.(interface{ Reset(context.Context) error }); ok {
694+
// return r.Reset(ctx)
695+
// }
696+
// return nil
697+
// })
689698
func (mc *mysqlConn) Reset(ctx context.Context) (err error) {
690699
return mc.sendSimpleCommandOK(ctx, comResetConnection)
691700
}

0 commit comments

Comments
 (0)