Bug #98068 SELECT FOR UPDATE not-exist table in PERFORMANCE SCHEMA reports confusing error

Submitted: 25 Dec 2019 7:09 Modified: 12 Feb 2021 19:03
Reporter: William ZHANG Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Data Dictionary Severity:S3 (Non-critical)
Version:8.0.18, 8.0.11 OS:Ubuntu (19.10.1)
Assigned to: Marc ALFF CPU Architecture:x86
Tags: regression

[25 Dec 2019 7:09] William ZHANG
Description:
Set current database to performance_schema, and select a not-exist table for update, the error message is:

ERROR 1142 (42000): SELECT with locking clause command denied to user 'root'@'localhost' for table 'not_exist_table'

which should be,

ERROR 1146 (42S02): Table 'performance_schema.not_exist_table' doesn't exist

If set current database to information_schema, then do the same selects, the error message is different. 

How to repeat:
$ sudo mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.18-0ubuntu0.19.10.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from not_exist_table;
ERROR 1146 (42S02): Table 'test.not_exist_table' doesn't exist

mysql> select * from not_exist_table for update;
ERROR 1146 (42S02): Table 'test.not_exist_table' doesn't exist

mysql> use performance_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 
mysql> select * from not_exist_table;
ERROR 1146 (42S02): Table 'performance_schema.not_exist_table' doesn't exist.   ===> EXPECTED

mysql> select * from not_exist_table for update;
ERROR 1142 (42000): SELECT with locking clause command denied to user 'root'@'localhost' for table 'not_exist_table'                                                                                                               ===> NOT EXPECTED

mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from not_exist_table;
ERROR 1109 (42S02): Unknown table 'NOT_EXIST_TABLE' in information_schema. ===> EXPECTED?

mysql> select * from not_exist_table for update;
ERROR 1109 (42S02): Unknown table 'NOT_EXIST_TABLE' in information_schema. ===> EXPECTED?

Suggested fix:
1. Fix the error message as sth. like 

ERROR 1146 (42S02): Table 'performance_schema.not_exist_table' doesn't exist.

2. Make sure the error messages are consistent whether current database is performance_schema or not.
[26 Dec 2019 7:15] MySQL Verification Team
Hello William,

Thank you for the report.

Thanks,
Umesh
[12 Feb 2021 19:03] Paul DuBois
Posted by developer:
 
Fixed in 8.0.24.

SELECT ... FOR UPDATE from a nonexistent Performance Schema table
produced ER_TABLEACCESS_DENIED_ERROR rather than ER_NO_SUCH_TABLE.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.