mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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. client/mysqldump.c: When creating a stand-in table, specify its type to avoid defaulting to a type with a column-number limit (like Inno). The type is always MyISAM as we know that to be available. mysql-test/r/mysqldump-max.result: add test results for 31434 mysql-test/r/mysqldump.result: mysqldump sets engine-type (MyISAM) for stand-in tables for views now. Update test results. mysql-test/t/mysqldump-max.test: Show that mysqldump's stand-in tables for views explicitly set engine-type to MyISAM to avoid falling back on an engine that might support fewer columns than the final view requires (here's lookin' at you, inno). Also show that this actually has the desired effect by dumping and reloading a view that has more columns than inno supports.
This commit is contained in:
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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`;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user