List:Commits« Previous MessageNext Message »
From:Greg Lehey Date:August 1 2006 7:10am
Subject:bk commit into 5.0 tree (grog:1.2212) BUG#13926
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of grog. When grog 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, 2006-08-01 14:40:32+09:30, grog@stripped +3 -0
  BUG#13926  mysqldump --order-by-primary fails if PK column needs quoting
  
  Fix by quoting columns.

  client/mysqldump.c@stripped, 2006-08-01 14:36:04+09:30, grog@stripped +52 -50
    Post-review tidy-up:
    Correct style.

  mysql-test/r/mysqldump.result@stripped, 2006-08-01 14:36:41+09:30, grog@stripped +1
-0
    Post-review tidy-up:
    Move 'use' command to correct test.
    Terminate with 'end of tests'.

  mysql-test/t/mysqldump.test@stripped, 2006-08-01 14:31:15+09:30, grog@stripped +2 -1

# 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:	grog
# Host:	eucla.lemis.com
# Root:	/MySQL/5.0-Bug-13926

--- 1.231/client/mysqldump.c	2006-08-01 14:40:40 +09:30
+++ 1.232/client/mysqldump.c	2006-08-01 14:40:40 +09:30
@@ -617,13 +617,13 @@
       tty_password=1;
     break;
   case 'r':
