Skip to content

Commit cac6129

Browse files
committed
Don't send text query larger than maxPacketAllowed
1 parent c8c9bb1 commit cac6129

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

connection.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ func (mc *mysqlConn) buildQuery(query string, args []driver.Value) (string, erro
265265
return "", driver.ErrSkip
266266
}
267267
}
268+
pktSize := len(query) + 4 // 4 bytes for header.
269+
for _, p := range parts {
270+
pktSize += len(p)
271+
}
272+
if pktSize > mc.maxPacketAllowed {
273+
return "", driver.ErrSkip
274+
}
268275
return strings.Join(parts, ""), nil
269276
}
270277

0 commit comments

Comments
 (0)