List:Commits« Previous MessageNext Message »
From:ramil Date:May 19 2006 11:21am
Subject:bk commit into 4.1 tree (ramil:1.2486) BUG#18536
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram 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
  1.2486 06/05/19 16:21:32 ramil@stripped +3 -0
  Fix for bug #18536: mysqldump does not maintain table orders as per --tables option

  mysql-test/t/mysqldump.test
    1.43 06/05/19 16:21:27 ramil@stripped +12 -1
    Fix for bug #18536: mysqldump does not maintain table orders as per --tables option
      - test case.

  mysql-test/r/mysqldump.result
    1.52 06/05/19 16:21:27 ramil@stripped +35 -1
    Fix for bug #18536: mysqldump does not maintain table orders as per --tables option
      - test result.

  client/mysqldump.c
    1.199 06/05/19 16:21:27 ramil@stripped +21 -33
    Fix for bug #18536: mysqldump does not maintain table orders as per --tables option
      - use list to store table names instead of hash.

# 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:	ramil
# Host:	myoffice.izhnet.ru
# Root:	/usr/home/ram/work/4.1.b18536

--- 1.198/client/mysqldump.c	2006-02-02 00:28:34 +04:00
+++ 1.199/client/mysqldump.c	2006-05-19 16:21:27 +05:00
@@ -2215,14 +2215,13 @@ static int dump_all_tables_in_db(char *d
   different case (e.g.  T1 vs t1)
   
   RETURN
-    int - 0 if a tablename was retrieved.  1 if not
+    pointer to the table name
+    0 if error
 */
 
-static int get_actual_table_name(const char *old_table_name, 
-                                  char *new_table_name, 
-                                  int buf_size)
+static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root)
 {
-  int retval;
+  char *name= 0;
   MYSQL_RES  *tableRes;
   MYSQL_ROW  row;
   char query[50 + 2*NAME_LEN];
@@ -2241,40 +2240,36 @@ static int get_actual_table_name(const c
   }
 
   tableRes= mysql_store_result( sock );
-  retval = 1;
   if (tableRes != NULL)
   {
     my_ulonglong numRows= mysql_num_rows(tableRes);
     if (numRows > 0)
     {
       row= mysql_fetch_row( tableRes );
-      strmake(new_table_name, row[0], buf_size-1);
-      retval= 0;
-      DBUG_PRINT("info", ("new_table_name: %s", new_table_name));
+      ulong *lengths= mysql_fetch_lengths(tableRes);
+      name= strmake_root(root, row[0], lengths[0]);
     }
     mysql_free_result(tableRes);
   }
-  DBUG_PRINT("exit", ("retval: %d", retval));
-  DBUG_RETURN(retval);
+  DBUG_PRINT("exit", ("new_table_name: %s", name));
+  DBUG_RETURN(name);
 }
 
 
 static int dump_selected_tables(char *db, char **table_names, int tables)
 {
-  uint numrows, i;
+  uint numrows;
   char table_buff[NAME_LEN*+3];
-  char new_table_name[NAME_LEN];
   DYNAMIC_STRING lock_tables_query;
-  HASH dump_tables;
+  MEM_ROOT root;
+  char **dump_tables, **pos;
   DBUG_ENTER("dump_selected_tables");
 
   if (init_dumping(db))
     return 1;
 
-  /* Init hash table for storing the actual name of tables to dump */
-  if (hash_init(&dump_tables, charset_info, 16, 0, 0,
-                (hash_get_key) get_table_key, (hash_free_key) free_table_ent,
-                0))
+  init_alloc_root(&root, 8192, 0);
+  if (!(dump_tables= pos= (char**) alloc_root(&root, tables * sizeof(char *))))
     exit(EX_EOM);
 
   init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024);
@@ -2282,22 +2277,16 @@ static int dump_selected_tables(char *db
   {
 
     /* the table name passed on commandline may be wrong case */
-    if (!get_actual_table_name(*table_names,
-                               new_table_name, sizeof(new_table_name) ))
+    if ((*pos= get_actual_table_name(*table_names, &root)))
     {
       /* Add found table name to lock_tables_query */
       if (lock_tables)
       {
         dynstr_append(&lock_tables_query,
-                      quote_name(new_table_name, table_buff, 1));
+                      quote_name(*pos, table_buff, 1));
         dynstr_append(&lock_tables_query, " READ /*!32311 LOCAL */,");
       }
-
-      /* Add found table name to dump_tables list */
-      if (my_hash_insert(&dump_tables,
-                         (byte*)my_strdup(new_table_name, MYF(0))))
-        exit(EX_EOM);
-
+      pos++;
     }
     else
     {
@@ -2326,15 +2315,14 @@ static int dump_selected_tables(char *db
     print_xml_tag1(md_result_file, "", "database name=", db, "\n");
 
   /* Dump each selected table */
-  for (i= 0 ; i < dump_tables.records ; i++)
+  for (; dump_tables < pos; dump_tables++)
   {
-    const char *table_name= hash_element(&dump_tables, i);
-    DBUG_PRINT("info",("Dumping table %s", table_name));
-    numrows= getTableStructure((char*) table_name, db);
+    DBUG_PRINT("info",("Dumping table %s", *dump_tables));
+    numrows= getTableStructure(*dump_tables, db);
     if (!dFlag && numrows > 0)
-      dumpTable(numrows, (char*) table_name);
+      dumpTable(numrows, *dump_tables);
   }
-  hash_free(&dump_tables);
+  free_root(&root, MYF(0));
   my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
   order_by= 0;
   if (opt_xml)

--- 1.51/mysql-test/r/mysqldump.result	2006-05-04 06:12:47 +05:00
+++ 1.52/mysql-test/r/mysqldump.result	2006-05-19 16:21:27 +05:00
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS t1, `"t"1`;
+DROP TABLE IF EXISTS t1, `"t"1`, t2, t3;
 CREATE TABLE t1(a int);
 INSERT INTO t1 VALUES (1), (2);
 <?xml version="1.0"?>
@@ -1540,4 +1540,38 @@ t1	CREATE TABLE `t1` (
   KEY `t1_name` (`t1_name`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
 drop table `t1`;
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t3`;
+CREATE TABLE `t3` (
+  `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+  `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS `t2`;
+CREATE TABLE `t2` (
+  `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+drop table t1, t2, t3;
 End of 4.1 tests

--- 1.42/mysql-test/t/mysqldump.test	2006-05-04 06:12:47 +05:00
+++ 1.43/mysql-test/t/mysqldump.test	2006-05-19 16:21:27 +05:00
@@ -2,7 +2,7 @@
 --source include/not_embedded.inc
 
 --disable_warnings
-DROP TABLE IF EXISTS t1, `"t"1`;
+DROP TABLE IF EXISTS t1, `"t"1`, t2, t3;
 --enable_warnings
 
 # XML output
@@ -676,5 +676,16 @@ select * from t1;
 show create table `t1`;
 
 drop table `t1`;
+
+#
+# Bug #18536: wrong table order
+#
+
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+--error 6
+--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
+drop table t1, t2, t3;
 
 --echo End of 4.1 tests
Thread
bk commit into 4.1 tree (ramil:1.2486) BUG#18536ramil19 May