List:Internals« Previous MessageNext Message »
From:msvensson Date:June 22 2005 1:33pm
Subject:bk commit into 5.0 tree (msvensson:1.1992)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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.1992 05/06/22 15:33:51 msvensson@neptunus.(none) +2 -0
  Merge

  mysql-test/t/mysqldump.test
    1.43 05/06/22 15:32:35 msvensson@neptunus.(none) +2 -17
    Auto merged

  client/mysqldump.c
    1.183 05/06/22 15:32:35 msvensson@neptunus.(none) +0 -0
    Auto merged

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/mysql-5.0/RESYNC

--- 1.182/client/mysqldump.c	2005-06-10 16:48:25 +02:00
+++ 1.183/client/mysqldump.c	2005-06-22 15:32:35 +02:00
@@ -57,6 +57,7 @@
 #define EX_CONSCHECK 3
 #define EX_EOM 4
 #define EX_EOF 5 /* ferror for output file was got */
+#define EX_ILLEGAL_TABLE 6
 
 /* index into 'show fields from table' */
 
@@ -142,14 +143,6 @@
 TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
 				  "", compatible_mode_names, NULL};
 
-#define TABLE_RULE_HASH_SIZE   16
-
-typedef struct st_table_rule_ent
-{
-  char* key;    /* dbname.tablename */
-  uint key_len;
-} TABLE_RULE_ENT;
-
 HASH ignore_table;
 
 static struct my_option my_long_options[] =
@@ -544,29 +537,21 @@
 } /* write_footer */
 
 
-static void free_table_ent(TABLE_RULE_ENT* e)
-{
-  my_free((gptr) e, MYF(0));
-}
-
-
-static byte* get_table_key(TABLE_RULE_ENT* e, uint* len,
-			   my_bool not_used __attribute__((unused)))
+byte* get_table_key(const char *entry, uint *length,
+				my_bool not_used __attribute__((unused)))
 {
-  *len= e->key_len;
-  return (byte*)e->key;
+  *length= strlen(entry);
+  return (byte*) entry;
 }
 
 
 void init_table_rule_hash(HASH* h)
 {
-  if(hash_init(h, charset_info, TABLE_RULE_HASH_SIZE, 0, 0,
-	       (hash_get_key) get_table_key,
-	       (hash_free_key) free_table_ent, 0))
+  if(hash_init(h, charset_info, 16, 0, 0,
+	       (hash_get_key) get_table_key, 0, 0))
     exit(EX_EOM);
 }
 
-
 static my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
 	       char *argument)
@@ -639,25 +624,15 @@
     break;
   case (int) OPT_IGNORE_TABLE:
   {
-    uint len= (uint)strlen(argument);
-    TABLE_RULE_ENT* e;
     if (!strchr(argument, '.'))
     {
       fprintf(stderr, "Illegal use of option --ignore-table=<database>.<table>\n");
       exit(1);
     }
-    /* len is always > 0 because we know the there exists a '.' */
-    e= (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT) + len, MYF(MY_WME));
-    if (!e)
-      exit(EX_EOM);
-    e->key= (char*)e + sizeof(TABLE_RULE_ENT);
-    e->key_len= len;
-    memcpy(e->key, argument, len);
-
     if (!hash_inited(&ignore_table))
       init_table_rule_hash(&ignore_table);
 
-    if(my_hash_insert(&ignore_table, (byte*)e))
+    if (my_hash_insert(&ignore_table, (byte*)my_strdup(argument, MYF(0))))
       exit(EX_EOM);
     break;
   }
@@ -980,7 +955,28 @@
   return buff;
 } /* quote_name */
 
