From 22a35da68c04e94a2adbde6436b71c23558e045c Mon Sep 17 00:00:00 2001 From: "jani@hynda.mysql.fi" <> Date: Wed, 3 Apr 2002 13:36:01 +0300 Subject: merge --- client/mysqlimport.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'client/mysqlimport.c') diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 9eb93dc4808..e8403abe8c1 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -47,6 +47,7 @@ static char *opt_password=0, *current_user=0, *escaped=0, *opt_columns=0, *default_charset; static uint opt_mysql_port=0; static my_string opt_mysql_unix_port=0; +static my_string opt_ignore_lines=0; #include "sslopt-vars.h" static struct my_option my_long_options[] = @@ -89,6 +90,8 @@ static struct my_option my_long_options[] = (gptr*) ¤t_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ignore", 'i', "If duplicate unique key was found, keep old row.", (gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", 0, 0, + 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -227,6 +230,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case (int) OPT_ESC: escaped= argument; break; + case (int) OPT_IGN_LINES: + opt_ignore_lines= argument; + break; #include "sslopt-case.h" } return 0; @@ -327,6 +333,8 @@ static int write_to_table(char *filename, MYSQL *sock) " OPTIONALLY ENCLOSED BY"); end= add_load_option(end, escaped, " ESCAPED BY"); end= add_load_option(end, lines_terminated, " LINES TERMINATED BY"); + if (opt_ignore_lines) + end= strmov(strmov(strmov(end, " IGNORE "), opt_ignore_lines), " LINES"); if (opt_columns) end= strmov(strmov(strmov(end, " ("), opt_columns), ")"); *end= '\0'; @@ -379,6 +387,9 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd) mysql_init(&mysql_connection); if (opt_compress) mysql_options(&mysql_connection,MYSQL_OPT_COMPRESS,NullS); + if (opt_local_file) + mysql_options(&mysql_connection,MYSQL_OPT_LOCAL_INFILE, + (char*) &opt_local_file); #ifdef HAVE_OPENSSL if (opt_use_ssl) mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, -- cgit v1.2.1