--source include/have_binlog_format_row.inc

#######################################################################
# BUG#13799489: ROWS_QUERY_LOG_EVENTS CORRUPTED IF QUERY LONGER THAN 255 BYTES
#
# Check that queries with more than 255 characters are not truncated
# when stored on Rows_query_log_events.
SET @@SESSION.BINLOG_ROWS_QUERY_LOG_EVENTS = 1;
CREATE TABLE t1 (a VARCHAR(256));

--let $as= `SELECT REPEAT('a', 256)`
--let $query= INSERT INTO t1 VALUES ('$as')

--let $assert_text= Logged query must match the one issued.
--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
--let $binlog_position= query_get_value("SHOW MASTER STATUS", Position, 1)
--eval $query

--let $row_number= 2
if (!`SELECT COUNT(*) = 0 OR VARIABLE_VALUE != 'ON' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE'`)
{
    # if GTID_MODE=ON, there is the extra event entry the binary log: Gtid_log_event
    --let $row_number=`SELECT $row_number + 1`
}

--let $logged_query= query_get_value(SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_position, Info, $row_number)
--let $assert_cond= `SELECT "$logged_query" LIKE "%$query"`
--source include/assert.inc

# Clean up
DROP TABLE t1;
