[CONC-297] The difference of local_infile definition makes issues on a big endian environment Created: 2017-12-04  Updated: 2018-08-08  Resolved: 2017-12-04

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.0.2
Fix Version/s: 3.0.3

Type: Bug Priority: Major
Reporter: Jun Aruga Assignee: Georg Richter
Resolution: Fixed Votes: 2
Labels: None
Environment:

OS: Fedora Project version 28 (rawhide) (develop version).
Architecture: ppc64 big endian.
mariadb-c-connector: 3.0.2
Ruby: 2.4.2
mysql2: MySQL Ruby binding.



 Description   

mariadb-c-connector is using mysql_optionsv `MYSQL_OPT_LOCAL_INFILE` value (arg1) as my_bool (char) in this code.

Ref: https://github.com/MariaDB/mariadb-connector-c/blob/v3.0.2/libmariadb/mariadb_lib.c#L2652

```
if (!arg1 || test((my_bool) arg1))
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
else
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
```

The part was changed from `uint` to `my_bool` in below commit.
https://github.com/MariaDB/mariadb-connector-c/commit/4ca933bb817efd90076d5bde968761047ac7e4cf

The issue is seeing other MySQL server and MariaDB server code, it is defined as uint, not my_bool (char).

Ex.
https://github.com/mysql/mysql-server/blob/mysql-5.7.20/sql-common/client.c#L5443
https://github.com/MariaDB/server/blob/10.3/sql-common/client.c#L4275
> if (!arg || MY_TEST((uint) arg))

It is also written on the document..
https://dev.mysql.com/doc/refman/5.7/en/mysql-options.html
> MYSQL_OPT_LOCAL_INFILE (argument type: optional pointer to unsigned int)

This difference causes that local_infile with mariadb-c-connector does not work on big endian environment.

Because on little endian (major environment such as x86_64), when set

mysql_options MYSQL_OPT_LOCAL_INFILE arg as type uint 1 = "0x01 0x00 0x00 0x00" to enable local_infile, this becomes "0x01" by char (my_bool) cast.
But on big endian environment, when set type uint 1 = "0x00 0x00 0x00 0x01" to enable local_infile, this becomes "0x00" by char (my_bool) cast. As a result, local_infile is not set as on.

I want to know why this project changed uint to my_bool (char).
I wish it is changed to uint (unsigned int) again.

I came from mysql ruby binding project. See https://github.com/brianmario/mysql2/pull/914 .

Thank you.



 Comments   
Comment by Georg Richter [ 2017-12-04 ]

Fixed rev. 434b67e624d72147a2987eed0a8e5a0765d16be1

Comment by Aaron Stone [ 2017-12-04 ]

Thank you!

Comment by Jun Aruga [ 2017-12-05 ]

Thank you!

Comment by Jun Aruga [ 2018-07-11 ]

@Georg I noticed that the local_file issue still happened with mariadb-connector-c 3.0.5 on big endian environment.

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