Below is the list of changes that have just been committed into a local
6.0 repository of rafal. When rafal 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, 2008-03-11 10:00:20+01:00, rafal@quant.(none) +3 -0
WL#4212 (Online Backup : Kernel updates for object metadata changes)
This patch fixes problem found in the Image_info destructor. This destructor was
refering to Snapshot_info
objects which are deleted earlier by the Backup_info destructor.
The Snapshot_info destructor is changed to iterate over all objects in the catalogue
using iterators
Db_iterator and Dbobj_iterator, which are available at destruction time. Also,
destructors are explicitly
called for all catalogue objects to free allocated resources.
sql/backup/backup_info.cc@stripped, 2008-03-11 10:00:16+01:00, rafal@quant.(none) +0 -1
Remove inline declaration causing compile problems.
sql/backup/image_info.cc@stripped, 2008-03-11 10:00:16+01:00, rafal@quant.(none) +16 -35
Change Image_info destructor to explicitly call destructors for all items stored in
the catalogue.
Iterators are used to iterate over all databases and all objects in each of them.
sql/backup/image_info.h@stripped, 2008-03-11 10:00:16+01:00, rafal@quant.(none) +7 -3
Make destructor of Image_info::Obj to delete server object instance if present.
Fix documentation.
diff -Nrup a/sql/backup/backup_info.cc b/sql/backup/backup_info.cc
--- a/sql/backup/backup_info.cc 2008-03-05 18:48:05 +01:00
+++ b/sql/backup/backup_info.cc 2008-03-11 10:00:16 +01:00
@@ -186,7 +186,6 @@ Backup_info::~Backup_info()
After this call the @c Backup_info object is ready for use as a catalogue
for backup stream functions such as @c bstream_wr_preamble().
*/
-inline
int Backup_info::close()
{
if (!is_valid())
diff -Nrup a/sql/backup/image_info.cc b/sql/backup/image_info.cc
--- a/sql/backup/image_info.cc 2008-03-05 18:48:05 +01:00
+++ b/sql/backup/image_info.cc 2008-03-11 10:00:16 +01:00
@@ -51,48 +51,29 @@ Image_info::Image_info()
Image_info::~Image_info()
{
- // Delete server table objects
+ Db_iterator dbit(*this);
+ const Db *db;
+
+ /*
+ We need to explicitly call destructors for all objects in the catalogue
+ since they are allocated using mem_root and thus destructors will not be
+ invoked when the mem_root is freed.
+ */
- for (uint n=0; n<256; ++n)
+ while ((db= static_cast<const Db*>(dbit++)))
{
- Snapshot_info *snap= m_snap[n];
-
- if (!snap)
- continue;
-
- for (ulong i=0; i < snap->table_count(); ++i)
- {
- Table *t= snap->get_table(i);
-
- if (!t)
- continue;
-
- delete t->m_obj_ptr;
- }
- }
+ // iterate over objects in the database
- // delete server database objects
+ Dbobj_iterator it(*this,*db);
+ const Obj *o;
- for (uint i=0; i < db_count(); ++i)
- {
- Db *db= get_db(i);
-
- if (!db)
- continue;
-
- delete db->m_obj_ptr;
+ while ((o= it++))
+ o->~Obj();
- // delete all server objects belonging to that database (except tables)
- for (ulong j=0; j < db->obj_count(); ++j)
- {
- Dbobj *o= db->get_obj(j);
- if (o)
- delete o->m_obj_ptr;
- }
-
- // explicitly call destructor since this is mem_root allocated object
db->~Db();
}
+
+ free_root(&mem_root, MYF(0));
}
/**
diff -Nrup a/sql/backup/image_info.h b/sql/backup/image_info.h
--- a/sql/backup/image_info.h 2008-03-05 18:48:05 +01:00
+++ b/sql/backup/image_info.h 2008-03-11 10:00:16 +01:00
@@ -60,7 +60,7 @@ public: // public interface
class Iterator; ///< Base for all iterators.
class Db_iterator; ///< Iterates over all databases.
class Perdb_iterator; ///< Iterates over all per-database objects (except tables).
- class Dbobj_iterator; ///< Iterates over tables in a database.
+ class Dbobj_iterator; ///< Iterates over objects in a database.
virtual ~Image_info();
@@ -300,7 +300,8 @@ Snapshot_info::~Snapshot_info()
@c obs::Obj, to be used by server's objects services API. If @c m_obj_ptr is
not NULL then it contains a pointer to the corresponding @c obs::Obj instance
which was obtained earlier (either with @c materialize() or from server's
- object iterators).
+ object iterators). The @c Obj instance owns the server object and is
+ responsible for deleting it.
*/
class Image_info::Obj: public Sql_alloc
{
@@ -350,7 +351,10 @@ Image_info::Obj::Obj() :m_obj_ptr(NULL)
inline
Image_info::Obj::~Obj()
-{}
+{
+ // Delete corresponding server object if present.
+ delete m_obj_ptr;
+}
/**
Specialization of @c Image_info::Obj for storing info about a database.