Bug #72107 mysql_real_connect() CLIENT_LOCAL_FILES flag doesn't work
Submitted: 24 Mar 2014 9:20 Modified: 4 Apr 2014 9:40
Reporter: Hartmut Holzgraefe Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / C Severity:S3 (Non-critical)
Version:5.6.16, any OS:Linux
Assigned to: CPU Architecture:Any

[24 Mar 2014 9:20] Hartmut Holzgraefe
Description:
This bug isn't reproducible with official binary packages as these are built ENABLED_LOCAL_INFILE, but is when using a default from-source build where it is enabled.

Enabling client side local infile handling using mysql_options() with MYSQL_OPT_LOCAL_INFILE before calling mysql_real_connect() works just 
fine, it sets the CLIENT_LOCAL_FILES flag in the 

  MYSQL->options.client_flag 

field.

When trying to enable the feature by passing CLIENT_LOCAL_FILES as part of the client_flags parameter of mysql_real_connect() it just gets copied to the 

  MYSQL->client_flag

field and not to

  MYSQL->options.client_flag

and so doesn't have any effect

How to repeat:
do "make test" with the attached source built against a mysql installation built
with -DENABLED_LOCAL_INFILE=OFF

expected result: both test invocations succeeding

actual result: the test run using mysql_real:connect(..., CLIENT_LOCAL_FILES) fails with a "Malformed packet" message and mysql->options.client_flag is still
zero instead of having a value of 0x80 (value of CLIENT_LOCAL_FILES)

=== testing with mysql_options() ===

./infile-test 
before setting options:
mysql->client_flag        : 0
mysql->options.client_flag: 0
using mysql_options()
Connect OK

mysql->client_flag        : EA28D
mysql->options.client_flag: 80

test OK

=== testing with mysql_real_connect() flags ===

./infile-test foo
before setting options:
mysql->client_flag        : 0
mysql->options.client_flag: 0
using connect flag
Connect OK

mysql->client_flag        : EA28D
mysql->options.client_flag: 0
LOAD failed: 1 2027 Malformed packet
make: *** [test] Error 1

Suggested fix:
make it work as documented
[24 Mar 2014 9:23] Hartmut Holzgraefe
test source

Attachment: infile-test.c (text/x-csrc), 3.12 KiB.

[24 Mar 2014 9:23] Hartmut Holzgraefe
simple makefile with "make test" target to run the test

Attachment: Makefile (application/octet-stream, text), 349 bytes.

[24 Mar 2014 9:24] Hartmut Holzgraefe
very simple input file

Attachment: t1.csv (text/csv), 14 bytes.

[4 Apr 2014 9:40] Umesh Shastry
Hello Hartmut,

Thank you for the bug report and test case.
Verified as described.

Thanks,
Umesh
[4 Apr 2014 9:41] Umesh Shastry
//

# make test

=== testing with mysql_options() ===

./infile-test
before setting options:
mysql->client_flag        : 0
mysql->options.client_flag: 0
using mysql_options()
Connect OK

mysql->client_flag        : 3EA28D
mysql->options.client_flag: 80

test OK

=== testing with mysql_real_connect() flags ===

./infile-test foo
before setting options:
mysql->client_flag        : 0
mysql->options.client_flag: 0
using connect flag
Connect OK

mysql->client_flag        : 3EA28D
mysql->options.client_flag: 0
LOAD failed: 1 2027 Malformed packet
make: *** [test] Error 1