+/*
+  Quote a table name so it can be used in "SHOW TABLES LIKE <tabname>"
 
+  SYNOPSIS
+    quote_for_like
+    name     - name of the table
+    buff     - quoted name of the table
+
+  DESCRIPTION
+    Quote \, _, ' and % characters
+
+    Note: Because MySQL uses the C escape syntax in strings
+    (for example, '\n' to represent newline), you must double
+    any '\' that you use in your LIKE  strings. For example, to
+    search for '\n', specify it as '\\n'. To search for '\', specify
+    it as '\\\\' (the backslashes are stripped once by the parser
+    and another time when the pattern match is done, leaving a
+    single backslash to be matched).
+
+    Example: "t\1" => "t\\\\1"
+
+*/
 
 static char *quote_for_like(const char *name, char *buff)
 {
@@ -988,7 +984,13 @@
   *to++= '\'';
   while (*name)
   {
-    if (*name == '\'' || *name == '_' || *name == '\\' || *name == '%')
+    if (*name == '\\')
+    {
+      *to++='\\';
+      *to++='\\';
+      *to++='\\';
+    }
+    else if (*name == '\'' || *name == '_'  || *name == '%')
       *to++= '\\';
     *to++= *name++;
   }
@@ -1139,6 +1141,7 @@
   FILE       *sql_file = md_result_file;
   int        len;
   DBUG_ENTER("get_table_structure");
+  DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
 
   if (!insert_pat_inited)
   {
@@ -2346,27 +2349,60 @@
 
 static int dump_selected_tables(char *db, char **table_names, int tables)
 {
-  uint numrows;
-  int i;
+  uint numrows, i;
   char table_buff[NAME_LEN*+3];
+  char new_table_name[NAME_LEN];
+  DYNAMIC_STRING lock_tables_query;
+  HASH dump_tables;
+
+  DBUG_ENTER("dump_selected_tables");
 
   if (init_dumping(db))
     return 1;
-  if (lock_tables)
+
+  /* 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, 0, 0))
+    exit(EX_EOM);
+
+  init_dynamic_string(&lock_tables_query, "LOCK TABLES ", 256, 1024);
+  for (; tables > 0 ; tables-- , table_names++)
   {
-    DYNAMIC_STRING query;
+    /* the table name passed on commandline may be wrong case */
+    if (!get_actual_table_name( *table_names,
+                                new_table_name, sizeof(new_table_name) ))
+    {
+      /* Add found table name to lock_tables_query */
+      if (lock_tables)
+      {
+        dynstr_append(&lock_tables_query,
+                      quote_name(new_table_name, table_buff, 1));
+        dynstr_append(&lock_tables_query, " READ /*!32311 LOCAL */,");
+      }
 
-    init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
-    for (i=0 ; i < tables ; i++)
+      /* 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);
+
+    }
+    else
     {
-      dynstr_append(&query, quote_name(table_names[i], table_buff, 1));
-      dynstr_append(&query, " READ /*!32311 LOCAL */,");
+       my_printf_error(0,"Couldn't find table: \"%s\"\n", MYF(0),
+                       *table_names);
+       safe_exit(EX_ILLEGAL_TABLE);
+       /* We shall countinue here, if --force was given */
     }
-    if (mysql_real_query(sock, query.str, query.length-1))
+  }
+
+  if (lock_tables)
+  {
+    if (mysql_real_query(sock, lock_tables_query.str,
+                         lock_tables_query.length-1))
       DB_error(sock, "when doing LOCK TABLES");
        /* We shall countinue here, if --force was given */
-    dynstr_free(&query);
   }
+  dynstr_free(&lock_tables_query);
   if (flush_logs)
   {
     if (mysql_refresh(sock, REFRESH_LOG))
@@ -2375,25 +2411,26 @@
   }
   if (opt_xml)
     print_xml_tag1(md_result_file, "", "database name=", db, "\n");
-  for (i=0 ; i < tables ; i++)
-  {
-    char new_table_name[NAME_LEN];
-
-    /* the table name passed on commandline may be wrong case */
-    if (!get_actual_table_name( table_names[i], new_table_name,
-                                sizeof(new_table_name)))
-    {
-      numrows= get_table_structure(new_table_name, db);
-      dump_table(numrows, new_table_name);
-    }
-    my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
-    order_by= 0;
+  /* Dump each selected table */
+  const char *table_name;
+  for (i= 0; i < dump_tables.records; i++)
+  {
+    table_name= hash_element(&dump_tables, i);
+    DBUG_PRINT("info",("Dumping table %s", table_name));
+    numrows = get_table_structure(table_name, db);
+    dump_table(numrows, table_name);
   }
   if (was_views)
   {
-    for (i=0 ; i < tables ; i++)
-      get_view_structure(table_names[i], db);
+    for(i=0; i < dump_tables.records; i++)
+    {
+      table_name= hash_element(&dump_tables, i);
+      get_view_structure(table_name, db);
+    }
   }
+  hash_free(&dump_tables);
+  my_free(order_by, MYF(MY_ALLOW_ZERO_PTR));
+  order_by= 0;
   if (opt_xml)
   {
     fputs("</database>\n", md_result_file);
@@ -2401,7 +2438,7 @@
   }
   if (lock_tables)
     mysql_query_with_error_report(sock, 0, "UNLOCK TABLES");
-  return 0;
+  DBUG_RETURN(0);
 } /* dump_selected_tables */
 
 

--- 1.42/mysql-test/t/mysqldump.test	2005-06-22 15:32:02 +02:00
+++ 1.43/mysql-test/t/mysqldump.test	2005-06-22 15:32:35 +02:00
@@ -600,6 +600,8 @@
 INSERT INTO t2 VALUES (1), (2);
 --exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db
 --exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db t1 t2
+--exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db
+--exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db t1 t2
 DROP TABLE t1, t2;
 DROP DATABASE mysqldump_test_db;
 
Thread
bk commit into 5.0 tree (msvensson:1.1992)msvensson22 Jun