Bug #109324 Expression Index not check whether the rely on table illegal or not
Submitted: 9 Dec 2022 6:13 Modified: 9 Dec 2022 7:55
Reporter: hangjie Mo Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.28, 8.0.31 OS:Any
Assigned to: CPU Architecture:Any

[9 Dec 2022 6:13] hangjie Mo
Description:
create table with SQL below

```
CREATE TABLE `t2` (
`id` int NOT NULL AUTO_INCREMENT ,
`name` varchar(30) DEFAULT NULL ,
`create_time` datetime NOT NULL ,
PRIMARY KEY (`id`) ,
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
```

Then create an expression index
```
create index idx_t2_name on test.t2((lower(texxst.t3.name)));
```

No matter what the schema name and table name are in lower function, it could create successful.

How to repeat:
See descriptions.

Suggested fix:
check schema name and table name. Report error when it not equal with current table.
[9 Dec 2022 7:55] MySQL Verification Team
Hello hangjie Mo,

Thank you for the report and feedback.

regards,
Umesh
[13 Dec 2022 2:56] huahua xu
Both schema name and table name in lower function are missed, when normalizing the expression's text into the DD by the method Value_generator::print_expr within flags `QT_NO_DB | QT_NO_TABLE`.