MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:May 30 2006 12:49pm
Subject:bk commit into 5.0 tree (tnurnberg:1.2128) BUG#17371
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg 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.2128 06/05/30 14:49:05 tnurnberg@stripped +3 -0
  Bug#17371: Unable to dump a schema with invalid views
  
  'show create' works even on views that are short of a base-table (this
  throw a warning though, like you would expect). Unfortunately, this is
  not what mysqldump uses; it creates stand-in tables and hence requests
  'show fields' on the view which fails with missing base-tables.  The
  --force option prevents the dump from stopping at this point; furthermore
  this patch dumps a comment showing create for the offending view for
  better diagnostics. This solution was confirmed by submitter as solving
  their/clients' problem. Problem might become non-issue once mysqldump no
  longer creates stand-in tables.

  mysql-test/t/mysqldump.test
    1.86 06/05/30 14:48:59 tnurnberg@stripped +13 -0
    add test for #17371 - be defensive. if we can't do a full dump on a view
    (incl. 'show fields' for a stand-in table), at least create a comment with
    the 'show create' info when --force is given.

  mysql-test/r/mysqldump.result
    1.94 06/05/30 14:48:59 tnurnberg@stripped +9 -0
    add test for #17371 - be defensive. if we can't do a full dump on a view
    (incl. 'show fields' for a stand-in table), at least create a comment with
    the 'show create' info when --force is given.

  client/mysqldump.c
    1.227 06/05/30 14:48:59 tnurnberg@stripped +20 -1
    Dump a comment showing create for a view if we can't show fields for it for
    better diagnostics.

# 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:	tnurnberg
# Host:	salvation.intern.azundris.com
# Root:	/home/mysql-5.0-maint-17371

--- 1.226/client/mysqldump.c	2006-04-18 17:58:22 +02:00
+++ 1.227/client/mysqldump.c	2006-05-30 14:48:59 +02:00
@@ -1494,9 +1494,15 @@
       field= mysql_fetch_field_direct(result, 0);
       if (strcmp(field->name, "View") == 0)
       {
+        char *scv_buff = NULL;
+
         if (verbose)
           fprintf(stderr, "-- It's a view, create dummy table for view\n");
 
+        /* save "show create" statement for later */
+        if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))
+          scv_buff= my_strdup(scv_buff, MYF(0));
+
         mysql_free_result(result);
 
         /*
@@ -1514,9 +1520,22 @@
                     "SHOW FIELDS FROM %s", result_table);
         if (mysql_query_with_error_report(sock, 0, query_buff))
         {
+          /*
+            View references invalid or privileged table/col/fun (err 1356),
+            so we cannot create a stand-in table.  Be defensive and dump
+            a comment with the view's 'show create' statement. (Bug #17371)
+          */
+
+          if (mysql_errno(sock) == ER_VIEW_INVALID)
+            fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : "");
+
+          my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
+
           safe_exit(EX_MYSQLERR);
-          DBUG_RETURN(0);
+          DBUG_RETURN(0); 
         }
+        else
+          my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR));
 
         if ((result= mysql_store_result(sock)))
         {

--- 1.93/mysql-test/r/mysqldump.result	2006-05-04 17:35:52 +02:00
+++ 1.94/mysql-test/r/mysqldump.result	2006-05-30 14:48:59 +02:00
@@ -2731,3 +2731,12 @@
 select 42
 drop function f;
 drop procedure p;
+create table t1 ( id serial );
+create view v1 as select * from t1;
+drop table t1;
+mysqldump {
+
+-- failed on view `v1`: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1`
+
+} mysqldump
+drop view v1;

--- 1.85/mysql-test/t/mysqldump.test	2006-05-04 17:35:52 +02:00
+++ 1.86/mysql-test/t/mysqldump.test	2006-05-30 14:48:59 +02:00
@@ -1143,3 +1143,16 @@
 drop function f;
 drop procedure p;
 
+#
+# Bug #17371 Unable to dump a schema with invalid views
+#
+#
+create table t1 ( id serial );
+create view v1 as select * from t1;
+drop table t1;
+# mysqldump gets 1356 from server, but gives us 2
+--echo mysqldump {
+--error 2
+--exec $MYSQL_DUMP --force -N --compact --skip-comments test
+--echo } mysqldump
+drop view v1;
Thread
bk commit into 5.0 tree (tnurnberg:1.2128) BUG#17371Tatjana A Nuernberg30 May