fix(oceanbase): u64 cell 改发 JSON 数字,对齐宿主 u64 契约 - #9
Merged
Merged
Conversation
共享 dbipc 的 toCellForKind 在 []byte 分支把 u64 序列化为十进制文本 (strconv.FormatUint),而同一函数里原生 uint 家族分支一直发 JSON 数字。 宿主 serde 结构体该字段定义为 u64,收到文本会先在反序列化层判定类型 不匹配:invalid type: string "4", expected u64(invalid external driver response),导致无符号列整表读取失败(navop issue #249 / #207)。 - toCellForKind 的 u64 分支与原生 uint 家族一致,直接发 JSON 数字; 精度不丢:宿主 serde_json 启用 arbitrary_precision,u64 上界按原始 十进制解析,不经 float64 - server_test 断言改为校验原始 JSON 里的精确数字,避免 map[string]any 的 float64 往返掩盖精度丢失;变异回旧编码时该断言立即失败 - bump oceanbase driver 0.1.11 -> 0.1.12 并同步 marketplace manifest 影响面:该分支由 264288d 为 MySQL 文本协议驱动引入,只有声明类型名含 unsigned 的列会判成 u64,当前只有 OceanBase(MySQL 兼容)会走到这里; dm/kingbase/oracle-go/iotdb 共用同一份 dbipc,但不产出 u64 cell。 Java 驱动(gbase8s/oscar)的 u64 分支只用于入参绑定,结果 cell 不发 u64。
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Navop 宿主
CellValue::U64 { value: u64 }把该字段定义为 u64,而共享internal/dbipc的toCellForKind在[]byte分支把 u64 序列化为十进制文本(strconv.FormatUint)。宿主在 serde 反序列化层就直接判定类型不匹配,无符号列整表读取失败:
关联:feigeCode/navop#249、feigeCode/navop#207。
改动
internal/dbipc/query.go:toCellForKind的u64分支与同一函数里的原生uint/uint64分支保持一致,直接发 JSON 数字;只有[]byte这一条分支发文本,属于实现不一致。精度不丢:宿主 serde_json 启用
arbitrary_precision,u64 上界按原始十进制解析,不经 float64。
internal/dbipc/server_test.go:断言改为校验原始 JSON里的精确数字(
"type":"u64","value":18446744073709551615),避免map[string]any的float64 往返掩盖精度丢失。
extensions/ipc/oceanbase/driver.json0.1.11 → 0.1.12,并同步根manifest.json(沿用 264288d / 7d7f4a0 的发布约定)。
影响面
该分支由 264288d 为 MySQL 文本协议驱动引入。
u64这个 kind 只由typeKind里「类型名含 unsigned」命中,属 MySQL 系专有,当前只有 OceanBase 会走到这里;
dm/kingbase/oracle-go/iotdb 共用同一份 dbipc,但不产出 u64 cell。Java 驱动
(gbase8s/oscar)的 u64 分支只用于入参绑定,结果 cell 不发 u64。
宿主侧另有兼容层(feigeCode/navop#257)容忍旧驱动发文本,两边可独立发布:
本 PR 是契约侧的根因修复,宿主兼容层保证老驱动不阻塞用户。
How to Test
CGO_ENABLED=0 go test ./... node --test tests/scripts.test.mjs gofmt -l internal/dbipcgo test ./...与脚本测试全绿。变异校验:把u64分支改回strconv.FormatUint(n, 10),TestCursorFetchEncodesByteArraysByDeclaredColumnType立即失败并打印出字符串形态的
"value":"18446744073709551615"。(本机默认 CGO 构建会因 Xcode SDK 与 clang 的
arm64e.x1-macos不匹配而链接失败,与本次改动无关;CI 上按默认设置跑
go test ./...即可。)