pingcap/tidb

Create view still keeps "for update" in subquery

Open

#26,254 opened on 2021年7月14日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Go (6,186 forks)batch import
help wantedseverity/minorsig/sql-infratype/bug

Repository metrics

Stars
 (40,090 stars)
PR merge metrics
 (平均マージ 14d 4h) (30d で 346 merged PRs)

説明

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table tn (id int primary key);
create view as select * from (select * from tn for update) as tn;
create view tv1 as select * from (select * from tn for update) as tn;
show create view tv1;

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

No FOR UPDATE in show create view

mysql> show create view tv1;
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                                                                                                                                | character_set_client | collation_connection |
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| tv1  | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` SQL SECURITY DEFINER VIEW `tv1` (`id`) AS SELECT `test`.`tn`.`id` AS `id` FROM (SELECT `test`.`tn`.`id` AS `id` FROM `test`.`tn`) AS `tn`            | utf8mb4              | utf8mb4_0900_ai_ci   |
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+

3. What did you see instead (Required)

FOR UPDATE still exists. Scalar subquery and correlated subquery also have the some problem

mysql> show create view tv1;
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                                                                                                                                | character_set_client | collation_connection |
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| tv1  | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` SQL SECURITY DEFINER VIEW `tv1` (`id`) AS SELECT `test`.`tn`.`id` AS `id` FROM (SELECT `test`.`tn`.`id` AS `id` FROM `test`.`tn` FOR UPDATE) AS `tn` | utf8mb4              | utf8mb4_0900_ai_ci   |
+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+

4. What is your TiDB version? (Required)

master

コントリビューターガイド