MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Satya B Date:March 9 2010 1:38pm
Subject:bzr commit into mysql-next-mr-backup branch (satya.bn:3108) Bug#37103
View as plain text  
#At file:///home/satya/WORK/37103/mysql-next-mr-backup-37103/ based on revid:charles.bell@stripped

 3108 Satya B	2010-03-09
      BUG#37103 - mysql.online_backup.username is ambiguous
      
      The 'username' column in the table mysql.backup_history is not in the mysql
      user's format which is generally 'user'@'host'.
      
      The 'host_or_server_name' column in the table mysql.backup_history is the
      host from where the user initiated the operation and it is NOT the host
      where BACKUP/RESTORE operation ran.
      
      Fixed by removing the column 'host_or_server_name' and adjusting the column
      'username' to 'user'@'host' format in mysql.backup_history table.
     @ mysql-test/suite/backup/r/backup_logs.result
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Updated the result file for backup_logs test as the 
        column 'host_or_server_name' is dropped from the 
        mysql.backup_history table.
     @ mysql-test/suite/backup/t/backup_logs.test
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Updated the  backup_logs test as the column 'host_or_server_name'
        is dropped from the mysql.backup_history table and username is updated
        to 'user'@'host' format.
     @ mysql-test/suite/funcs_1/r/is_columns_mysql.result
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Fix the result file for the is_columns_mysql test as
        the number of columns in mysql.backup_history are reduced
        to 18 after deleting the 'host_or_server_name' column in
        mysql.backup_history
     @ scripts/mysql_system_tables.sql
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Update the CREATE TABLE statement for backup_history as the column 
        'host_or_server_name' is dropped.
     @ scripts/mysql_system_tables_fix.sql
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Add to check to fix the mysql.backup_history table for
        mysql_upgrade.
     @ sql/log.cc
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Update the username in methods Log_to_csv_event_handler::
        log_backup_history(..) and MYSQL_BACKUP_LOG::write(..) to the
        mysql user format 'user'@'host'.
        
        Added a new method create_mysql_user_format(..) to create
        the required user format.
     @ sql/log.h
        BUG#37103 - mysql.online_backup.username is ambiguous
        
        Removed ET_OBH_FILED_HOST_OR_SERVER from the enum
        enum_backup_history_log_field.

    modified:
      mysql-test/suite/backup/r/backup_logs.result
      mysql-test/suite/backup/t/backup_logs.test
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      scripts/mysql_system_tables.sql
      scripts/mysql_system_tables_fix.sql
      sql/log.cc
      sql/log.h
=== modified file 'mysql-test/suite/backup/r/backup_logs.result'
--- a/mysql-test/suite/backup/r/backup_logs.result	2010-02-11 18:28:07 +0000
+++ b/mysql-test/suite/backup/r/backup_logs.result	2010-03-09 13:38:43 +0000
@@ -14,7 +14,6 @@ backup_state	utf8
 binlog_file	utf8
 command	utf8
 drivers	utf8
-host_or_server_name	utf8
 operation	utf8
 username	utf8
 user_comment	utf8
@@ -78,7 +77,7 @@ WHERE command LIKE "BACKUP DATABASE back
 SELECT operation,num_objects, username, command FROM mysql.backup_history
 WHERE backup_id=@bup_id;
 operation	num_objects	username	command
-backup	1	tom	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
+backup	1	tom@localhost	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
 SELECT CURRENT_USER();
 CURRENT_USER()
 root@localhost
@@ -92,7 +91,7 @@ WHERE command LIKE "BACKUP DATABASE back
 SELECT operation,num_objects, username, command FROM mysql.backup_history
 WHERE backup_id=@bup_id;
 operation	num_objects	username	command
-backup	1	root	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
+backup	1	root@localhost	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
 Include all objects in database(Databases, tables, procedures and
 functions, views, triggers and events) and perform backup operation.
 con1: Create tables
@@ -258,8 +257,7 @@ total_bytes	4224
 validity_point_time	#
 start_time	#
 stop_time	#
-host_or_server_name	localhost
-username	tom
+username	tom@localhost
 backup_file	#
 backup_file_path	#
 user_comment	
@@ -341,8 +339,7 @@ total_bytes	4224
 validity_point_time	#
 start_time	#
 stop_time	#
