Skip to content

Commit 589fef4

Browse files
committed
replace panic with error, handle missing error case
1 parent 81d54a2 commit 589fef4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packets.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,11 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
10761076
dstlen = 8
10771077
case 1, 2, 3, 4, 5, 6:
10781078
dstlen = 8 + 1 + decimals
1079+
default:
1080+
return fmt.Errorf(
1081+
"MySQL protocol error, illegal decimals value %d",
1082+
rows.columns[i].decimals,
1083+
)
10791084
}
10801085
dest[i], err = formatBinaryDateTime(data[pos:pos+int(num)], dstlen, true)
10811086
case rows.mc.parseTime:
@@ -1091,9 +1096,10 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
10911096
case 1, 2, 3, 4, 5, 6:
10921097
dstlen = 19 + 1 + decimals
10931098
default:
1094-
panic(fmt.Sprintf("unexpected decimals value in column %d: %#v",
1095-
i, rows.columns[i],
1096-
))
1099+
return fmt.Errorf(
1100+
"MySQL protocol error, illegal decimals value %d",
1101+
rows.columns[i].decimals,
1102+
)
10971103
}
10981104
}
10991105
dest[i], err = formatBinaryDateTime(data[pos:pos+int(num)], dstlen, false)

0 commit comments

Comments
 (0)