mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
Fixed BUG #14554: mysqldump does not separate "ROW" and trigger
statement for tables created in the IGNORE_SPACE sql mode. client/mysqldump.c: Modified dump_triggers_for_table(): if trigger statement returned by SHOW TRIGGERS query does not contain a leading white space, additional space is inserted between "ROW" and the statement. The leading white spaces are removed by yylex() in the IGNORE_SPACE sql mode. mysql-test/r/mysqldump.result: Fixed test case result for bug 14554. mysql-test/t/mysqldump.test: Added test case for bug 14554.
This commit is contained in:
parent
32e6e6aac6
commit
3ecbc8e66e
3 changed files with 82 additions and 1 deletions
|
@ -1841,12 +1841,13 @@ DELIMITER ;;\n");
|
|||
while ((row= mysql_fetch_row(result)))
|
||||
{
|
||||
fprintf(sql_file, "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n\
|
||||
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s */;;\n\n",
|
||||
/*!50003 CREATE TRIGGER %s %s %s ON %s FOR EACH ROW%s%s */;;\n\n",
|
||||
row[6], /* sql_mode */
|
||||
quote_name(row[0], name_buff, 0), /* Trigger */
|
||||
row[4], /* Timing */
|
||||
row[1], /* Event */
|
||||
result_table,
|
||||
(strchr(" \t\n\r", *(row[3]))) ? "" : " ",
|
||||
row[3] /* Statement */);
|
||||
}
|
||||
if (mysql_num_rows(result))
|
||||
|
|
|
@ -2494,3 +2494,59 @@ drop view v2;
|
|||
drop view v0;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
SET @old_sql_mode = @@SQL_MODE;
|
||||
SET SQL_MODE = IGNORE_SPACE;
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE TRIGGER tr1 BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET new.a = 0;
|
||||
END|
|
||||
SET SQL_MODE = @old_sql_mode;
|
||||
|
||||
/*!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
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
|
||||
LOCK TABLES `t1` WRITE;
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
|
||||
|
||||
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
|
||||
DELIMITER ;;
|
||||
/*!50003 SET SESSION SQL_MODE="IGNORE_SPACE" */;;
|
||||
/*!50003 CREATE TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
|
||||
SET new.a = 0;
|
||||
END */;;
|
||||
|
||||
DELIMITER ;
|
||||
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!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 TRIGGER tr1;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -999,3 +999,27 @@ drop view v2;
|
|||
drop view v0;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
|
||||
# for tables with trigger created in the IGNORE_SPACE sql mode.
|
||||
#
|
||||
|
||||
SET @old_sql_mode = @@SQL_MODE;
|
||||
SET SQL_MODE = IGNORE_SPACE;
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
DELIMITER |;
|
||||
CREATE TRIGGER tr1 BEFORE INSERT ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET new.a = 0;
|
||||
END|
|
||||
DELIMITER ;|
|
||||
|
||||
SET SQL_MODE = @old_sql_mode;
|
||||
|
||||
--exec $MYSQL_DUMP --skip-comments --databases test
|
||||
|
||||
DROP TRIGGER tr1;
|
||||
DROP TABLE t1;
|
||||
|
|
Loading…
Reference in a new issue