Skip to content

[Compatibility]: EXTRACTVALUE rejects MySQL XPath aggregate and composed expressions #29329

Closed

Description

@Ariznawlll

Branch Name

main

Commit ID

95b1d2b

Other Environment Information

  • MatrixOne was built from the commit above and started locally with etc/launch/launch.toml.
  • MySQL comparison version: 8.0.45.
  • Each MatrixOne statement was repeated three times with the same result.

Actual Behavior

MatrixOne's EXTRACTVALUE parser accepts basic location paths and count(path), but rejects other XPath expressions that MySQL accepts:

SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', 'sum(/a/b)');
SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', 'count(/a/b)=2');
SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', '/a/b[position()=last()]');

All three statements return:

ERROR 20105 (HY000): not supported: XPATH syntax error or unsupported XPath feature

An adjacent supported expression still works after every error:

SELECT EXTRACTVALUE('<a><b>1</b></a>', '/a/b');
-- 1

Expected Behavior

MySQL 8.0.45 accepts the same expressions and returns:

sum(/a/b)                 -> 3
count(/a/b)=2             -> 1
/a/b[position()=last()]   -> 2

MatrixOne should support the MySQL XPath expression subset used by EXTRACTVALUE, including numeric aggregate expressions, scalar comparisons, and positional predicates composed from XPath functions.

Steps to Reproduce

SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', 'sum(/a/b)');
SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', 'count(/a/b)=2');
SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', '/a/b[position()=last()]');
SELECT EXTRACTVALUE('<a><b>1</b><b>2</b></a>', '/a/b[2]');

The final control expression /a/b[2] is supported by both systems and returns 2.

Additional Information

This is narrower than closed issue #28306, which tracked the prior absence of the entire XML function family. EXTRACTVALUE is now available, but pkg/sql/plan/function/func_xml_xpath.go implements only a subset of the XPath expressions accepted by MySQL.

MySQL reference: https://dev.mysql.com/doc/refman/8.0/en/xml-functions.html

Activity

  1. added this to the MO-202609 milestone on Sep 24, 2026
  2. added theissue type on Sep 24, 2026
  3. self-assigned this
    on Sep 24, 2026
  4. added a commit that references this issue on Sep 25, 2026
    27ea64a
  5. Ariznawlll commented on Sep 27, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:5be6cd90b501da225be591ffffe6000bf01f515e
    • 部署方式:本地单机(1 CN / 1 TN / 1 LogService)
    • 测试日期:2026-09-27

    原问题验证

    在上述最新 main 上按 issue 原始复现步骤执行,并独立重复 3 次;3/3 均满足修复后的预期。当前 main 已包含修复提交 27ea64ab038c80cfc94ad4368315ab30d21e6d56。

    Happy Path 覆盖

    1. EXTRACTVALUE 支持 sum/count/last 及 descendant/union 组合表达式,结果正确。

    Unhappy Path 覆盖

    1. 覆盖重叠 descendant 与 union 去重路径,未返回 unsupported XPath。

    白盒验证

    确认修复提交 27ea64ab038c80cfc94ad4368315ab30d21e6d56 是当前 main 的祖先,并核对对应 MatrixOne BVT/实现路径;本次另以公开 SQL 协议执行黑盒验收。

    回归测试

    已加入 MOTR PR #204 的 issue_29323_29325_29327_29328_29329_29330_29331_sql_contracts.test,MOTR 提交 2b4462f2;本地基线比对连续 3 次通过。

    测试证据

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions