MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Patrick Galbraith Date:September 4 2005 5:24pm
Subject:bk commit into 5.0 tree (patg:1.1952) BUG#7815
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of patg. When patg 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.1952 05/09/04 19:24:15 patg@stripped +3 -0
  BUG #7815 Re-enabled delayed inserts in mysqldump

  mysql-test/t/mysqldump.test
    1.56 05/09/04 19:23:29 patg@stripped +64 -0
    BUG #7815 Test delayed inserts in mysqldum

  mysql-test/r/mysqldump.result
    1.62 05/09/04 19:23:28 patg@stripped +122 -4
    BUG #7815 Added test to test results delayed inserts

  client/mysqldump.c
    1.196 05/09/04 19:23:28 patg@stripped +38 -33
    BUG #7815 Re-enabled delayed-insert, added boolean check_if_support_delayed

# 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:	patg
# Host:	radha.local
# Root:	/Users/patg/mysql-build/mysql-5.0.bug7815

--- 1.195/client/mysqldump.c	2005-08-26 14:45:19 +02:00
+++ 1.196/client/mysqldump.c	2005-09-04 19:23:28 +02:00
@@ -209,9 +209,7 @@
   {"default-character-set", OPT_DEFAULT_CHARSET,
    "Set the default character set.", (gptr*) &default_charset,
    (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; "
-   "currently ignored because of http://bugs.mysql.com/bug.php?id=7815 "
-   "but will be re-enabled later",
+  {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ",
    (gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
    0, 0},
   {"delete-master-logs", OPT_DELETE_MASTER_LOGS,
@@ -408,7 +406,8 @@
 static int dump_databases(char **);
 static int dump_all_databases();
 static char *quote_name(const char *name, char *buff, my_bool force);
-static const char *check_if_ignore_table(const char *table_name);
+static const char *check_if_ignore_table(const char *table_name,
+                                         bool check_if_supports_delayed);
 static char *primary_key_fields(const char *table_name);
 static my_bool get_view_structure(char *table, char* db);
 static my_bool dump_all_views_in_db(char *database);
@@ -717,25 +716,6 @@
       }
       break;
     }
-#ifndef REMOVE_THIS_CODE_WHEN_FIX_BUG_7815
-  case (int) OPT_DELAYED:
-    /*
-      Because of http://bugs.mysql.com/bug.php?id=7815, we disable
-      --delayed-insert; when the bug gets fixed by checking the storage engine
-      (using the table definition cache) before printing INSERT DELAYED, we
-      can correct the option's description and re-enable it again (scheduled
-      for later 5.0 or 5.1 versions).
-      It's ok to do the if() below as get_one_option is called after
-      opt_delayed is set.
-    */
-    if (opt_delayed)
-    {
-      fprintf(stderr, "Warning: ignoring --delayed-insert (as explained "
-	      "in the output of 'mysqldump --help').\n");
-      opt_delayed= 0;
-    }
-    break;
-#endif
   }
   return 0;
 }
@@ -1193,7 +1173,7 @@
   my_bool    init=0;
   uint       numFields;
   char	     *result_table, *opt_quoted_table;
-  const char *insert_option;
+  const char *insert_option, *table_type;
   char	     name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
   char	     table_buff2[NAME_LEN*2+3];
   char       query_buff[512];
@@ -1209,9 +1189,15 @@
   else
     dynstr_set(&insert_pat, "");
 
-  insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " : 
-                  opt_delayed ? " DELAYED " :
-                  opt_ignore ? " IGNORE " : "");
+  if (opt_delayed)
+  {
+    if ((table_type= check_if_ignore_table(table,1)))
+      insert_option= (opt_ignore) ? "IGNORE " : "";
+    else
+      insert_option= (opt_ignore) ? "DELAYED IGNORE " : "DELAYED ";
+  }
+  else
+    insert_option= (opt_ignore) ? "IGNORE " : "";
 
   if (verbose)
     fprintf(stderr, "-- Retrieving table structure for table %s...\n", table);
@@ -1760,8 +1746,8 @@
   result_table= quote_name(table,table_buff, 1);
   opt_quoted_table= quote_name(table, table_buff2, 0);
 
