Skip to content

Commit

Permalink
Merge branch '5.5' into 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Apr 26, 2019
2 parents caa9023 + 757daa4 commit 2ce5279
Show file tree
Hide file tree
Showing 29 changed files with 357 additions and 108 deletions.
21 changes: 21 additions & 0 deletions mysql-test/r/grant4.result
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t_select_priv`.`a` AS `a`,`t_select_priv`.`b` AS `b` from `t_select_priv` latin1 latin1_swedish_ci
drop database mysqltest_db1;
drop user mysqltest_u1@localhost;
call mtr.add_suppression("Table 'mysql.user' doesn't exist");
call mtr.add_suppression("'mysql.user' is not TABLE");
rename table mysql.user to mysql.user1;
create view mysql.user as select * from mysql.user1;
flush privileges;
ERROR HY000: 'mysql.user' is not TABLE
drop view mysql.user;
create temporary table mysql.user select * from mysql.user1 limit 0;
flush privileges;
ERROR 42S02: Table 'mysql.user' doesn't exist
drop temporary table mysql.user;
rename table mysql.user1 to mysql.user;
call mtr.add_suppression('mysql.user table is damaged');
rename table mysql.user to mysql.user1;
create table mysql.user (Host char(100), User char(100));
flush privileges;
ERROR HY000: Unknown error
drop table mysql.user;
rename table mysql.user1 to mysql.user;
End of 5.5 tests
#
# Additional coverage for refactoring which is made as part
# of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
Expand Down Expand Up @@ -215,3 +235,4 @@ ERROR HY000: Password hash should be a 16-digit hexadecimal number
create user foo4 identified via mysql_old_password using '11111111111111111111111111111111111111111';
ERROR HY000: Password hash should be a 16-digit hexadecimal number
set GLOBAL sql_mode=default;
End of 10.1 tests
4 changes: 4 additions & 0 deletions mysql-test/r/information_schema_prepare.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PREPARE stmt2 FROM "CREATE VIEW v AS SELECT * FROM INFORMATION_SCHEMA.TABLES";
FLUSH PRIVILEGES;
EXECUTE stmt2;
DROP VIEW v;
21 changes: 21 additions & 0 deletions mysql-test/r/multi_update.result
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,27 @@ execute stmt1;
deallocate prepare stmt1;
drop view v3,v2,v1;
drop table t1,t2,t3;
create table t1 (id int not null, v1 varchar(10) not null);
insert into t1 values (1,1),(2,2);
create table t2 (log varchar(10) not null);
create trigger t1_after_update after update on t1
for each row insert into t2 values ('triggered');
create user foo;
grant select, insert, update, delete, create, drop, reload, index, alter, show databases, create temporary tables, lock tables, execute, create view, show view, create routine, alter routine, trigger on *.* to 'foo'@'%';
set global read_only=1;
create temporary table temp_t1 (id int not null, update_me varchar(10));
insert into temp_t1 values (1,1),(2,2),(3,3);
update temp_t1 left join t1 on temp_t1.id = t1.id set temp_t1.update_me = 'hello';
set global read_only = 0;
create table t3 (id int not null);
insert t3 values (2);
update t1 left join t3 on t1.id = t3.id set t1.v1 = 'hello';
select * from t2;
log
triggered
triggered
drop table t1,t2, t3;
drop user foo;
end of 5.5 tests

# Bug mdev-5970
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions mysql-test/r/view_grant.result
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ create table mysqltest.t1 (a int, b int, primary key(a));
insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10);
create table mysqltest.t2 (x int);
insert into mysqltest.t2 values (3), (4), (5), (6);
create table mysqltest.t3 (x int);
insert into mysqltest.t3 values (3), (4), (5), (6);
create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1;
create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1;
create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1;
create user mysqltest_1@localhost;
grant update (a) on mysqltest.v2 to mysqltest_1@localhost;
grant update on mysqltest.v1 to mysqltest_1@localhost;
grant update on mysqltest.t3 to mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;
use mysqltest;
update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c;
Expand Down Expand Up @@ -217,6 +220,7 @@ a b
48 4
62 5
71 10
update t3,v3 set t3.x=t3.x+v3.c where t3.x=v3.c;
update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c;
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2'
update v2 set c=a+c;
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/suite/innodb/r/innodb-truncate.result
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,16 @@ a
1
2
DROP TABLE t1;
call mtr.add_suppression('InnoDB: Error: in RENAME TABLE table `test`.`t3`');
SET FOREIGN_KEY_CHECKS= OFF;
CREATE TABLE t1 (f2 INT, f4 INT, KEY(f2), FOREIGN KEY (f4) REFERENCES t3 (f4)) ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS= ON;
CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
CREATE TABLE t3 (a INT) ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t3` (errno: 150 "Foreign key constraint is incorrectly formed")
ALTER TABLE t1 RENAME TO t3;
ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 150 "Foreign key constraint is incorrectly formed")
ALTER TABLE t1 FORCE;
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `test`.`t3` (`f2`))
DROP TABLE t2, t1;
18 changes: 18 additions & 0 deletions mysql-test/suite/innodb/t/innodb-truncate.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--source include/have_innodb.inc
let $datadir=`select @@datadir`;
--echo #
--echo # TRUNCATE TABLE
--echo #
Expand Down Expand Up @@ -62,3 +63,20 @@ INSERT INTO t1 VALUES (NULL), (NULL);
SELECT * FROM t1 ORDER BY a;
DROP TABLE t1;

