Skip to content

Commit 8826242

Browse files
committed
More acculate estimation of upper bound
1 parent 9f84dfb commit 8826242

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

connection.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,18 @@ func (mc *mysqlConn) escapeBytes(buf, v []byte) []byte {
179179
return buf
180180
}
181181

182+
// estimateParamLength calculates upper bound of string length from types.
182183
func estimateParamLength(args []driver.Value) (int, bool) {
183184
l := 0
184185
for _, a := range args {
185186
switch v := a.(type) {
186187
case int64, float64:
187-
l += 20
188+
// 24 (-1.7976931348623157e+308) may be upper bound. But I'm not sure.
189+
l += 25
188190
case bool:
189-
l += 5
191+
l += 1 // 0 or 1
190192
case time.Time:
191-
l += 30
193+
l += 30 // '1234-12-23 12:34:56.777777'
192194
case string:
193195
l += len(v)*2 + 2
194196
case []byte:

0 commit comments

Comments
 (0)