Repository navigation
Description
Description
MBRWithin 与 MBRCoveredBy 当前调用完全相同的包含判定,导致位于另一个 MBR 边界上的点同时满足两者。Within 要求第一个 MBR 的内部位于第二个 MBR 的内部;仅被边界覆盖时应由 MBRCoveredBy 表达。
这会让依赖 MBRWithin 排除边界对象的空间过滤返回额外行。
Environment
- Branch:
main - Commit:
e7bb0572235ec4bac81eb098eb0ad8900f0065ab - Deployment: macOS arm64,单节点 MatrixOne,默认 launch 配置
- Date: 2026-09-05
Steps to reproduce
SELECT
MBRWithin(
ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POLYGON((0 0,4 0,4 4,0 4,0 0))')
) AS on_boundary_within,
MBRCoveredBy(
ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POLYGON((0 0,4 0,4 4,0 4,0 0))')
) AS on_boundary_covered_by;
SELECT
MBRWithin(
ST_GeomFromText('POINT(2 2)'),
ST_GeomFromText('POLYGON((0 0,4 0,4 4,0 4,0 0))')
) AS interior_within;Actual behavior
on_boundary_within = 1
on_boundary_covered_by = 1
interior_within = 1
Expected behavior
on_boundary_within = 0
on_boundary_covered_by = 1
interior_within = 1
MySQL 8.3.0 对相同输入返回上述 expected result。
Stability and controls
- 边界点、内部点场景各重复 3 次,结果稳定。
- 常量表达式、表列扫描以及创建 R-tree 空间索引后的查询均得到相同错误结果。
MBRCoveredBy对边界点返回 1,符合其包含边界的语义;问题集中在MBRWithin的严格性。- 576 组 Point/LineString/Polygon MBR 配对、共 5,184 个谓词差分中,此差异可稳定归类到退化 MBR 的边界包含场景。
Evidence and code analysis
- Exact main commit: e7bb057
bboxContainsuses inclusive comparisons:matrixone/pkg/sql/plan/function/func_binary.go
Lines 9947 to 9949 in e7bb057
func bboxContains(a, b geo.BBox) bool { return a.MinX <= b.MinX && a.MinY <= b.MinY && a.MaxX >= b.MaxX && a.MaxY >= b.MaxY } MBRWithinandMBRCoveredByare aliases of the same predicate:matrixone/pkg/sql/plan/function/func_binary.go
Lines 9990 to 9996 in e7bb057
func MBRWithin(ivecs []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int, selectList *FunctionSelectList) error { return mbrBinary("MBRWithin", func(a, b geo.BBox) bool { return bboxContains(b, a) })(ivecs, result, proc, length, selectList) } func MBRCoveredBy(ivecs []*vector.Vector, result vector.FunctionResultWrapper, proc *process.Process, length int, selectList *FunctionSelectList) error { return mbrBinary("MBRCoveredBy", func(a, b geo.BBox) bool { return bboxContains(b, a) })(ivecs, result, proc, length, selectList) }
MBRWithin 与 MBRCoveredBy 没有独立实现,两者都反向调用含 <=/>= 的 bboxContains,因此无法区分内部包含与边界覆盖。
Regression coverage
修复时应覆盖 Point/LineString/Polygon 的 MBR 位于内部、边界、角点、完全相等、部分重叠和不相交场景,并同时断言 Within/CoveredBy 与 Contains/Covers 的对偶关系;覆盖常量、表列和空间索引路径。
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working
Activity
XuPeng-SH commentedon Sep 13, 2026
Fix is submitted in PR #28811.
MBRWithin/MBRContains now require closed-box coverage plus intersecting relative interiors, so an interior point is within while a boundary-only point is not. MBRCoveredBy/MBRCovers retain inclusive boundary coverage. This also repairs the shared boundary distinction implicated by #28190.
The change adds evaluator tests across 0D/1D/2D MBRs and public SQL constant/table-column regressions. Focused and full function-package UT, go vet, and incremental golangci-lint passed. Local BVT was not run because the configured host has an unrelated active MatrixOne service; PR CI is running.
fix(spatial): correct MBR predicates for degenerate bounds (#28811)
Ariznawlll commentedon Sep 14, 2026
测试版本
原问题验证
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
回归测试
测试证据
测试结论
测试通过。
fix(spatial): correct MBR predicates for degenerate bounds (matrixori…
fix(spatial): correct MBR predicates for degenerate bounds (matrixori…
fix(spatial): correct MBR predicates for degenerate bounds (matrixori…