Bug #55666 SET clause missing in mysqlimport
Submitted: 31 Jul 2010 22:50 Modified: 1 Aug 2010 8:29
Reporter: Daniel Gasparotto Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.1.49 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution, mysqlimport

[31 Jul 2010 22:50] Daniel Gasparotto
The LOAD DATA INFILE syntax supports a SET clause:  [SET col_name = expr,...],

but in mysqlimport there is no reference to this option!

How to repeat:
mysqlimport --help

Observe lack of SET clause option

Suggested fix:
implement the SET clause in mysqlimport params,
ex: mysqlimport --columns="@id,name" --set="id=@id+1,load_date=CURRENT_TIMESTAMP" ...

suggested patch for client/mysqlimport.c:

< 		*escaped=0, *opt_columns=0,  
> 		*escaped=0, *opt_columns=0, *opt_set=0, 
>   {"set", 'T',"Defines the SET clause (comma separated).", &opt_set, &opt_set, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
>   if (opt_set)
> 	end= strmov(strmov(end, " SET "), opt_set);

A temporary fix is to inject the SET clause in the --columns option, ex:

--columns="call_date,line_id) SET filename=(\"file1.txt\""
# notice: leave the parenthesis unbalanced, as it is concatenated as "(" + opt_columns + ")" in mysqlimport.c
[1 Aug 2010 8:29] Valeriy Kravchuk
Thank you for the feature request.