Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The text gives examples how to enable/disable LOAD LOCAL DATA INFILE
mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, NULL); /* disable */
mysql_optionsv(mysql, MYSQL_OPT_LOCAL_INFILE, (void )"1"); / enable */
while looking at the code,
case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/ |
if (!arg1 || test(*(unsigned int*) arg1)) |
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
|
else |
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
|
if (arg1) { |
CHECK_OPT_EXTENSION_SET(&mysql->options);
|
mysql->extension->auto_local_infile= *(uint*)arg1 == LOCAL_INFILE_MODE_AUTO
|
? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
|
}
|
break; |
it's obvious, that NULL value enables, and not disables "LOAD LOCAL DATA INFILE". More over, the value is expected to be pointer to unsigned int, and pointed value is tested as boolean value, while manual page has string "1" as the example of how to enable.
Given all that, I guess it can be also considered a bug in the connector, and not only in documentation, and it should be
if (!arg1 || !test((unsigned int) arg1))
so NULL and 0 have the same effect - disable LOCAL DATA, and that will be in line with current documentation and more logically consistent.
It seems also, that the value pointed by arg1 is also important, and it's not only true/false, since LOCAL_INFILE_MODE_AUTO has value 2.
#define LOCAL_INFILE_MODE_OFF 0
#define LOCAL_INFILE_MODE_ON 1
#define LOCAL_INFILE_MODE_AUTO 2
#define ENABLED_LOCAL_INFILE LOCAL_INFILE_MODE_AUTO