Bug #42624 corrupt view when connecting while --skip-grant-tables is active
Submitted: 5 Feb 2009 15:53 Modified: 16 Feb 2009 15:17
Reporter: S Kim Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Views Severity:S3 (Non-critical)
Version:5.1.30, 5.0, 5.1, 6.0 bzr OS:Any (MS Windows, Linux)
Assigned to: CPU Architecture:Any
Tags: --skip-grant-tables, 1141, 42000

[5 Feb 2009 15:53] S Kim
Description:
I started a server with the --skip-grant-tables options (because I was doing a backup training and had removed the data directory.) I later flushed the privileges, but hat the session still open that began before the flush privileges.

This session behaved strangely.

When I do "Show grants":
ERROR 1141 (42000): There is no such grant defined for user '' on host ''
mysql> select user(), current_user();
+--------+----------------+
| user() | current_user() |
+--------+----------------+
| root@  | @              |
+--------+----------------+
1 row in set (0.00 sec)

But worst, I can create a view, but can't query it:
mysql> create view kor_city as select * from city where countrycode='KOR';
Query OK, 0 rows affected (0.00 sec)
mysql> select * from kor_city;
ERROR 1449 (HY000): The user specified as a definer (''@'') does not exist
mysql> show tables like 'kor_city%';
+-----------------------------+
| Tables_in_world (kor_city%) |
+-----------------------------+
| kor_city                    |
+-----------------------------+
1 row in set (0.00 sec)

How to repeat:
start mysql --skip-grant-tables
flush privileges
but leave mysql client session open
create view
query view

Suggested fix:
give an error message when trying to create views without a valid user context
[5 Feb 2009 17:41] Sveta Smirnova
Thank you for the report.

Please indicate accurate minor version of the MySQL server you use.
[6 Feb 2009 10:15] S Kim
5.1.30-community-log
[16 Feb 2009 15:17] Sveta Smirnova
Thank you for the report.

Verified as described.

Test case for MTR:

$cat src/tests/t/bug42624.test 
create table t1(f1 int);

flush privileges;

create view v1 as select f1 from t1;

select * from v1;

$cat src/tests/t/bug42624-master.opt 
--skip-grant-tables