-host_or_server_name	localhost
-username	tom
+username	tom@localhost
 backup_file	#
 backup_file_path	#
 user_comment	

=== modified file 'mysql-test/suite/backup/t/backup_logs.test'
--- a/mysql-test/suite/backup/t/backup_logs.test	2010-01-22 18:32:04 +0000
+++ b/mysql-test/suite/backup/t/backup_logs.test	2010-03-09 13:38:43 +0000
@@ -371,7 +371,7 @@ SHOW VARIABLES LIKE 'log_backup_output';
 --replace_regex /[0-9]/#/ /-.*//
 SELECT VERSION();
 --enable_query_log
---replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 15 # 16 #
+--replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 14 # 15 #
 --query_vertical SELECT * FROM mysql.backup_history WHERE backup_id = 500
 --replace_column 1 # 3 # 4 #
 SELECT * FROM mysql.backup_progress WHERE backup_id = 500;
@@ -479,7 +479,7 @@ SELECT timediff(stop_time, start_time) >
 --replace_regex /[0-9]/#/ /-.*//
 SELECT VERSION();
 --enable_query_log
---replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 15 # 16 #
+--replace_column 1 # 2 # 3 # 4 # 10 # 11 # 12 # 14 # 15 #
 --query_vertical SELECT * FROM mysql.backup_history WHERE backup_id = 501
 
 # Correct backup/restore times and progress should be indicated in the backup

=== modified file 'mysql-test/suite/funcs_1/r/is_columns_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2010-02-15 11:57:48 +0000
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2010-03-09 13:38:43 +0000
@@ -2,24 +2,23 @@ SELECT * FROM information_schema.columns
 WHERE table_schema = 'mysql'
 ORDER BY table_schema, table_name, column_name;
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT
-def	mysql	backup_history	backup_file	15		NO	char	255	765	NULL	NULL	utf8	utf8_general_ci	char(255)			select,insert,update,references	The name of the file
-def	mysql	backup_history	backup_file_path	16		NO	varchar	512	1536	NULL	NULL	utf8	utf8_general_ci	varchar(512)			select,insert,update,references	The full path to the backup image file
+def	mysql	backup_history	backup_file	14		NO	char	255	765	NULL	NULL	utf8	utf8_general_ci	char(255)			select,insert,update,references	The name of the file
+def	mysql	backup_history	backup_file_path	15		NO	varchar	512	1536	NULL	NULL	utf8	utf8_general_ci	varchar(512)			select,insert,update,references	The full path to the backup image file
 def	mysql	backup_history	backup_id	1	NULL	NO	bigint	NULL	NULL	19	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	Surrogate key for (near) duplicate entries
 def	mysql	backup_history	backup_state	5	NULL	NO	enum	14	42	NULL	NULL	utf8	utf8_general_ci	enum('complete','starting','validity point','running','error','cancel')			select,insert,update,references	Status of current operation
 def	mysql	backup_history	binlog_file	4		NO	char	64	192	NULL	NULL	utf8	utf8_general_ci	char(64)			select,insert,update,references	The recorded binlog filename at time of backup/restore
 def	mysql	backup_history	binlog_start_pos	3	0	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	The recorded binlog position of backup/restore
-def	mysql	backup_history	command	18		NO	varchar	512	1536	NULL	NULL	utf8	utf8_general_ci	varchar(512)			select,insert,update,references	The command used to issue operation
-def	mysql	backup_history	drivers	19		NO	varchar	100	300	NULL	NULL	utf8	utf8_general_ci	varchar(100)			select,insert,update,references	The name of the backup drivers used in the operation
+def	mysql	backup_history	command	17		NO	varchar	512	1536	NULL	NULL	utf8	utf8_general_ci	varchar(512)			select,insert,update,references	The command used to issue operation
+def	mysql	backup_history	drivers	18		NO	varchar	100	300	NULL	NULL	utf8	utf8_general_ci	varchar(100)			select,insert,update,references	The name of the backup drivers used in the operation
 def	mysql	backup_history	error_num	7	0	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	The error from this run 0 == none
