You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: VARCHAR equality predicate returns zero rows with owner-bound PK and covering secondary index #25341
Unknown from SQL variables. Reproduced with Docker image matrixorigin/matrixone:4.0.0-rc4.
Other Environment Information
Hardware parameters: local Docker Compose development environment
OS type: Linux
MatrixOne version: 8.0.30-MatrixOne-v4.0.0-rc4
Docker image: matrixorigin/matrixone:4.0.0-rc4
Actual Behavior
For a table with an owner-bound composite primary key and a secondary index that includes the VARCHAR predicate column plus the primary-key columns, status = 'active' evaluates to 1 in a row projection, but the same predicate in WHERE returns zero rows.
status <=> 'active' returns the expected row count.
Observed output:
id status row_eq row_nullsafe
a1 active 1 1
count_eq
0
count_nullsafe
1
Expected Behavior
WHERE status = 'active' should return the inserted row, so count_eq should be 1, matching the row-level expression result.
Steps to Reproduce
Run this SQL on MatrixOne 8.0.30-MatrixOne-v4.0.0-rc4:
DROPDATABASE IF EXISTS astra_repro_varchar_predicate;
CREATEDATABASEastra_repro_varchar_predicate;
USE astra_repro_varchar_predicate;
CREATETABLEt (
id VARCHAR(64) NOT NULL,
user_id VARCHAR(64) NOT NULL,
session_id VARCHAR(64) NOT NULL,
status VARCHAR(32) NOT NULL,
due DATETIME(6) NULL,
PRIMARY KEY (user_id, session_id, id),
INDEX idx_ret(status, due, user_id, session_id, id)
);
INSERT INTO t
VALUES ('a1', 'u1', 's1', 'active', DATE_ADD(NOW(6), INTERVAL 1 DAY));
SELECT id, status, status ='active'AS row_eq, status <=>'active'AS row_nullsafe
FROM t;
SELECTCOUNT(*) AS count_eq
FROM t
WHERE status ='active';
SELECTCOUNT(*) AS count_nullsafe
FROM t
WHERE status <=>'active';
Additional information
This was found while debugging retention queries on a table with this index shape:
The broader query WHERE status IN ('active', 'expiring') showed the same symptom: row-level expressions evaluated correctly, while WHERE aggregates returned 0.
Supplemental composite-PK + composite-secondary-index coverage on latest main 51656deb6:
The composite primary key itself matched MySQL in a clean control matrix, but once the owner-bound composite-PK table has covering secondary indexes, row-returning predicates on the secondary-index leading VARCHAR columns still miss rows.
Minimal shape:
createtableindexed_tasks (
user_id varchar(16) not null,
session_id varchar(16) not null,
task_id varchar(16) not null,
status varchar(12) not null,
policy varchar(12) null,
due datetime null,
score intnull,
amount decimal(10,2) null,
payload varchar(30),
primary key(user_id, session_id, task_id),
key idx_status_due_owner(status, due, user_id, session_id, task_id),
key idx_policy_owner(policy, user_id, session_id, task_id)
);
With rows containing four status='active' records and four policy='keep' records:
-- MySQL and MO no-secondary-index control
where status='active' -> 4 rows
where policy='keep' -> 4 rows
-- MO indexed table on main 51656deb6
where status='active' -> 0 rows
where policy='keep' -> 0 rows
policy IS NULL did return the expected row, so this repro specifically reinforces the equality/prefix path for non-NULL VARCHAR values on composite secondary indexes with composite-PK columns appended.
Activity
Ariznawlll commentedon Jul 2, 2026
Supplemental composite-PK + composite-secondary-index coverage on latest main
51656deb6:The composite primary key itself matched MySQL in a clean control matrix, but once the owner-bound composite-PK table has covering secondary indexes, row-returning predicates on the secondary-index leading
VARCHARcolumns still miss rows.Minimal shape:
With rows containing four
status='active'records and fourpolicy='keep'records:policy IS NULLdid return the expected row, so this repro specifically reinforces the equality/prefix path for non-NULLVARCHARvalues on composite secondary indexes with composite-PK columns appended.fix: maintain covering secondary indexes (#25342)
1 remaining item
[4.1-dev] fix: maintain covering secondary indexes (#25397)
fix: maintain covering secondary indexes (matrixorigin#25342)
fix: maintain covering secondary indexes (matrixorigin#25342)
fix: maintain covering secondary indexes (matrixorigin#25342)