mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-10431: Please implement mysqldump --add-drop-trigger from MySQL 5.6
Port of mysql changeset by Georgi Kodinov <Georgi.Kodinov@Oracle.com>: Bug #34325 : --add-drop-trigger option for mysqldump Implemented the --add-drop-trigger option to prepend each CREATE TRIGGER in the dump file with DROP TRIGGER. The option is off by default. Added a test case.
This commit is contained in:
@ -114,7 +114,8 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_no_data_m
|
||||
opt_slave_apply= 0,
|
||||
opt_include_master_host_port= 0,
|
||||
opt_events= 0, opt_comments_used= 0,
|
||||
opt_alltspcs=0, opt_notspcs= 0, opt_logging;
|
||||
opt_alltspcs=0, opt_notspcs= 0, opt_logging,
|
||||
opt_drop_trigger= 0 ;
|
||||
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
|
||||
static ulong opt_max_allowed_packet, opt_net_buffer_length;
|
||||
static MYSQL mysql_connection,*mysql=0;
|
||||
@ -233,6 +234,9 @@ static struct my_option my_long_options[] =
|
||||
{"add-drop-table", OPT_DROP, "Add a DROP TABLE before each create.",
|
||||
&opt_drop, &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
|
||||
0},
|
||||
{"add-drop-trigger", 0, "Add a DROP TRIGGER before each create.",
|
||||
&opt_drop_trigger, &opt_drop_trigger, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
|
||||
0},
|
||||
{"add-locks", OPT_LOCKS, "Add locks around INSERT statements.",
|
||||
&opt_lock, &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
|
||||
0},
|
||||
@ -3281,6 +3285,10 @@ static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
|
||||
if (opt_compact)
|
||||
fprintf(sql_file, "/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;\n");
|
||||
|
||||
if (opt_drop_trigger)
|
||||
fprintf(sql_file, "/*!50032 DROP TRIGGER IF EXISTS %s */;\n",
|
||||
(*show_trigger_row)[0]);
|
||||
|
||||
fprintf(sql_file,
|
||||
"DELIMITER ;;\n"
|
||||
"/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
|
||||
@ -3361,6 +3369,10 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
|
||||
|
||||
switch_sql_mode(sql_file, ";", row[1]);
|
||||
|
||||
if (opt_drop_trigger)
|
||||
fprintf(sql_file, "/*!50032 DROP TRIGGER IF EXISTS %s */;\n",
|
||||
row[0]);
|
||||
|
||||
query_str= cover_definer_clause(row[2], strlen(row[2]),
|
||||
C_STRING_WITH_LEN("50017"),
|
||||
C_STRING_WITH_LEN("50003"),
|
||||
|
Reference in New Issue
Block a user