Skip to content

MDEV-36389 Incorrect query results for an indexed text column #4124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 11.8
Choose a base branch
from

Conversation

DaveGosselin-MariaDB
Copy link
Member

@DaveGosselin-MariaDB DaveGosselin-MariaDB commented Jun 17, 2025

Fixes a scenario where an IN subquery returned the wrong result because the pushed WHERE clause was not retained for downstream result filtering. For example:

  CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1)));
  INSERT INTO t1 (c1) VALUES ('a');
  SELECT 'abc' IN (SELECT c1 FROM t1);

Internally, he 'abc' IN subquery condition becomes the constant condition:

  'abc' = t1.c1 or t1.c1 is null

Prior to this patch, this condition was incorrectly removed when converting the subquery engine to an index lookup-based engine. Now eligible conditions are preserved during such engine rewrites.

Fixes a scenario where an IN subquery returned the wrong result
because the pushed WHERE clause was not retained for downstream
result filtering.  For example:
  CREATE TABLE t1 (c1 TEXT, UNIQUE (c1(1)));
  INSERT INTO t1 (c1) VALUES ('a');
  SELECT 'abc' IN (SELECT c1 FROM t1);
Internally, he 'abc' IN subquery condition becomes the constant
condition:
  'abc' = t1.c1 or t1.c1 is null
Prior to this patch, this condition was incorrectly removed when
converting the subquery engine to an index lookup-based engine.
Now eligible conditions are preserved during such engine rewrites.
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 11.8-mdev-36389-indexed-text-column-wrong-result branch from 2b41617 to 2cefd28 Compare June 17, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant