mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge rolltop.ignatz42.dyndns.org:/mnt/storeage/bug21424/my50-bug21424
into rolltop.ignatz42.dyndns.org:/mnt/storeage/mysql-5.0-maint
This commit is contained in:
@ -85,7 +85,7 @@ static char *alloc_query_str(ulong size);
|
|||||||
static char *field_escape(char *to,const char *from,uint length);
|
static char *field_escape(char *to,const char *from,uint length);
|
||||||
static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
|
static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
|
||||||
quick= 1, extended_insert= 1,
|
quick= 1, extended_insert= 1,
|
||||||
lock_tables=1,ignore_errors=0,flush_logs=0,
|
lock_tables=1,ignore_errors=0,flush_logs=0,flush_privileges=0,
|
||||||
opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
|
opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
|
||||||
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
|
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
|
||||||
opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,
|
opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,
|
||||||
@ -256,6 +256,12 @@ static struct my_option my_long_options[] =
|
|||||||
"--lock-all-tables or --master-data with --flush-logs",
|
"--lock-all-tables or --master-data with --flush-logs",
|
||||||
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
(gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
||||||
0, 0},
|
0, 0},
|
||||||
|
{"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement "
|
||||||
|
"after dumping the mysql database. This option should be used any "
|
||||||
|
"time the dump contains the mysql database and any other database "
|
||||||
|
"that depends on the data in the mysql database for proper restore. ",
|
||||||
|
(gptr*) &flush_privileges, (gptr*) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
|
||||||
|
0, 0},
|
||||||
{"force", 'f', "Continue even if we get an sql-error.",
|
{"force", 'f', "Continue even if we get an sql-error.",
|
||||||
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG,
|
(gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG,
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
@ -2767,6 +2773,7 @@ static int dump_all_tables_in_db(char *database)
|
|||||||
|
|
||||||
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
|
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
|
||||||
char *afterdot;
|
char *afterdot;
|
||||||
|
int using_mysql_db= my_strcasecmp(&my_charset_latin1, database, "mysql");
|
||||||
|
|
||||||
afterdot= strmov(hash_key, database);
|
afterdot= strmov(hash_key, database);
|
||||||
*afterdot++= '.';
|
*afterdot++= '.';
|
||||||
@ -2821,6 +2828,11 @@ static int dump_all_tables_in_db(char *database)
|
|||||||
}
|
}
|
||||||
if (lock_tables)
|
if (lock_tables)
|
||||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||||
|
if (flush_privileges && using_mysql_db == 0)
|
||||||
|
{
|
||||||
|
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
|
||||||
|
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} /* dump_all_tables_in_db */
|
} /* dump_all_tables_in_db */
|
||||||
|
|
||||||
|
@ -2927,14 +2927,32 @@ drop user mysqltest_1@localhost;
|
|||||||
create database mysqldump_myDB;
|
create database mysqldump_myDB;
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
create user myDB_User;
|
create user myDB_User;
|
||||||
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
|
grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
|
||||||
create table t1 (c1 int);
|
create table t1 (c1 int);
|
||||||
insert into t1 values (3);
|
insert into t1 values (3);
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
|
create table u1 (f1 int);
|
||||||
|
insert into u1 values (4);
|
||||||
create view v1 (c1) as select * from t1;
|
create view v1 (c1) as select * from t1;
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
drop table u1;
|
||||||
|
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
||||||
|
drop user myDB_User;
|
||||||
|
drop database mysqldump_myDB;
|
||||||
|
flush privileges;
|
||||||
|
use mysqldump_myDB;
|
||||||
|
select * from mysqldump_myDB.v1;
|
||||||
|
c1
|
||||||
|
3
|
||||||
|
select * from mysqldump_myDB.u1;
|
||||||
|
f1
|
||||||
|
4
|
||||||
|
use mysqldump_myDB;
|
||||||
|
drop view v1;
|
||||||
|
drop table t1;
|
||||||
|
drop table u1;
|
||||||
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
||||||
drop user myDB_User;
|
drop user myDB_User;
|
||||||
drop database mysqldump_myDB;
|
drop database mysqldump_myDB;
|
||||||
|
@ -1322,28 +1322,59 @@ drop user mysqltest_1@localhost;
|
|||||||
# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
|
# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
|
||||||
# information_schema database.
|
# information_schema database.
|
||||||
#
|
#
|
||||||
|
# Bug #21424 mysqldump failing to export/import views
|
||||||
|
#
|
||||||
|
|
||||||
|
# Do as root
|
||||||
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||||
connection root;
|
connection root;
|
||||||
create database mysqldump_myDB;
|
create database mysqldump_myDB;
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
create user myDB_User;
|
create user myDB_User;
|
||||||
grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
|
grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
|
||||||
create table t1 (c1 int);
|
create table t1 (c1 int);
|
||||||
insert into t1 values (3);
|
insert into t1 values (3);
|
||||||
|
|
||||||
|
# Do as a user
|
||||||
connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
|
connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||||
connection user1;
|
connection user1;
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
|
create table u1 (f1 int);
|
||||||
|
insert into u1 values (4);
|
||||||
create view v1 (c1) as select * from t1;
|
create view v1 (c1) as select * from t1;
|
||||||
|
|
||||||
# Backup should not fail.
|
# Backup should not fail for Bug #21527. Flush priviliges test begins.
|
||||||
--exec $MYSQL_DUMP --all-databases --add-drop-table > $MYSQLTEST_VARDIR/tmp/bug21527.sql
|
--exec $MYSQL_DUMP --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
connection root;
|
connection root;
|
||||||
use mysqldump_myDB;
|
use mysqldump_myDB;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
drop table u1;
|
||||||
|
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
||||||
|
drop user myDB_User;
|
||||||
|
drop database mysqldump_myDB;
|
||||||
|
flush privileges;
|
||||||
|
|
||||||
|
# Bug #21424 continues from here.
|
||||||
|
# Restore. Flush Privileges test ends.
|
||||||
|
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21527.sql;
|
||||||
|
|
||||||
|
# Do as a user
|
||||||
|
connection user1;
|
||||||
|
use mysqldump_myDB;
|
||||||
|
|
||||||
|
# Ultimate test for correct data.
|
||||||
|
select * from mysqldump_myDB.v1;
|
||||||
|
select * from mysqldump_myDB.u1;
|
||||||
|
|
||||||
|
#Final cleanup.
|
||||||
|
connection root;
|
||||||
|
use mysqldump_myDB;
|
||||||
|
drop view v1;
|
||||||
|
drop table t1;
|
||||||
|
drop table u1;
|
||||||
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
|
||||||
drop user myDB_User;
|
drop user myDB_User;
|
||||||
drop database mysqldump_myDB;
|
drop database mysqldump_myDB;
|
||||||
|
Reference in New Issue
Block a user