Bug #38572 Privileges required for commented commands
Submitted: 5 Aug 2008 13:35 Modified: 5 Aug 2008 14:37
Reporter: Pierre Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:4.1.22 OS:Linux (Mandriva Linux)
Assigned to: CPU Architecture:Any
Tags: comments, privileges

[5 Aug 2008 13:35] Pierre
Description:
I want to load a sql file (a database dump)

it contains some DROP TABLE, CREATE TABLE and INSERT commands;

it contains too some things like this :

/*!40000 ALTER TABLE `table1` DISABLE KEYS */;
LOCK TABLES `table1` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `table1` ENABLE KEYS */;

so i'm loading this dump with some user who has CREATE, DROP, INSERT and LOCK privileges but not ALTER.

so as long as the ALTER commande is between comments I thought it was ok like this, but when i try to load the file with this user, I got an error :

ERROR 1044 (42000) at line 40: Access denied for user 'myuser'@'localhost' to database 'mydb'

if I add the ALTER privilege to my user, I got no more error...

I'm not sure but I think it's a bug.

How to repeat:
Take a dump with some commands commented
Make sure the user has not the privilege for this command
Load the dump
[5 Aug 2008 14:37] Valeriy Kravchuk
This is not a bug. /*!40000 ... */ is a MySQL-specific comment that is applied (i.e. commented statement is executed) to version 4.0 or newer. Read the manual, http://dev.mysql.com/doc/refman/4.1/en/comments.html, for the details.