Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-332

mysql_change_user does not reset server_status

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.3.1, 2.3.5, 3.0.4
    • 3.0.6
    • None
    • None
    • 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

      Attachments

        Activity

          People

            georg Georg Richter
            rcannao René Cannaò
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.