Explorar el Código

Don't send text query larger than maxPacketAllowed

INADA Naoki hace 11 años
padre
commit
cac6129f8a
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      connection.go

+ 7 - 0
connection.go

@@ -265,6 +265,13 @@ func (mc *mysqlConn) buildQuery(query string, args []driver.Value) (string, erro
 			return "", driver.ErrSkip
 		}
 	}
+	pktSize := len(query) + 4 // 4 bytes for header.
+	for _, p := range parts {
+		pktSize += len(p)
+	}
+	if pktSize > mc.maxPacketAllowed {
+		return "", driver.ErrSkip
+	}
 	return strings.Join(parts, ""), nil
 }