MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Ignacio Galarza Date:August 28 2006 4:41pm
Subject:bk commit into 5.0 tree (iggy:1.2254) BUG#21527
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of iggy. When iggy 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-28 12:41:02-04:00, iggy@stripped +3 -0
  Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the information_schema database.
      
  init_dumping now accepts a function pointer to the table or view specific init_dumping function.  This allows both tables and views to use the init_dumping function.

  client/mysqldump.c@stripped, 2006-08-28 12:40:59-04:00, iggy@stripped +80 -54
    Added functions for table and view specific dumping initalization.

  mysql-test/r/mysqldump.result@stripped, 2006-08-28 12:41:00-04:00, iggy@stripped +14 -0
    Added Result.

  mysql-test/t/mysqldump.test@stripped, 2006-08-28 12:41:00-04:00, iggy@stripped +30 -0
    Added test case.

# 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:	iggy
# Host:	rolltop.ignatz42.dyndns.org
# Root:	/mnt/storeage/mysql-5.0-maint_21527

--- 1.237/client/mysqldump.c	2006-08-28 12:41:06 -04:00
+++ 1.238/client/mysqldump.c	2006-08-28 12:41:07 -04:00
@@ -417,7 +417,9 @@
                         int string_value);
 static int dump_selected_tables(char *db, char **table_names, int tables);
 static int dump_all_tables_in_db(char *db);
-static int init_dumping(char *);
+static int init_dumping_views(char *);
+static int init_dumping_tables(char *);
+static int init_dumping(char *, int init_func(char*));
 static int dump_databases(char **);
 static int dump_all_databases();
 static char *quote_name(const char *name, char *buff, my_bool force);
@@ -2635,7 +2637,76 @@
 } /* dump_databases */
 
 
-static int init_dumping(char *database)
+/*
+View Specific database initalization.
+
+SYNOPSIS
+  init_dumping_views
+  qdatabase      quoted name of the database
+
+RETURN VALUES
+  0        Success.
+  1        Failure.
+*/
+int init_dumping_views(char *qdatabase)
+{
+    return 0;
+} /* init_dumping_views */
+
+
+/*
+Table Specific database initalization.
+
+SYNOPSIS
+  init_dumping_tables
+  qdatabase      quoted name of the database
+
+RETURN VALUES
+  0        Success.
+  1        Failure.
+*/
+int init_dumping_tables(char *qdatabase)
+{
+  if (!opt_create_db)
+  {
+    char qbuf[256];
+    MYSQL_ROW row;
+    MYSQL_RES *dbinfo;
+
+    my_snprintf(qbuf, sizeof(qbuf),
+                "SHOW CREATE DATABASE IF NOT EXISTS %s",
+                qdatabase);
+
+    if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql)))
+    {
+      /* Old server version, dump generic CREATE DATABASE */
+      if (opt_drop_database)
+        fprintf(md_result_file,
+                "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
+                qdatabase);
+      fprintf(md_result_file,
+              "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
+              qdatabase);
+    }
+    else
+    {
+      if (opt_drop_database)
+        fprintf(md_result_file,
+                "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
+                qdatabase);
+      row = mysql_fetch_row(dbinfo);
+      if (row[1])
+      {
+        fprintf(md_result_file,"\n%s;\n",row[1]);
+      }
+    }
+  }
+
+  return 0;
+} /* init_dumping_tables */
+
+
+static int init_dumping(char *database, int init_func(char*))
 {
   if (mysql_get_server_version(mysql) >= 50003 &&
       !my_strcasecmp(&my_charset_latin1, database, "information_schema"))
@@ -2660,40 +2731,10 @@
         fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
         check_io(md_result_file);
       }
