Bug #33354 Backup: restore changes current database to null
Submitted: 19 Dec 2007 3:24 Modified: 20 Feb 2010 19:39
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0.5-alpha OS:Linux (SUSE 10 64-bit)
Assigned to: Sanjay Manwani CPU Architecture:Any

[19 Dec 2007 3:24] Peter Gulutzan
Description:
I say 'use test'.
I backup database test.
I restore.
Now my current database is no long 'test', it is NULL.

How to repeat:
mysql> select database();
+------------+
| database() |
+------------+
| test       |
+------------+
1 row in set (0.00 sec)

mysql> backup database test to 'e';
+-----------+
| backup_id |
+-----------+
| 5         |
+-----------+
1 row in set (3.48 sec)

mysql> restore from 'e';
+-----------+
| backup_id |
+-----------+
| 6         |
+-----------+
1 row in set (3.46 sec)

mysql> select database();
+------------+
| database() |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)
[19 Dec 2007 13:38] MySQL Verification Team
Thank you for the bug report. Verified as described.

[miguel@amanhecer 6.0b]$ bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.5-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test
Database changed
mysql> backup database test to 'e';
+-----------+
| backup_id |
+-----------+
| 1         | 
+-----------+
1 row in set (1.83 sec)

mysql> restore from 'e';
+-----------+
| backup_id |
+-----------+
| 2         | 
+-----------+
1 row in set (3.49 sec)

mysql> select database();
+------------+
| database() |
+------------+
| NULL       | 
+------------+
1 row in set (0.00 sec)

mysql>
[15 May 2008 17:42] Peter Gulutzan
Another test case:

use test
create database q2;
create table q2.q (s1 int);
backup database q2 to 'b2';
restore from 'b2';
select database();
/* The database is now q2. */
[14 Oct 2009 11:08] 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/86774

2881 Sanjay Manwani	2009-10-14
      BUG#33354 Backup: restore changes current database to null  
      
      Added a variable m_db_saved to Si_session_context to save the default database if available
      
      added test backup_use_db_restore.test and its result file
[15 Oct 2009 13:58] Chuck Bell
Setting back to in progress based on review of patch. No record of acceptance though. Sending email to request correct status.
[16 Oct 2009 15:24] 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/87160
[16 Oct 2009 16:19] Chuck Bell
Setting to in progress as there are serious issues in the patch WRT collateral test failures.
[4 Nov 2009 13:39] 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/89308
[5 Nov 2009 21:09] Chuck Bell
Patch rejected. Collateral test failures show that CREATE statements have been changed.
[16 Nov 2009 14:59] 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/90523
[16 Nov 2009 22:28] Chuck Bell
STATUS
------
Approved pending changes (under protest).

REQUIRED
--------
1. I have not received a satisfactory answer as to why the backup_events test fails with this patch and why it has not been fixed as requested. If this appears in the team tree it will cause complications for me not only as MC but also since I have a patch that alters the test. 

This alone should be enough to seek a fully justified reason the test fails. I strongly suggest when the reply is made as to why it is failing, that the test result be corrected before pushing so that it does not interfere with your colleague's work.
[18 Nov 2009 17:33] 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/90893
[19 Nov 2009 17:50] Rafal Somla
Asked for patch fixes.
[25 Nov 2009 14:41] 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/91630
[25 Nov 2009 15:29] Rafal Somla
Good to push.
[27 Nov 2009 10:17] 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/91885

2898 Sanjay Manwani	2009-11-27
      BUG#33354 Backup: restore changes current database to null
      
      Additional changes due to the backup_use_db_restore.test failures in PB
      
      @ backup_use_db_restore.test
      added the line "--source include/not_embedded.inc"
[20 Feb 2010 9:18] Bugs System
Pushed into 6.0.14-alpha (revid:ingo.struewing@sun.com-20100218152520-s4v1ld76bif06eqn) (version source revid:ingo.struewing@sun.com-20100119103538-wtp5alpz4p2jayl5) (merge vers: 6.0.14-alpha) (pib:16)
[20 Feb 2010 19:39] Paul DuBois
Noted in 6.0.14 changelog.

RESTORE caused the default database to become NULL.
[23 Feb 2010 22:36] 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/101264