[CONC-332] mysql_change_user does not reset server_status Created: 2018-05-15  Updated: 2018-08-08  Resolved: 2018-08-02

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 2.3.1, 2.3.5, 3.0.4
Fix Version/s: 3.0.6

Type: Bug Priority: Major
Reporter: René Cannaò Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux



 Description   

mysql_change_user doesn't reset the value on server_status, therefore the value of server_status refers to the "old" connection.

Here an example:

#include "mysql.h"
#include <stdio.h>
#include <stdlib.h>

int main() {
MYSQL *con = mysql_init(NULL);
if (mysql_real_connect(con, "127.0.0.1", "sbtest", "sbtest", NULL, 0, NULL, 0) == NULL)

Unknown macro: { fprintf(stderr, "%sn", mysql_error(con)); exit(EXIT_FAILURE); }

fprintf(stderr, "Current autocommit flag after connect : %u\n", ( con->server_status & SERVER_STATUS_AUTOCOMMIT ? 1 : 0 ) );
if (mysql_query(con, "SET autocommit=1"))

fprintf(stderr, "Current autocommit flag after SET autocommit=1 : %u\n", ( con->server_status & SERVER_STATUS_AUTOCOMMIT ? 1 : 0 ) );
if (mysql_query(con, "SET autocommit=0"))

Unknown macro: { fprintf(stderr, "%sn", mysql_error(con)); exit(EXIT_FAILURE); }

fprintf(stderr, "Current autocommit flag after SET autocommit=0 : %u\n", ( con->server_status & SERVER_STATUS_AUTOCOMMIT ? 1 : 0 ) );
if (mysql_change_user(con, "sbtest", "sbtest", NULL))

fprintf(stderr, "Current autocommit flag after change user : %u\n", ( con->server_status & SERVER_STATUS_AUTOCOMMIT ? 1 : 0 ) );
exit(EXIT_SUCCESS);
}

Output from the above:

Current autocommit flag after connect : 1
Current autocommit flag after SET autocommit=1 : 1
Current autocommit flag after SET autocommit=0 : 0
Current autocommit flag after change user : 0

Expected output:

Current autocommit flag after connect : 1
Current autocommit flag after SET autocommit=1 : 1
Current autocommit flag after SET autocommit=0 : 0
Current autocommit flag after change user : 1

Note 1: tcpdump confirms that the new autocommit should be 1, not 0.
Note 2: the example above focus on autocommit flag, yet the whole value of server_status is not reset.

Tested with 2.3.1 , 2.3.5 and 3.0.4


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