pingcap / pingcap/tiflash

predicate not (true != col) in where clause causes "can't find a proper physical plan" error

Open
#10,535 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/compute contribution type/bug
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
DROP TABLE IF EXISTS tb0;
DROP TABLE IF EXISTS tb1;
DROP TABLE IF EXISTS tb2;
DROP VIEW IF EXISTS v1;
CREATE TABLE tb0 (id INT UNIQUE AUTO_INCREMENT NOT NULL, c0 DATETIME);
CREATE TABLE tb1 (id INT UNIQUE AUTO_INCREMENT NOT NULL, c0 BOOLEAN) CHARSET=latin1;
CREATE TABLE tb2 (id INT UNIQUE AUTO_INCREMENT NOT NULL, c0 TINYINT DEFAULT 0, c1 CHAR(7) DEFAULT 'default', c2 LONGTEXT, PRIMARY KEY (`id`));
INSERT INTO tb0 (c0) VALUES ('7951-04-19 03:21:17'), ('7508-11-01 11:40:01'), (NULL), (NULL), ('4179-12-30 18:20:20');
INSERT INTO tb1 (c0) VALUES (NULL), (false), (false);
INSERT INTO tb2 (c0, c1, c2) VALUES (52, 'DaPb1', 'IMzHwvvJbrpyfS3NsYNTdu5NZRELraQ4YYWc');
CREATE VIEW v1 AS SELECT id, c0 FROM tb1 WHERE 1=1;
CREATE INDEX idx_comp_tb0_id_c0 ON tb0 (id, c0);

ALTER TABLE tb0 SET TIFLASH REPLICA 1;
ALTER TABLE tb1 SET TIFLASH REPLICA 1;
ALTER TABLE tb2 SET TIFLASH REPLICA 1;


# [HY000][1815] Internal : Can't find a proper physical plan for this query
SELECT /*+ read_from_storage(tiflash[t0,t1,t2,t3]) */ t2.c0 AS col_0, t0.c0 AS col_1
FROM v1 AS t0
         INNER JOIN tb0 AS t1 ON (t0.id = t1.id)
         INNER JOIN tb0 AS t2 ON (t1.c0 = t2.c0)
         INNER JOIN tb0 AS t3 ON (t2.c0 = t3.c0)
WHERE (NOT (true != t1.id));

2. What did you expect to see? (Required)

tidb result:

mysql> SELECT /*+ read_from_storage(tidb[t0,t1,t2,t3]) */ t2.c0 AS col_0, t0.c0 AS col_1
    -> FROM v1 AS t0
    ->          INNER JOIN tb0 AS t1 ON (t0.id = t1.id)
    ->          INNER JOIN tb0 AS t2 ON (t1.c0 = t2.c0)
    ->          INNER JOIN tb0 AS t3 ON (t2.c0 = t3.c0)
    -> WHERE (NOT (true != t1.id));
+---------------------+-------+
| col_0               | col_1 |
+---------------------+-------+
| 7951-04-19 03:21:17 |  NULL |
+---------------------+-------+
1 row in set, 1 warning (0.004 sec)

remove not operator:

mysql> SELECT /*+ read_from_storage(tiflash[t0,t1,t2,t3]) */ t2.c0 AS col_0, t0.c0 AS col_1
    -> FROM v1 AS t0
    ->          INNER JOIN tb0 AS t1 ON (t0.id = t1.id)
    ->          INNER JOIN tb0 AS t2 ON (t1.c0 = t2.c0)
    ->          INNER JOIN tb0 AS t3 ON (t2.c0 = t3.c0)
    -> WHERE ((true != t1.id));
+---------------------+-------+
| col_0               | col_1 |
+---------------------+-------+
| 7508-11-01 11:40:01 |     0 |
+---------------------+-------+
1 row in set, 1 warning (0.020 sec)
3. What did you see instead (Required)
mysql> SELECT /*+ read_from_storage(tiflash[t0,t1,t2,t3]) */ t2.c0 AS col_0, t0.c0 AS col_1
    -> FROM v1 AS t0
    ->          INNER JOIN tb0 AS t1 ON (t0.id = t1.id)
    ->          INNER JOIN tb0 AS t2 ON (t1.c0 = t2.c0)
    ->          INNER JOIN tb0 AS t3 ON (t2.c0 = t3.c0)
    -> WHERE (NOT (true != t1.id));
ERROR 1815 (HY000): Internal : Can't find a proper physical plan for this query
4. What is your TiFlash version? (Required)
mysql> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-250-ga6d415f24a
Edition: Community
Git Commit Hash: a6d415f24a7d182ebca3d189c457d9044537028f
Git Branch: HEAD
UTC Build Time: 2025-08-03 10:01:12
GoVersion: go1.23.11
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is named. Start by reproducing the query on TiFlash v9.0.0-beta.2.pre-250-ga6d415f24a and compare it with the TiDB and non-NOT results; done means the NOT predicate produces the expected row instead of error 1815, with regression coverage added in the appropriate planner tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.