Below is the list of changes that have just been committed into a local
5.1 repository of cbell. When cbell 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-04-04 08:39:36-04:00, cbell@mysql_cab_desk. +1 -0
Merge mysql_cab_desk.:C:/source/c++/mysql-5.1-backup-prototype
into mysql_cab_desk.:C:/source/c++/mysql-5.1-backup-phase2
MERGE: 1.2501.1.1
sql/backup/meta_backup.cc@stripped, 2007-04-04 08:39:33-04:00, cbell@mysql_cab_desk. +1 -9
Manual merge.
MERGE: 1.4.1.3
# 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: cbell
# Host: mysql_cab_desk.
# Root: C:/source/c++/mysql-5.1-backup-phase2/RESYNC
--- 1.6/sql/backup/meta_backup.cc 2007-04-04 08:39:50 -04:00
+++ 1.7/sql/backup/meta_backup.cc 2007-04-04 08:39:50 -04:00
@@ -218,6 +218,7 @@
***********************************************************/
+bool get_create_stmt(THD*,TABLE_LIST*,String&);
bool write_table_definitions(THD *thd, const Backup_info &info, OStream &s)
{
@@ -246,16 +247,8 @@
while (ptr)
{
- String create_statement; // The create statement
-
- DBUG_ASSERT(!store_create_info(thd,ptr,&create_statement,NULL));
-
- /*
- Capture the table name then create a database.table string
- for inserting into the CREATE statement in replace of the
- table name.
- */
- DBUG_ASSERT(!insert_db_in_create(ptr, &create_statement));
+ String create_statement;
+ DBUG_ASSERT(!get_create_stmt(thd,ptr,create_statement));
ptr= tl->next_global;
// free memory? (it is allocated using sql_alloc)
@@ -300,9 +293,8 @@
// remove tables which exist
- DBUG_PRINT("restore",(" dropping tables"));
err= mysql_rm_table_part2_with_lock(thd, tl, TRUE, FALSE, TRUE); // = DROP TABLE IF
EXISTS
- DBUG_PRINT("restore",(" result= %d",err));
+ DBUG_PRINT("restore",(" drop tables result= %d",err));
DBUG_ASSERT( err == 0 );
@@ -316,6 +308,7 @@
// execute the statement
bool res= silent_exec_query(thd,create_statement);
+ DBUG_PRINT("restore",(" res=%d after executing %s",res,create_statement.c_ptr()));
if (!res)
DBUG_RETURN(res);
@@ -329,6 +322,83 @@
DBUG_PRINT("restore",("All tables created"));
DBUG_RETURN(TRUE);
+}
+
+/**
+ Produce a CREATE TABLE statement corresponding to a given table.
+
+ @note The statement uses qualified table name (<db name>.<table>) so
+ that it works correctly regardless of the current database.
+
+ @param tbl (in) open TABLE_LIST structure for the table
+ @param s (out) String where the statement is stored.
+
+ @returns TRUE if there were errors, FALSE otherwise.
+ */
+
+bool get_create_stmt(THD *thd, TABLE_LIST *tbl, String &s)
+{
+ String table_name; // Buffer to store table name
+ uint len; // store length of the table name
+ int index= 0; // index of table name in create string
+ int period= 0; // index of "." in create string
+
+ DBUG_ENTER("backup::get_create_stmt");
+
+ /*
+ If table is NULL or the table's database name is missing,
+ abort.
+ */
+ if (!tbl || !tbl->db)
+ {
+ DBUG_PRINT("backup", ("table or database not specified: "));
+ DBUG_RETURN(TRUE);
+ }
+
+ bool res= store_create_info(thd,tbl,&s,NULL);
+
+ if (res)
+ DBUG_RETURN(TRUE);
+
+ /*
+ Aparrently, it is not possible to make the store_create_info() function
+ produce a CREATE TABLE statement with qualified table names.
+
+ Therefore we modify the returned statement replacing table name with the
+ qualified one.
+ */
+
+ table_name.length(0);
+ table_name.append(tbl->table_name);
+ len= table_name.length();
+ index= s.strstr(table_name); // locate table name in the statement
+
+ table_name.set_ascii(".",1);
+ period= s.strstr(table_name); // to check if db name is already there
+
+ /*
+ If the table name isn't found in the string or if a period appears
+ in the string before the table name (indicating the db.table is
+ already in there), abort.
+ */
+ if (!index || ((period > 0) && (period < index)))
+ {
+ DBUG_PRINT("backup", ("table name not found in string!"));
+ DBUG_RETURN(TRUE);
+ }
+
+ table_name.length(0);
+ table_name.append(tbl->db);
+ table_name.append("`.`");
+ table_name.append(tbl->table_name);
+
+ /*
+ Insert the database.table string at the location
+ of the table name in the CREATE command.
+ */
+ DBUG_PRINT("backup", ("inserting database %s into %s",
+ table_name.c_ptr() , s.c_ptr()));
+ DBUG_RETURN(s.replace(index, len, table_name));
}
| Thread |
|---|
| • bk commit into 5.1 tree (cbell:1.2504) | cbell | 4 Apr |