List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:April 28 2009 8:13pm
Subject:bzr commit into mysql-5.1-bugteam branch (jimw:2876) Bug#27149
View as plain text  
#At file:///Users/jimw/my/mysql-5.1/ based on revid:jimw@stripped

 2876 Jim Winstead	2009-04-28
      Check for MEMORY, HEAP, and BLACKHOLE in mysql_convert_table_format when
      preventing a change that would result in table data loss. (Bug #27149)
      
      Also updated mysql_convert_table_format to use --engine as the documentation
      claimed, and use the engine terminology throughout instead of the obsolete
      'table type'.
      modified:
        scripts/mysql_convert_table_format.sh

=== modified file 'scripts/mysql_convert_table_format.sh'
--- a/scripts/mysql_convert_table_format.sh	2007-12-28 00:07:42 +0000
+++ b/scripts/mysql_convert_table_format.sh	2009-04-28 18:12:50 +0000
@@ -23,18 +23,18 @@ $opt_help=$opt_version=$opt_verbose=$opt
 $opt_user=$opt_database=$opt_password=undef;
 $opt_host="localhost";
 $opt_socket="";
-$opt_type="MYISAM";
+$opt_engine="MYISAM";
 $opt_port=0;
 $exit_status=0;
 
-GetOptions("force","help","host=s","password=s","user=s","type=s","verbose","version","socket=s", "port=i") || 
+GetOptions("force","help","host=s","password=s","user=s","engine|type=s","verbose","version","socket=s", "port=i") || 
   usage(0);
 usage($opt_version) if ($#ARGV < 0 || $opt_help || $opt_version);
 $opt_database=shift(@ARGV);
 
-if (uc($opt_type) eq "HEAP")
+if (grep { /^$opt_engine$/i } qw(HEAP MEMORY BLACKHOLE))
 {
-  print "Converting to type HEAP would delete your tables; aborting\n";
+  print "Converting to '$opt_engine' would delete your data; aborting\n";
   exit(1);
 }
 
@@ -76,14 +76,15 @@ foreach $table (@ARGV)
   $sth=$dbh->prepare("show table status like '$table'");  
   if ($sth->execute && ($row = $sth->fetchrow_arrayref))
   {
-    if (uc($row->[1]) eq uc($opt_type))
+    if (uc($row->[1]) eq uc($opt_engine))
     {
-      print "$table is already of type $opt_type;  Ignored\n";
+      print "$table already uses the '$opt_engine' engine;  Ignored\n";
       next;
     }
   }
   print "converting $table\n" if ($opt_verbose);
-  if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type"))
+  $table=~ s/`/``/g;
+  if (!$dbh->do("ALTER TABLE `$table` ENGINE=$opt_engine"))
   {
     print STDERR "Can't convert $table: Error $DBI::errstr\n";
     exit(1) if (!$opt_force);
@@ -103,7 +104,7 @@ sub usage
 
   print <<EOF;
 
-Conversion of a MySQL tables to other table types.
+Conversion of a MySQL tables to other storage engines
 
  Usage: $0 database [tables]
  If no tables has been specifed, all tables in the database will be converted.
@@ -113,9 +114,12 @@ Conversion of a MySQL tables to other ta
 --force
   Continue even if there is some error.
 
---help or --Information
+--help
   Shows this help
 
+--engine='engine'
+  Converts tables to the given storage engine (Default: $opt_engine)
+
 --host='host name' (Default $opt_host)
   Host name where the database server is located.
 
@@ -128,10 +132,6 @@ Conversion of a MySQL tables to other ta
 --socket='/path/to/socket'
   Socket to connect with.
 
---ENGINE='table-type'
-  Converts tables to the given table type (Default: $opt_type)
-  MySQL 3.23 supports at least the BDB, ISAM and MYISAM types.
-
 --user='user_name'
   User name to log into the SQL server.
 

Thread
bzr commit into mysql-5.1-bugteam branch (jimw:2876) Bug#27149Jim Winstead28 Apr