Commit cecdc15a authored by unknown's avatar unknown

This cset fixes BUG# 12838, 14061, 12129

mysqldump.result:
  BUG# 12838
      New test results for mysqldump -x on a DB with views
mysqldump.test:
  sqldump.test:
      BUG# 12838
      New test to run mysqldump -x on a DB with views
mysqldump.c:
  BUG# 12838
      Removed/Changed code which created tables to be put into the dump
      (For loading views of views) by creating temp tables and then using
      the CREATE TABLE information in those temp tables. The problem with this
      is that when mysqldump -x is called, it locks all tables, so the
      temp tables could not be created, causing the mysqldump to exit with
      failure. The code was changed to use SHOW FIELDS to get the column
      names and type to build CREATE TABLE text used to create these tables
      that views need in the dump.


client/mysqldump.c:
  BUG# 12838
      Removed/Changed code which created tables to be put into the dump
      (For loading views of views) by creating temp tables and then using
      the CREATE TABLE information in those temp tables. The problem with this
      is that when mysqldump -x is called, it locks all tables, so the
      temp tables could not be created, causing the mysqldump to exit with
      failure. The code was changed to use SHOW FIELDS to get the column
      names and type to build CREATE TABLE text used to create these tables
      that views need in the dump.
mysql-test/t/mysqldump.test:
  sqldump.test:
      BUG# 12838
      New test to run mysqldump -x on a DB with views
mysql-test/r/mysqldump.result:
  BUG# 12838
      New test results for mysqldump -x on a DB with views
parent bd3ec22f
This diff is collapsed.
......@@ -1459,8 +1459,8 @@ UNLOCK TABLES;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` varchar(30)
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
......@@ -1702,8 +1702,8 @@ UNLOCK TABLES;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` int(11)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1`*/;
......@@ -1757,8 +1757,8 @@ UNLOCK TABLES;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` varchar(30)
) */;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') WITH CASCADED CHECK OPTION*/;
......@@ -1846,22 +1846,22 @@ UNLOCK TABLES;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11) default NULL,
`b` int(11) default NULL,
`c` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` int(11),
`b` int(11),
`c` varchar(30)
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` int(11)
) */;
DROP TABLE IF EXISTS `v3`;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 CREATE TABLE `v3` (
`a` int(11) default NULL,
`b` int(11) default NULL,
`c` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1*/;
`a` int(11),
`b` int(11),
`c` varchar(30)
) */;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `v3`.`a` AS `a`,`v3`.`b` AS `b`,`v3`.`c` AS `c` from `v3` where (`v3`.`b` in (1,2,3,4,5,6,7))*/;
......@@ -2374,3 +2374,92 @@ UNLOCK TABLES;
DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
drop table if exists t1;
create table t1 (a int, b varchar(32), c varchar(32));
insert into t1 values (1, 'first value', 'xxxx');
insert into t1 values (2, 'second value', 'tttt');
insert into t1 values (3, 'third value', 'vvv vvv');
create view v1 as select * from t1;
create view v0 as select * from v1;
create view v2 as select * from v0;
select * from v2;
a b c
1 first value xxxx
2 second value tttt
3 third value vvv vvv
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL,
`b` varchar(32) default NULL,
`c` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,'first value','xxxx'),(2,'second value','tttt'),(3,'third value','vvv vvv');
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
`a` int(11),
`b` varchar(32),
`c` varchar(32)
) */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v0` AS select `v1`.`a` AS `a`,`v1`.`b` AS `b`,`v1`.`c` AS `c` from `v1`*/;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b`,`t1`.`c` AS `c` from `t1`*/;
/*!50001 DROP TABLE IF EXISTS `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v0`.`a` AS `a`,`v0`.`b` AS `b`,`v0`.`c` AS `c` from `v0`*/;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop view v2;
drop view v0;
drop view v1;
drop table t1;
......@@ -962,3 +962,26 @@ DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
--enable_warnings
#
# BUG# 12838 mysqldump -x with views exits with error
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (a int, b varchar(32), c varchar(32));
insert into t1 values (1, 'first value', 'xxxx');
insert into t1 values (2, 'second value', 'tttt');
insert into t1 values (3, 'third value', 'vvv vvv');
create view v1 as select * from t1;
create view v0 as select * from v1;
create view v2 as select * from v0;
select * from v2;
--exec $MYSQL_DUMP -x --skip-comments --databases test
drop view v2;
drop view v0;
drop view v1;
drop table t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment