Bug #9796 Query Cache: caches queries with CURRENT_USER() function.
Submitted: 10 Apr 2005 19:06 Modified: 26 Apr 2005 0:46
Reporter: Dmitry Lenev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.25-bk OS:Any (Any)
Assigned to: Dmitry Lenev CPU Architecture:Any

[10 Apr 2005 19:06] Dmitry Lenev
Description:
When query cache is enabled, queries which contain CURRENT_USER() are cached and thus return wrong results.

How to repeat:
Enable query cache on your server. 
Connect under some user (e.g. root) and do:

drop table if exists t1;
create table t1 select 1;
select *, user() from t1;
#+---+----------------+
#| 1 | user()         |
#+---+----------------+
#| 1 | root@localhost |
#+---+----------------+

select *, current_user() from t1;
#+---+----------------+
#| 1 | current_user() |
#+---+----------------+
#| 1 | root@localhost |
#+---+----------------+

Now connect under another user (e.g. anonymous) and do:

select *, user() from t1;
#+---+---------------+
#| 1 | user()        |
#+---+---------------+
#| 1 | zzz@localhost |
#+---+---------------+
select *, current_user() from t1;
#+---+----------------+
#| 1 | current_user() |
#+---+----------------+
#| 1 | root@localhost |
#+---+----------------+
# This is wrong!

select current_user();
#+----------------+
#| current_user() |
#+----------------+
#| @localhost     |
#+----------------+
# And this is right value of current_user()

Suggested fix:
Do not cache queries containing CURRENT_USER() function as we do it for queries with USER() function...
[11 Apr 2005 15:01] Dmitry Lenev
Fixed in 4.0.25, 4.1.12, 5.0.5
[26 Apr 2005 0:46] Paul DuBois
Noted in 4.0.25, 4.1.12, 5.0.5 changelogs.