-      if (!opt_create_db)
-      {
-        char qbuf[256];
-        MYSQL_ROW row;
-        MYSQL_RES *dbinfo;
-
-        my_snprintf(qbuf, sizeof(qbuf),
-                    "SHOW CREATE DATABASE IF NOT EXISTS %s",
-                    qdatabase);
-
-        if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql)))
-        {
-          /* Old server version, dump generic CREATE DATABASE */
-          if (opt_drop_database)
-            fprintf(md_result_file,
-                    "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
-                    qdatabase);
-          fprintf(md_result_file,
-                  "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
-                  qdatabase);
-        }
-        else
-        {
-          if (opt_drop_database)
-            fprintf(md_result_file,
-                    "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
-                    qdatabase);
-          row = mysql_fetch_row(dbinfo);
-          if (row[1])
-          {
-            fprintf(md_result_file,"\n%s;\n",row[1]);
-          }
-        }
-      }
+
+      /* Call the view or table specific function */
+      init_func(qdatabase);
+
       fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
       check_io(md_result_file);
     }
@@ -2725,7 +2766,7 @@
   afterdot= strmov(hash_key, database);
   *afterdot++= '.';
 
-  if (init_dumping(database))
+  if (init_dumping(database, &init_dumping_tables))
     return 1;
   if (opt_xml)
     print_xml_tag1(md_result_file, "", "database name=", database, "\n");
@@ -2797,23 +2838,8 @@
   uint numrows;
   char table_buff[NAME_LEN*2+3];
 
-  if (mysql_select_db(mysql, database))
-  {
-    DB_error(mysql, "when selecting the database");
+  if (init_dumping(database, &init_dumping_views))
     return 1;
-  }
-  if (opt_databases || opt_alldbs)
-  {
-    char quoted_database_buf[NAME_LEN*2+3];
-    char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
-    if (opt_comments)
-    {
-      fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", qdatabase);
-      check_io(md_result_file);
-    }
-    fprintf(md_result_file,"\nUSE %s;\n", qdatabase);
-    check_io(md_result_file);
-  }
   if (opt_xml)
     print_xml_tag1(md_result_file, "", "database name=", database, "\n");
   if (lock_tables)
@@ -2908,7 +2934,7 @@
   char **dump_tables, **pos, **end;
   DBUG_ENTER("dump_selected_tables");
 
-  if (init_dumping(db))
+  if (init_dumping(db, &init_dumping_tables))
     return 1;
 
   init_alloc_root(&root, 8192, 0);

--- 1.110/mysql-test/r/mysqldump.result	2006-08-28 12:41:07 -04:00
+++ 1.111/mysql-test/r/mysqldump.result	2006-08-28 12:41:07 -04:00
@@ -2892,3 +2892,17 @@
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 drop table t1;
 drop user mysqltest_1@localhost;
+create database mysqldump_myDB;
+use mysqldump_myDB;
+create user myDB_User;
+grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
+create table t1 (c1 int);
+insert into t1 values (3);
+use mysqldump_myDB;
+create view v1 (c1) as select * from t1;
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;

--- 1.100/mysql-test/t/mysqldump.test	2006-08-28 12:41:07 -04:00
+++ 1.101/mysql-test/t/mysqldump.test	2006-08-28 12:41:07 -04:00
@@ -1309,3 +1309,33 @@
 # Clean up
 drop table t1;
 drop user mysqltest_1@localhost;
+
+#
+# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the 
+# information_schema database.
+#
+connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+connection root;
+create database mysqldump_myDB;
+use mysqldump_myDB;
+create user myDB_User;
+grant create view, select on mysqldump_myDB.* to myDB_User@localhost;
+create table t1 (c1 int);
+insert into t1 values (3);
+
+connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
+connection user1;
+use mysqldump_myDB;
+create view v1 (c1) as select * from t1;
+
+# Backup should not fail.
+--exec $MYSQL_DUMP --all-databases --add-drop-table > $MYSQLTEST_VARDIR/tmp/bug21527.sql
+
+# Clean up
+connection root;
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;
Thread
bk commit into 5.0 tree (iggy:1.2254) BUG#21527Ignacio Galarza28 Aug