[CONC-574] Incorrect documentation for MYSQL_OPT_LOCAL_INFILE option Created: 2022-01-10  Updated: 2022-01-10  Resolved: 2022-01-10

Status: Closed
Project: MariaDB Connector/C
Component/s: API, Documentation
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: 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



 Comments   
Comment by Georg Richter [ 2022-01-10 ]

Fxed in documentation:

https://github.com/mariadb-corporation/mariadb-connector-c/wiki/mysql_optionsv

Generated at Thu Feb 08 03:06:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.