From fa57e118445735fce44565b7dea48ec8bf86bbe4 Mon Sep 17 00:00:00 2001
From: Andrei Elkin <andrei.elkin@mariadb.com>
Date: Mon, 11 Feb 2019 14:36:24 +0200
Subject: [PATCH] MDEV-10963 manual merge 10.1->10.3.

---
 client/mysqlbinlog.cc                         |  6 +-
 .../main/mysqlbinlog_row_minimal.result       | 61 ++-----------------
 sql/log_event.cc                              | 10 ++-
 sql/log_event_old.cc                          |  1 +
 4 files changed, 17 insertions(+), 61 deletions(-)

diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 58d3b0f372c..4f6f19f5f02 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -896,10 +896,8 @@ static bool print_base64(PRINT_EVENT_INFO *print_event_info, Log_event *ev)
             type_str);
     return 1;
   }
-  ev->print(result_file, print_event_info);
-  return
-    print_event_info->head_cache.error == -1 ||
-    print_event_info->body_cache.error == -1;
+
+  return ev->print(result_file, print_event_info);
 }
 
 
diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result
index a919cda529e..b3cee345428 100644
--- a/mysql-test/main/mysqlbinlog_row_minimal.result
+++ b/mysql-test/main/mysqlbinlog_row_minimal.result
@@ -237,13 +237,7 @@ BEGIN
 #Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
 #<date> server id 1  end_log_pos 2591 CRC32 XXX 	Table_map: `test`.`t2` mapped to number num
 # at 2591
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
-#<date> server id 1  end_log_pos 2665 CRC32 XXX 	Update_rows: table id 33 flags: STMT_END_F
-||||||| merged common ancestors
-#<date> server id 1  end_log_pos 2665 CRC32 XXX 	Update_rows: table id 32 flags: STMT_END_F
-=======
-#<date> server id 1  end_log_pos 2657 CRC32 XXX 	Update_rows: table id 32 flags: STMT_END_F
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
+#<date> server id 1  end_log_pos 2657 CRC32 XXX 	Update_rows: table id 33 flags: STMT_END_F
 ### UPDATE `test`.`t2`
 ### WHERE
 ###   @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -259,17 +253,9 @@ BEGIN
 ###   @1=12 /* INT meta=0 nullable=0 is_null=0 */
 ### SET
 ###   @5=5 /* INT meta=0 nullable=1 is_null=0 */
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
 # Number of rows: 3
-# at 2665
-#<date> server id 1  end_log_pos 2738 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-||||||| merged common ancestors
-# at 2665
-#<date> server id 1  end_log_pos 2738 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-=======
 # at 2657
 #<date> server id 1  end_log_pos 2730 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
 SET TIMESTAMP=X/*!*/;
 COMMIT
 /*!*/;
@@ -282,19 +268,9 @@ BEGIN
 # at 2809
 #<date> server id 1  end_log_pos 2809 CRC32 XXX 	Annotate_rows:
 #Q> DELETE FROM t1
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
-#<date> server id 1  end_log_pos 2873 CRC32 XXX 	Table_map: `test`.`t1` mapped to number num
-# at 2873
-#<date> server id 1  end_log_pos 2927 CRC32 XXX 	Delete_rows: table id 32 flags: STMT_END_F
-||||||| merged common ancestors
-#<date> server id 1  end_log_pos 2873 CRC32 XXX 	Table_map: `test`.`t1` mapped to number num
-# at 2873
-#<date> server id 1  end_log_pos 2927 CRC32 XXX 	Delete_rows: table id 31 flags: STMT_END_F
-=======
 #<date> server id 1  end_log_pos 2865 CRC32 XXX 	Table_map: `test`.`t1` mapped to number num
 # at 2865
-#<date> server id 1  end_log_pos 2919 CRC32 XXX 	Delete_rows: table id 31 flags: STMT_END_F
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
+#<date> server id 1  end_log_pos 2919 CRC32 XXX 	Delete_rows: table id 32 flags: STMT_END_F
 ### DELETE FROM `test`.`t1`
 ### WHERE
 ###   @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -307,17 +283,9 @@ BEGIN
 ### DELETE FROM `test`.`t1`
 ### WHERE
 ###   @1=13 /* INT meta=0 nullable=0 is_null=0 */
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
 # Number of rows: 4
-# at 2927
-#<date> server id 1  end_log_pos 3000 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-||||||| merged common ancestors
-# at 2927
-#<date> server id 1  end_log_pos 3000 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-=======
 # at 2919
 #<date> server id 1  end_log_pos 2992 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
 SET TIMESTAMP=X/*!*/;
 COMMIT
 /*!*/;
