[MDEV-6726] CONNECTION_ATTRS not stored in performance schema Created: 2014-09-10  Updated: 2014-10-09  Due: 2014-09-30  Resolved: 2014-10-09

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.12
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: upstream
Environment:

Linux x64



 Description   

Both mysql_client_test (from MySQL Server package) and mariadb-native-client test suite suite fail, since connection attributes are not stored in performance schema.

Test:

static void test_wl5924()
{
  int rc;
  MYSQL *l_mysql;
  MYSQL_RES *res;
  MYSQL_ROW row;
 
  myheader("test_wl5924");
 
  l_mysql= mysql_client_init(NULL);
  DIE_UNLESS(l_mysql != NULL);
 
  /* we want a non-default character set */
  rc= mysql_set_character_set(l_mysql, "cp1251");
  DIE_UNLESS(rc == 0);
 
  /* put in an attr */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key1", "value1");
  DIE_UNLESS(rc == 0);
 
  /* put a second attr */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key2", "value2");
  DIE_UNLESS(rc == 0);
 
  /* put the second attr again : should fail */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key2", "value2");
  DIE_UNLESS(rc != 0);
 
  /* delete the second attr */
  rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_DELETE,
                    "key2");
  DIE_UNLESS(rc == 0);
 
  /* put the second attr again : should pass */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key2", "value2");
  DIE_UNLESS(rc == 0);
 
  /* full reset */
  rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_RESET, NULL);
  DIE_UNLESS(rc == 0);
 
  /* put the second attr again : should pass */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key2", "value2");
  DIE_UNLESS(rc == 0);
 
  /* full reset */
  rc= mysql_options(l_mysql, MYSQL_OPT_CONNECT_ATTR_RESET, NULL);
  DIE_UNLESS(rc == 0);
 
  /* add a third attr */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key3", "value3");
  DIE_UNLESS(rc == 0);
 
  /* add a fourth attr */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "key4", "value4");
  DIE_UNLESS(rc == 0);
 
  /* add a non-ascii attr */
  /* note : this is Георги, Кодинов in windows-1251 */
  rc= mysql_options4(l_mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
                     "\xc3\xe5\xee\xf0\xe3\xe8",
                     "\xca\xee\xe4\xe8\xed\xee\xe2");
  DIE_UNLESS(rc == 0);
 
  l_mysql= mysql_real_connect(l_mysql, opt_host, opt_user,
                         opt_password, current_db, opt_port,
                         opt_unix_socket, 0);
  DIE_UNLESS(l_mysql != 0);
 
  rc= mysql_query(l_mysql,
                  "SELECT ATTR_NAME, ATTR_VALUE "
                  " FROM performance_schema.session_account_connect_attrs"
                  " WHERE ATTR_NAME IN ('key1','key2','key3','key4',"
                  "  '\xc3\xe5\xee\xf0\xe3\xe8') AND"
                  "  PROCESSLIST_ID = CONNECTION_ID() ORDER BY ATTR_NAME");
  myquery2(l_mysql,rc);
  res= mysql_use_result(l_mysql);
  DIE_UNLESS(res);
 
  row= mysql_fetch_row(res);
  DIE_UNLESS(row);
  DIE_UNLESS(0 == strcmp(row[0], "key3"));
  DIE_UNLESS(0 == strcmp(row[1], "value3"));
 
  row= mysql_fetch_row(res);
  DIE_UNLESS(row);
  DIE_UNLESS(0 == strcmp(row[0], "key4"));
  DIE_UNLESS(0 == strcmp(row[1], "value4"));
 
  row= mysql_fetch_row(res);
  DIE_UNLESS(row);
  DIE_UNLESS(0 == strcmp(row[0], "\xc3\xe5\xee\xf0\xe3\xe8"));
  DIE_UNLESS(0 == strcmp(row[1], "\xca\xee\xe4\xe8\xed\xee\xe2"));
 
  mysql_free_result(res);
 
  l_mysql->reconnect= 1;
  rc= mysql_reconnect(l_mysql);
  myquery2(l_mysql,rc);
 
  mysql_close(l_mysql);
}



 Comments   
Comment by Elena Stepanova [ 2014-09-23 ]

Are you running the server with --performance-schema?
Keep in mind that it's disabled by default in 10.0 (unlike 5.6 where it's enabled by default).

Comment by Georg Richter [ 2014-09-23 ]

Hi Elena,

i wasn't aware that performance-schema was disabled by default.
However in this case I would expect that testing

mysql->server_capabilities & CLIENT_CONNECT_ATTRS

will fail.

Comment by Elena Stepanova [ 2014-09-23 ]

According to the documentation (http://dev.mysql.com/doc/internals/en/capability-flags.html), the flag only means that the server allows connection attributes in Protocol::HandshakeResponse41. It still does, whether performance schema is enabled or not, so why should this check fail?

Comment by Elena Stepanova [ 2014-09-24 ]

In any case, it's an upstream problem. It would be particularly unfortunate if our server or clients became incompatible with the upstream on this level.

georg
Do you want to report it to MySQL to see what they say?

Comment by Sergei Golubchik [ 2014-10-09 ]

I believe it is not a bug. The server supports connection attributes, it knows how to parse the packet with them, that's why the capability bit is set.

Whether the server will store them or throw away is a separate issue. Currently, the server stores them in the performance schema, that's why if performance schema is disabled — connection attributes are not stored.

Generated at Thu Feb 08 07:14:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.