Bug #1907 handle_options() ignores GET_BOOL/OPT_ARG options
Submitted: 20 Nov 2003 23:41 Modified: 24 Nov 2003 3:27
Reporter: Michael Fuhr Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.16 OS:Solaris (Solaris 9)
Assigned to: Jani Tolonen CPU Architecture:Any

[20 Nov 2003 23:41] Michael Fuhr
Description:
[Note: I'm not entirely certain of the analysis below.  If it's incorrect, hopefully it'll at least lead somebody to the correct solution, or to whatever mistake I might be making.]

The mysql command-line client appears to ignore the --local-infile option.  After verifying that C, Perl, and PHP programs could successfully execute LOAD DATA LOCAL INFILE statements on the server in question, yet having no success doing so with the mysql program regardless of the --local-infile setting, I started examining the source code.  I think I've tracked the problem down to the handle_options() function in mysys/my_getopt.c: lines 308-320 appear to handle options whose var_type is GET_BOOL and arg_type is OPT_ARG, but there's no call to get_one_option() in this section of code.  As a result, these options don't get set in the mysql client. Adding a call to get_one_option() before the continue statement fixes the problem.

Possible indication of faulty analysis: mysqld appears to call handle_options() as well, yet it doesn't exhibit the problem I see with the mysql client.

How to repeat:
1. Connect to a database server with the mysql command-line client (4.0.16) and specify the --local-infile option:

  mysql --local-infile [-h, -u, -p options as necessary] test

2. Verify that the server has enabled LOAD DATA LOCAL INFILE by executing the following SQL statement:

  SHOW VARIABLES LIKE 'local_infile';

The output of this command should show that local_infile is ON.  If it's OFF then enable it (e.g., by adding local-infile to the [mysqld] section of my.cnf) and restart mysqld.

3. Execute the following command (the file and table don't have to exist):

  LOAD DATA LOCAL INFILE 'nonexistent-file.txt' INTO TABLE nonexistent_table;

If you see the error "The used command is not allowed with this MySQL version" then you've duplicated the problem I'm seeing; otherwise you should get the error "Table 'test.nonexistent_table' doesn't exist".

Suggested fix:
Possible fix, if my analysis is correct: add a call to get_one_option() in the section of code that handles GET_BOOL/OPT_ARG options in handle_options() (around line 320 in mysys/my_getopt.c).
[24 Nov 2003 3:27] Jani Tolonen
Thanks for the bug report!

This is fixed in 4.0 and 4.1 source now.

Regards,
Jani