| 25 | } |
| 26 | |
| 27 | func (h *Handle) HandleQuery(c *server.Conn, query string) (res *mysql.Result, err error) { |
| 28 | // Check if this is a readonly connection attempting a write |
| 29 | if h.conn.GetUser() == config.Get().Mysql.Readonly.User && isDML(query) { |
| 30 | return nil, errors.New("readonly user cannot execute write operations") |
| 31 | } |
| 32 | |
| 33 | res, err = h.conn.Execute(query) |
| 34 | if err == nil && isDML(query) { |
| 35 | // Determine access type based on connection user |
| 36 | accessType := "admin" |
| 37 | if h.conn.GetUser() == config.Get().Mysql.Readonly.User { |
| 38 | accessType = "readonly" |
| 39 | } |
| 40 | broadcast(query, accessType) |
| 41 | } |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | func (h *Handle) HandleFieldList(c *server.Conn, table string, fieldWildcard string) ([]*mysql.Field, error) { |
| 46 | return h.conn.FieldList(table, fieldWildcard) |