@@ -330,19 +298,9 @@ BEGIN
 # at 3071
 #<date> server id 1  end_log_pos 3071 CRC32 XXX 	Annotate_rows:
 #Q> DELETE FROM t2
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
-#<date> server id 1  end_log_pos 3135 CRC32 XXX 	Table_map: `test`.`t2` mapped to number num
-# at 3135
-#<date> server id 1  end_log_pos 3189 CRC32 XXX 	Delete_rows: table id 33 flags: STMT_END_F
-||||||| merged common ancestors
-#<date> server id 1  end_log_pos 3135 CRC32 XXX 	Table_map: `test`.`t2` mapped to number num
-# at 3135
-#<date> server id 1  end_log_pos 3189 CRC32 XXX 	Delete_rows: table id 32 flags: STMT_END_F
-=======
 #<date> server id 1  end_log_pos 3127 CRC32 XXX 	Table_map: `test`.`t2` mapped to number num
 # at 3127
-#<date> server id 1  end_log_pos 3181 CRC32 XXX 	Delete_rows: table id 32 flags: STMT_END_F
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
+#<date> server id 1  end_log_pos 3181 CRC32 XXX 	Delete_rows: table id 33 flags: STMT_END_F
 ### DELETE FROM `test`.`t2`
 ### WHERE
 ###   @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -355,17 +313,9 @@ BEGIN
 ### DELETE FROM `test`.`t2`
 ### WHERE
 ###   @1=13 /* INT meta=0 nullable=0 is_null=0 */
-<<<<<<< HEAD:mysql-test/main/mysqlbinlog_row_minimal.result
 # Number of rows: 4
-# at 3189
-#<date> server id 1  end_log_pos 3262 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-||||||| merged common ancestors
-# at 3189
-#<date> server id 1  end_log_pos 3262 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
-=======
 # at 3181
 #<date> server id 1  end_log_pos 3254 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
->>>>>>> 10.2:mysql-test/r/mysqlbinlog_row_minimal.result
 SET TIMESTAMP=X/*!*/;
 COMMIT
 /*!*/;
@@ -415,15 +365,16 @@ BEGIN
 #Q> UPDATE t1 t1 INNER JOIN t2 t2 ON t1.ref_id = t2.id
 #Q> SET t1.is_deleted = TRUE
 #Q> WHERE t1.id =
-#<date> server id 1  end_log_pos 594 CRC32 XXX 	Table_map: `test`.`t1` mapped to number 34
+#<date> server id 1  end_log_pos 594 CRC32 XXX 	Table_map: `test`.`t1` mapped to number 35
 # at 594
-#<date> server id 1  end_log_pos 643 CRC32 XXX 	Update_rows: table id 34 flags: STMT_END_F
+#<date> server id 1  end_log_pos 643 CRC32 XXX 	Update_rows: table id 35 flags: STMT_END_F
 ### UPDATE `test`.`t1`
 ### WHERE
 ###   @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
 ### SET
 ###   @2=b'1' /* BIT(1) meta=1 nullable=1 is_null=0 */
 ###   @3=X /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
+# Number of rows: 1
 # at 643
 #<date> server id 1  end_log_pos 725 CRC32 XXX 	Query	thread_id=5	exec_time=x	error_code=0
 SET TIMESTAMP=X/*!*/;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index db291d1f910..7d099479549 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3897,7 +3897,7 @@ bool Log_event::print_base64(IO_CACHE* file,
         if (print_event_info->base64_output_mode !=
             BASE64_OUTPUT_DECODE_ROWS)
           my_b_printf(file, "'%s\n", print_event_info->delimiter);
-        ev->print_verbose(file, print_event_info);
+        error= ev->print_verbose(file, print_event_info);
       }
       else
       {
@@ -13077,7 +13077,13 @@ bool Table_map_log_event::print(FILE *file, PRINT_EVENT_INFO *print_event_info)
   }
   if (!print_event_info->short_form || print_event_info->print_row_count)
   {
-    if (print_base64(&print_event_info->body_cache, print_event_info, TRUE) ||
+    bool do_print_encoded=
+      print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER &&
+      print_event_info->base64_output_mode != BASE64_OUTPUT_DECODE_ROWS &&
+      !print_event_info->short_form;
+
+    if (print_base64(&print_event_info->body_cache, print_event_info,
+                     do_print_encoded) ||
         copy_event_cache_to_file_and_reinit(&print_event_info->head_cache,
                                             file))
       goto err;
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 67a3e54f2dd..b5381ec6d74 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1851,6 +1851,7 @@ bool Old_rows_log_event::print_helper(FILE *file,
   IO_CACHE *const body= &print_event_info->body_cache;
   bool do_print_encoded=
     print_event_info->base64_output_mode != BASE64_OUTPUT_DECODE_ROWS &&
+    print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER &&
     !print_event_info->short_form;
 
   if (!print_event_info->short_form)
-- 
2.30.9