-def	mysql	backup_history	host_or_server_name	13		NO	char	30	90	NULL	NULL	utf8	utf8_general_ci	char(30)			select,insert,update,references	The server name where operation ran
 def	mysql	backup_history	num_objects	8	0	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	The number of objects in the backup
 def	mysql	backup_history	operation	6	NULL	NO	enum	7	21	NULL	NULL	utf8	utf8_general_ci	enum('backup','restore')			select,insert,update,references	Type of operation
 def	mysql	backup_history	process_id	2	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	The process id that operation ran as
 def	mysql	backup_history	start_time	11	0000-00-00 00:00:00	NO	datetime	NULL	NULL	NULL	NULL	NULL	NULL	datetime			select,insert,update,references	The date/time of start of operation
 def	mysql	backup_history	stop_time	12	0000-00-00 00:00:00	NO	datetime	NULL	NULL	NULL	NULL	NULL	NULL	datetime			select,insert,update,references	The date/time of end of operation
 def	mysql	backup_history	total_bytes	9	0	NO	bigint	NULL	NULL	19	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	The size of the backup repository in bytes
-def	mysql	backup_history	username	14		NO	char	30	90	NULL	NULL	utf8	utf8_general_ci	char(30)			select,insert,update,references	The user name who ran the operation
-def	mysql	backup_history	user_comment	17		NO	varchar	200	600	NULL	NULL	utf8	utf8_general_ci	varchar(200)			select,insert,update,references	The comment from user entered at command line
+def	mysql	backup_history	username	13		NO	char	30	90	NULL	NULL	utf8	utf8_general_ci	char(30)			select,insert,update,references	The user name who ran the operation
+def	mysql	backup_history	user_comment	16		NO	varchar	200	600	NULL	NULL	utf8	utf8_general_ci	varchar(200)			select,insert,update,references	The comment from user entered at command line
 def	mysql	backup_history	validity_point_time	10	0000-00-00 00:00:00	NO	datetime	NULL	NULL	NULL	NULL	NULL	NULL	datetime			select,insert,update,references	The time of the validity point.
 def	mysql	backup_progress	backup_id	1	NULL	NO	bigint	NULL	NULL	19	0	NULL	NULL	bigint(20) unsigned			select,insert,update,references	Key for backup_history table entries
 def	mysql	backup_progress	error_num	3	0	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	The error from this run 0 == none
@@ -325,7 +324,6 @@ NULL	mysql	backup_history	total_bytes	bi
 NULL	mysql	backup_history	validity_point_time	datetime	NULL	NULL	NULL	NULL	datetime
 NULL	mysql	backup_history	start_time	datetime	NULL	NULL	NULL	NULL	datetime
 NULL	mysql	backup_history	stop_time	datetime	NULL	NULL	NULL	NULL	datetime
-3.0000	mysql	backup_history	host_or_server_name	char	30	90	utf8	utf8_general_ci	char(30)
 3.0000	mysql	backup_history	username	char	30	90	utf8	utf8_general_ci	char(30)
 3.0000	mysql	backup_history	backup_file	char	255	765	utf8	utf8_general_ci	char(255)
 3.0000	mysql	backup_history	backup_file_path	varchar	512	1536	utf8	utf8_general_ci	varchar(512)

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-02-11 14:04:43 +0000
+++ b/scripts/mysql_system_tables.sql	2010-03-09 13:38:43 +0000
@@ -104,7 +104,7 @@ DROP TABLE IF EXISTS mysql.online_backup
 
 DROP TABLE IF EXISTS mysql.online_backup_progress;
 
