#At file:///D:/source/bzr/mysql-6.0-bug-40160/
2728 Chuck Bell 2008-11-05 [merge]
Local merge
modified:
mysql-test/suite/backup/r/backup_errors.result
mysql-test/suite/backup/t/backup_errors.test
sql/backup/backup_info.cc
sql/backup/image_info.cc
sql/backup/image_info.h
sql/share/errmsg.txt
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_yacc.yy
=== modified file 'mysql-test/suite/backup/r/backup_errors.result'
--- a/mysql-test/suite/backup/r/backup_errors.result 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/r/backup_errors.result 2008-11-05 09:41:15 +0000
@@ -20,6 +20,8 @@ BACKUP DATABASE foo TO 'test.bak';
ERROR 42000: Unknown database 'foo'
BACKUP DATABASE test,foo,bdb,bar TO 'test.bak';
ERROR 42000: Unknown database 'foo,bar'
+BACKUP DATABASE foo,test,bar,foo TO 'test.bak';
+ERROR 42000: Not unique database: 'foo'
use adb;
create table t1 (a int);
create procedure p1() backup database test to 'test.bak';
=== modified file 'mysql-test/suite/backup/t/backup_errors.test'
--- a/mysql-test/suite/backup/t/backup_errors.test 2008-10-07 17:15:44 +0000
+++ b/mysql-test/suite/backup/t/backup_errors.test 2008-11-05 09:41:15 +0000
@@ -50,6 +50,10 @@ BACKUP DATABASE foo TO 'test.bak';
-- error ER_BAD_DB_ERROR
BACKUP DATABASE test,foo,bdb,bar TO 'test.bak';
+# repeated database
+-- error ER_NONUNIQ_DB
+BACKUP DATABASE foo,test,bar,foo TO 'test.bak';
+
# Test that BACKUP/RESTORE statements are disable inside stored routines,
# triggers and events.
=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc 2008-10-27 13:06:21 +0000
+++ b/sql/backup/backup_info.cc 2008-11-05 09:41:15 +0000
@@ -543,6 +543,10 @@ int Backup_info::add_dbs(List< ::LEX_STR
while ((s= it++))
{
backup::String db_name(*s);
+
+ // Ignore the database if it has already been inserted into the catalogue.
+ if (has_db(db_name))
+ continue;
if (is_internal_db_name(&db_name))
{
=== modified file 'sql/backup/image_info.cc'
--- a/sql/backup/image_info.cc 2008-10-14 12:08:56 +0000
+++ b/sql/backup/image_info.cc 2008-11-05 09:41:15 +0000
@@ -206,7 +206,7 @@ int Image_info::add_snapshot(Snapshot_in
/**
Check if catalogue contains given database.
*/
-bool Image_info::has_db(const String &db_name)
+bool Image_info::has_db(const String &db_name) const
{
for (uint n=0; n < m_dbs.count() ; ++n)
if (m_dbs[n] && m_dbs[n]->name() == db_name)
=== modified file 'sql/backup/image_info.h'
--- a/sql/backup/image_info.h 2008-10-15 15:38:28 +0000
+++ b/sql/backup/image_info.h 2008-11-05 09:41:15 +0000
@@ -83,7 +83,7 @@ public: // public interface
// Examine contents of the catalogue.
- bool has_db(const String&);
+ bool has_db(const String&) const;
// Retrieve objects using their coordinates.
=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt 2008-10-30 17:53:24 +0000
+++ b/sql/share/errmsg.txt 2008-11-05 09:41:15 +0000
@@ -6418,3 +6418,5 @@ ER_RESTORE_ON_MASTER
eng "A restore operation was initiated on the master."
ER_RESTORE_ON_SLAVE
eng "A restore operation was attempted on a slave during replication. You must stop the slave prior to running a restore."
+ER_NONUNIQ_DB 42000 S1009
+ eng "Not unique database: '%-.192s'"
=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc 2008-10-07 22:05:23 +0000
+++ b/sql/sql_lex.cc 2008-11-05 09:41:15 +0000
@@ -3022,3 +3022,28 @@ bool LEX::is_partition_management() cons
alter_info.flags == ALTER_REORGANIZE_PARTITION));
}
+int LEX::add_db_to_list(LEX_STRING *name)
+{
+ DBUG_ASSERT(name);
+
+ List_iterator<LEX_STRING> it(db_list);
+ LEX_STRING *copy;
+
+ while ((copy= it++))
+ if (!my_strnncoll(system_charset_info,
+ (const uchar*) name->str, name->length ,
+ (const uchar*) copy->str, copy->length ))
+ {
+ my_error(ER_NONUNIQ_DB, MYF(0), name->str);
+ return ER_NONUNIQ_DB;
+ }
+
+ copy= (LEX_STRING*) sql_memdup(name, sizeof(LEX_STRING));
+ if (copy == NULL)
+ return ER_OUT_OF_RESOURCES;
+
+ if (db_list.push_back(copy))
+ return ER_OUT_OF_RESOURCES;
+
+ return 0;
+}
=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h 2008-10-28 14:17:05 +0000
+++ b/sql/sql_lex.h 2008-11-05 09:41:15 +0000
@@ -1876,6 +1876,13 @@ struct LEX: public Query_tables_list
}
return FALSE;
}
+
+ void clear_db_list()
+ {
+ db_list.empty();
+ }
+
+ int add_db_to_list(LEX_STRING *name);
};
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2008-10-28 14:17:05 +0000
+++ b/sql/sql_yacc.yy 2008-11-05 09:41:15 +0000
@@ -6422,8 +6422,6 @@ slave_until_opts:
restore:
RESTORE_SYM
- FROM
- TEXT_STRING_sys
{
LEX *lex= Lex;
if (lex->sphead)
@@ -6432,18 +6430,17 @@ restore:
MYSQL_YYABORT;
}
lex->sql_command = SQLCOM_RESTORE;
- lex->db_list.empty();
- lex->backup_dir = $3;
+ lex->clear_db_list();
+ }
+ FROM
+ TEXT_STRING_sys
+ {
+ Lex->backup_dir = $4;
}
;
-backup:
- BACKUP_SYM
- DATABASE
- database_list
- TO_SYM
- TEXT_STRING_sys
- opt_compression
+backup:
+ BACKUP_SYM
{
LEX *lex= Lex;
if (lex->sphead)
@@ -6452,7 +6449,15 @@ backup:
MYSQL_YYABORT;
}
lex->sql_command = SQLCOM_BACKUP;
- lex->backup_dir = $5;
+ lex->clear_db_list();
+ }
+ DATABASE
+ database_list
+ TO_SYM
+ TEXT_STRING_sys
+ opt_compression
+ {
+ Lex->backup_dir = $6;
}
| BACKUP_TEST_SYM
database_list
@@ -6485,29 +6490,19 @@ opt_compression_algorithm:
database_list:
'*'
- {
- Lex->db_list.empty();
- }
+ {}
| database_ident_list
;
database_ident_list:
ident
{
- LEX *lex= Lex;
- LEX_STRING* ls= (LEX_STRING*) sql_memdup(&$1, sizeof(LEX_STRING));
- if (ls == NULL)
- MYSQL_YYABORT;
- lex->db_list.empty();
- if (lex->db_list.push_back(ls))
+ if (Lex->add_db_to_list(&$1))
YYABORT;
}
| database_ident_list ',' ident
{
- LEX_STRING *ls= (LEX_STRING*) sql_memdup(&$3, sizeof(LEX_STRING));
- if (ls == NULL)
- MYSQL_YYABORT;
- if (Lex->db_list.push_back(ls))
+ if (Lex->add_db_to_list(&$3))
YYABORT;
}
;
| Thread |
|---|
| • bzr commit into mysql-6.0-backup branch (cbell:2728) | Chuck Bell | 5 Nov |