WL#8733: Session information service

Affects: Server-5.7   —   Status: Complete

After implementation of WLs #7947 and #8177 it became clear that there's a
need to get/set more information about session, e.g peer (client) port,
current database, etc. To limit risks for WLs above those getters/setters
was moved to this WL.
This WL will introduce a new service, allowing a plugin to obtain additional
information about given session. This WL is limited to few functions below,
but the service introduced here might be extended with other functions in
scope of future WLs.

struct srv_session_info_service_st {
  /**
    Return server thread handler (THD) that belongs to given session.

    @param session Session to return THD from

    @return
      NULL  given session is invalid 
      valid MYSQL_THD, otherwise
  */
  MYSQL_THD (*get_thd)(MYSQL_SESSION session);


  /**
    Return server session id of the current session

    @param session Session to return THD from

    @note Value being returned isn't physical thread id
    
    @return
      0           session is invalid
      session id  otherwise
  */
  my_thread_id (*get_session_id)(MYSQL_SESSION session);


  /**
    Return session's current database name

    @param session Session to return database name from

    @return
      empty string  session is invalid
      db name       otherwise
  */
  LEX_CSTRING (*get_current_db)(MYSQL_SESSION session);


  /**
    Return client's port

    @param session Session to return client port from

    @return
      0            session is invalid
      client port  otherwise
  */
  uint16_t (*get_client_port)(MYSQL_SESSION session);


  /**
    Set client port to given session
    
    @param session Session to set client port to

    @return
      1  session is invalid
      0  otherwise

  */
  int (*set_client_port)(MYSQL_SESSION session, uint16_t port);

  /**
    Sets the connection type of a session.

    @see enum_vio_type

    @note If NO_VIO_TYPE passed as type the call will fail.

    @return
      0  success
      1  failure
  */
  int (*set_connection_type)(MYSQL_SESSION session, enum enum_vio_type type);

  /**
    Returns whether the session was killed

    @param session  Session

    @return
      0  not killed
      1  killed
  */
  int (*killed)(MYSQL_SESSION session);
}