Bug #10875 unreferenced variables in procedures
Submitted: 26 May 2005 0:55 Modified: 14 Jul 2005 11:37
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.4 OS:Windows (windows 2k)
Assigned to: Per-Erik Martin CPU Architecture:Any

[26 May 2005 0:55] [ name withheld ]
Description:
In creating procedures to facilitate administration, I've found that in some casees, variables are not dereferenced to their values (the variable name is used as the text) in some functions.  In addition, ones involving password are not accepted.

For example:

  delimiter $
  create procedure CreateUser (
    in _user varchar(16),
    in _pw char(16)
  )
  sql security invoker
  begin
    create user _user@'localhost' identified by _pw;
    flush privileges;
  end
  $
  delimiter ;

errors with: 
   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
   that corresponds to your MySQL server version for the right syntax to use
   near '_pw;
   flush privileges;
   end' at line 7

Removing the identified clause is accepted, but when the procedure is run, the user "_user" is created rather than the user described by the variable _user.

How to repeat:
see description
[26 May 2005 12:06] Vasily Kishkin
Tested on Win 2000 Sp4, MySQL server 5.0.6 beta
[14 Jul 2005 11:37] Per-Erik Martin
Variables are not substituted in all places, they are evaluated in expressions.
The statement CREATE USER (and other similar statements, like GRANT), doesn't take expressions as paramaters.