Skip to content

[Bug]: INSERT VALUES with a nested scalar IF subquery is rejected as an unsupported JOIN condition (v4.2.5) #29902

Closed

Description

@dengn

Is there an existing issue for the same bug?

  • I searched exact error strings, failing syntax and affected native applications; no matching issue was identified. Related reports are distinguished below.

Application compatibility replay on official v4.2.5

Branch Name

Official stable release v4.2.5; current main has not been retested for this report.

Commit ID

1a44f3db3056e32975fde86ca0ab69a094996a3f (SELECT git_version() returns 1a44f3d).

Other Environment Information

Linux x86_64 standalone official binary, 4 CPUs, ~16 GiB container memory limit. SELECT VERSION() = 8.0.30-MatrixOne-v4.2.5. PyMySQL 1.2.3 client. Only fresh owned test schemas were used for SQL probes; the native Airflow diagnostic is a read-only SELECT against the retained test fixture.

Actual Behavior

Native application impact: 用户 ACL 原生写入失败。

ERROR 20102: subquery in JOIN condition is not yet implemented

Expected Behavior

Execute scalar lookup subqueries inside the INSERT value expression, including the nested IF owner lookup, without incorrectly rejecting an internal JOIN.

Steps to Reproduce

Use a dedicated fresh test schema (create one without DROP DATABASE), then run:

CREATE TABLE `user`(id INT PRIMARY KEY,`user` VARCHAR(64) UNIQUE);

INSERT INTO `user` VALUES(1,'alice');

CREATE TABLE user_access(user_id INT NOT NULL,topic VARCHAR(255),`read` BOOL,`write` BOOL,owner_user_id INT NULL,provisioned BOOL,PRIMARY KEY(user_id,topic));

INSERT INTO user_access (user_id,topic,`read`,`write`,owner_user_id,provisioned) VALUES((SELECT id FROM `user` WHERE `user`='alice'),'owned_topic',TRUE,TRUE,(SELECT IF(''='',NULL,(SELECT id FROM `user` WHERE `user`=''))),FALSE) ON DUPLICATE KEY UPDATE `read`=VALUES(`read`),`write`=VALUES(`write`),owner_user_id=VALUES(owner_user_id),provisioned=VALUES(provisioned);

Additional information

  • Native applications: ntfy.
  • This is release v4.2.5 evidence, not a claim that the same failure remains on current main.
  • Observation family MO-OBS-008. App-side workarounds do not constitute an engine fix.
  • All disclosed values are owned synthetic fixtures; no passwords, tokens, application cookies or raw private logs are attached.

The scalar IF fixture is reconstructed from the original ntfy SQLite permission query with MySQL IF/ON DUPLICATE KEY syntax. It does not contain a user-written JOIN condition; the rejected JOIN is produced during subquery lowering. Related #24996/#25973 concern explicit JOIN ON subqueries.

