diff --git a/mysql-test/r/compound.result b/mysql-test/r/compound.result index 3ccb51cc8b0..76aa3831553 100644 --- a/mysql-test/r/compound.result +++ b/mysql-test/r/compound.result @@ -155,11 +155,20 @@ execute stmt using @a, @b, @c| include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; SELECT "test"."fn"(9) +master-bin.000001 # Query # # use `test`; SELECT `test`.`fn`(9) master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; SELECT "test"."fn"(1) +master-bin.000001 # Query # # use `test`; SELECT `test`.`fn`(1) master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; insert t1 values( NAME_CONST('a',4)+3) master-bin.000001 # Query # # COMMIT drop function fn| drop table t1| +begin not atomic select @@sql_mode; end| +@@sql_mode + +create table t1 (a int)| +select a from t1 having a > 1| +a +begin not atomic select a from t1 having a > 1; end| +a +drop table t1| diff --git a/mysql-test/t/compound.test b/mysql-test/t/compound.test index a2f12d7f3bb..06d09817ac1 100644 --- a/mysql-test/t/compound.test +++ b/mysql-test/t/compound.test @@ -148,3 +148,13 @@ delimiter |; drop function fn| drop table t1| +# +# MDEV-6606 Server crashes in String::append on selecting sql_mode inside anonymous block +# MDEV-6609 SQL inside an anonymous block is executed with wrong SQL_MODE +# +begin not atomic select @@sql_mode; end| +create table t1 (a int)| +select a from t1 having a > 1| +begin not atomic select a from t1 having a > 1; end| +drop table t1| + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a7c6a7e04ec..6828139eb27 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -254,6 +254,7 @@ static bool maybe_start_compound_statement(THD *thd) Lex->sp_chistics.suid= SP_IS_NOT_SUID; Lex->sphead->set_body_start(thd, YYLIP->get_cpp_ptr()); + Lex->sphead->m_sql_mode= thd->variables.sql_mode; } return 0; }