List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:February 11 2009 9:46am
Subject:bzr commit into mysql-6.0-backup branch (jorgen.loland:2764) Bug#39109
View as plain text  
#At file:///localhome/jl208045/mysql/mysql-6.0-backup-39109/

 2764 Jorgen Loland	2009-02-11
      Bug#39109 - Mysql Online Backup table doesn't show correct num_object count
      
      Previously, the num_objects column in the backup_history table showed the number of tables in the backup image. It now shows the number of objects with names (i.e, tablespace, database, table, view, routine)
modified:
  mysql-test/suite/backup/r/backup_logs.result
  mysql-test/suite/backup/t/backup_logs.test
  sql/backup/image_info.cc
  sql/backup/image_info.h
  sql/backup/logger.cc

per-file messages:
  mysql-test/suite/backup/r/backup_logs.result
    Updated object counts
  mysql-test/suite/backup/t/backup_logs.test
    Added tablespace to check that num_objects counts ts. Removed comments about this bug
  sql/backup/image_info.cc
    Added counting of views, routines and privileges in the backup image
  sql/backup/image_info.h
    Added counting of views, routines and privileges in the backup image
  sql/backup/logger.cc
    Changed logging to backup_history to show number of objects instead of number of tables in the column "num_objects"
=== modified file 'mysql-test/suite/backup/r/backup_logs.result'
--- a/mysql-test/suite/backup/r/backup_logs.result	2009-02-06 08:28:24 +0000
+++ b/mysql-test/suite/backup/r/backup_logs.result	2009-02-11 09:45:55 +0000
@@ -78,7 +78,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	0	tom	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
+backup	1	tom	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
 SELECT CURRENT_USER();
 CURRENT_USER()
 root@localhost
@@ -92,11 +92,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	0	root	BACKUP DATABASE backup_logs TO 'backup_logs1.bak'
-
-From the above tables we can notice that num_objects shows '0' if only DB
-is included in backup image(BUG#39109)
-
+backup	1	root	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
@@ -104,6 +100,8 @@ CREATE TABLE backup_logs.t1 (a char(30))
 CREATE TABLE backup_logs.t2 (a char(30)) ENGINE=INNODB;
 CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
 CREATE TABLE backup_logs.t4(id INT, name CHAR(20))ENGINE=BLACKHOLE;
+CREATE TABLESPACE ts ADD DATAFILE 'afile' ENGINE=FALCON;
+CREATE TABLE backup_logs.t5 (i INT) ENGINE=FALCON TABLESPACE ts;
 INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress");
 INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress");
 INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress");
@@ -241,7 +239,8 @@ timediff(validity_point_time, start_time
 From backup_history log we will notice that "drivers" column will show
 Myisam, snapshot, default and no-data drivers
 "error_num" will be '0' as both backup and restore was successful
-"num_objects" count is always 5(as there are 5 tables in database).
+"num_objects" count is 13: (1 db, 1 tablespace, 
+4 routines, 2 views, 4 tables, 1 db)
 It does not list other objects from the backup image(BUG#39109)
 SHOW VARIABLES LIKE 'log_backup_output';
 Variable_name	Value
@@ -254,7 +253,7 @@ binlog_file	#
 backup_state	complete
 operation	backup
 error_num	0
-num_objects	4
+num_objects	13
 total_bytes	5215
 validity_point_time	#
 start_time	#
@@ -323,7 +322,7 @@ binlog_file	#
 backup_state	complete
 operation	restore
 error_num	0
-num_objects	4
+num_objects	13
 total_bytes	1483
 validity_point_time	#
 start_time	#
@@ -370,3 +369,4 @@ SET @@global.log_backup_output = 'TABLE'
 DROP USER 'tom'@'localhost';
 SET DEBUG_SYNC= 'reset';
 DROP DATABASE backup_logs;
+DROP TABLESPACE ts ENGINE=Falcon;

=== modified file 'mysql-test/suite/backup/t/backup_logs.test'
--- a/mysql-test/suite/backup/t/backup_logs.test	2009-02-06 08:28:24 +0000
+++ b/mysql-test/suite/backup/t/backup_logs.test	2009-02-11 09:45:55 +0000
@@ -9,6 +9,7 @@
 --source include/not_embedded.inc
 --source include/have_debug.inc
 --source include/blackhole.inc
+--source include/have_falcon.inc
 
 SET DEBUG_SYNC= 'RESET';
 
@@ -143,15 +144,6 @@ SELECT operation,num_objects, username, 
      WHERE backup_id=@bup_id;
 --remove_file $MYSQLD_DATADIR/backup_logs1.bak
 
---echo
---echo From the above tables we can notice that num_objects shows '0' if only DB
---echo is included in backup image(BUG#39109)
---echo
-
-# BUG#39109: Mysql Online Backup table doesn't show correct num_object count
-# Once BUG#39109 is fixed, all the objects should be listed in the num_object
-# count of backup_history log
-
 --echo Include all objects in database(Databases, tables, procedures and
 --echo functions, views, triggers and events) and perform backup operation.
 
@@ -167,6 +159,13 @@ CREATE TABLE backup_logs.t2 (a char(30))
 CREATE TABLE backup_logs.t3 (a char(30)) ENGINE=MEMORY;
 CREATE TABLE backup_logs.t4(id INT, name CHAR(20))ENGINE=BLACKHOLE;
 
+# Create a Falcon table using defined tablespace to ensure that
+# tablespaces are counted in the num_objects column of the
+# backup_history table.
+
+CREATE TABLESPACE ts ADD DATAFILE 'afile' ENGINE=FALCON;
+CREATE TABLE backup_logs.t5 (i INT) ENGINE=FALCON TABLESPACE ts;
+
 INSERT INTO backup_logs.t1 VALUES ("01 Test #1 - progress"); 
 INSERT INTO backup_logs.t1 VALUES ("02 Test #1 - progress"); 
 INSERT INTO backup_logs.t1 VALUES ("03 Test #1 - progress"); 
@@ -330,7 +329,8 @@ from mysql.backup_history WHERE backup_i
 --echo From backup_history log we will notice that "drivers" column will show
 --echo Myisam, snapshot, default and no-data drivers
 --echo "error_num" will be '0' as both backup and restore was successful
---echo "num_objects" count is always 5(as there are 5 tables in database).
+--echo "num_objects" count is 13: (1 db, 1 tablespace, 
+--echo                             4 routines, 2 views, 4 tables, 1 db)
 --echo It does not list other objects from the backup image(BUG#39109)
 
 #Show results
@@ -483,5 +483,6 @@ SET @@global.log_backup_output = 'TABLE'
 DROP USER 'tom'@'localhost';
 SET DEBUG_SYNC= 'reset';
 DROP DATABASE backup_logs;
+DROP TABLESPACE ts ENGINE=Falcon;
 remove_file $MYSQLD_BACKUPDIR/backup_logs_orig.bak;
 

=== modified file 'sql/backup/image_info.cc'
--- a/sql/backup/image_info.cc	2008-12-18 21:46:36 +0000
+++ b/sql/backup/image_info.cc	2009-02-11 09:45:55 +0000
@@ -14,7 +14,13 @@
 namespace backup {
 
 Image_info::Image_info()
-  :data_size(0), m_table_count(0), m_dbs(16, 16), m_ts_map(16,16)
+  :data_size(0),
+   m_table_count(0),
+   m_view_count(0),
+   m_routine_count(0),
+   m_priv_count(0),
+   m_dbs(16, 16),
+   m_ts_map(16,16)
 {
   init_alloc_root(&mem_root, 4 * 1024, 0);      // Never errors
 
@@ -246,6 +252,7 @@ Image_info::Dbobj* Image_info::add_db_ob
     return NULL;
     
   o->base.pos= pos;
+  count_object(type);
 
   return o;
 }
@@ -310,7 +317,7 @@ Image_info::add_table(Db &db, const ::St
   t->snap_num= snap.m_num - 1;
   t->base.base.pos= pos;
 
-  m_table_count++;
+  count_object(BSTREAM_IT_TABLE);
 
   return t;  
 }

=== modified file 'sql/backup/image_info.h'
--- a/sql/backup/image_info.h	2009-01-08 14:57:41 +0000
+++ b/sql/backup/image_info.h	2009-02-11 09:45:55 +0000
@@ -90,9 +90,13 @@ public: // public interface
   size_t     data_size;      ///< How much of table data is saved in the image.
   st_bstream_binlog_pos  master_pos; ///< To store master position info.
 
-  ulong      table_count() const;
+  uint       object_count() const;
   uint       db_count() const;
   uint       ts_count() const;
+  uint       table_count() const;
+  uint       view_count() const;
+  uint       routine_count() const;
+  uint       priv_count() const;
   ushort     snap_count() const;
 
   // Examine contents of the catalogue.
@@ -149,10 +153,17 @@ protected:
 
   Image_info();
   uint m_table_count;    ///< Number of tables in the image.
+  uint m_view_count;     ///< Number of views in the image
+  uint m_routine_count;  ///< Number of stored routines in the image
+  uint m_priv_count;     ///< Number of privileges in the image
+
   MEM_ROOT  mem_root;    ///< Memory root for storage of catalogue items.
 
   class Tables; ///< Implementation of Table_list interface. 
 
+  /// 
+  void count_object(const enum_bstream_item_type type);
+
 private:
 
   Map<uint, Db>   m_dbs; ///< Pointers to Db instances.
@@ -721,6 +732,64 @@ Image_info::Dbobj_iterator::Dbobj_iterat
  
  ********************************************************************/ 
 
+/**
+   Increase counter for this type of object. This is displayed as info
+   in the backup_history table.
+
+   @param[in] type type of the object
+*/
+inline
+void Image_info::count_object(const enum_bstream_item_type type)
+{
+
+  switch (type) {
+
+    case BSTREAM_IT_TABLE: 
+      m_table_count++;
+      break;
+    case BSTREAM_IT_VIEW: 
+      m_view_count++; 
+      break;
+    case BSTREAM_IT_SPROC: 
+    case BSTREAM_IT_SFUNC: 
+    case BSTREAM_IT_EVENT: 
+    case BSTREAM_IT_TRIGGER:
+      m_routine_count++;
+      break;
+    case BSTREAM_IT_PRIVILEGE: 
+      m_priv_count++;
+      break;
+      
+    case BSTREAM_IT_DB:           // counted via m_dbs.count()
+    case BSTREAM_IT_TABLESPACE:   // counted via m_ts_map.count()
+    case BSTREAM_IT_CHARSET:      // not counted yet
+    case BSTREAM_IT_USER:         // not counted yet
+      break;
+    default: DBUG_ASSERT(FALSE);  // explicitly count or ignore any new type
+  }
+}
+
+/**
+   Get number of named objects (ts, db, table, view, routines) in the
+   image.
+*/
+inline
+uint Image_info::object_count() const
+{ 
+  return db_count()
+    + ts_count()
+    + table_count()
+    + view_count()
+    + routine_count();
+}
+
+/// Returns number of routines in the image.
+inline
+uint Image_info::routine_count() const
+{ 
+  return m_routine_count;
+}
+
 /// Returns number of databases in the image.
 inline
 uint Image_info::db_count() const
@@ -737,11 +806,25 @@ uint Image_info::ts_count() const
 
 /// Returns total number of tables in the image.
 inline
-ulong Image_info::table_count() const
+uint Image_info::table_count() const
 { 
   return m_table_count;
 }
 
+/// Returns total number of views in the image.
+inline
+uint Image_info::view_count() const
+{ 
+  return m_view_count;
+}
+
+/// Returns total number of privileges in the image.
+inline
+uint Image_info::priv_count() const
+{ 
+  return m_priv_count;
+}
+
 /// Returns number of snapshots used by the image.
 inline
 ushort Image_info::snap_count() const

=== modified file 'sql/backup/logger.cc'
--- a/sql/backup/logger.cc	2009-02-04 10:49:16 +0000
+++ b/sql/backup/logger.cc	2009-02-11 09:45:55 +0000
@@ -155,7 +155,7 @@ int Logger::v_write_message(log_level::v
 void Logger::report_stats_pre(const Image_info &info)
 {
   DBUG_ASSERT(m_state == RUNNING);
-  backup_log->num_objects(info.table_count());
+  backup_log->num_objects(info.object_count());
   // Compose list of databases.
 
   Image_info::Db_iterator *it= info.get_dbs();

Thread
bzr commit into mysql-6.0-backup branch (jorgen.loland:2764) Bug#39109Jorgen Loland11 Feb
  • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2764)Bug#39109Chuck Bell11 Feb
    • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2764)Bug#39109Jørgen Løland12 Feb
      • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2764)Bug#39109Rafal Somla13 Feb
        • Re: bzr commit into mysql-6.0-backup branch (jorgen.loland:2764)Bug#39109Jørgen Løland13 Feb