From 099ce1dda1291eb4ef789039db400ee380d75376 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 25 Nov 2016 15:59:47 +0400 Subject: [PATCH] MDEV-11348 LOAD DATA LOCAL INFILE crashes the server on loading a backslash followed by a multi-byte character The crash happened when if my_error() was called for any reasons during loading (e.g. a bad multi-byte sequence or a bad GEOMETRY value was found). The server sent both error and progress packets, so the client disconnected. The server then crashed on a assert about a wrong packet order in Debug build. The server also tried to read from a closed socket when calling READ_INFO::skip_data_till_eof(). As the crash happened only with "mysql" running in interactive mode, no tests are possible. The problem was not reproducible with "mysqltest" or "mysql" in batch mode. --- sql/sql_load.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index a21fc692ecc..af4b25185d0 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -521,7 +521,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, *enclosed, skip_lines, ignore); thd_proc_info(thd, "End bulk insert"); - thd_progress_next_stage(thd); + if (!error) + thd_progress_next_stage(thd); if (thd->locked_tables_mode <= LTM_LOCK_TABLES && table->file->ha_end_bulk_insert() && !error) {