-    if (!(md_result_file = my_fopen(argument, O_WRONLY | FILE_BINARY,
+    if (!(md_result_file= my_fopen(argument, O_WRONLY | FILE_BINARY,
                                     MYF(MY_WME))))
       exit(1);
     break;
   case 'W':
 #ifdef __WIN__
-    opt_protocol = MYSQL_PROTOCOL_PIPE;
+    opt_protocol= MYSQL_PROTOCOL_PIPE;
 #endif
     break;
   case 'N':
@@ -638,7 +638,7 @@
 #include <sslopt-case.h>
   case 'V': print_version(); exit(0);
   case 'X':
-    opt_xml = 1;
+    opt_xml= 1;
     extended_insert= opt_drop= opt_lock=
       opt_disable_keys= opt_autocommit= opt_create_db= 0;
     break;
@@ -1404,7 +1404,7 @@
   const char *insert_option;
   char       name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
   char       table_buff2[NAME_LEN*2+3], query_buff[512];
-  FILE       *sql_file = md_result_file;
+  FILE       *sql_file= md_result_file;
   int        len;
   MYSQL_RES  *result;
   MYSQL_ROW  row;
@@ -1451,7 +1451,7 @@
   opt_quoted_table= quote_name(table, table_buff2, 0);
 
   if (opt_order_by_primary)
-    order_by = primary_key_fields(result_table);
+    order_by= primary_key_fields(result_table);
 
   if (!opt_xml && !mysql_query_with_error_report(sock, 0, query_buff))
   {
@@ -1887,7 +1887,7 @@
   char       name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
   char       query_buff[512];
   uint old_opt_compatible_mode=opt_compatible_mode;
-  FILE       *sql_file = md_result_file;
+  FILE       *sql_file= md_result_file;
   MYSQL_RES  *result;
   MYSQL_ROW  row;
 
@@ -2138,15 +2138,15 @@
     end= strmov(end,buff);
     if (where || order_by)
     {
-      query = alloc_query_str((ulong) ((end - query) + 1 +
+      query= alloc_query_str((ulong) ((end - query) + 1 +
                              (where ? strlen(where) + 7 : 0) +
                              (order_by ? strlen(order_by) + 10 : 0)));
-      end = strmov(query, query_buf);
+      end= strmov(query, query_buf);
 
       if (where)
-        end = strxmov(end, " WHERE ", where, NullS);
+        end= strxmov(end, " WHERE ", where, NullS);
       if (order_by)
-        end = strxmov(end, " ORDER BY ", order_by, NullS);
+        end= strxmov(end, " ORDER BY ", order_by, NullS);
     }
     if (mysql_real_query(sock, query, (uint) (end - query)))
     {
@@ -2167,10 +2167,10 @@
                 result_table);
     if (where || order_by)
     {
-      query = alloc_query_str((ulong) (strlen(query) + 1 +
+      query= alloc_query_str((ulong) (strlen(query) + 1 +
                              (where ? strlen(where) + 7 : 0) +
                              (order_by ? strlen(order_by) + 10 : 0)));
-      end = strmov(query, query_buf);
+      end= strmov(query, query_buf);
 
       if (where)
       {
@@ -2179,7 +2179,7 @@
           fprintf(md_result_file, "-- WHERE:  %s\n", where);
           check_io(md_result_file);
         }
-        end = strxmov(end, " WHERE ", where, NullS);
+        end= strxmov(end, " WHERE ", where, NullS);
       }
       if (order_by)
       {
@@ -2188,7 +2188,7 @@
           fprintf(md_result_file, "-- ORDER BY:  %s\n", order_by);
           check_io(md_result_file);
         }
-        end = strxmov(end, " ORDER BY ", order_by, NullS);
+        end= strxmov(end, " ORDER BY ", order_by, NullS);
       }
     }
     if (!opt_xml && !opt_compact)
@@ -2260,12 +2260,12 @@
         check_io(md_result_file);
       }
 
-      for (i = 0; i < mysql_num_fields(res); i++)
+      for (i= 0; i < mysql_num_fields(res); i++)
       {
         int is_blob;
         ulong length= lengths[i];
 
-        if (!(field = mysql_fetch_field(res)))
+        if (!(field= mysql_fetch_field(res)))
         {
           my_snprintf(query, QUERY_LENGTH,
                       "%s: Not enough fields from table %s! Aborting.\n",
@@ -2337,7 +2337,7 @@
               else
               {
                 /* change any strings ("inf", "-inf", "nan") into NULL */
-                char *ptr = row[i];
+                char *ptr= row[i];
                 if (my_isalpha(charset_info, *ptr) || (*ptr == '-' &&
                     my_isalpha(charset_info, ptr[1])))
                   dynstr_append(&extended_row, "NULL");
@@ -2397,7 +2397,7 @@
             else
             {
               /* change any strings ("inf", "-inf", "nan") into NULL */
-              char *ptr = row[i];
+              char *ptr= row[i];
               if (opt_xml)
               {
                 print_xml_tag1(md_result_file, "\t\t", "field name=",
@@ -2443,10 +2443,10 @@
       {
         ulong row_length;
         dynstr_append(&extended_row,")");
-        row_length = 2 + extended_row.length;
+        row_length= 2 + extended_row.length;
         if (total_length + row_length < opt_net_buffer_length)
         {
-          total_length += row_length;
+          total_length+= row_length;
           fputc(',',md_result_file);            /* Always row break */
           fputs(extended_row.str,md_result_file);
         }
@@ -2458,7 +2458,7 @@
 
           fputs(insert_pat.str,md_result_file);
           fputs(extended_row.str,md_result_file);
-          total_length = row_length+init_length;
+          total_length= row_length+init_length;
         }
         check_io(md_result_file);
       }
@@ -2521,15 +2521,15 @@
 
 static char *getTableName(int reset)
 {
-  static MYSQL_RES *res = NULL;
+  static MYSQL_RES *res= NULL;
   MYSQL_ROW    row;
 
   if (!res)
   {
-    if (!(res = mysql_list_tables(sock,NullS)))
+    if (!(res= mysql_list_tables(sock,NullS)))
       return(NULL);
   }
-  if ((row = mysql_fetch_row(res)))
+  if ((row= mysql_fetch_row(res)))
     return((char*) row[0]);
 
   if (reset)
@@ -2537,7 +2537,7 @@
   else
   {
     mysql_free_result(res);
-    res = NULL;
+    res= NULL;
   }
   return(NULL);
 } /* getTableName */
@@ -2551,7 +2551,7 @@
 
   if (mysql_query_with_error_report(sock, &tableres, "SHOW DATABASES"))
     return 1;
-  while ((row = mysql_fetch_row(tableres)))
+  while ((row= mysql_fetch_row(tableres)))
   {
     if (dump_all_tables_in_db(row[0]))
       result=1;
@@ -2559,13 +2559,13 @@
   if (seen_views)
   {
     if (mysql_query(sock, "SHOW DATABASES") ||
-        !(tableres = mysql_store_result(sock)))
+        !(tableres= mysql_store_result(sock)))
     {
       my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s",
                       MYF(0), mysql_error(sock));
       return 1;
     }
-    while ((row = mysql_fetch_row(tableres)))
+    while ((row= mysql_fetch_row(tableres)))
     {
       if (dump_all_views_in_db(row[0]))
         result=1;
@@ -2632,7 +2632,7 @@
                     "SHOW CREATE DATABASE IF NOT EXISTS %s",
                     qdatabase);
 
-        if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
+        if (mysql_query(sock, qbuf) || !(dbinfo= mysql_store_result(sock)))
         {
           /* Old server version, dump generic CREATE DATABASE */
           if (opt_drop_database)
@@ -2649,7 +2649,7 @@
             fprintf(md_result_file,
                     "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
                     qdatabase);
-          row = mysql_fetch_row(dbinfo);
+          row= mysql_fetch_row(dbinfo);
           if (row[1])
           {
             fprintf(md_result_file,"\n%s;\n",row[1]);
@@ -2952,7 +2952,7 @@
   }
   else
   {
-    row = mysql_fetch_row(master);
+    row= mysql_fetch_row(master);
     if (row && row[0] && row[1])
     {
       /* SHOW MASTER STATUS reports file and position */
@@ -3079,7 +3079,7 @@
   MYSQL_FIELD   *field;
   mysql_field_seek(result, 0);
 
-  for ( ; (field = mysql_fetch_field(result)) ; row++)
+  for ( ; (field= mysql_fetch_field(result)) ; row++)
   {
     if (!strcmp(field->name,name))
     {
@@ -3208,19 +3208,19 @@
 
 static char *primary_key_fields(const char *table_name)
 {
-  MYSQL_RES  *res = NULL;
+  MYSQL_RES  *res= NULL;
   MYSQL_ROW  row;
   /* SHOW KEYS FROM + table name * 2 (escaped) + 2 quotes + \0 */
   char show_keys_buff[15 + 64 * 2 + 3];
-  uint result_length = 0;
-  char *result = 0;
-  char buff[NAME_LEN*2+3];
+  uint result_length= 0;
+  char *result= 0;
+  char buff[NAME_LEN * 2 + 3];
   char *quoted_field;
 
   my_snprintf(show_keys_buff, sizeof(show_keys_buff),
               "SHOW KEYS FROM %s", table_name);
   if (mysql_query(sock, show_keys_buff) ||
-      !(res = mysql_store_result(sock)))
+      !(res= mysql_store_result(sock)))
   {
     fprintf(stderr, "Warning: Couldn't read keys from table %s;"
             " records are NOT sorted (%s)\n",
@@ -3235,13 +3235,14 @@
    * row, and UNIQUE keys come before others.  So we only need to check
    * the first key, not all keys.
    */
-  if ((row = mysql_fetch_row(res)) && atoi(row[1]) == 0)
+  if ((row= mysql_fetch_row(res)) && atoi(row[1]) == 0)
   {
     /* Key is unique */
-    do {
-      quoted_field = quote_name(row[4], buff, 0);
-      result_length += strlen(quoted_field) + 1;      /* + 1 for ',' or \0 */
-    } while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1);
+    do
+    {
+      quoted_field= quote_name(row[4], buff, 0);
+      result_length+= strlen(quoted_field) + 1; /* + 1 for ',' or \0 */
+    } while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1);
   }
 
   /* Build the ORDER BY clause result */
@@ -3249,19 +3250,20 @@
   {
     char *end;
     /* result (terminating \0 is already in result_length) */
-    result = my_malloc(result_length + 10, MYF(MY_WME));
+    result= my_malloc(result_length + 10, MYF(MY_WME));
     if (!result)
     {
       fprintf(stderr, "Error: Not enough memory to store ORDER BY clause\n");
       goto cleanup;
     }
     mysql_data_seek(res, 0);
-    row = mysql_fetch_row(res);
-    quoted_field = quote_name(row[4], buff, 0);
-    end = strmov(result, quoted_field);
-    while ((row = mysql_fetch_row(res)) && atoi(row[3]) > 1) {
-      quoted_field = quote_name(row[4], buff, 0);
-      end = strxmov(end, ",", quoted_field, NullS);
+    row= mysql_fetch_row(res);
+    quoted_field= quote_name(row[4], buff, 0);
+    end= strmov(result, quoted_field);
+    while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1)
+    {
+      quoted_field= quote_name(row[4], buff, 0);
+      end= strxmov(end, ",", quoted_field, NullS);
     }
   }
 
@@ -3330,7 +3332,7 @@
   char       table_buff[NAME_LEN*2+3];
   char       table_buff2[NAME_LEN*2+3];
   char       query[QUERY_LENGTH];
-  FILE       *sql_file = md_result_file;
+  FILE       *sql_file= md_result_file;
   DBUG_ENTER("get_view_structure");
 
   if (tFlag) /* Don't write table creation info */

--- 1.99/mysql-test/r/mysqldump.result	2006-08-01 14:40:40 +09:30
+++ 1.100/mysql-test/r/mysqldump.result	2006-08-01 14:40:40 +09:30
@@ -2888,3 +2888,4 @@
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
 DROP TABLE `t1`;
+End of 5.0 tests

--- 1.91/mysql-test/t/mysqldump.test	2006-08-01 14:40:40 +09:30
+++ 1.92/mysql-test/t/mysqldump.test	2006-08-01 14:40:40 +09:30
@@ -1178,12 +1178,12 @@
 drop view v1;
 drop table t1;
 drop database mysqldump_test_db;
+USE test;
 
 #
 # BUG#13926: --order-by-primary fails if PKEY contains quote character
 #
 --disable_warnings
-USE test;
 DROP TABLE IF EXISTS `t1`;
 CREATE TABLE `t1` (
   `a b` INT,
@@ -1197,3 +1197,4 @@
 --exec $MYSQL_DUMP --skip-comments --order-by-primary test t1
 DROP TABLE `t1`;
 --enable_warnings
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (grog:1.2212) BUG#13926Greg Lehey1 Aug