Activity

  1. added
    kind/bug
    on Oct 11, 2026
  2. added
    severity/s0
    and removed on Oct 11, 2026
  3. Ariznawlll commented on Oct 14, 2026

    @Ariznawlll
    Collaborator

    补充当前 main 复测:固定源码 commit 2ce4e58af6f03b943ee288ffad81012766cf830a(本地 mo-service Go build metadata 对应该 commit),MySQL 8.0.46。独立 user/user_access fixture 中,issue 原 SQL 的执行路径在当前 main 仍返回 ERROR 20102: subquery in JOIN condition is not yet implemented;每轮执行后检查目标表,MO 未插入任何行,MySQL 成功写入 (user_id=1, topic='owned_topic', owner_user_id=NULL)。

    扩展矩阵缩小后发现触发点不局限于嵌套 IF,也不要求 ODKU:

    • 无子查询的普通 INSERT ... VALUES ... ON DUPLICATE KEY UPDATE 两边正常;
    • 仅 user_id 使用标量子查询(有/无 ODKU)、仅 owner_user_id 使用普通标量子查询、嵌套 IF、把 IF 换成 CASE、两个子查询同时存在,MO 均报同一错误;MySQL 均成功。
    • 普通 SELECT 计算相同标量表达式正常;相同表达式放进 INSERT ... SELECT 或 REPLACE ... VALUES 也都能执行并与 MySQL 一致。

    白盒上,bind_insert.go 对 VALUES 调用 buildValueScan(..., isReplace, ...);DefaultBinder.BindSubquery 在 allowSubquery=false 时返回该 NYI,而当前 buildValueScanWithSubqueries lowering 仅在 allowSubquery 路径启用。当前结果因此是普通 INSERT VALUES 的标量子查询能力缺口,不是 IF 特例,也不是重复键冲突导致;兼容性契约中未登记此限制。未改产品代码或新增测试。

  4. XuPeng-SH commented on Oct 17, 2026

    @XuPeng-SH
    Contributor

    本轮版本对照复验:main aa4b6eddfdad54d11be6fd75a5675eb9801f6690 上原始嵌套 scalar IF / INSERT VALUES 场景实际通过;当前 4.2-dev c914080bba57dd17fb86be300c22b9be43cc2b61 同一场景仍返回 20102:subquery in JOIN condition is not yet implemented。原报告目标为 v4.2.5,所以 main 的修复不能代替该版本分支交付。本轮保持开发负责人,尚不转测,沿用本 issue 跟踪版本缺口。

  5. XuPeng-SH commented on Oct 17, 2026

    @XuPeng-SH
    Contributor

    继续验证记录(2026-10-17),4.2-dev ac27db31696c0394ab1b2787b7b0a8f4933f088f(Go 1.26.4),Linux/amd64、匹配 CGo 产物、真实测试执行结果:

    4.2 原始嵌套标量子查询 INSERT ... ON DUPLICATE KEY UPDATE 仍返回 20102: subquery in JOIN condition is not yet implemented。

    此项仍未解决;保留现有开发指派,不转测。使用现有 issue 跟踪,没有为同一现象重复建 issue。

  6. XuPeng-SH commented on Oct 18, 2026

    @XuPeng-SH
    Contributor

    补齐 continue18 本轮已经完成的实测记录(2026-10-18,本条未启动第二次新测试)。环境 Linux/amd64、Go 1.27.1、各分支独立新建 CPU/CGo;main 4226537e5094995155eab9c2a883db649ff7b95b,4.2-dev 35273bcd6a5cfa9468bcf7ca4031fe17560b5ab1。生产逻辑未提交修改。

    真实认证 MySQL TCP 在 CN0/CN1 分别运行嵌套标量 IF 子查询的 INSERT ... ON DUPLICATE KEY UPDATE:main 均成功,并确认写入用户 id=1、owner 为 NULL;4.2 两个 CN 仍报 20102: subquery in JOIN condition is not yet implemented。失败子场景 29902_nested_scalar。

    原日志 logs/main-sql-final.log、logs/4.2-sql-final.log 与 .exit 均保留在 /workspace/work/pr-audit-continue18;混合批次 exit 1,逐场景结果明确。版本缺口仍在,保留 aunjgr 开发处理,不整体转测。

  7. assigned and unassigned on Oct 18, 2026
  8. XuPeng-SH commented on Oct 18, 2026

    @XuPeng-SH
    Contributor

    纠正此前将 4.2 回移作为本 issue 转测前提的审计结论:#30220 明确声明本次修复 targets main / does not backport to the reported release。报告环境 v4.2.5 本身不构成必须回移的交付要求,4.2 差异不再阻塞 main 修复转测。

    本轮 main 2508ce7029b03e6bb3ac0bd8e66a994d12593664,Linux/amd64、Go 1.27.1、新建 CPU/CGo 产物,真实认证 MySQL TCP 在 CN0/CN1 分别执行嵌套 scalar IF 的 INSERT VALUES / ON DUPLICATE KEY UPDATE,均成功,且断言 user_id=1、owner_id IS NULL。命令 .agents/skills/mo-dev/scripts/mo-cgo-test -overlay=/workspace/work/pr-audit-continue19/main-overlay.json -p 2 -count=1 -v -timeout=15m -run '^TestAuditContinue18PublicSQL$/^CN[01]$/^(30505_warning_utf8|29902_nested_scalar)$' ./pkg/tests/issues,exit 0;原始日志 /workspace/work/pr-audit-continue19/logs/main-public-sql.log。

    本轮顺带复测 4.2-dev 35273bcd6a5cfa9468bcf7ca4031fe17560b5ab1,同一场景两 CN 仍失败(logs/4.2-nested-scalar.log),该结果仅记录版本差异,不自动提出 pick 要求,也不退回开发。保留现有 @Ariznawlll 测试指派;此前“因 4.2 未修复不转测”的结论撤回。

  9. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    Collaborator

    测试版本

    验收范围按本 issue 研发对修复 PR #30220 的说明和用户最新要求限定为官方 main,不要求 v4.2.5/4.2-dev 回补。执行时 origin/main 完整 SHA 为 873282742714436bff407dfcdbbe879147162bd3;修复 merge commit 5f9a8c313813d7e1f89c39c5e78f182fa8ea4551 已确认是其祖先。macOS/arm64 隔离 worktree 构建的 1 CN / 1 TN / 1 LogService,真实 MySQL 协议端口 6001。

    原问题验证

    在该 SHA 上重跑原始 INSERT ... VALUES((SELECT id ...), ..., (SELECT IF(...))) ON DUPLICATE KEY UPDATE。三轮均成功,初次插入的 user_id=1、topic=owned_topic、owner_user_id IS NULL 与独立预期相符;未出现旧版 20102。

    Happy Path 覆盖

    同一回归中,重复键更新将 owner_user_id 更新为 Bob 的 id=2,并检查布尔列及最终行值,3/3。

    Unhappy Path 覆盖

    多行标量子查询返回 1242;失败后的原有行保持不变,3/3。每轮独立重建并删除专用测试库。此处不声称 v4.2.5/4.2-dev 已修复:旧发布线此前仍报 20102。

    白盒验证

    本轮未重跑 Go UT 或 race;研发已在另一次 main 双 CN 实测原始 SQL 成功,见 issue 既有研发评论。本条结论以当前 SHA 的真实协议 SQL 和独立期望值为准。

    回归测试

    本任务汇总 MOTR PR #247 当前仍 OPEN,head d164677890934ec5b2187d4218675c80d71ba55e,包含配对 suites/14_issue_regression/t/issue_29902_insert_scalar_if.test 与 r/issue_29902_insert_scalar_if.result。在上述当前 main 上执行 ./motr --branch main --repeat 3 14_issue_regression.issue_29902_insert_scalar_if:3/3 success、39/39 语句成功、0 failed、0 skipped。完整 suite 与集成 CI 本轮未执行,PR 尚未合入。

    测试证据

    修复 PR #30220、MOTR PR #247;本次本地运行摘要 total=3 success=3 failed=0 skipped=0 | stmts=39 ok=39 fail=0。此前因 4.2 回补缺口给出的未通过判断,按已澄清的 main-only 交付范围更新;不代表发布线通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions