Bug #17255 mysqlimport deletes the rows multiple times
Submitted: 9 Feb 2006 1:06 Modified: 9 Feb 2006 11:03
Reporter: David Pearce Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:Ver 3.5 Distrib 5.0.18 OS:pc-linux-gnu (i686)
Assigned to: CPU Architecture:Any

[9 Feb 2006 1:06] David Pearce
Description:
If you try to import multiple files AND use the -d or --delete command, the table rows will be deleted before each imported file. This leaves only the data from the last file imported in the table.

How to repeat:
Create a test table. Create two files with appropriate but differing data. Import the data with this sort of command:
mysqlimport -u root -p MySQL /tmp/bugtest.? -d

Only the data from the last file will be in the database.

Suggested fix:
Delete the rows in the table once at the begining or the program execution and not before each file.
[9 Feb 2006 1:09] David Pearce
The same problem occurs if you specify two files by name:
mysqlimport -u root -p /tmp/bugtest.1 /tmp/bugtest.2
[9 Feb 2006 10:44] Valeriy Kravchuk
Thank you for a problem report. I do not think that it is a bug, though. It is known and intended behaviour (see http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html and last comment there). Use two mysqlimport commands if you want to delete the current data and that import form multiple files.
[9 Feb 2006 11:03] David Pearce
Thank you for considering this matter. The comment you mention is my own I placed there when I saw no indication of the designers intent.

Perhaps the program was designed this way, but may I suggest that allowing the program to process multiple files (which is very good), but to allow another function to have unintended consequences is perhaps not the best of designs.

I would think that moving the delete action to an earlier point in the program flow would allow for a more logical flow.

Good day.