--source include/master-slave.inc
--source include/have_binlog_format_statement.inc
--source include/only_mts_slave_parallel_workers.inc

#
# Proving correct error reporting by Worker in condition of the failing query
# size is close to that of internal buffer MAX_SLAVE_ERRMSG.
# bug#18563480 MTS: CRASH WHEN SLAVE WORKER TRY TO EXECUTE A BIG STATEMENT doomed to fail
#

# Create a table on the slave to set up future error on its creation
# via replication

--connection slave
call mtr.add_suppression("Slave SQL: Worker.*failed executing transaction");
call mtr.add_suppression("Slave SQL:.*The slave coordinator and worker threads are stopped");

--eval CREATE TABLE t (a TEXT) select "a" as a

# Create a query size of over MAX_SLAVE_ERRMSG = 1024

--connection master

--let i=0
--let select_arg=a

while ($i < 1024)
{
    --inc $i
    --let $select_arg=a$select_arg
}

--eval CREATE TABLE t (a TEXT) select "$select_arg" as a

--connection slave

# Error is found as expected.
--let $slave_sql_errno= convert_error(ER_TABLE_EXISTS_ERROR)
--source include/wait_for_slave_sql_error.inc

# Remove slave side table, recover slave to catch up
DROP TABLE t;
--source include/start_slave_sql.inc

--connection master
--source include/sync_slave_sql_with_master.inc


#
# Cleanup
#

--connection master
DROP TABLE t;
--source include/sync_slave_sql_with_master.inc


--source include/rpl_end.inc
