Browse Source

Don't send text query larger than maxPacketAllowed

INADA Naoki 11 năm trước cách đây
mục cha
commit
cac6129f8a
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  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
 }