-CREATE TABLE IF NOT EXISTS backup_history ( backup_id BIGINT UNSIGNED NOT NULL COMMENT 'Surrogate key for (near) duplicate entries', process_id INT UNSIGNED NOT NULL COMMENT 'The process id that operation ran as', binlog_start_pos INT UNSIGNED  NOT NULL DEFAULT 0 COMMENT 'The recorded binlog position of backup/restore', binlog_file CHAR(64)  NOT NULL DEFAULT '' COMMENT 'The recorded binlog filename at time of backup/restore', backup_state ENUM('complete', 'starting', 'validity point', 'running', 'error', 'cancel') NOT NULL COMMENT 'Status of current operation', operation ENUM('backup', 'restore') NOT NULL COMMENT 'Type of operation', error_num INT NOT NULL DEFAULT 0 COMMENT 'The error from this run 0 == none', num_objects INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The number of objects in the backup', total_bytes BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The size of the backup repository in bytes', validity_point_time datetime NOT NULL DEFAULT 0 COMMENT 'The time of the val!
 idity poi
+CREATE TABLE IF NOT EXISTS backup_history ( backup_id BIGINT UNSIGNED NOT NULL COMMENT 'Surrogate key for (near) duplicate entries', process_id INT UNSIGNED NOT NULL COMMENT 'The process id that operation ran as', binlog_start_pos INT UNSIGNED  NOT NULL DEFAULT 0 COMMENT 'The recorded binlog position of backup/restore', binlog_file CHAR(64)  NOT NULL DEFAULT '' COMMENT 'The recorded binlog filename at time of backup/restore', backup_state ENUM('complete', 'starting', 'validity point', 'running', 'error', 'cancel') NOT NULL COMMENT 'Status of current operation', operation ENUM('backup', 'restore') NOT NULL COMMENT 'Type of operation', error_num INT NOT NULL DEFAULT 0 COMMENT 'The error from this run 0 == none', num_objects INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The number of objects in the backup', total_bytes BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The size of the backup repository in bytes', validity_point_time datetime NOT NULL DEFAULT 0 COMMENT 'The time of the val!
 idity poi
 
 CREATE TABLE IF NOT EXISTS backup_progress ( backup_id BIGINT UNSIGNED NOT NULL COMMENT 'Key for backup_history table entries', object CHAR (30) NOT NULL DEFAULT '' COMMENT 'The object being operated on', error_num INT NOT NULL DEFAULT 0 COMMENT 'The error from this run 0 == none', notes CHAR(100) NOT NULL DEFAULT '' COMMENT 'Commentary from the backup engine') ENGINE=CSV DEFAULT CHARACTER SET utf8;
 

=== modified file 'scripts/mysql_system_tables_fix.sql'
--- a/scripts/mysql_system_tables_fix.sql	2010-02-11 14:04:43 +0000
+++ b/scripts/mysql_system_tables_fix.sql	2010-03-09 13:38:43 +0000
@@ -661,3 +661,19 @@ DELIMITER ;
 CALL fix_backup_progress();
 DROP PROCEDURE fix_backup_progress;
 
+#
+# Remove columns from backup_history if present.
+#
+DELIMITER ||
+CREATE PROCEDURE fix_backup_history ()
+BEGIN
+  SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE 
+    TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'backup_history'
+    INTO @x;
+  IF (@x > 18) THEN 
+    ALTER TABLE backup_history DROP COLUMN host_or_server_name;
+  END IF;
+END ||
+DELIMITER ;
+CALL fix_backup_history();
+DROP PROCEDURE fix_backup_history;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-02-23 19:28:33 +0000
+++ b/sql/log.cc	2010-03-09 13:38:43 +0000
@@ -54,6 +54,9 @@ LOGGER logger;
 
 MYSQL_BIN_LOG mysql_bin_log(&sync_binlog_period);
 
+static void create_mysql_user_format(const char *user,
+                                     const char *host,
+                                     char *dest);
 static bool test_if_number(const char *str,
 			   ulong *res, bool allow_wildcards);
 static int binlog_init(void *p);
@@ -868,9 +871,13 @@ bool Log_to_csv_event_handler::
   ulonglong save_thd_options;
   bool save_time_zone_used;
   char *host= current_thd->security_ctx->host; // host name
-  char *user= current_thd->security_ctx->user; // user name
+  char *username= current_thd->security_ctx->user; // user name
+  char user[MAX_USER_HOST_SIZE + 1];
   THD::killed_state saved_killed_state= THD::NOT_KILLED;
 
+  //create mysql user format: 'user'@'host'
+  create_mysql_user_format(username, host, user);
+
   /*
     Turn the binlog off and don't replicate the
     updates to the backup logs.
@@ -985,14 +992,6 @@ bool Log_to_csv_event_handler::
       MYSQL_TIMESTAMP_DATETIME);
   }
 
-  if (host)
-  {
-    if(table->field[ET_OBH_FIELD_HOST_OR_SERVER]->store(host, 
-       strlen(host), system_charset_info))
-      goto err;
-    table->field[ET_OBH_FIELD_HOST_OR_SERVER]->set_notnull();
-  }
-
   if (user)
   {
     if (table->field[ET_OBH_FIELD_USERNAME]->store(user,
@@ -3912,7 +3911,7 @@ bool MYSQL_BACKUP_LOG::open(const char *
                    "\tbinlog_file \tbackup_state \toperation "
                    "\terror_num \tnum_objects \ttotal_bytes "
                    "\tvalidity_point_time \tstart_time \tstop_time "
-                   "\thost_or_server_name \tusername \tbackup_file "
+                   "\tusername \tbackup_file "
                    "\tbackup_file_path \tuser_comment \tcommand \tdrivers\n",
                    sizeof(buff) - len);
     else
@@ -4064,13 +4063,17 @@ bool MYSQL_BACKUP_LOG::write_str(const c
 bool MYSQL_BACKUP_LOG::write(THD *thd, st_backup_history *history_data)
 {
   char *host= current_thd->security_ctx->host; // host name
-  char *user= current_thd->security_ctx->user; // user name
+  char *username= current_thd->security_ctx->user; // user name
+  char user[MAX_USER_HOST_SIZE + 1];
   bool save_time_zone_used;
 
   save_time_zone_used= thd->time_zone_used;
 
   (void) mysql_mutex_lock(&LOCK_log);
 
+  //create mysql user format: 'user'@'host'
+  create_mysql_user_format(username, host, user);
+
   /*
     Test if someone closed between the is_open test and lock 
   */
@@ -4166,8 +4169,6 @@ bool MYSQL_BACKUP_LOG::write(THD *thd, s
       goto err;
     if (write_datetime(history_data->stop))
       goto err;
-    if (write_str(host))
-      goto err;
     if (write_str(user))
       goto err;
     if (write_str(history_data->backup_file))
@@ -7165,6 +7166,37 @@ void MYSQL_BIN_LOG::set_max_size(ulong m
   DBUG_VOID_RETURN;
 }
 
+/**
+  Create mysql user format string which is 'user'@'host'
+
+  @param[IN]  user  mysql username
+  @param[IN]  host  mysql user's hostname
+  @param[OUT] dest  The destination string to store mysql user 
+                    format             
+*/
+
+static void create_mysql_user_format(const char *user,
+                                     const char *host,
+                                     char *dest)
+{
+  DBUG_ENTER("create_mysql_user_format");
+  if (dest == NULL)
+    DBUG_VOID_RETURN;
+  /*
+    We need check this only for 'user' as
+    strxnmov() doesn't append the remaining
+    strings if the first string is NULL
+  */ 
+  if (user == NULL)
+    strxnmov(dest, MAX_USER_HOST_SIZE, "",
+             "@", host, NullS);
+  else
+    strxnmov(dest, MAX_USER_HOST_SIZE, user,
+             "@", host, NullS);
+   
+  DBUG_VOID_RETURN;
+} /* create_mysql_user_format */
+
 
 /**
   Check if a string is a valid number.

=== modified file 'sql/log.h'
--- a/sql/log.h	2010-02-16 15:15:35 +0000
+++ b/sql/log.h	2010-03-09 13:38:43 +0000
@@ -35,7 +35,6 @@ enum enum_backup_history_log_field
   ET_OBH_FIELD_VP,
   ET_OBH_FIELD_START_TIME,
   ET_OBH_FIELD_STOP_TIME,
-  ET_OBH_FIELD_HOST_OR_SERVER,
   ET_OBH_FIELD_USERNAME,
   ET_OBH_FIELD_BACKUP_FILE,
   ET_OBH_FIELD_BACKUP_FILE_PATH,


Attachment: [text/bzr-bundle] bzr/satya.bn@sun.com-20100309133843-81i3ixr79q85fs07.bundle
Thread
bzr commit into mysql-next-mr-backup branch (satya.bn:3108) Bug#37103Satya B9 Mar
  • Re: bzr commit into mysql-next-mr-backup branch (satya.bn:3108)Bug#37103Rafal Somla11 Mar
    • Re: bzr commit into mysql-next-mr-backup branch (satya.bn:3108)Bug#37103Satya B11 Mar
      • Re: bzr commit into mysql-next-mr-backup branch (satya.bn:3108)Bug#37103Rafal Somla12 Mar