Bug #16430 Events: no storage of current_database value
Submitted: 12 Jan 2006 4:28 Modified: 5 May 2006 11:30
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.1.6-alpha-debug OS:Linux (SUSE 10.0)
Assigned to: Andrey Hristov CPU Architecture:Any

[12 Jan 2006 4:28] Peter Gulutzan
Description:
The value of current_database isn't stored.
If I create an event, and I don't explicitly
use the current database name for statements
that reference database objects, the statements
fail. But the execution should occur with the
definer's privileges on the definer's default.

Perhaps this is related to the sql_mode bug.

How to repeat:
I create two events:

create event e43_p20 on schedule every 1 second do insert into db1.tp3 values ('a'); 
create event e43_p21 on schedule every 1 second do insert into tp3 values ('b');

The first event works. The second event fails, even though the
default database is 'db1' at time of creation.
[12 Jan 2006 6:29] Aleksey Kishkin
mysql> create database db1;
Query OK, 1 row affected (0.03 sec)

mysql> use db1;
Database changed
mysql> create table tp3(a varchar(5));
Query OK, 0 rows affected (0.04 sec)

mysql> create event e43_p20 on schedule every 1 second do insert into db1.tp3 values
    -> ('a');
Query OK, 1 row affected (0.00 sec)

mysql> create event e43_p21 on schedule every 1 second do insert into tp3 values
    -> ('b');
Query OK, 1 row affected (0.00 sec)

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> set global event_scheduler = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from db1.tp3;
+------+
| a    |
+------+
| a    |
| a    |
| b    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
| a    |
+------+
43 rows in set (0.00 sec)
[23 Jan 2006 17:55] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/1515