[CONC-598] Callback support for session tracking Created: 2022-06-05  Updated: 2022-08-02  Resolved: 2022-08-02

Status: Closed
Project: MariaDB Connector/C
Component/s: Protocol
Affects Version/s: 3.3.1
Fix Version/s: 3.3.2

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks CONPY-210 Disallow changing client_character set Closed

 Description   

Currently the API functions mysql_session_track_get_first/get_next() provide access to session tracking data sent by server in it's OK packet.

It would be more convenient to offer the possibility to register a callback function, which will be called if the server sends session track information to the client.

Callback function:

void session_track_cb(void *userdata, enum enum_session_state_type type,
                           char *val1, size_t len1, char *val2, size_t len2)
{
  switch (type) {
    case SESSION_TRACK_SCHEMA:
      printf("New schema: %.*s\n", len1, val1);
      break;
    case SESSION_TRACK_SYSTEM_VARIABLES:
      printf("Variable: "%.*s  Value: %.*s\n", len1, val1, len2, val2);
      break;
  }
}

Registering the callback function:

if (mysql_optionsv(handle, MARIADB_OPT_SESSION_TRACK_CALLBACK, session_track_cb, data))
{
  printf("Error: %s\n", mysql_error(handle));
}


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