Skip to content

[Bug]: Prepared IN on information_schema.TABLES drops nested OR branches on 4.2 #27503

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

4.2-dev and the released Docker image matrixorigin/matrixone:4.2.0

Commit ID

01ae8ec (Docker image matrixorigin/matrixone:4.2.0)

Other Environment Information

  • Reproduced with SQL PREPARE/EXECUTE and Go database/sql using go-sql-driver/mysql.
  • The equivalent literal IN query returns the correct rows.

Actual Behavior

A prepared query against information_schema.TABLES drops names from a parameterized IN list.

With five existing tables, only t001, t002, and t005 are returned. The production query uses 132 names and returns only 2 of 132.

Expected Behavior

The prepared query should return every existing table named in the IN list, matching the equivalent literal query.

Steps to Reproduce

DROP DATABASE IF EXISTS moi;
CREATE DATABASE moi;
CREATE TABLE moi.t001 (id INT PRIMARY KEY);
CREATE TABLE moi.t002 (id INT PRIMARY KEY);
CREATE TABLE moi.t003 (id INT PRIMARY KEY);
CREATE TABLE moi.t004 (id INT PRIMARY KEY);
CREATE TABLE moi.t005 (id INT PRIMARY KEY);

SET @schema_name = 'moi';
SET @n1 = 't001';
SET @n2 = 't002';
SET @n3 = 't003';
SET @n4 = 't004';
SET @n5 = 't005';

PREPARE stmt FROM '
  SELECT TABLE_NAME
  FROM information_schema.TABLES
  WHERE TABLE_SCHEMA = ?
    AND TABLE_NAME IN (?,?,?,?,?)
  ORDER BY TABLE_NAME
';
EXECUTE stmt USING @schema_name, @n1, @n2, @n3, @n4, @n5;
DEALLOCATE PREPARE stmt;

Actual:

t001
t002
t005

Literal control:

SELECT TABLE_NAME
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'moi'
  AND TABLE_NAME IN ('t001','t002','t003','t004','t005')
ORDER BY TABLE_NAME;

The literal control returns all five rows.

Additional information

The hidden composite-primary-key predicate is folded into nested OR filters. A disjunctive BasePKFilter container has a zero-value Op equal to function.EQUAL; mergeFilters can therefore treat nested disjunction containers as atomic equality filters and discard the right-hand subtree.

Main no longer reproduces this exact SQL after #26627 added a cast that prevents this query from taking PK pruning, but the nested-OR merge defect itself was not fixed.

Activity

  1. added
    kind/bug
    on Aug 23, 2026
  2. self-assigned this
    on Aug 23, 2026
  3. added
    severity/s0
    and removed on Aug 23, 2026
  4. guopengfei116 commented on Aug 25, 2026

    @guopengfei116

    Independent validation against the released 4.2.0 image confirms this is the direct cause of MatrixFlow workspace-creation failures.

    Image and client

    • Image: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:4.2.0
    • Multi-arch index digest: sha256:c72d249f6f039c31cbfd673b43b6d31f456eeb982b5436add309d3184d6b5b9c
    • SELECT VERSION(): 8.0.30-MatrixOne-v4.2.0
    • Client: Go database/sql + go-sql-driver/mysql v1.9.3
    • Reproduced on both native linux/arm64 and CI-matching linux/amd64

    Minimal four-table result

    With repro_a through repro_d present:

    server prepared:
    TABLE_SCHEMA = ? AND TABLE_NAME IN (?,?,?,?)
    => 2 rows: [repro_a repro_b]
    
    literal control:
    TABLE_SCHEMA = '...' AND TABLE_NAME IN ('repro_a','repro_b','repro_c','repro_d')
    => 4 rows
    
    client interpolation control (`interpolateParams=true`):
    => 4 rows
    

    The parameterized query is correct for one, two, and three names. At four or more names it consistently returns only two. The same parameterized IN query against a normal user table returns every requested row, so the failure is specific to the information_schema.TABLES execution path.

    Production-shaped result

    MatrixFlow creates 136 tenant tables and then verifies them from a fresh connection:

    SHOW TABLES                                      => 136
    information_schema.TABLES without the IN filter => 136
    parameterized required-table IN query            => 2
    readiness                                         => false (found=2 expected=136)
    literal required-table IN query                  => 136
    

    This rules out DDL failure and metadata propagation lag: all 136 tables are already visible to the fresh connection. Four concurrent tenant initializations reproduced the same 2/136 result. The equivalent test on MatrixOne 4.1.2 returns 136/136 and readiness succeeds.

    Observed CI failure: https://github.com/matrixorigin/matrixflow/actions/runs/32803786263/job/97671695276

    PR #27502 is merged into 4.2-dev, but the released 4.2.0 image still contains the defect. Is there a 4.2 patch image/release containing merge commit 5f4cd9d2b1ed5464f660e74fcab94447135fdd6a, or a planned tag that MatrixFlow CI can consume?

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