#
# MDEV-18923 Assertion `!lex_string_cmp(system_charset_info, fk_info->referenced_table, &table->s->table_name)' failed in fk_truncate_illegal_if_parent
#
call mtr.add_suppression('InnoDB: Error: in RENAME TABLE table `test`.`t3`');
SET FOREIGN_KEY_CHECKS= OFF;
CREATE TABLE t1 (f2 INT, f4 INT, KEY(f2), FOREIGN KEY (f4) REFERENCES t3 (f4)) ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS= ON;
CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t3 (a INT) ENGINE=InnoDB;
--replace_result $datadir ./
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 RENAME TO t3;
ALTER TABLE t1 FORCE;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
DROP TABLE t2, t1;
13 changes: 13 additions & 0 deletions mysql-test/suite/rpl/r/kill_race_condition.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include/master-slave.inc
[connection master]
set global debug_dbug='d,rows_log_event_before_open_table';
set debug_sync='now WAIT_FOR before_open_table';
create table t1 (a int);
insert t1 values (1),(2),(3);
kill slave_sql_thread;
set debug_sync='now SIGNAL go_ahead_sql';
set global debug_dbug='';
set debug_sync='RESET';
drop table t1;
start slave;
include/rpl_end.inc
28 changes: 28 additions & 0 deletions mysql-test/suite/rpl/t/kill_race_condition.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
source include/have_debug_sync.inc;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;

connection slave;
set global debug_dbug='d,rows_log_event_before_open_table';
send set debug_sync='now WAIT_FOR before_open_table';

connection master;
create table t1 (a int);
insert t1 values (1),(2),(3);

connection slave;
reap;
let $a=`select id from information_schema.processlist where state='debug sync point: now'`;
replace_result $a slave_sql_thread;
eval kill $a;
set debug_sync='now SIGNAL go_ahead_sql';
set global debug_dbug='';
set debug_sync='RESET';

connection master;
drop table t1;

connection slave;
start slave;

source include/rpl_end.inc;
31 changes: 30 additions & 1 deletion mysql-test/t/grant4.test
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,34 @@ disconnect con1;
drop database mysqltest_db1;
drop user mysqltest_u1@localhost;

#
# MDEV-18241 Downgrade from 10.4 to 10.3 crashes
#
call mtr.add_suppression("Table 'mysql.user' doesn't exist");
call mtr.add_suppression("'mysql.user' is not TABLE");
rename table mysql.user to mysql.user1;
create view mysql.user as select * from mysql.user1;
--error ER_WRONG_OBJECT
flush privileges;
drop view mysql.user;
create temporary table mysql.user select * from mysql.user1 limit 0;
--error ER_NO_SUCH_TABLE
flush privileges;
drop temporary table mysql.user;
rename table mysql.user1 to mysql.user;

#
# Bug#28986737: RENAMING AND REPLACING MYSQL.USER TABLE CAN LEAD TO A SERVER CRASH
#
call mtr.add_suppression('mysql.user table is damaged');
rename table mysql.user to mysql.user1;
create table mysql.user (Host char(100), User char(100));
--error ER_UNKNOWN_ERROR
flush privileges;
drop table mysql.user;
rename table mysql.user1 to mysql.user;

--echo End of 5.5 tests

--echo #
--echo # Additional coverage for refactoring which is made as part
Expand Down Expand Up @@ -235,5 +263,6 @@ create user foo3 identified via mysql_old_password using '00';
--error ER_PASSWD_LENGTH
create user foo4 identified via mysql_old_password using '11111111111111111111111111111111111111111';


set GLOBAL sql_mode=default;

--echo End of 10.1 tests
7 changes: 7 additions & 0 deletions mysql-test/t/information_schema_prepare.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# MDEV-15907 ASAN heap-use-after-free in strnmov / .. / fill_effective_table_privileges on concurrent GRANT and CREATE VIEW
#
PREPARE stmt2 FROM "CREATE VIEW v AS SELECT * FROM INFORMATION_SCHEMA.TABLES";
FLUSH PRIVILEGES;
EXECUTE stmt2;
DROP VIEW v;
31 changes: 31 additions & 0 deletions mysql-test/t/multi_update.test
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,37 @@ deallocate prepare stmt1;

drop view v3,v2,v1;
drop table t1,t2,t3;

#
# MDEV-18507 can't update temporary table when joined with table with triggers on read-only
#
create table t1 (id int not null, v1 varchar(10) not null);
insert into t1 values (1,1),(2,2);
create table t2 (log varchar(10) not null);
create trigger t1_after_update after update on t1
for each row insert into t2 values ('triggered');

create user foo;
grant select, insert, update, delete, create, drop, reload, index, alter, show databases, create temporary tables, lock tables, execute, create view, show view, create routine, alter routine, trigger on *.* to 'foo'@'%';

