Просмотр исходного кода

Don't send text query larger than maxPacketAllowed

INADA Naoki 11 лет назад
Родитель
Сommit
cac6129f8a
1 измененных файлов с 7 добавлено и 0 удалено
  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
 }