跳到主内容
@wquguru
精选90modernc.org/sqlite(GitLab Commits)语言与库

modernc.org/sqlite: 修复零长度 BLOB 被误读为 NULL 的破坏性变更

conn.go, pre_update_hook.go: read a zero-length BLOB as an empty []byte

原文
发到 X
推荐理由

这是针对 Go SQLite 驱动的破坏性修复。如果你依赖空 BLOB 的正确读写,必须升级以恢复语义一致性,否则会导致数据静默损坏。

sqlite3_column_blob returns a NULL pointer for a zero-length BLOB, and columnBlob returned nil for it. database/sql reads nil as NULL, so x'' and NULL scanned alike, and an empty BLOB read and written back became NULL. The driver already binds []byte{} and nil apart, so only reading lost the difference. The pre-update hook had the same fault.

sqlite3_column_blob 对于长度为零的 BLOB 返回 NULL 指针,而 columnBlob 对此返回 nil。database/sql 将 nil 读作 NULL,因此 x'' 和 NULL 被同等扫描,空 BLOB 读取并写回后变成了 NULL。驱动程序已经区分了 []byte{} 和 nil,因此仅在读取时丢失了这种差异。预更新钩子也存在同样的问题。

Both now return an empty, non-nil slice for a zero-length BLOB. TestEmptyBlob and TestEmptyBlobPreUpdateHook fail on the old code. The whole suite passes, and the new tests pass under -race and as GOARCH=386.

现在两者对于长度为零的 BLOB 都返回一个非 nil 的空切片。TestEmptyBlob 和 TestEmptyBlobPreUpdateHook 在旧代码下会失败。整个测试套件通过,且新测试在 -race 模式下以及 GOARCH=386 下均通过。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件