set global read_only=1;
connect a, localhost, foo;

create temporary table temp_t1 (id int not null, update_me varchar(10));
insert into temp_t1 values (1,1),(2,2),(3,3);
update temp_t1 left join t1 on temp_t1.id = t1.id set temp_t1.update_me = 'hello';

connection default;
set global read_only = 0;

create table t3 (id int not null);
insert t3 values (2);
update t1 left join t3 on t1.id = t3.id set t1.v1 = 'hello';
select * from t2;

drop table t1,t2, t3;
drop user foo;

--echo end of 5.5 tests


Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions mysql-test/t/view_grant.test
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,16 @@ create table mysqltest.t1 (a int, b int, primary key(a));
insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10);
create table mysqltest.t2 (x int);
insert into mysqltest.t2 values (3), (4), (5), (6);
create table mysqltest.t3 (x int);
insert into mysqltest.t3 values (3), (4), (5), (6);
create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1;
create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1;
create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1;

create user mysqltest_1@localhost;
grant update (a) on mysqltest.v2 to mysqltest_1@localhost;
grant update on mysqltest.v1 to mysqltest_1@localhost;
grant update on mysqltest.t3 to mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;

connection user1;
Expand All @@ -265,6 +268,8 @@ update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c;
select * from t1;
update v2 set a=a+c;
select * from t1;
# update a table, select only on view
update t3,v3 set t3.x=t3.x+v3.c where t3.x=v3.c;
# no rights on column
--error ER_COLUMNACCESS_DENIED_ERROR
update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c;
Expand Down
25 changes: 15 additions & 10 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -40,6 +40,7 @@
#include "transaction.h"
#include <my_dir.h>
#include "sql_show.h" // append_identifier
#include "debug_sync.h" // debug_sync
#include <mysql/psi/mysql_statement.h>
#include <strfunc.h>
#include "compat56.h"
Expand Down Expand Up @@ -9910,6 +9911,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
/* A small test to verify that objects have consistent types */
DBUG_ASSERT(sizeof(thd->variables.option_bits) == sizeof(OPTION_RELAXED_UNIQUE_CHECKS));

DBUG_EXECUTE_IF("rows_log_event_before_open_table",
{
const char action[] = "now SIGNAL before_open_table WAIT_FOR go_ahead_sql";
DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(action)));
};);

if (slave_run_triggers_for_rbr)
{
LEX *lex= thd->lex;
Expand All @@ -9934,7 +9941,6 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
}
if (open_and_lock_tables(thd, rgi->tables_to_lock, FALSE, 0))
{
uint actual_error= thd->get_stmt_da()->sql_errno();
#ifdef WITH_WSREP
if (WSREP(thd))
{
Expand All @@ -9947,23 +9953,22 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
(long long)wsrep_thd_trx_seqno(thd));
}
#endif
if ((thd->is_slave_error || thd->is_fatal_error) &&
!is_parallel_retry_error(rgi, actual_error))
if (thd->is_error() &&
!is_parallel_retry_error(rgi, error= thd->get_stmt_da()->sql_errno()))
{
/*
Error reporting borrowed from Query_log_event with many excessive
simplifications.
simplifications.
We should not honour --slave-skip-errors at this point as we are
having severe errors which should not be skiped.
having severe errors which should not be skipped.
*/
rli->report(ERROR_LEVEL, actual_error, rgi->gtid_info(),
rli->report(ERROR_LEVEL, error, rgi->gtid_info(),
"Error executing row event: '%s'",
(actual_error ? thd->get_stmt_da()->message() :
(error ? thd->get_stmt_da()->message() :
"unexpected success or fatal error"));
thd->is_slave_error= 1;
}
/* remove trigger's tables */
error= actual_error;
goto err;
}

Expand Down
19 changes: 9 additions & 10 deletions sql/log_event_old.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2007, 2018, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB
/* Copyright (c) 2007, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -101,21 +101,20 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi)

if (open_and_lock_tables(ev_thd, rgi->tables_to_lock, FALSE, 0))
{
uint actual_error= ev_thd->get_stmt_da()->sql_errno();
if (ev_thd->is_slave_error || ev_thd->is_fatal_error)
if (ev_thd->is_error())
{
/*
Error reporting borrowed from Query_log_event with many excessive
simplifications (we don't honour --slave-skip-errors)
simplifications.
We should not honour --slave-skip-errors at this point as we are
having severe errors which should not be skipped.
*/
rli->report(ERROR_LEVEL, actual_error, NULL,
rli->report(ERROR_LEVEL, ev_thd->get_stmt_da()->sql_errno(), NULL,
"Error '%s' on opening tables",
(actual_error ? ev_thd->get_stmt_da()->message() :
"unexpected success or fatal error"));
ev_thd->get_stmt_da()->message());
ev_thd->is_slave_error= 1;
}
rgi->slave_close_thread_tables(thd);
DBUG_RETURN(actual_error);
DBUG_RETURN(1);
}

/*
Expand Down
Loading

0 comments on commit 2ce5279

Please sign in to comment.