Bug #1628 mysqlimport does not support "LINES STARTING BY"

Submitted: 22 Oct 2003 10:03 Modified: 26 Nov 2005 13:58
Reporter: [ name withheld ] Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:4.0.15a OS:
Assigned to: CPU Architecture:Any

[22 Oct 2003 10:03] [ name withheld ]
Description:
mysqlimport does not support the corresponding command line argument for "LINES STARTING BY".

How to repeat:
N/A - This is a new feature request.

Suggested fix:
--- client/mysqlimport.c-	Tue Sep 16 13:05:46 2003
+++ client/mysqlimport.c	Tue Oct 21 23:42:38 2003
@@ -42,7 +42,8 @@
 static MYSQL	mysql_connection;
 static char	*opt_password=0, *current_user=0,
 		*current_host=0, *current_db=0, *fields_terminated=0,
-		*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
+		*lines_starting=0, *lines_terminated=0,
+		*enclosed=0, *opt_enclosed=0,
 		*escaped=0, *opt_columns=0, *default_charset;
 static uint     opt_mysql_port=0;
 static my_string opt_mysql_unix_port=0;
@@ -92,6 +93,9 @@
   {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.",
    (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"lines-starting-by", OPT_LTB, "Lines in the i.file are started by ...",
+   (gptr*) &lines_starting, (gptr*) &lines_starting, 0, GET_STR,
+   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},
@@ -289,7 +293,10 @@
   end= add_load_option(end, opt_enclosed,
 		       " OPTIONALLY ENCLOSED BY");
   end= add_load_option(end, escaped, " ESCAPED BY");
-  end= add_load_option(end, lines_terminated, " LINES TERMINATED BY");
+  if (lines_starting || lines_terminated)
+      end= strmov(end, " LINES");
+  end= add_load_option(end, lines_starting, " STARTING BY");
+  end= add_load_option(end, lines_terminated, " TERMINATED BY");
   if (opt_ignore_lines)
     end= strmov(strmov(strmov(end, " IGNORE "), opt_ignore_lines), " LINES");
   if (opt_columns)
[23 Oct 2003 12:02] [ name withheld ]
Here is a better patch.

--- ./client/client_priv.h-	Tue Sep 16 13:05:48 2003
+++ ./client/client_priv.h	Wed Oct 22 10:24:54 2003
@@ -30,8 +30,8 @@
 	       OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE,
 	       OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
 	       OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE,
-	       OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES,
-	       OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH,
+	       OPT_FTB, OPT_LSB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+	       OPT_TABLES, OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH,
 	       OPT_LINE_NUMBERS, OPT_COLUMN_NAMES, OPT_CONNECT_TIMEOUT,
 	       OPT_MAX_ALLOWED_PACKET, OPT_NET_BUFFER_LENGTH,
 	       OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,

--- ./client/mysqlimport.c-	Tue Sep 16 13:05:46 2003
+++ ./client/mysqlimport.c	Wed Oct 22 10:23:39 2003
@@ -42,7 +42,8 @@
 static MYSQL	mysql_connection;
 static char	*opt_password=0, *current_user=0,
 		*current_host=0, *current_db=0, *fields_terminated=0,
-		*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
+		*lines_starting=0, *lines_terminated=0,
+		*enclosed=0, *opt_enclosed=0,
 		*escaped=0, *opt_columns=0, *default_charset;
 static uint     opt_mysql_port=0;
 static my_string opt_mysql_unix_port=0;
@@ -92,6 +93,9 @@
   {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.",
    (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"lines-starting-by", OPT_LSB, "Lines in the i.file are started by ...",
+   (gptr*) &lines_starting, (gptr*) &lines_starting, 0, GET_STR,
+   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},
@@ -289,7 +293,10 @@
   end= add_load_option(end, opt_enclosed,
 		       " OPTIONALLY ENCLOSED BY");
   end= add_load_option(end, escaped, " ESCAPED BY");
-  end= add_load_option(end, lines_terminated, " LINES TERMINATED BY");
+  if (lines_starting || lines_terminated)
+      end= strmov(end, " LINES");
+  end= add_load_option(end, lines_starting, " STARTING BY");
+  end= add_load_option(end, lines_terminated, " TERMINATED BY");
   if (opt_ignore_lines)
     end= strmov(strmov(strmov(end, " IGNORE "), opt_ignore_lines), " LINES");
   if (opt_columns)
[26 Nov 2005 13:58] Valeriy Kravchuk
Thank you for a feature request. I see no reason to not support all the clauses of LOAD DATA INFILE by command line options.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.