Row.Scan 可能返回错误的结果 #2134

Closed
opened 2022-04-21 04:10:46 +00:00 by davies · 0 comments

当扫描一个带有二进制列的 表时,如果用来保存结果的 数据结构中的 []byte 的长度不为 0,那它会将当前行的部分结果拷贝到 []byte 中,也没有更新它的长度。

相关代码在 sessions.go 中 582 行。

建议 对于 长度不为0 的 []byte, 先将长度改成 0, 然后再 append 就行了,在确保正确的情况下,尽量沿用已有的内存。

我们目前碰到了这个问题,在使用时做了绕过处理: https://github.com/juicedata/juicefs/pull/1854

当扫描一个带有二进制列的 表时,如果用来保存结果的 数据结构中的 []byte 的长度不为 0,那它会将当前行的部分结果拷贝到 []byte 中,也没有更新它的长度。 相关代码在 sessions.go 中 582 行。 建议 对于 长度不为0 的 []byte, 先将长度改成 0, 然后再 append 就行了,在确保正确的情况下,尽量沿用已有的内存。 我们目前碰到了这个问题,在使用时做了绕过处理: https://github.com/juicedata/juicefs/pull/1854
lunny added the
kind
bug
label 2022-04-22 01:19:57 +00:00
lunny added this to the 1.3.1 milestone 2022-04-22 01:20:12 +00:00
lunny closed this issue 2022-04-22 02:16:35 +00:00
lunny referenced this issue from a commit 2022-04-22 02:16:36 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2134
No description provided.