| 55 | } |
| 56 | |
| 57 | func (h *Handle) HandleStmtExecute(c *server.Conn, context any, query string, args []any) (*mysql.Result, error) { |
| 58 | // Check if this is a readonly connection attempting a write |
| 59 | if h.conn.GetUser() == config.Get().Mysql.Readonly.User && isDML(query) { |
| 60 | return nil, errors.New("readonly user cannot execute write operations") |
| 61 | } |
| 62 | |
| 63 | stmt, ok := context.(*client.Stmt) |
| 64 | if !ok { |
| 65 | return nil, errors.New("other error") |
| 66 | } |
| 67 | res, err := stmt.Execute(args...) |
| 68 | if err == nil && isDML(query) { |
| 69 | // Determine access type based on connection user |
| 70 | accessType := "admin" |
| 71 | if h.conn.GetUser() == config.Get().Mysql.Readonly.User { |
| 72 | accessType = "readonly" |
| 73 | } |
| 74 | broadcast(query, accessType) |
| 75 | } |
| 76 | return res, err |
| 77 | } |
| 78 | |
| 79 | func (h *Handle) HandleStmtClose(c *server.Conn, context any) error { |
| 80 | stmt, ok := context.(*client.Stmt) |