-  /* Check table type */
-  if ((table_type= check_if_ignore_table(table)))
+  /* Check table type , not checking if supports delayed (the 0) */
+  if ((table_type= check_if_ignore_table(table, 0)))
   {
     if (verbose)
       fprintf(stderr,
@@ -2763,6 +2749,8 @@
   SYNOPSIS
     check_if_ignore_table()
     table_name			Table name to check
+    check_if_supports_delayed   Boolean flag to toggle if we're checking if the
+                                type supports delayed inserts
 
   GLOBAL VARIABLES
     sock			MySQL socket
@@ -2773,7 +2761,8 @@
     #	Type of table (that should be skipped)
 */
 
-static const char *check_if_ignore_table(const char *table_name)
+static const char *check_if_ignore_table(const char *table_name,
+                                         bool check_if_supports_delayed)
 {
   char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
   MYSQL_RES *res;
@@ -2807,9 +2796,25 @@
       result= "VIEW";
   else
   {
-    if (strcmp(row[1], (result= "MRG_MyISAM")) &&
-        strcmp(row[1], (result= "MRG_ISAM")))
-      result= 0;
+    if (check_if_supports_delayed)
+    {
+      /*
+        if the table is any of these types, then it
+        supports INSERT DELAYED. I'm using an _inclusive_
+        list since it is shorter.
+      */
+      if (!strcmp(row[1], (result= "MyISAM")) ||
+          !strcmp(row[1], (result= "ISAM")) ||
+          !strcmp(row[1], (result= "ARCHIVE")) ||
+          !strcmp(row[1], (result= "MEMORY")))
+        result= 0;
+    }
+    else
+    {
+      if (strcmp(row[1], (result= "MRG_MyISAM")) &&
+          strcmp(row[1], (result= "MRG_ISAM")))
+        result= 0;
+    }
   }
   mysql_free_result(res);
   return result;

--- 1.61/mysql-test/r/mysqldump.result	2005-07-30 08:24:47 +02:00
+++ 1.62/mysql-test/r/mysqldump.result	2005-09-04 19:23:28 +02:00
@@ -584,7 +584,7 @@
 
 /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
 LOCK TABLES `t1` WRITE;
-INSERT  IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
+INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
 UNLOCK TABLES;
 /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
 
@@ -612,9 +612,7 @@
 
 
 /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
-LOCK TABLES `t1` WRITE;
-INSERT  IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
-UNLOCK TABLES;
+INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
 /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
 
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1875,3 +1873,123 @@
 end if;
 end	BEFORE	#	STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
 DROP TABLE t1, t2;
+create table mytable (id int(8), name varchar(32));
+create table memtable (id int(8), name varchar(32)) ENGINE="MEMORY";
+create table archtable (id int(8), name varchar(32)) ENGINE="ARCHIVE";
+create table innotable (id int(8), name varchar(32)) ENGINE="InnoDB";
+insert into mytable values (1, 'first value');
+insert into mytable values (2, 'first value');
+insert into mytable values (3, 'first value');
+insert into mytable values (4, 'first value');
+insert into mytable values (5, 'first value');
+insert into memtable values (1, 'first value');
+insert into memtable values (2, 'first value');
+insert into memtable values (3, 'first value');
+insert into memtable values (4, 'first value');
+insert into memtable values (5, 'first value');
+insert into archtable values (1, 'first value');
+insert into archtable values (2, 'first value');
+insert into archtable values (3, 'first value');
+insert into archtable values (4, 'first value');
+insert into archtable values (5, 'first value');
+insert into innotable values (1, 'first value');
+insert into innotable values (2, 'first value');
+insert into innotable values (3, 'first value');
+insert into innotable values (4, 'first value');
+insert into innotable values (5, 'first value');
+select * from mytable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from memtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from archtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from innotable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;
+select * from mytable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from memtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from archtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from innotable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;
+select * from mytable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from memtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from archtable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+select * from innotable;
+id	name
+1	first value
+2	first value
+3	first value
+4	first value
+5	first value
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;

--- 1.55/mysql-test/t/mysqldump.test	2005-07-29 22:40:00 +02:00
+++ 1.56/mysql-test/t/mysqldump.test	2005-09-04 19:23:29 +02:00
@@ -762,3 +762,67 @@
 --replace_column 6 #
 show triggers;
 DROP TABLE t1, t2;
+
+create table mytable (id int(8), name varchar(32));
+create table memtable (id int(8), name varchar(32)) ENGINE="MEMORY";
+create table archtable (id int(8), name varchar(32)) ENGINE="ARCHIVE";
+create table innotable (id int(8), name varchar(32)) ENGINE="InnoDB";
+
+insert into mytable values (1, 'first value');
+insert into mytable values (2, 'first value');
+insert into mytable values (3, 'first value');
+insert into mytable values (4, 'first value');
+insert into mytable values (5, 'first value');
+
+insert into memtable values (1, 'first value');
+insert into memtable values (2, 'first value');
+insert into memtable values (3, 'first value');
+insert into memtable values (4, 'first value');
+insert into memtable values (5, 'first value');
+
+insert into archtable values (1, 'first value');
+insert into archtable values (2, 'first value');
+insert into archtable values (3, 'first value');
+insert into archtable values (4, 'first value');
+insert into archtable values (5, 'first value');
+
+insert into innotable values (1, 'first value');
+insert into innotable values (2, 'first value');
+insert into innotable values (3, 'first value');
+insert into innotable values (4, 'first value');
+insert into innotable values (5, 'first value');
+
+select * from mytable;
+select * from memtable;
+select * from archtable;
+select * from innotable;
+
+--exec $MYSQL_DUMP --skip-comments --delayed-insert --insert-ignore --databases test > var/tmp/ignore_insert_dump.sql
+--exec $MYSQL_DUMP --skip-comments --delayed-insert --databases test > var/tmp/delayed_insert_dump.sql
+
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;
+
+--exec $MYSQL test < var/tmp/ignore_insert_dump.sql
+select * from mytable;
+select * from memtable;
+select * from archtable;
+select * from innotable;
+
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;
+
+--exec $MYSQL test < var/tmp/delayed_insert_dump.sql
+select * from mytable;
+select * from memtable;
+select * from archtable;
+select * from innotable;
+
+drop table mytable;
+drop table archtable;
+drop table memtable;
+drop table innotable;
Thread
bk commit into 5.0 tree (patg:1.1952) BUG#7815Patrick Galbraith4 Sep