2018-01-23  638 views 评论

MySQL Dapper程序执行中报Got a packet bigger than ‘max_allowed_packet’ bytes

遇到一个很奇怪的问题,SQL语句如下:

SELECT D.StoreId,D.AddressId,
D.Province,D.City,D.AreaInfomation_Id,D.CompanyName,D.DetailAddress,D.Tel,D.ContactNumber,D.Contact,D.ReceiveAddress_Id,D.Remark,D.CountyArea,
GROUP_CONCAT(AdDefault  SEPARATOR '|')
FROM 
(
SELECT A.StoreId,A.AddressId,
C.Province,C.City,C.AreaInfomation_Id,C.CompanyName,C.DetailAddress,C.Tel,C.ContactNumber,C.Contact,C.ReceiveAddress_Id,C.Remark,C.CountyArea,
concat(A.AddressType,'_',A.IsDefault) as AdDefault FROM StoreAddress A
LEFT JOIN StoreAddress B ON (A.AddressId = B.AddressId AND A.StoreId = B.StoreId)
LEFT JOIN ReceivingAddress C ON A.AddressId = C.ReceiveAddress_Id
GROUP BY A.StoreAdId
HAVING A.StoreId=22
ORDER BY AddressId ASC,AdDefault DESC) D
GROUP BY D.AddressId;

在Navicate和黑框中执行都没有报错,放到程序中执行(使用Dapper),报如下异常

Got a packet bigger than 'max_allowed_packet' bytes

有知道怎么解决的吗?

查询资料 max_allowed_packet是允许Server接收数据包的大小,问题是以上这段语句大小不可能超过1MB吧,数据库中的数据也只有4条,感觉有毒啊,最主要Navicate和黑框都执行不报错!!!

我最后的解决方案比较折中,把查询写成存储过程,调用就能行。

有知道为什么的请留言告知,感激不尽!

给我留言

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: