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-04-11 10:16:37+02:00, rafal@quant.(none) +8 -0
WL#4348 (tablespace support for old backup kernel)
This patch adds the same functionality as WL#4341 and WL#4347 to the old, pre-WL#4212
backup kernel.
sql/backup/backup_kernel.h@stripped, 2008-04-11 10:15:20+02:00, rafal@quant.(none) +11 -0
- Add add_ts() method to Backup_info class.
- Add ts_hash member to Backup_info class and Ts_hash_node struct for HASH entries.
sql/backup/catalog.cc@stripped, 2008-04-11 10:15:21+02:00, rafal@quant.(none) +24 -5
- Added initialization of new member m_ts to Image_info constructor.
- Delete tablespace objects in Image_info destructor.
- Update Image_info::locate_item() to handle tablespaces.
- Update bcat_iterator_get() to return new iterators (tablespace and global iterator).
sql/backup/catalog.h@stripped, 2008-04-11 10:15:21+02:00, rafal@quant.(none) +217 -1
- Add Ts_item class to Image_info.
- Add new iterators Ts_iterator and Global_iterator to Image_info.
- Add m_ts member to Image_info for storing tablespace catalogue entries.
- Add methods for manipulatiog tablespace catalogue entries: ts_count(), add_ts(),
get_ts().
sql/backup/kernel.cc@stripped, 2008-04-11 10:15:21+02:00, rafal@quant.(none) +160 -1
- Implementation of Backup_info::Ts_hash_node structure used for ts_hash.
- Handle tables which use tablespaces in Backup_info::add_db_items().
- Implementation of Backup_info::add_ts() method.
- Update Restore_info::restore_item() method to handle tablespaces.
- Update bcat_add_item() to handle tablespaces.
sql/backup/stream_v1.c@stripped, 2008-04-11 10:15:21+02:00, rafal@quant.(none) +73 -14
Backup stream format and library extensions to handle tablespaces (taken from
WL#4341).
sql/backup/stream_v1.h@stripped, 2008-04-11 10:15:22+02:00, rafal@quant.(none) +17 -1
Backup stream format and library extensions to handle tablespaces (taken from
WL#4341).
sql/share/errmsg.txt@stripped, 2008-04-11 10:15:22+02:00, rafal@quant.(none) +3 -0
New error message ER_BACKUP_TS_CHANGE.
sql/si_objects.cc@stripped, 2008-04-11 10:15:20+02:00, rafal@quant.(none) +2 -2
- Moved declaration of ret to avoid compile problems (jump crosses variable
initialization).
- Fixed DBUG_PRINT() statement.
diff -Nrup a/sql/backup/backup_kernel.h b/sql/backup/backup_kernel.h
--- a/sql/backup/backup_kernel.h 2008-01-15 01:26:32 +01:00
+++ b/sql/backup/backup_kernel.h 2008-04-11 10:15:20 +02:00
@@ -159,6 +159,7 @@ class Backup_info: public Image_info, pu
int find_backup_engine(const ::TABLE *const, const Table_ref&);
+ Ts_item* add_ts(obs::Obj*);
Table_item* add_table(Db_item&, const Table_ref&);
int add_db_items(Db_item&);
@@ -177,6 +178,16 @@ class Backup_info: public Image_info, pu
*/
// FIXME: use better solution, e.g., MEM_ROOT
List<String> name_strings;
+
+ struct Ts_hash_node; ///< Hash nodes used in @c ts_hash.
+
+ /**
+ Hash storing all tablespaces added to the backup catalogue.
+
+ Used for quickly determining if the catalogue contains a given
+ tablespace or not.
+ */
+ HASH ts_hash;
void save_binlog_pos(const ::LOG_INFO &li)
{
diff -Nrup a/sql/backup/catalog.cc b/sql/backup/catalog.cc
--- a/sql/backup/catalog.cc 2008-02-14 19:28:04 +01:00
+++ b/sql/backup/catalog.cc 2008-04-11 10:15:21 +02:00
@@ -21,7 +21,8 @@ namespace backup {
/* Image_info implementation */
Image_info::Image_info():
- backup_prog_id(0), table_count(0), data_size(0), m_items(32,128)
+ backup_prog_id(0), table_count(0), data_size(0),
+ m_ts(16,32), m_items(32,128)
{
/* initialize st_bstream_image_header members */
version= 1;
@@ -81,6 +82,14 @@ Image_info::~Image_info()
// delete server object instances as we own them.
+ for (uint i=0; i < ts_count(); ++i)
+ {
+ Ts_item *ts= m_ts[i];
+
+ if (ts)
+ delete ts->obj_ptr();
+ }
+
for (uint i=0; i < db_count(); ++i)
{
Db_item *db= m_db[i];
@@ -155,6 +164,9 @@ Image_info::locate_item(const st_bstream
{
switch (item->type) {
+ case BSTREAM_IT_TABLESPACE:
+ return get_ts(item->pos);
+
case BSTREAM_IT_DB:
return get_db(item->pos);
@@ -311,11 +323,14 @@ static uint null_iter; ///< Used to imp
void* bcat_iterator_get(st_bstream_image_header *catalogue, unsigned int type)
{
+ DBUG_ASSERT(catalogue);
+ backup::Image_info *info= static_cast<backup::Image_info*>(catalogue);
+
switch (type) {
case BSTREAM_IT_PERDB:
return
- new
backup::Image_info::PerDb_iterator(*static_cast<backup::Image_info*>(catalogue));
+ new backup::Image_info::PerDb_iterator(*info);
case BSTREAM_IT_PERTABLE:
return &null_iter;
@@ -327,12 +342,16 @@ void* bcat_iterator_get(st_bstream_image
case BSTREAM_IT_USER:
return &null_iter;
- case BSTREAM_IT_GLOBAL:
- // only global items (for which meta-data is stored) are databases
case BSTREAM_IT_DB:
return
- new
backup::Image_info::Db_iterator(*static_cast<backup::Image_info*>(catalogue));
+ new backup::Image_info::Db_iterator(*info);
// TODO: report error if iterator could not be created
+
+ case BSTREAM_IT_TABLESPACE:
+ return new backup::Image_info::Ts_iterator(*info);
+
+ case BSTREAM_IT_GLOBAL:
+ return new backup::Image_info::Global_iterator(*info);
default:
return NULL;
diff -Nrup a/sql/backup/catalog.h b/sql/backup/catalog.h
--- a/sql/backup/catalog.h 2008-03-12 13:20:53 +01:00
+++ b/sql/backup/catalog.h 2008-04-11 10:15:21 +02:00
@@ -42,14 +42,17 @@ class Image_info: public st_bstream_imag
// Classes representing various types of meta-data items.
class Item; ///< base class for all item types
+ class Ts_item;
class Db_item;
class Table_item;
class PerDb_item;
class Iterator; ///< base for all iterators
class Db_iterator; ///< iterates over databases in archive
+ class Ts_iterator; ///< iterates over tablespaces
class Ditem_iterator; ///< iterates over all objects in a given database
class PerDb_iterator; ///< iterates over all per-db objects, except tables
+ class Global_iterator; ///< iterates over all global objects
virtual ~Image_info();
@@ -97,6 +100,7 @@ class Image_info: public st_bstream_imag
};
Databases m_db; ///< list of databases
+ Dynamic_array<Ts_item> m_ts; ///< list of tablespaces
Snapshot_info *m_snap[256]; ///< list of snapshots
Dynamic_array<PerDb_item> m_items;
@@ -107,6 +111,9 @@ class Image_info: public st_bstream_imag
uint db_count() const
{ return m_db.count(); }
+ uint ts_count() const
+ { return m_ts.size(); }
+
/*
Methods for populating backup catalogue (just wrappers which access m_db
member)
@@ -146,6 +153,12 @@ class Image_info: public st_bstream_imag
int add_objects(Db_item&, const enum_bstream_item_type, obs::ObjIterator&);
+ Ts_item* add_ts(obs::Obj&);
+ Ts_item* add_ts(const ::String&, uint pos);
+
+ Ts_item* get_ts(uint pos) const
+ { return m_ts[pos]; }
+
private:
/**
@@ -402,6 +415,39 @@ class Image_info::Item
friend class Restore_info;
};
+class Image_info::Ts_item
+ : public st_bstream_ts_info,
+ public Image_info::Item
+{
+ obs::Obj *m_obj_ptr;
+
+ public:
+
+ Ts_item();
+
+ const st_bstream_item_info* info() const { return &base; }
+ const st_bstream_ts_info* ts_info() const { return this; }
+
+ obs::Obj* obj_ptr()
+ { return m_obj_ptr; }
+
+ obs::Obj* obj_ptr(uint ver, ::String &sdata)
+ {
+ delete m_obj_ptr;
+
+ return m_obj_ptr= obs::materialize_tablespace(&m_name, ver, &sdata);
+ }
+
+ friend class Image_info;
+};
+
+inline
+Image_info::Ts_item::Ts_item() :m_obj_ptr(NULL)
+{
+ bzero(&base, sizeof(base));
+ base.type= BSTREAM_IT_TABLESPACE;
+}
+
/**
Specialization of @c Image_info::Item for storing info about a database.
*/
@@ -426,7 +472,7 @@ class Image_info::Db_item
obs::Obj* obj_ptr()
{ return Db_ref::obj_ptr(); }
- obs::Obj* obj_ptr(uint ver, ::String &sdata) // unit ver, ::String &sdata)
+ obs::Obj* obj_ptr(uint ver, ::String &sdata)
{
obs::Obj *obj= obs::materialize_database(&name(), ver, &sdata);
@@ -599,6 +645,50 @@ class Image_info::PerDb_item
const st_bstream_item_info* info() const { return &base; }
};
+inline
+Image_info::Ts_item*
+Image_info::add_ts(obs::Obj &obj)
+{
+ uint pos= ts_count();
+
+ Ts_item *tsi= m_ts.get_entry(pos);
+
+ if (!tsi)
+ return NULL;
+
+ tsi->base.pos= pos;
+ tsi->m_obj_ptr= &obj;
+
+ const ::String *name= obj.get_name();
+
+ DBUG_ASSERT(name);
+ tsi->m_name= *name;
+
+ tsi->base.name.begin= (byte*) name->ptr();
+ tsi->base.name.end= tsi->base.name.begin + name->length();
+
+ return tsi;
+}
+
+inline
+Image_info::Ts_item*
+Image_info::add_ts(const ::String &name, uint pos)
+{
+ Ts_item *tsi= m_ts.get_entry(pos);
+
+ if (!tsi)
+ return NULL;
+
+ tsi->base.pos= pos;
+
+ tsi->m_name.copy(name);
+
+ tsi->base.name.begin= (byte*) tsi->m_name.ptr();
+ tsi->base.name.end= tsi->base.name.begin + tsi->m_name.length();
+
+ return tsi;
+}
+
/**
Add table to given snapshot at the indicated location.
@@ -805,6 +895,52 @@ class Image_info::Db_iterator
};
+
+class Image_info::Ts_iterator
+ : public Image_info::Iterator
+{
+ public:
+
+ Ts_iterator(const Image_info&);
+
+ protected:
+
+ uint pos;
+ const Item* get_ptr() const;
+ bool next();
+};
+
+inline
+Image_info::Ts_iterator::Ts_iterator(const Image_info &info)
+ :Iterator(info), pos(0)
+{}
+
+inline
+const Image_info::Item* Image_info::Ts_iterator::get_ptr() const
+{
+ /*
+ There should be no "holes" in the sequence of tablespaces. That is,
+ if there are N tablespaces in the catalogue then for i=0,1,..,N-1,
+ m_info.m_ts_map[i] should store pointer to the i-th database.
+ */
+ DBUG_ASSERT(pos >= m_info.ts_count() || m_info.m_ts[pos]);
+ return m_info.m_ts[pos];
+}
+
+/// Implementation of @c Image_info::Iterator virtual method.
+inline
+bool Image_info::Ts_iterator::next()
+{
+ if (pos < m_info.ts_count())
+ {
+ pos++;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
class Image_info::PerDb_iterator: public Image_info::Db_iterator
{
public:
@@ -847,6 +983,86 @@ class Image_info::Ditem_iterator
bool next();
};
+
+
+class Image_info::Global_iterator
+ : public Image_info::Iterator
+{
+ /**
+ Indicates whether tablespaces or databases are being currently enumearated.
+ */
+ enum { TABLESPACES, DATABASES, DONE } mode;
+
+ Iterator *m_it; ///< Points at the currently used iterator.
+ const Item *m_obj; ///< Points at next object to be returned by this iterator.
+
+ public:
+
+ Global_iterator(const Image_info&);
+
+ private:
+
+ const Item* get_ptr() const;
+ bool next();
+};
+
+inline
+Image_info::Global_iterator::Global_iterator(const Image_info &info)
+ :Iterator(info), mode(TABLESPACES), m_it(NULL), m_obj(NULL)
+{
+ m_it= new Ts_iterator(m_info);
+ next();
+}
+
+inline
+const Image_info::Item*
+Image_info::Global_iterator::get_ptr() const
+{
+ return m_obj;
+}
+
+inline
+bool
+Image_info::Global_iterator::next()
+{
+ if (mode == DONE)
+ return FALSE;
+
+ DBUG_ASSERT(m_it);
+
+ // get next object from the current iterator
+ m_obj= (*m_it)++;
+
+ if (m_obj)
+ return TRUE;
+
+ /*
+ If the current iterator has finished (m_obj == NULL) then, depending on
+ the mode, either switch to the next iterator or mark end of the sequence.
+ */
+
+ delete m_it;
+
+ switch (mode) {
+
+ case TABLESPACES:
+
+ mode= DATABASES;
+ m_it= new Db_iterator(m_info);
+ m_obj= (*m_it)++;
+ return m_obj != NULL;
+
+ case DATABASES:
+
+ mode= DONE;
+
+ case DONE:
+
+ break;
+ }
+
+ return FALSE;
+}
} // backup namespace
diff -Nrup a/sql/backup/kernel.cc b/sql/backup/kernel.cc
--- a/sql/backup/kernel.cc 2008-03-20 15:53:11 +01:00
+++ b/sql/backup/kernel.cc 2008-04-11 10:15:21 +02:00
@@ -587,6 +587,46 @@ namespace backup {
TABLE* get_schema_table(THD *thd, ST_SCHEMA_TABLE *st);
+/*
+ Definition of Backup_info::Ts_hash_node structure used by Backup_info::ts_hash
+ HASH.
+ */
+
+struct Backup_info::Ts_hash_node
+{
+ const ::String *name; ///< Name of the tablespace.
+ Ts_item *it; ///< Catalogue entry holding the tablespace (if exists).
+
+ Ts_hash_node(const ::String*);
+
+ static uchar* get_key(const uchar *record, size_t *key_length, my_bool);
+ static void free(void *record);
+};
+
+inline
+Backup_info::Ts_hash_node::Ts_hash_node(const ::String *name) :name(name), it(NULL)
+{}
+
+void Backup_info::Ts_hash_node::free(void *record)
+{
+ delete (Ts_hash_node*)record;
+}
+
+uchar* Backup_info::Ts_hash_node::get_key(const uchar *record,
+ size_t *key_length,
+ my_bool)
+{
+ Ts_hash_node *n= (Ts_hash_node*)record;
+
+ // ts_hash entries are indexed by tablespace name.
+
+ if (n->name && key_length)
+ *key_length= n->name->length();
+
+ return (uchar*)(n->name->ptr());
+}
+
+
/**
Create @c Backup_info structure and prepare it for populating with meta-data
items.
@@ -603,6 +643,9 @@ Backup_info::Backup_info(THD *thd):
m_state(INIT),
m_thd(thd), i_s_tables(NULL)
{
+ hash_init(&ts_hash, &::my_charset_bin, 16, 0, 0,
+ Ts_hash_node::get_key, Ts_hash_node::free, MYF(0));
+
i_s_tables= get_schema_table(m_thd, ::get_schema_table(SCH_TABLES));
if (!i_s_tables)
{
@@ -635,6 +678,8 @@ Backup_info::~Backup_info()
m_state= DONE;
name_strings.delete_elements();
// Note: snapshot objects are deleted in ~Image_info()
+
+ hash_free(&ts_hash);
}
/**
@@ -877,7 +922,7 @@ int Backup_info::add_db_items(Db_item &d
/*
add_table() method selects/creates a snapshot to which this table is added.
- The backup engine is chooden in Backup_info::find_backup_engine() method.
+ The backup engine is choosen in Backup_info::find_backup_engine() method.
*/
Table_item *ti= add_table(dbi,Table_ref(dbi,t));
@@ -887,6 +932,21 @@ int Backup_info::add_db_items(Db_item &d
goto error;
}
+ // If this table uses a tablespace, add this tablespace to the catalogue.
+
+ Obj *ts= get_tablespace_for_table(m_thd, &dbi.name(), &ti->name());
+
+ if (ts)
+ {
+ Ts_item *tsi= add_ts(ts); // reports errors
+
+ if (!tsi)
+ {
+ delete ts;
+ goto error;
+ }
+ }
+
if (add_table_items(*ti))
goto error;
}
@@ -959,6 +1019,67 @@ int Backup_info::add_db_items(Db_item &d
return res;
}
+
+/**
+ Add tablespace to backup catalogue.
+
+ @param[in] obj sever object representing the tablespace
+
+ If tablespace is already present in the catalogue, the existing catalogue entry
+ is returned. Otherwise a new entry is created and tablespace info stored in it.
+
+ @return Pointer to (the new or existing) catalogue entry holding info about the
+ tablespace.
+ */
+backup::Image_info::Ts_item* Backup_info::add_ts(obs::Obj *obj)
+{
+ const ::String *name;
+
+ DBUG_ASSERT(obj);
+ name= obj->get_name();
+ DBUG_ASSERT(name);
+
+ /*
+ Check if tablespace with that name is already present in the catalogue using
+ ts_hash.
+ */
+
+ Ts_hash_node n0(name);
+ size_t klen;
+ uchar *key= Ts_hash_node::get_key((const uchar*)&n0, &klen, TRUE);
+
+ Ts_hash_node *n1= (Ts_hash_node*) hash_search(&ts_hash, key, klen);
+
+ // if tablespace was found, return the catalogue entry stored in the hash
+ if (n1)
+ return n1->it;
+
+ // otherwise create a new catalogue entry
+
+ Ts_item *ts= Image_info::add_ts(*obj);
+
+ if (!ts)
+ {
+ // TODO: report error
+ return NULL;
+ }
+
+ // add new entry to ts_hash
+
+ n1= new Ts_hash_node(n0);
+
+ if (!n1)
+ {
+ // TODO: report error
+ return NULL;
+ }
+
+ n1->it= ts;
+ my_hash_insert(&ts_hash, (uchar*)&n1);
+
+ return ts;
+}
+
/**
Add table to archive's list of meta-data items.
@@ -1211,6 +1332,31 @@ result_t Restore_info::restore_item(Item
if (!obj)
return ERROR;
+
+ // If we are to create a tablespace, first check if it already exists.
+
+ if (it.info()->type == BSTREAM_IT_TABLESPACE)
+ {
+ // if the tablespace exists, there is nothing more to do
+ if (tablespace_exists(m_thd, it.obj_ptr()))
+ return OK;
+
+ /*
+ If there is a different tablespace with the same name then we can't re-create the
original
+ tablespace used by tables being restored. We report this and cancel restore
process.
+ */
+
+ Obj *ts= is_tablespace(m_thd, &it.m_name);
+
+ if (ts)
+ {
+ report_error(ER_BACKUP_TS_CHANGE,
+ it.m_name.ptr(),
+ describe_tablespace(it.obj_ptr()),
+ describe_tablespace(ts));
+ return ERROR;
+ }
+ }
return obj->execute(m_thd) ? ERROR : OK;
}
@@ -1336,6 +1482,19 @@ int bcat_add_item(st_bstream_image_heade
item->pos));
switch (item->type) {
+
+ case BSTREAM_IT_TABLESPACE:
+ {
+ Image_info::Ts_item *tsi= info->add_ts(name_str, item->pos);
+
+ if (!tsi)
+ {
+ // TODO: report error
+ return BSTREAM_ERROR;
+ }
+
+ return BSTREAM_OK;
+ }
case BSTREAM_IT_DB:
{
diff -Nrup a/sql/backup/stream_v1.c b/sql/backup/stream_v1.c
--- a/sql/backup/stream_v1.c 2008-03-18 15:18:54 +01:00
+++ b/sql/backup/stream_v1.c 2008-04-11 10:15:21 +02:00
@@ -535,8 +535,8 @@ int bstream_rd_image_info(backup_stream
identify and select them.
@verbatim
- [catalogue]= [ charsets ! 0x00 ! users ! 0x00 ! databases |
- db catalogue | ... | db catalogue ]
+ [catalogue]= [ charsets ! 0x00 ! users ! 0x00 ! tablespaces ! 0x00 !
+ databases | db catalogue | ... | db catalogue ]
@endverbatim
Catalogue starts with list of charsets where each charset is identified by its
@@ -560,6 +560,7 @@ int bstream_rd_image_info(backup_stream
The following charsets are any charsets used by the items stored in the image
and thus needed to restore these items.
+
@verbatim
[users]= [ user name ! ... ! user name ]
@@ -567,7 +568,15 @@ int bstream_rd_image_info(backup_stream
User list contains users for which any privileges are stored in the image.
- After [users] a list of all databases follows. If the list is empty, it
+ Following user list is a list of tablespaces used by the tables stored in
+ the backup image. Only tablespace names are listed here, their definitions
+ are stored in the meta-data section.
+ @verbatim
+
+ [tablespaces]= [ ts name ! ... ! ts name ]
+ @endverbatim
+
+ Finally, a list of all databases follows. If the list is empty, it
consists of a single null string. Otherwise it has format:
@verbatim
@@ -584,7 +593,7 @@ int bstream_rd_image_info(backup_stream
are no database catalogues.
@verbatim
- [catalogue (no databases)] = [ charsets ! 0x00 ! users ! 0x00 ]
+ [catalogue (no databases)] = [ charsets ! 0x00 ! users ! 0x00 ! tablespaces ! 0x00 ]
@endverbatim
*/
@@ -642,6 +651,22 @@ int bstream_wr_catalogue(backup_stream *
bcat_iterator_free(cat,it);
+ /* list of table spaces */
+
+ it= bcat_iterator_get(cat,BSTREAM_IT_TABLESPACE);
+
+ if (!it)
+ return BSTREAM_ERROR;
+
+ while ((name= (blob*) bcat_iterator_next(cat,it)))
+ {
+ CHECK_WR_RES(bstream_wr_string(s,*name));
+ }
+
+ CHECK_WR_RES(bstream_wr_byte(s,0x00));
+
+ bcat_iterator_free(cat,it);
+
/* list of databases */
it= bcat_iterator_get(cat,BSTREAM_IT_DB);
@@ -726,6 +751,27 @@ int bstream_rd_catalogue(backup_stream *
/* list of users */
item.type= BSTREAM_IT_USER;
+ item.pos= 0;
+
+ do{
+
+ CHECK_RD_RES(bstream_rd_string(s,&item.name));
+
+ /* empty string signals end of the list */
+ if (item.name.begin == NULL)
+ break;
+
+ if (bcat_add_item(cat,&item) != BSTREAM_OK)
+ return BSTREAM_ERROR;
+
+ item.pos++;
+
+ } while (ret == BSTREAM_OK);
+
+ /* list of table spaces */
+
+ item.type= BSTREAM_IT_TABLESPACE;
+ item.pos= 0;
do{
@@ -815,6 +861,11 @@ int bstream_rd_catalogue(backup_stream *
- 4 = database,
- 5 = table,
- 6 = view.
+ - 7 = stored procedure.
+ - 8 = stored function.
+ - 9 = event.
+ - 10 = trigger.
+ - 11 = table space.
Value 0 doesn't encode a valid item type and is used as item list separator.
*/
@@ -838,6 +889,7 @@ int bstream_wr_item_type(backup_stream *
case BSTREAM_IT_SFUNC: return bstream_wr_int2(s,8);
case BSTREAM_IT_EVENT: return bstream_wr_int2(s,9);
case BSTREAM_IT_TRIGGER: return bstream_wr_int2(s,10);
+ case BSTREAM_IT_TABLESPACE: return bstream_wr_int2(s,11);
case BSTREAM_IT_LAST: return bstream_wr_int2(s,0);
default: return BSTREAM_ERROR;
}
@@ -873,6 +925,7 @@ int bstream_rd_item_type(backup_stream *
case 8: *type= BSTREAM_IT_SFUNC; break;
case 9: *type= BSTREAM_IT_EVENT; break;
case 10: *type= BSTREAM_IT_TRIGGER; break;
+ case 11: *type= BSTREAM_IT_TABLESPACE; break;
default: return BSTREAM_ERROR;
}
@@ -899,11 +952,11 @@ int bstream_rd_item_type(backup_stream *
[optional item data] is used only for tables:
- [optional item data (table)]= [ flags:1 ! snapshot no:1 ! pos !
+ [optional item data (table)]= [ flags:1 ! snapshot no.:1 ! pos !
optional extra data ]
@endverbatim
- [snapshot no] tells which snapshot contains tables data and [pos] tells what
+ [snapshot no.] tells which snapshot contains tables data and [pos] tells what
is the position of the table in this snapshot.
Presence of extra data is indicated by a flag.
@@ -980,6 +1033,7 @@ int bstream_rd_db_catalogue(backup_strea
{
unsigned short int flags;
struct st_bstream_table_info ti;
+ unsigned long int pos= 0;
int ret;
bzero(&ti,sizeof(ti));
@@ -1007,6 +1061,8 @@ int bstream_rd_db_catalogue(backup_strea
CHECK_RD_OK(bstream_rd_byte(s,&ti.snap_no));
CHECK_RD_RES(bstream_rd_num(s,&ti.base.base.pos));
}
+ else
+ ti.base.base.pos= pos++;
if (bcat_add_item(cat, &ti.base.base) != BSTREAM_OK)
return BSTREAM_ERROR;
@@ -1042,9 +1098,12 @@ int bstream_rd_db_catalogue(backup_strea
[meta data]= [ global items | tables | other items ]
@endverbatim
- [Global items] include all databases. [Tables] section contains all tables
- which are grouped on per-database basis (this is for easier skipping of tables
- upon selective restore).
+ The only global items for which we store meta-data information are tablespaces
+ and databases. Tablespace definitions should come before database definitions
+ on the [global items] list.
+
+ [Tables] section contains all tables which are grouped on per-database basis
+ (this is for easier skipping of tables upon selective restore).
@verbatim
[tables] = [ tables from db1 | ... | tables from dbN ]
@@ -1315,10 +1374,10 @@ int bstream_rd_meta_data(backup_stream *
in which part of catalogue the entry lies.
@verbatim
- [item position (global)]= [db no]
- [item position (table)]= [ snap no ! pos in snapshot's table list ]
- [item position (other per-db item)]= [ pos in db item list ! db no ]
- [item position (per-table item)] = [ pos in table's item list ! db no ! table pos ]
+ [item position (global)]= [db no.]
+ [item position (table)]= [ snap no. ! pos in snapshot's table list ]
+ [item position (other per-db item)]= [ pos in db item list ! db no. ]
+ [item position (per-table item)] = [ pos in table's item list ! db no. ! table pos ]
@endverbatim
Note that table is identified by its position inside the snapshot to which it
@@ -1587,7 +1646,7 @@ int read_and_create_items(backup_stream
[table data]= [ table data chunk | ... | table data chunk ]
- [table data chunk]= [ snapshot no:1 ! seq no:2 ! flags:1 ! table no ! data ]
+ [table data chunk]= [ snapshot no.:1 ! seq no.:2 ! flags:1 ! table no. ! data ]
@endverbatim
Data chunks of each snapshot are numbered by consecutive numbers. This can be
diff -Nrup a/sql/backup/stream_v1.h b/sql/backup/stream_v1.h
--- a/sql/backup/stream_v1.h 2008-02-13 12:40:24 +01:00
+++ b/sql/backup/stream_v1.h 2008-04-11 10:15:22 +02:00
@@ -164,7 +164,12 @@ struct st_bstream_image_header
/** number of table data snapshots in the image */
unsigned short int snap_count;
- /** descriptions of table data snapshots */
+
+ /**
+ Descriptions of table data snapshots.
+
+ We have at most 256 snapshots because their number is stored using one byte.
+ */
struct st_bstream_snapshot_info snapshot[256];
};
@@ -219,6 +224,7 @@ enum enum_bstream_item_type {
BSTREAM_IT_SFUNC,
BSTREAM_IT_EVENT,
BSTREAM_IT_TRIGGER,
+ BSTREAM_IT_TABLESPACE,
BSTREAM_IT_LAST
};
@@ -230,6 +236,16 @@ struct st_bstream_item_info
enum enum_bstream_item_type type; /**< type of the item */
bstream_blob name; /**< name of the item */
unsigned long int pos; /**< position of the item in image's catalogue */
+};
+
+/**
+ Describes tablespace item.
+
+ Currently no data specific to tablespace items is used.
+*/
+struct st_bstream_ts_info
+{
+ struct st_bstream_item_info base;
};
/**
diff -Nrup a/sql/share/errmsg.txt b/sql/share/errmsg.txt
--- a/sql/share/errmsg.txt 2008-04-07 20:53:34 +02:00
+++ b/sql/share/errmsg.txt 2008-04-11 10:15:22 +02:00
@@ -6256,3 +6256,6 @@ ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
ER_BACKUP_LOG_WRITE_ERROR
eng "Can't write to the online backup progress log %-.64s."
+
+ER_BACKUP_TS_CHANGE
+ eng "Tablespace `%-.64s` needed by tables being restored has changed on the
server. The original definition of the required tablespace is '%-.256s' while the same
tablespace is defined on the server as '%-.256s'"
diff -Nrup a/sql/si_objects.cc b/sql/si_objects.cc
--- a/sql/si_objects.cc 2008-04-09 14:55:57 +02:00
+++ b/sql/si_objects.cc 2008-04-11 10:15:20 +02:00
@@ -2722,6 +2722,7 @@ static bool find_tablespace_schema_row(T
String *datafile,
String *comments)
{
+ int ret= 0;
TABLE *is_table;
handler *ha;
my_bitmap_map *orig_col;
@@ -2756,7 +2757,6 @@ static bool find_tablespace_schema_row(T
Attempt to locate the row in the tablespaces table.
If found, proceed to the retrieving the data.
*/
- int ret= 0;
is_table->field[0]->val_str(&found_ts_name);
while (!ret && found_ts_name.length() &&
(strncasecmp(found_ts_name.ptr(), ts_name->ptr(),
@@ -2888,7 +2888,7 @@ Obj *get_tablespace_for_table(THD *thd,
String ts_name;
DBUG_ENTER("obs::get_tablespace_for_table()");
DBUG_PRINT("obs::get_tablespace_for_table", ("name: %s.%s",
- db_name, tbl_name));
+ db_name->ptr(), tbl_name->ptr()));
const char *db= db_name->ptr();
const char *name= tbl_name->ptr();
| Thread |
|---|
| • bk commit into 6.0 tree (rafal:1.2608) WL#4348 | rsomla | 11 Apr |