@@ -48,8 +48,8 @@ static char *add_load_option(char *ptr,const char *object,
4848 const char * statement );
4949
5050static my_bool verbose = 0 ,lock_tables = 0 ,ignore_errors = 0 ,opt_delete = 0 ,
51- replace = 0 , silent = 0 , ignore = 0 , opt_compress = 0 ,
52- opt_low_priority = 0 , tty_password = 0 ;
51+ replace , silent , ignore , ignore_foreign_keys ,
52+ opt_compress , opt_low_priority , tty_password ;
5353static my_bool debug_info_flag = 0 , debug_check_flag = 0 ;
5454static uint opt_use_threads = 0 , opt_local_file = 0 , my_end_arg = 0 ;
5555static char * opt_password = 0 , * current_user = 0 ,
@@ -123,6 +123,10 @@ static struct my_option my_long_options[] =
123123 & current_host , 0 , GET_STR , REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
124124 {"ignore" , 'i' , "If duplicate unique key was found, keep old row." ,
125125 & ignore , & ignore , 0 , GET_BOOL , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
126+ {"ignore-foreign-keys" , 'k' ,
127+ "Disable foreign key checks while importing the data." ,
128+ & ignore_foreign_keys , & ignore_foreign_keys , 0 , GET_BOOL , NO_ARG ,
129+ 0 , 0 , 0 , 0 , 0 , 0 },
126130 {"ignore-lines" , OPT_IGN_LINES , "Ignore first n lines of data infile." ,
127131 & opt_ignore_lines , & opt_ignore_lines , 0 , GET_LL ,
128132 REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
@@ -489,6 +493,9 @@ static MYSQL *db_connect(char *host, char *database,
489493 ignore_errors = 0 ;
490494 db_error (mysql );
491495 }
496+ if (ignore_foreign_keys )
497+ mysql_query (mysql , "set foreign_key_checks= 0;" );
498+
492499 return mysql ;
493500}
494501
0 commit comments