(m *mysqlProxy, s *p2p.Message, txConn map[string]*client.Conn, accessType string)
| 107 | } |
| 108 | |
| 109 | func handleInboundSQL(m *mysqlProxy, s *p2p.Message, txConn map[string]*client.Conn, accessType string) { |
| 110 | var err error |
| 111 | conn, ok := txConn[s.SenderID] |
| 112 | |
| 113 | if !ok { |
| 114 | // Get appropriate connection based on access type |
| 115 | if accessType == "admin" { |
| 116 | conn, err = m.popAdminConn() |
| 117 | } else { |
| 118 | conn, err = m.popReadonlyConn() |
| 119 | } |
| 120 | if err != nil { |
| 121 | logrus.Errorf("asyncSQL get %s conn err: %v", accessType, err) |
| 122 | return |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // Execute query |
| 127 | _, err = conn.Execute(s.Content) |
| 128 | if err != nil { |
| 129 | logrus.Infof("Inbound %s sql: %s err: %v", accessType, s.Content, err) |
| 130 | return |
| 131 | } |
| 132 | logrus.Infof("Inbound %s id: %s, sql: %s", accessType, s.SenderID, s.Content) |
| 133 | |
| 134 | if !ok { |
| 135 | if conn.IsInTransaction() { |
| 136 | txConn[s.SenderID] = conn |
| 137 | } else { |
| 138 | if accessType == "admin" { |
| 139 | m.pushAdminConn(conn, err) |
| 140 | } else { |
| 141 | m.pushReadonlyConn(conn, err) |
| 142 | } |
| 143 | } |
| 144 | } else if ok && !conn.IsInTransaction() { |
| 145 | delete(txConn, s.SenderID) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | var DMLSQL = []string{ |
| 150 | "BEGIN", |
no test coverage detected