Bug #19584 CREATE USER in STORED PROCEDURE doesn't work with Variables
Submitted: 6 May 2006 20:42 Modified: 11 May 2006 18:52
Reporter: Christian Benner
Status: Verified
Category:Server: SP Severity:S4 (Feature request)
Version:5.0.20-nt-max OS:Microsoft Windows (W2K SRV)
Assigned to: Target Version:
Triage: Triaged: D5 (Feature request)

[6 May 2006 20:42] Christian Benner
Description:
I tried to create a new user on a testmachine with a stored procedure but
only with "select UNA" I get the correct value from the given variable back.
Behind the "CREATE USER" statement the variable isn't used as variable but as a
statement.  (the Declare and Select I've used here are only for demonstration of the
problem)

Maybe this isn't a bug but a feature ? :-)

mysql> call mysql.createUser('testname','testpw');
+----------+
| UNA      |
+----------+
| testname |
+----------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

How to repeat:
CREATE DEFINER=`sala`@`localhost` PROCEDURE `createUser`(IN uname varchar(255),IN pwort
varchar(255))
BEGIN
Declare UNA varchar(255);
set UNA=uname;
SELECT UNA;
     CREATE USER UNA;
END
[11 May 2006 18:52] Valeriy Kravchuk
Thank you for a problem report. Using locally declared varaibles in such a way may be
useful. So, I think, it is a valid feature request.

Some day a combination of prepared statement
(http://dev.mysql.com/doc/refman/5.0/en/sqlps.html) and user varaibles
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html will do the job. But not yet.
[25 Jan 2007 12:38] Dariusz Wlodarczyk
Is any progress with this bug/feature request ?
[8 Feb 18:31] Demkó Gábor
Just tried to do the same, but it didnt worked for me, yet
[7 Jul 18:14] Andy Royer
Still not implemented yet. I'd definitely like to see this feature added.