Commit 8049d2e9 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.0 into 10.1

parents fb5ee7d6 f0c19b6a
...@@ -5831,6 +5831,31 @@ f1 f2 ...@@ -5831,6 +5831,31 @@ f1 f2
drop table t1, t2; drop table t1, t2;
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1; SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
ERROR 42S22: Unknown column 'SOME_GARBAGE.b.a' in 'field list' ERROR 42S22: Unknown column 'SOME_GARBAGE.b.a' in 'field list'
#
# MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
# FOR UPDATE
#
CREATE TABLE t1 (a INT);
insert into t1 values (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` for update latin1 latin1_swedish_ci
select * from v1;
a
1
2
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` lock in share mode latin1 latin1_swedish_ci
select * from v1;
a
1
2
DROP VIEW v1;
DROP TABLE t1;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 10.0 tests. # -- End of 10.0 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------
......
...@@ -3,7 +3,8 @@ include/master-slave.inc ...@@ -3,7 +3,8 @@ include/master-slave.inc
call mtr.add_suppression("Unsafe statement written to the binary log"); call mtr.add_suppression("Unsafe statement written to the binary log");
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES(SLEEP(2)); INSERT INTO t1 VALUES(SLEEP(2));
Seconds_Behind_Master: 1 Seconds_Behind_Master_is_less_than_100
1
Warnings: Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
drop table t1; drop table t1;
......
...@@ -3,24 +3,60 @@ source include/have_binlog_format_statement.inc; ...@@ -3,24 +3,60 @@ source include/have_binlog_format_statement.inc;
call mtr.add_suppression("Unsafe statement written to the binary log"); call mtr.add_suppression("Unsafe statement written to the binary log");
# Make sure that the start time of the first event is certainly different
# from the next event
--let $timestamp= `SELECT @@timestamp`
--disable_query_log
eval SET TIMESTAMP= $timestamp-100;
--enable_query_log
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
# Make sure that the slave is done with the first event, and all checks
# that we'll perform later will be really against the second event
sync_slave_with_master;
connection master;
# Restore the timestamp now. It doesn't matter that it's not precise,
# it just needs to be very different from the earlier event
--disable_query_log
eval SET TIMESTAMP= $timestamp;
--enable_query_log
send INSERT INTO t1 VALUES(SLEEP(2)); send INSERT INTO t1 VALUES(SLEEP(2));
connection slave; connection slave;
let $run = 10;
# When the slave starts executing the event, Seconds_Behind_Master
# should start growing steadilly. The bugfix ensures that they are
# calculated based on the start time of the current event, rather
# than the start time of the previous event. To check it, we only need
# the first non-zero value
let $run = 20;
while ($run) while ($run)
{ {
dec $run; dec $run;
let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1); let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1);
# for debugging uncomment echo and remove the if() # for debugging uncomment echo and remove the if()
#echo Seconds_Behind_Master: $sbm; # echo Seconds_Behind_Master: $sbm;
if ($sbm) if ($sbm)
{ {
let $run = 0; let $run = 0;
} }
sleep 0.5; sleep 0.5;
} }
echo Seconds_Behind_Master: $sbm;
# Normally the first non-zero value should be 1. However, due to race
# conditions on slow servers, sometimes the check might miss the value 1,
# and only catch a higher one. It does not matter, we just need to make
# sure it didn't start with 100+, as it would have with bug MDEV-5114
--disable_query_log
eval SELECT $sbm > 0 and $sbm < 99 AS Seconds_Behind_Master_is_less_than_100;
--enable_query_log
connection master; connection master;
reap; reap;
drop table t1; drop table t1;
......
...@@ -5706,6 +5706,28 @@ drop table t1, t2; ...@@ -5706,6 +5706,28 @@ drop table t1, t2;
--error ER_BAD_FIELD_ERROR --error ER_BAD_FIELD_ERROR
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1; SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
--echo #
--echo # MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
--echo # FOR UPDATE
--echo #
CREATE TABLE t1 (a INT);
insert into t1 values (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
SHOW CREATE VIEW v1;
select * from v1;
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
SHOW CREATE VIEW v1;
select * from v1;
DROP VIEW v1;
DROP TABLE t1;
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
--echo # -- End of 10.0 tests. --echo # -- End of 10.0 tests.
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
......
...@@ -2169,6 +2169,7 @@ void st_select_lex::init_select() ...@@ -2169,6 +2169,7 @@ void st_select_lex::init_select()
m_agg_func_used= false; m_agg_func_used= false;
name_visibility_map= 0; name_visibility_map= 0;
join= 0; join= 0;
lock_type= TL_READ_DEFAULT;
} }
/* /*
......
...@@ -893,6 +893,9 @@ class st_select_lex: public st_select_lex_node ...@@ -893,6 +893,9 @@ class st_select_lex: public st_select_lex_node
/* namp of nesting SELECT visibility (for aggregate functions check) */ /* namp of nesting SELECT visibility (for aggregate functions check) */
nesting_map name_visibility_map; nesting_map name_visibility_map;
/* it is for correct printing SELECT options */
thr_lock_type lock_type;
void init_query(); void init_query();
void init_select(); void init_select();
st_select_lex_unit* master_unit() { return (st_select_lex_unit*) master; } st_select_lex_unit* master_unit() { return (st_select_lex_unit*) master; }
......
...@@ -25230,6 +25230,12 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) ...@@ -25230,6 +25230,12 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
// limit // limit
print_limit(thd, str, query_type); print_limit(thd, str, query_type);
// lock type
if (lock_type == TL_READ_WITH_SHARED_LOCKS)
str->append(" lock in share mode");
else if (lock_type == TL_WRITE)
str->append(" for update");
// PROCEDURE unsupported here // PROCEDURE unsupported here
} }
......
...@@ -429,6 +429,15 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, ...@@ -429,6 +429,15 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
lex->link_first_table_back(view, link_to_local); lex->link_first_table_back(view, link_to_local);
view->open_type= OT_BASE_ONLY; view->open_type= OT_BASE_ONLY;
/*
ignore lock specs for CREATE statement
*/
if (lex->current_select->lock_type != TL_READ_DEFAULT)
{
lex->current_select->set_lock_for_tables(TL_READ_DEFAULT);
view->mdl_request.set_type(MDL_EXCLUSIVE);
}
if (open_temporary_tables(thd, lex->query_tables) || if (open_temporary_tables(thd, lex->query_tables) ||
open_and_lock_tables(thd, lex->query_tables, TRUE, 0)) open_and_lock_tables(thd, lex->query_tables, TRUE, 0))
{ {
......
...@@ -8389,12 +8389,14 @@ opt_select_lock_type: ...@@ -8389,12 +8389,14 @@ opt_select_lock_type:
| FOR_SYM UPDATE_SYM | FOR_SYM UPDATE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->current_select->lock_type= TL_WRITE;
lex->current_select->set_lock_for_tables(TL_WRITE); lex->current_select->set_lock_for_tables(TL_WRITE);
lex->safe_to_cache_query=0; lex->safe_to_cache_query=0;
} }
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM | LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->current_select->lock_type= TL_READ_WITH_SHARED_LOCKS;
lex->current_select-> lex->current_select->
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS); set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
lex->safe_to_cache_query=0; lex->safe_to_cache_query=0;
......
...@@ -3942,7 +3942,7 @@ ha_innobase::prepare_inplace_alter_table( ...@@ -3942,7 +3942,7 @@ ha_innobase::prepare_inplace_alter_table(
index->name, TRUE); index->name, TRUE);
my_error(ER_INDEX_CORRUPT, MYF(0), index_name); my_error(ER_INDEX_CORRUPT, MYF(0), index_name);
DBUG_RETURN(true); goto err_exit;
} }
} }
} }
......
...@@ -3959,7 +3959,7 @@ ha_innobase::prepare_inplace_alter_table( ...@@ -3959,7 +3959,7 @@ ha_innobase::prepare_inplace_alter_table(
index->name, TRUE); index->name, TRUE);
my_error(ER_INDEX_CORRUPT, MYF(0), index_name); my_error(ER_INDEX_CORRUPT, MYF(0), index_name);
DBUG_RETURN(true); goto err_exit;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment