Skip to content

[Bug]: DATA BRANCH DIFF OUTPUT LIMIT 0 returns one row #26034

Closed

Description

@Ariznawlll

Summary

DATA BRANCH DIFF ... OUTPUT LIMIT 0 returns one diff row instead of an empty result.

Version

  • Branch: main
  • Commit: e15943929885c2c5c83daed90f0f8caeb9a1f0d0

Reproduction

DROP DATABASE IF EXISTS g4d_limit;
CREATE DATABASE g4d_limit;
USE g4d_limit;

CREATE TABLE base(id INT PRIMARY KEY, v INT);
INSERT INTO base VALUES (1,10),(2,20),(3,30);
DATA BRANCH CREATE TABLE child FROM base;
UPDATE child SET v = v + 1;
INSERT INTO child VALUES (4,40);

DATA BRANCH DIFF child AGAINST base OUTPUT LIMIT 0;

The result contains one row, for example:

diff child against base  flag    id  v
child                    UPDATE  1   11

The behavior reproduced in 3 out of 3 clean runs. OUTPUT LIMIT 1 and OUTPUT LIMIT 2 returned one and two rows respectively, and a negative limit was rejected by the parser.

Expected behavior

OUTPUT LIMIT 0 should return zero rows.

Actual behavior

OUTPUT LIMIT 0 returns one row.

Code observation

In satisfyDiffOutputOpt, the current row is appended before the limit condition is checked. For a zero limit, the first row is therefore added before the producer is stopped.

Activity

  1. added this to the MO-202607 milestone on Jul 22, 2026
  2. added
    kind/bug
    on Jul 22, 2026
  3. added theissue type on Jul 22, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Jul 31, 2026
  5. added a commit that references this issue on Aug 1, 2026
    34fdf9d
  6. gouhongshen commented on Aug 2, 2026

    @gouhongshen
    Contributor

    fixed

  7. added and removed
    severity/s0
    on Aug 2, 2026
  8. Ariznawlll commented on Aug 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

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

    原问题验证

    重跑 DATA BRANCH DIFF ... OUTPUT LIMIT 0,结果稳定返回 0 行差异,没有退化为无限制输出。相同用例连续执行 3 轮,结果一致。

    Happy Path 覆盖

    1. 覆盖 LIMIT 0、1、n-1、n、n+1,返回行数均符合边界定义。
    2. 覆盖完整主键排序、投影列以及复合主键。
    3. LIMIT n 和 LIMIT n+1 均返回完整差异集,源表和 branch 内容保持不变。

    Unhappy Path 覆盖

    1. 超出合法范围的无符号整数会被拒绝,不会进入无限制输出路径。
    2. 拒绝后重新读取源表和 branch,行数及数据均未变化,未观察到 panic 或部分状态。

    白盒验证

    执行 TestDataBranchOutputLimitBoundaries 定向测试,覆盖 0、最大合法值及边界转换;连续执行 3 轮通过。

    回归测试

    • 修复及回归测试:PR #26540
    • BVT:test/distributed/cases/git4data/branch/edge/branch_output_limit_zero.sql

    测试证据

    测试结论

    测试通过。

  9. Ariznawlll commented on Aug 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

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

    原问题验证

    重新执行 DATA BRANCH DIFF ... OUTPUT LIMIT 0,完整行和 projection 两种输出均只返回表头、不返回差异行;完整 motr 边界矩阵连续执行 3 轮通过。

    Happy Path 覆盖

    1. 覆盖 LIMIT 0、1、n-1、n、n+1。
    2. LIMIT 1 返回最终排序的首行;LIMIT n 和 n+1 返回完整差异集。
    3. 覆盖 projection、单列主键和复合主键。

    Unhappy Path 覆盖

    1. 9223372036854775808 越界 literal 被 SQL parser 拒绝。
    2. 拒绝后 base 仍为 id 1、2、50,child 仍为 id 50、99、100,未进入无限制输出或修改数据。

    白盒验证

    不适用:本次补充通过真实 DIFF 输出和读后状态验证 LIMIT 边界。

    回归测试

    测试证据

    • 12_git4data.issue_26034_26056_output_limit:26 条语句全部成功,连续 3 轮 baseline 一致。

    测试结论

    测试通过。

  10. added 3 commits that reference this issue on Sep 17, 2026
    d707147
    1cd7d7a
    024934b
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