Bug #78318 mysqlimport --delete deletes for every imported file
Submitted: 3 Sep 2015 20:43 Modified: 11 Sep 2015 9:04
Reporter: Nicolas De Rico Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:3.7, mysqlimport Ver 3.7 Distrib 5.6.26 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysqlimport

[3 Sep 2015 20:43] Nicolas De Rico
When using the --delete option of mysqlimport to import multiple files, the delete operation is run before importing each file resulting in only data from the last imported file to be present in the table.

How to repeat:
$ vi test.1.csv

$ vi test.2.csv

$ mysql -e "CREATE DATABASE test; CREATE TABLE test.test(c1 INT, c2 INT);"

$ mysqlimport --delete --local --fields-terminated-by=, --lines-terminated-by="\n" test test.1.csv test.2.csv
test.test: Records: 3  Deleted: 0  Skipped: 0  Warnings: 0
test.test: Records: 3  Deleted: 0  Skipped: 0  Warnings: 0

$ mysql -e "SELECT * FROM test.test;"
| c1   | c2   |
|    4 |    4 |
|    5 |    5 |
|    6 |    6 |

Suggested fix:
While noting that mysqlimport can import multiple files into multiple tables with a single command, thus making the current behavior useful for that scenario, and that there are workarounds for deleting data prior to a load, it would be a nice improvement if the --delete option could keep track of tables that have already been deleted once and not delete them again for every file that loads into those tables.  That way, this option could be useful when loading multiple files into one table and have the whole load remain instead of just the last file present on the command prompt.

This feature request could also be implemented with a new flag, ex. --delete-once.
[11 Sep 2015 9:04] MySQL Verification Team
Hello Nicolas De rico,

Thank you for the feature request.