MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / handleInboundSQL

Function handleInboundSQL

IceFireDB-SQLProxy/internal/mysql/p2p.go:109–147  ·  view source on GitHub ↗
(m *mysqlProxy, s *p2p.Message, txConn map[string]*client.Conn, accessType string)

Source from the content-addressed store, hash-verified

107}
108
109func 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
149var DMLSQL = []string{
150 "BEGIN",

Callers 1

asyncSQLFunction · 0.85

Calls 6

popAdminConnMethod · 0.80
popReadonlyConnMethod · 0.80
pushAdminConnMethod · 0.80
pushReadonlyConnMethod · 0.80
ExecuteMethod · 0.65
IsInTransactionMethod · 0.45

Tested by

no test coverage detected