Below is the list of changes that have just been committed into a local
5.1 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, 2007-04-12 09:06:35+02:00, rafal@quant.(none) +5 -0
WL#3327: Slight refactoring and change of the user feedback code to make it compile
on unix platform.
mysql-test/r/backup.result@stripped, 2007-04-12 09:06:32+02:00, rafal@quant.(none) +4 -4
Result update.
sql/backup/archive.h@stripped, 2007-04-12 09:06:32+02:00, rafal@quant.(none) +1 -1
Fix spaces.
sql/backup/be_default.cc@stripped, 2007-04-12 09:06:32+02:00, rafal@quant.(none) +1 -1
Fix spaces.
sql/backup/meta_backup.cc@stripped, 2007-04-12 09:06:32+02:00, rafal@quant.(none) +44 -44
Fix spaces.
sql/backup/sql_backup.cc@stripped, 2007-04-12 09:06:32+02:00, rafal@quant.(none) +15 -24
- Fix spaces.
- Use my_snprintf to create backup summary message.
- Don't use itoa() function not defined on unix platform.
# 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: rafal
# Host: quant.(none)
# Root: /ext/mysql/bk/backup/prototype
--- 1.11/sql/backup/be_default.cc 2007-04-12 09:06:41 +02:00
+++ 1.12/sql/backup/be_default.cc 2007-04-12 09:06:41 +02:00
@@ -595,7 +595,7 @@
{
i++;
res= next_table();
- }
+ }
while ((i != buf.stream_no) && !res);
tbl_num= i - 1;
}
--- 1.19/sql/backup/sql_backup.cc 2007-04-12 09:06:41 +02:00
+++ 1.20/sql/backup/sql_backup.cc 2007-04-12 09:06:41 +02:00
@@ -39,7 +39,7 @@
List<String> *buffer);
bool get_db_metadata(THD *thd, const char *db,
List<String> *buffer);
-bool send_summary(List<schema_ref> *catalog, bool backup,
+bool send_summary(List<schema_ref> *catalog, bool backup,
size_t header_size, size_t data_size);
/*
@@ -137,7 +137,7 @@
0 - no errors.
-1 - error.
*/
-bool send_summary(List<schema_ref> *catalog, bool backup,
+bool send_summary(List<schema_ref> *catalog, bool backup,
size_t header_size, size_t data_size)
{
Protocol *protocol= ::current_thd->protocol; // client comms
@@ -154,42 +154,33 @@
else
op_str.append("Restore Summary");
- DBUG_PRINT("backup", ("sending %s", op_str));
+ DBUG_PRINT("backup", ("sending %s", op_str.c_ptr()));
field_list.push_back(item= new Item_empty_string(op_str.c_ptr(),255)); // TODO: use
varchar field
item->maybe_null= TRUE;
protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF);
size_t total_size= header_size + data_size;
-
- op_str.length(0);
- if (backup)
- op_str.append("Backed up ");
- else
- op_str.append("Restored ");
- /*
+ /*
Loop through the catalog and list the contents by
database.
*/
List<schema_ref> cat1= *catalog;
List_iterator<schema_ref> cat(cat1);
schema_ref *tmp;
+
while ((tmp= cat++))
{
- List_iterator<table_info> tbls(tmp->tables);
- print_str.length(0);
- print_str.append(op_str);
- itoa(tmp->tables.elements, buf, 10);
- print_str.append(buf);
- if (tmp->tables.elements > 1)
- print_str.append(" tables in database ");
- else
- print_str.append(" table in database ");
- print_str.append(*tmp->db_name);
- print_str.append(".");
+ uint howmuch= tmp->tables.elements;
+
+ my_snprintf(buf,sizeof(buf),"%s %3d %s in database %s.",
+ backup? "Backed up" : "Restored",
+ howmuch, howmuch > 1 ? "tables" : " table",
+ tmp->db_name->c_ptr());
+
protocol->prepare_for_resend();
- protocol->store(print_str.c_ptr() ,system_charset_info);
+ protocol->store(buf,system_charset_info);
protocol->write();
}
@@ -208,7 +199,7 @@
protocol->store(buf,system_charset_info);
protocol->write();
- my_snprintf(buf,sizeof(buf)," --------------",data_size);
+ my_snprintf(buf,sizeof(buf)," --------------");
protocol->prepare_for_resend();
protocol->store(buf,system_charset_info);
protocol->write();
@@ -705,7 +696,7 @@
//{
// if (my_access(buff, (F_OK|W_OK)))
// {
- // my_error(ER_CANT_CREATE_FILE, MYF(0), where.str,
+ // my_error(ER_CANT_CREATE_FILE, MYF(0), where.str,
// ER_CANT_CREATE_FILE);
// return NULL;
// }
--- 1.6/sql/backup/archive.h 2007-04-12 09:06:41 +02:00
+++ 1.7/sql/backup/archive.h 2007-04-12 09:06:41 +02:00
@@ -146,7 +146,7 @@
~schema_ref()
{
db_metadata.empty();
- tables.empty();
+ tables.empty();
}
};
--- 1.9/sql/backup/meta_backup.cc 2007-04-12 09:06:41 +02:00
+++ 1.10/sql/backup/meta_backup.cc 2007-04-12 09:06:41 +02:00
@@ -60,7 +60,7 @@
OStream str - The stream to write to.
DESCRIPTION
- This procedure writes the contents of the catalog to the
+ This procedure writes the contents of the catalog to the
stream. Lists are prequalified with the number of elements to
enable faster construction of the catalog on read.
@@ -176,7 +176,7 @@
OStream str - The stream to write to.
DESCRIPTION
- This procedure writes the contents of the catalog to the
+ This procedure writes the contents of the catalog to the
stream. Lists are prequalified with the number of elements to
enable faster construction of the catalog on read.
@@ -192,7 +192,7 @@
schema_ref *cat; // reference to database data
String db_name; // database name
uint num_schemas= 0; // num of schemas to read
- uint num_db_strings= 0; // num of db metadata strings
+ uint num_db_strings= 0; // num of db metadata strings
uint num_table_strings= 0; // num of table metadata strings
uint num_tables= 0; // num of tables to read
table_info *ti; // table data
@@ -350,10 +350,10 @@
DBUG_RETURN(-1);
}
- /*
- Capture the table name then create a database.table string
+ /*
+ Capture the table name then create a database.table string
for inserting into the CREATE statement in replace of the
- table name.
+ table name.
*/
table_name.length(0);
table_name.append(tbl->table_name);
@@ -365,7 +365,7 @@
tmp.length(0);
tmp.append(".");
period= create_str->strstr(tmp);
-
+
/*
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
@@ -376,12 +376,12 @@
DBUG_PRINT("backup", ("table name not found in string!"));
DBUG_RETURN(-1);
}
-
+
/*
Insert the database.table string at the location
of the table name in the CREATE command.
*/
- DBUG_PRINT("backup", ("inserting database %s into %s",
+ DBUG_PRINT("backup", ("inserting database %s into %s",
db_table_name.c_ptr(), create_str->c_ptr()));
DBUG_RETURN(create_str->replace(index, table_name.length(), db_table_name));
}
@@ -416,14 +416,14 @@
0 - no errors.
-1 - error reading table or trigger metadata
*/
-bool get_table_metadata(THD *thd, TABLE_LIST *table,
+bool get_table_metadata(THD *thd, TABLE_LIST *table,
List<String> *buffer)
{
String *tbl_sql;
DBUG_ENTER("get_table_metadata");
/*
- Check to see if tables exist and open them. Abort if
+ Check to see if tables exist and open them. Abort if
something is wrong or tables cannot be locked.
*/
table->lock_type= TL_READ;
@@ -436,7 +436,7 @@
tbl_sql= new (current_thd->mem_root) String();
tbl_sql->length(0);
- /*
+ /*
Get the CREATE statement for the table and store it in the buffer.
*/
DBUG_PRINT("metadata_backup", ("constructing CREATE TABLE statement"));
@@ -446,7 +446,7 @@
DBUG_PRINT("metadata_backup", ("query = %s", tbl_sql->c_ptr()));
buffer->push_back(tbl_sql);
- /*
+ /*
If triggers exist for this table, open the trigger list
and construct the CREATE TRIGGER statements placing them in
the buffer.
@@ -471,7 +471,7 @@
&sql_mode,
&definer_buffer))
{
- DBUG_PRINT("metadata_backup",
+ DBUG_PRINT("metadata_backup",
("constructing the CREATE TRIGGER statement"));
tbl_sql= new (current_thd->mem_root) String();
tbl_sql->length(0);
@@ -493,16 +493,16 @@
Store the size of the string in the buffer followed by the
SQL string. Adjust pointer for next SQL string.
*/
- DBUG_PRINT("metadata_backup", ("trg query size = %d",
+ DBUG_PRINT("metadata_backup", ("trg query size = %d",
tbl_sql->length()));
DBUG_PRINT("metadata_backup", ("trg query = %s", tbl_sql->c_ptr()));
buffer->push_back(tbl_sql);
}
- /*
+ /*
Skip this trigger if it isn't for this table.
*/
else
- continue;
+ continue;
}
}
}
@@ -530,13 +530,13 @@
DESCRIPTION
This procedure loads the string list with the SQL statements for
creating the database and all of the stored procedures and
- functions associated with it.
+ functions associated with it.
RETURNS
0 - no errors.
-1 - database cannot be read or doesn't exist.
*/
-bool get_db_metadata(THD *thd, const char *db,
+bool get_db_metadata(THD *thd, const char *db,
List<String> *buffer)
{
TABLE *proc_table;
@@ -577,7 +577,7 @@
proc_tables.table_name_length= 4;
proc_tables.lock_type= TL_READ;
Open_tables_state open_tables_state_backup;
-
+
/*
Check to see if the proc table can be opened for reading.
*/
@@ -603,41 +603,41 @@
Setup preamble for create statements including definer or
invoker access options.
*/
- DBUG_PRINT("metadata_backup",
+ DBUG_PRINT("metadata_backup",
("constructing the CREATE PROCEDURE/FUNCION statement"));
db_sql->length(0);
- db_sql->append("CREATE ");
+ db_sql->append("CREATE ");
get_field(thd->mem_root, proc_table->field[7], &tmp);
- db_sql->append(tmp);
+ db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[11], &tmp);
- db_sql->append(" = ");
- db_sql->append(tmp);
+ db_sql->append(" = ");
+ db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[2], &tmp);
- db_sql->append(" ");
- db_sql->append(tmp);
+ db_sql->append(" ");
+ db_sql->append(tmp);
if (!my_strcasecmp(system_charset_info, tmp.c_ptr(), "PROCEDURE"))
- {
- /* It's a procedure */
+ {
+ /* It's a procedure */
get_field(thd->mem_root, proc_table->field[1], &tmp);
- db_sql->append(" ");
- db_sql->append(tmp);
+ db_sql->append(" ");
+ db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[8], &tmp);
- db_sql->append(" (");
- db_sql->append(tmp);
+ db_sql->append(" (");
+ db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[10], &tmp);
- db_sql->append(") \n");
+ db_sql->append(") \n");
db_sql->append(tmp);
}
else
{
/* It's a function */
get_field(thd->mem_root, proc_table->field[1], &tmp);
- db_sql->append(" ");
- db_sql->append(tmp);
+ db_sql->append(" ");
+ db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[8], &tmp);
- db_sql->append(" (");
- db_sql->append(tmp);
- db_sql->append(") \nRETURNS ");
+ db_sql->append(" (");
+ db_sql->append(tmp);
+ db_sql->append(") \nRETURNS ");
get_field(thd->mem_root, proc_table->field[9], &tmp);
db_sql->append(tmp);
get_field(thd->mem_root, proc_table->field[6], &tmp);
@@ -646,7 +646,7 @@
else
db_sql->append(" ");
get_field(thd->mem_root, proc_table->field[10], &tmp);
- db_sql->append(tmp);
+ db_sql->append(tmp);
}
DBUG_PRINT("metadata_backup", ("db query = %s", db_sql->c_ptr()));
buffer->push_back(db_sql);
@@ -672,9 +672,9 @@
Restore_info info - Restore information.
DESCRIPTION
- This procedure iterates through the catalog and executes
+ This procedure iterates through the catalog and executes
the metadata strings for each database and table in the
- catalog.
+ catalog.
NOTES
- Algorithm:
@@ -693,12 +693,12 @@
DBUG_ENTER("restore::restore_metadata");
DBUG_ASSERT(thd);
-
+
List<schema_ref> cat= info.catalog;
List_iterator<schema_ref> catalog(cat);
while ((tmp= catalog++))
{
- /*
+ /*
DROP DATABASE: Execute the DROP DATABASE IF EXISTS
*/
sql.length(0);
--- 1.31/mysql-test/r/backup.result 2007-04-12 09:06:41 +02:00
+++ 1.32/mysql-test/r/backup.result 2007-04-12 09:06:41 +02:00
@@ -57,8 +57,8 @@
UNLOCK TABLES;
BACKUP DATABASE db1,db2 TO 'test.ba';
Backup Summary
-This archive contains 2 databases
-and a total of 4 tables.
+Backed up 2 tables in database db1.
+Backed up 2 tables in database db2.
header = 1028 bytes
data = 2276 bytes
@@ -94,8 +94,8 @@
USE mysql;
RESTORE DATABASE FROM 'test.ba';
Restore Summary
-This archive restored 2 databases
-and a total of 4 tables.
+Restored 2 tables in database db1.
+Restored 2 tables in database db2.
header = 1028 bytes
data = 2276 bytes
| Thread |
|---|
| • bk commit into 5.1 tree (rafal:1.2510) | rsomla | 12 Apr |