Commit 4b0ab1e0 authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg
Browse files

Bug#31434 mysqldump dumps view as table

mysqldump creates stand-in tables before dumping the actual view.
Those tables were of the default type; if the view had more columns
than that (a pathological case, arguably), loading the dump would
fail. We now make the temporary stand-ins MyISAM tables to prevent
this.
parents 969ea5ed 743149bc
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2396,8 +2396,15 @@ static uint get_table_structure(char *table, char *db, char *table_type,
            fprintf(sql_file, ",\n  %s %s",
                    quote_name(row[0], name_buff, 0), row[1]);
          }

          /*
            Stand-in tables are always MyISAM tables as the default
            engine might have a column-limit that's lower than the
            number of columns in the view, and MyISAM support is
            guaranteed to be in the server anyway.
          */
          fprintf(sql_file,
                  "\n) */;\n"
                  "\n) ENGINE=MyISAM */;\n"
                  "SET character_set_client = @saved_cs_client;\n");

          check_io(sql_file);
+13 −0
Original line number Diff line number Diff line
@@ -277,3 +277,16 @@ drop table t3;
drop table t4;
drop table t5;
drop table t6;
SELECT @@global.storage_engine INTO @old_engine;
SET GLOBAL storage_engine=InnoDB;
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES();
SELECT COUNT(*) FROM v1;
COUNT(*)
1
SELECT COUNT(*) FROM v1;
COUNT(*)
1
DROP VIEW  v1;
DROP TABLE t1;
SET GLOBAL storage_engine=@old_engine;
+12 −12
Original line number Diff line number Diff line
@@ -1999,7 +1999,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
  `a` varchar(30)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2096,7 +2096,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
  `a` int(11)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -2170,7 +2170,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
  `a` varchar(30)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2286,7 +2286,7 @@ SET character_set_client = utf8;
  `a` int(11),
  `b` int(11),
  `c` varchar(30)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2294,7 +2294,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v2` (
  `a` int(11)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
@@ -2304,7 +2304,7 @@ SET character_set_client = utf8;
  `a` int(11),
  `b` int(11),
  `c` varchar(30)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -3041,7 +3041,7 @@ SET character_set_client = utf8;
  `a` int(11),
  `b` varchar(32),
  `c` varchar(32)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -3051,7 +3051,7 @@ SET character_set_client = utf8;
  `a` int(11),
  `b` varchar(32),
  `c` varchar(32)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -3061,7 +3061,7 @@ SET character_set_client = utf8;
  `a` int(11),
  `b` varchar(32),
  `c` varchar(32)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

USE `test`;
@@ -3441,7 +3441,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
  `id` int(11)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

USE `mysqldump_test_db`;
@@ -3501,7 +3501,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `nasishnasifu` (
  `id` bigint(20) unsigned
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

USE `mysqldump_tables`;
@@ -3959,7 +3959,7 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `v1` (
  `id` int(11)
) */;
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

USE `mysqldump_test_db`;
+1058 −0

File changed.

Preview size limit exceeded, changes collapsed.