Skip to content

[Bug]: correlated MAX subquery panics with two range bounds and an unused column #32440

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

4.2-dev (the container reports HEAD; the build commit is on 4.2-dev).

Commit ID

71498157cc21f833b8e717f45d50d1f926be3134

Other Environment Information

  • MatrixOne SQL version: 8.0.30-MatrixOne-v4.2.6
  • Docker image: matrixorigin/matrixone@sha256:14a5c1e88bf1d60b78d47dcc550e724f65a81dc47c07331cf8b6286c12fdd535
  • Container architecture: Linux arm64, running on macOS arm64

Actual Behavior

A correlated scalar subquery using MAX and two bounds on the same inner column returns an internal panic. It reproduced 3/3 times in a fresh database with one row in each table:

ERROR 20101 (HY000): internal error: panic runtime error: index out of range [2] with length 2
runtime.panicBounds64
github.com/matrixorigin/matrixone/pkg/sql/colexec.(*ColumnExpressionExecutor).Eval
    pkg/sql/colexec/evalExpression.go:1194

Expected Behavior

The query should return one row containing 1, without an internal error.

Steps to Reproduce

Run the following in an empty test database:

CREATE TABLE parent (id INT, ceiling BIGINT);
CREATE TABLE child (unused INT, parent_id INT, event_idx BIGINT);
INSERT INTO parent VALUES (1, 49);
INSERT INTO child VALUES (0, 1, 1);

SELECT (
    SELECT MAX(c.event_idx)
    FROM child AS c
    WHERE c.parent_id = p.id
      AND c.event_idx > -1
      AND c.event_idx <= p.ceiling
)
FROM parent AS p;

Additional information

  • Removing the unused first column from child makes the query return 1.
  • Keeping the original schema and replacing MAX(c.event_idx) with c.event_idx ORDER BY c.event_idx DESC LIMIT 1 also returns 1.
  • No index is needed for the reproduction.
  • A similar correlated MAX query on a wider real schema instead produced panic unsafe slice cast: from length 8 is not enough for length 24; it is not yet established whether that is the same underlying defect.
  • All reproduction data above is synthetic; the temporary database was removed after testing.

Activity

  1. added
    kind/bug
    on Nov 10, 2026
  2. self-assigned this
    on Nov 10, 2026
  3. XuPeng-SH commented on Nov 10, 2026

    @XuPeng-SH
    ContributorAuthor

    already fixed by #26827 and #31512

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions