MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:March 22 2007 5:27pm
Subject:bk commit into 5.0 tree (serg:1.2406) BUG#27171
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of serg. When serg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-22 19:27:01+02:00, serg@stripped +3 -0
  Bug#27171 mysqlbinlog produces different output depends from option -R
  Server starts any binlog dump from Format_description_log_event,
  this shifted all offset calculations in mysqlbinlog and made it
  to stop the dump earlier than --stop-position. Now mysqlbinlog
  takes Format_description_log_event into account

  client/mysqlbinlog.cc@stripped, 2007-03-22 19:26:58+02:00, serg@stripped +44 -33
    Bug#27171 mysqlbinlog produces different output depends from option -R
    Server starts any binlog dump from Format_description_log_event,
    this shifted all offset calculations in mysqlbinlog and made it
    to stop the dump earlier than --stop-position. Now mysqlbinlog
    takes Format_description_log_event into account

  mysql-test/r/mysqlbinlog2.result@stripped, 2007-03-22 19:26:58+02:00, serg@stripped +36 -0
    Bug#27171 mysqlbinlog produces different output depends from option -R

  mysql-test/t/mysqlbinlog2.test@stripped, 2007-03-22 19:26:58+02:00, serg@stripped +9 -1
    Bug#27171 mysqlbinlog produces different output depends from option -R

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	serg
# Host:	sergbook.mysql.com
# Root:	/usr/home/serg/Abk/mysql-5.0-marvel

--- 1.133/client/mysqlbinlog.cc	2007-03-22 19:27:09 +02:00
+++ 1.134/client/mysqlbinlog.cc	2007-03-22 19:27:09 +02:00
@@ -91,15 +91,14 @@
   This is because the event will be created (alloced) in read_log_event()
   (which returns a pointer) in check_header().
 */
-Format_description_log_event* description_event; 
+Format_description_log_event* glob_description_event; 
 
 static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
                                   const char* logname);
 static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
                                    const char* logname);
 static int dump_log_entries(const char* logname);
-static int dump_remote_file(NET* net, const char* fname);
-static void die(const char* fmt, ...);
+static void die(const char* fmt, ...)  __attribute__ ((__noreturn__));
 static MYSQL* safe_connect();
 
 
@@ -560,7 +559,7 @@
       ce->print(result_file, print_event_info, TRUE);
 
       // If this binlog is not 3.23 ; why this test??
-      if (description_event->binlog_version >= 3)
+      if (glob_description_event->binlog_version >= 3)
       {
 	if (load_processor.process(ce))
 	  break;				// Error
@@ -595,9 +594,9 @@
       break;
     }
     case FORMAT_DESCRIPTION_EVENT:
-      delete description_event;
-      description_event= (Format_description_log_event*) ev;
-      print_event_info->common_header_len= description_event->common_header_len;
+      delete glob_description_event;
+      glob_description_event= (Format_description_log_event*) ev;
+      print_event_info->common_header_len= glob_description_event->common_header_len;
       ev->print(result_file, print_event_info);
       /*
         We don't want this event to be deleted now, so let's hide it (I
@@ -803,7 +802,7 @@
 
 static void print_version()
 {
-  printf("%s Ver 3.1 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
+  printf("%s Ver 3.2 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
   NETWARE_SET_SCREEN_MODE(1);
 }
 
@@ -974,7 +973,7 @@
   This is not as smart as check_header() (used for local log); it will not work
   for a binlog which mixes format. TODO: fix this.
 */
-static int check_master_version(MYSQL* mysql,
+static int check_master_version(MYSQL *mysql_arg,
                                 Format_description_log_event
                                 **description_event)
 {
@@ -982,26 +981,31 @@
   MYSQL_ROW row;
   const char* version;
 
-  if (mysql_query(mysql, "SELECT VERSION()") ||
-      !(res = mysql_store_result(mysql)))
+  if (mysql_query(mysql_arg, "SELECT VERSION()") ||
+      !(res = mysql_store_result(mysql_arg)))
   {
+    /* purecov: begin inspected */
     char errmsg[256];
-    strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1);
-    mysql_close(mysql);
+    strmake(errmsg, mysql_error(mysql_arg), sizeof(errmsg)-1);
+    mysql_close(mysql_arg);
     die("Error checking master version: %s", errmsg);
+    /* purecov: end */
   }
   if (!(row = mysql_fetch_row(res)))
   {
+    /* purecov: begin inspected */
     mysql_free_result(res);
     mysql_close(mysql);
     die("Master returned no rows for SELECT VERSION()");
-    return 1;
+    /* purecov: end */
   }
   if (!(version = row[0]))
   {
+    /* purecov: begin inspected */
     mysql_free_result(res);
-    mysql_close(mysql);
+    mysql_close(mysql_arg);
     die("Master reported NULL for the version");
+    /* purecov: end */
   }
 
   switch (*version) {
@@ -1020,11 +1024,11 @@
     *description_event= new Format_description_log_event(3);
     break;
   default:
-    sql_print_error("Master reported unrecognized MySQL version '%s'",
-		    version);
+    /* purecov: begin inspected */
     mysql_free_result(res);
-    mysql_close(mysql);
-    return 1;
+    mysql_close(mysql_arg);
+    die("Master reported unrecognized MySQL version '%s'", version);
+    /* purecov: end */
   }
   mysql_free_result(res);
   return 0;
@@ -1040,7 +1044,7 @@
   uint logname_len;
   NET* net;
   int error= 0;
-  my_off_t old_off= start_position_mot;
+  my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE);
   char fname[FN_REFLEN+1];
   DBUG_ENTER("dump_remote_log_entries");
 
@@ -1052,12 +1056,12 @@
   mysql= safe_connect();
   net= &mysql->net;
 
-  if (check_master_version(mysql, &description_event))
+  if (check_master_version(mysql, &glob_description_event))
   {
     fprintf(stderr, "Could not find server version");
     DBUG_RETURN(1);
   }
-  if (!description_event || !description_event->is_valid())
+  if (!glob_description_event || !glob_description_event->is_valid())
   {
     fprintf(stderr, "Invalid Format_description log event; \
 could be out of memory");
@@ -1107,7 +1111,7 @@
 			len, net->read_pos[5]));
     if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
                                         len - 1, &error_msg,
-                                        description_event)))
+                                        glob_description_event)))
     {
       fprintf(stderr, "Could not construct log event object\n");
       error= 1;
@@ -1115,7 +1119,7 @@
     }   
 
     Log_event_type type= ev->get_type_code();
-    if (description_event->binlog_version >= 3 ||
+    if (glob_description_event->binlog_version >= 3 ||
         (type != LOAD_EVENT && type != CREATE_FILE_EVENT))
     {
       /*
@@ -1192,10 +1196,17 @@
       }
     }
     /*
-      Let's adjust offset for remote log as for local log to produce 
-      similar text.
+      Let's adjust offset for remote log as for local log to produce
+      similar text and to have --stop-position to work identically.
+
+      Exception - the server sends Format_description_log_event
+      in the beginning of the dump, and only after it the event from
+      start_position. Let the old_off reflect it.
     */
-    old_off+= len-1;
+    if (old_off < start_position_mot)
+      old_off= start_position_mot;
+    else
+      old_off+= len-1;
   }
 
 err:
@@ -1321,7 +1332,7 @@
       my_close(fd, MYF(MY_WME));
       return 1;
     }
-    check_header(file, &description_event);
+    check_header(file, &glob_description_event);
   }
   else // reading from stdin;
   {
@@ -1347,7 +1358,7 @@
     if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
 		      0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
       return 1;
-    check_header(file, &description_event);
+    check_header(file, &glob_description_event);
     if (start_position)
     {
       /* skip 'start_position' characters from stdin */
@@ -1365,7 +1376,7 @@
     }
   }
 
-  if (!description_event || !description_event->is_valid())
+  if (!glob_description_event || !glob_description_event->is_valid())
     die("Invalid Format_description log event; could be out of memory");
 
   if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
@@ -1378,14 +1389,14 @@
     char llbuff[21];
     my_off_t old_off = my_b_tell(file);
 
-    Log_event* ev = Log_event::read_log_event(file, description_event);
+    Log_event* ev = Log_event::read_log_event(file, glob_description_event);
     if (!ev)
     {
       /*
         if binlog wasn't closed properly ("in use" flag is set) don't complain
         about a corruption, but treat it as EOF and move to the next binlog.
       */
-      if (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
+      if (glob_description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
         file->error= 0;
       else if (file->error)
       {
@@ -1410,7 +1421,7 @@
   if (fd >= 0)
     my_close(fd, MYF(MY_WME));
   end_io_cache(file);
-  delete description_event;
+  delete glob_description_event;
   return error;
 }
 

--- 1.10/mysql-test/r/mysqlbinlog2.result	2007-03-22 19:27:09 +02:00
+++ 1.11/mysql-test/r/mysqlbinlog2.result	2007-03-22 19:27:09 +02:00
@@ -122,6 +122,24 @@
 ROLLBACK /* added by mysqlbinlog */;
 /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 
+--- start and stop positions ---
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET INSERT_ID=4/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1579609946/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+insert into t1 values(null, "d")/*!*/;
+SET INSERT_ID=5/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
 --- start-datetime --
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
@@ -476,6 +494,24 @@
 SET INSERT_ID=3/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 insert into t1 values(null, "c")/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+
+--- start and stop positions ---
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+SET INSERT_ID=4/*!*/;
+use test/*!*/;
+SET TIMESTAMP=1579609946/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+insert into t1 values(null, "d")/*!*/;
+SET INSERT_ID=5/*!*/;
 DELIMITER ;
 # End of log file
 ROLLBACK /* added by mysqlbinlog */;

--- 1.8/mysql-test/t/mysqlbinlog2.test	2007-03-22 19:27:09 +02:00
+++ 1.9/mysql-test/t/mysqlbinlog2.test	2007-03-22 19:27:09 +02:00
@@ -36,7 +36,7 @@
 --enable_query_log
 
 #
-# We should use --short-form everywhere because in other case output will
+# We should use  everywhere because in other case output will
 # be time dependent (the Start events). Better than nothing.
 #
 
@@ -55,6 +55,10 @@
 --enable_query_log
 --exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001 
 --disable_query_log
+select "--- start and stop positions ---" as "";
+--enable_query_log
+--exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 $MYSQLTEST_VARDIR/log/master-bin.000001 
+--disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log
 --exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 
@@ -110,6 +114,10 @@
 select "--- stop-position --" as "";
 --enable_query_log
 --exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
+--disable_query_log
+select "--- start and stop positions ---" as "";
+--enable_query_log
+--exec $MYSQL_BINLOG --short-form --start-position=600 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
 --disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log
Thread
bk commit into 5.0 tree (serg:1.2406) BUG#27171Sergei Golubchik22 Mar