Skip to content

[Bug]: DATA BRANCH PICK literal KEYS rejects BOOL and BIT primary keys #26074

Description

@Ariznawlll

Description

DATA BRANCH PICK ... KEYS(...) rejects literal keys when the primary key type is BOOL or BIT, even though the same operation succeeds when the key is provided by a typed subquery.

The literal path and subquery path therefore support different primary-key type sets.

Environment

  • Branch: main
  • Commit: 2eb7f523e5a10f352d3e258183ed8440510388de
  • Version: 8.0.30-MatrixOne-v1.3.0

Steps to reproduce

DROP DATABASE IF EXISTS g4d_pick_bool_bit;
CREATE DATABASE g4d_pick_bool_bit;
USE g4d_pick_bool_bit;

CREATE TABLE bool_base(k BOOL PRIMARY KEY, v INT);
INSERT INTO bool_base VALUES(FALSE, 10), (TRUE, 20);
DATA BRANCH CREATE TABLE bool_src FROM bool_base;
DATA BRANCH CREATE TABLE bool_dst FROM bool_base;
UPDATE bool_src SET v = v + 100;

DATA BRANCH PICK bool_src INTO bool_dst KEYS(1);
DATA BRANCH PICK bool_src INTO bool_dst KEYS(TRUE);

-- Control: the same BOOL key succeeds through the typed subquery path.
DATA BRANCH PICK bool_src INTO bool_dst
  KEYS(SELECT k FROM bool_src ORDER BY k DESC LIMIT 1);

CREATE TABLE bit_base(k BIT(8) PRIMARY KEY, v INT);
INSERT INTO bit_base VALUES(b'00000001', 10), (b'00000010', 20);
DATA BRANCH CREATE TABLE bit_src FROM bit_base;
DATA BRANCH CREATE TABLE bit_dst FROM bit_base;
UPDATE bit_src SET v = v + 100;

DATA BRANCH PICK bit_src INTO bit_dst KEYS(1);

-- Control: the same BIT key succeeds through the typed subquery path.
DATA BRANCH PICK bit_src INTO bit_dst
  KEYS(SELECT k FROM bit_src ORDER BY k LIMIT 1);

Actual result

The literal cases fail consistently:

invalid input: unsupported PK type for engine filter: BOOL
invalid input: unsupported PK type for engine filter: BIT

The corresponding typed-subquery cases succeed and update the expected destination rows.

The result reproduced in 3 out of 3 runs.

Expected result

Literal KEYS(...) should accept values compatible with BOOL and BIT primary keys, consistently with the typed-subquery form.

Code observation

appendNumericStringToVec in pkg/frontend/data_branch_pick.go does not handle BOOL or BIT, while formatPickKeyVectorValueAsString supports these types for the subquery path.

Activity

  1. added this to the MO-202607 milestone on Jul 23, 2026
  2. added
    kind/bug
    on Jul 23, 2026
  3. added theissue type on Jul 23, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Jul 29, 2026
  5. added and removed
    severity/s0
    on Jul 30, 2026
  6. Ariznawlll commented on Jul 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    在最新 main 上对该问题进行了原始场景复测和扩展覆盖。

    测试版本

    已通过的场景

    1. BOOL 单列主键:
      • KEYS(FALSE)、KEYS(TRUE)
      • 数字形式 KEYS(0)、KEYS(1)
      • 分别选择 UPDATE 和 DELETE
    2. BOOL 复合主键:
      • (BOOL, INT) tuple keys
      • 同时覆盖 UPDATE、DELETE 和未选择行保持不变
    3. 冲突处理:
      • WHEN CONFLICT FAIL 正确返回冲突,目标行保持 dst-true,没有部分覆盖
      • WHEN CONFLICT ACCEPT 正确将目标行更新为 src-true
    4. BIT:
      • BIT(1) 的 0/1
      • BIT(8) 的下界 0、中间值 127、上界 255、DELETE 和不存在 key 的 no-op
      • BIT(64) 的 0、9223372036854775808、18446744073709551615
      • typed subquery 形式
    5. 非法值和原子性:
      • BIT(8) 的 256、-1 均正确报越界错误
      • 两次失败后目标表内容均保持原状,没有部分写入

    新增 BVT 已连续运行 3 轮,每轮 69/69 条命令通过:

    白盒验证也通过:

    go test ./pkg/frontend \
      -run '^(TestAppendNumericStringToVec_AllTypes|TestAppendNumericStringToVec_BitOutOfRange|TestAppendExprToVec_BoolLiteral)$' \
      -count=3
    
    go test -race ./pkg/frontend \
      -run '^(TestAppendNumericStringToVec_AllTypes|TestAppendNumericStringToVec_BitOutOfRange|TestAppendExprToVec_BoolLiteral)$' \
      -count=1
    

    仍未通过的扩展场景

    原生 BIT 字面量仍稳定失败:

    DATA BRANCH PICK bit8_literal_src
    INTO bit8_literal_dst
    KEYS(b'00000001');

    3/3 次均返回:

    ERROR 1690: data out of range: data type bit(8), value '0b00000001'
    

    失败后目标表未发生变化。当前实现将 AST 保留的 0b00000001 直接交给十进制 strconv.ParseUint(..., 10, ...),因此该语法没有被识别。检索现有 issue 未找到重复项;该边界仍属于本 issue 描述的 “BIT literal KEYS” 范围。

    Unhappy path 覆盖

    • WHEN CONFLICT FAIL:命中冲突时操作被拒绝,目标表保持原值,没有部分更新。
    • BIT(8) 越界值 256 和 -1:均返回范围错误,失败后目标表保持不变。
    • 原生 BIT 字面量 KEYS(b'00000001'):连续 3 次均返回 ERROR 1690,说明该 issue 的原生 BIT literal 路径仍未修复。

    测试结论

    测试不通过。

  7. removed their assignment
    on Jul 30, 2026
  8. 2 remaining items

  9. added a commit that references this issue on Aug 3, 2026
    bb011f2
  10. gouhongshen commented on Aug 4, 2026

    @gouhongshen
    Contributor

    fixed

  11. added and removed
    severity/s0
    on Aug 4, 2026
  12. Ariznawlll commented on Aug 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:c58cd292d3e6e039a8882654d3b20ad345171e87
    • 部署方式:macOS arm64,本地 MatrixOne 单 CN 黑盒环境
    • 测试日期:2026-08-04

    原问题验证

    在前次评论中仍失败的原生 BIT 字面量路径已重新验证:DATA BRANCH PICK ... KEYS(b'00000001') 连续执行 3 轮均成功,选中的 BIT(8) 行从 v=10 更新为 v=110,未选择行保持 v=20。

    Happy Path 覆盖

    1. BOOL 单列/复合主键覆盖 FALSE/TRUE 和 0/1。
    2. BIT(1)、BIT(8)、BIT(64) 覆盖 0、中间值、上界和 typed subquery。
    3. 原生 BIT literal b'00000001' 现已连续 3 轮通过。
    4. 覆盖 UPDATE、DELETE、缺失 key no-op 和 WHEN CONFLICT ACCEPT。

    Unhappy Path 覆盖

    1. BIT(8) 的 256 和 -1 返回范围错误,失败后目标表保持不变。
    2. WHEN CONFLICT FAIL 返回冲突,目标行保持原值,没有部分覆盖。
    3. 非法 BIT literal AST 在白盒路径被拒绝,不会产生 secondary panic。

    白盒验证

    执行原生、unary、parenthesized 和 invalid BIT literal 的定向前端测试,连续执行 3 轮通过。

    回归测试

    测试证据

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions