Bug #109712 mysqlimport --delete does not delimit table name
Submitted: 19 Jan 2023 20:59 Modified: 25 Jan 2023 4:33
Reporter: Bill Karwin (Candidate Quality Contributor) (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any

[19 Jan 2023 20:59] Bill Karwin
Description:
When using mysqlimport --delete, the table identifier is not delimited. This causes an error if the table name is not a valid identifier.

How to repeat:
Define a test table with a name matching a reserved keyword.

mysql> create table test.`key` ( t text );

Prepare a text file:

% echo "abc" > key.txt

Import without using the delete option. It works without error.

% mysqlimport --local test key.txt      
test.key: Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

Import using the delete option. It fails.

% mysqlimport --local --delete test key.txt
mysqlimport: Error: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1, when using table: key

Tested with MySQL Community Edition 8.0.31 on MacOS, but I assume it will work the same on any OS.

Suggested fix:
Delimit the table identifier with back-ticks in the DELETE statement, as is done currently in the LOAD DATA INFILE statement.
[19 Jan 2023 21:00] Bill Karwin
Reference to Bug #28071 in which the table identifier is delimited for the LOAD DATA INFILE statement. That was reported to have been fixed in MySQL 5.1.39.
[20 Jan 2023 7:48] MySQL Verification Team
Hello Bill,

Thank you for the bug report and the test case. 
Imho this is duplicate of Bug #109711, please see Bug #109711.
If you have no objections then I would like to close this as a duplicate of Bug #109711. Thank you.

regards,
Umesh
[20 Jan 2023 18:17] Bill Karwin
Yes, it's a duplicate. Fair enough, he beat my bug report by 35 minutes. :-)
[25 Jan 2023 4:33] MySQL Verification Team
Thank you, Bill.

Sincerely,
Umesh