You are here : Cmysql/mysql.hmysql_session_track_get_first

mysql_session_track_get_first() - mysql/mysql.h

 This function fetches the first session state-change information
        received from the server. It was added in MySQL 5.7.4.To control notification for changes to session state, use the
        session_track_state_change,
        session_track_schema,
        session_track_system_variables,
        and session_track_gtids system
        variables (see Section 6.1.4, “Server System Variables”).session_track_state_changesession_track_state_changesession_track_schemasession_track_schemasession_track_system_variablessession_track_system_variablessession_track_gtidssession_track_gtidsSection 6.1.4, “Server System Variables”The function parameters are used as follows. These descriptions
        also apply to
        mysql_session_track_get_first(),
        which takes the same parameters.mysql_session_track_get_first()mysql_session_track_get_first()mysql: The connection handle.
          
type: The type of information to
            retrieve. Permitted values for this parameter are the
            members of the enum_session_state_type
            enumeration defined in mysql_com.h:
          
enum enum_session_state_type
{
  SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  SESSION_TRACK_SCHEMA,           /* Current schema */
  SESSION_TRACK_STATE_CHANGE      /* track session state changes */
  SESSION_TRACK_GTIDS,            /* track GTIDs/*
};

            To make it easy to loop over all possible types of session
            information, the SESSION_TRACK_BEGIN and
            SESSION_TRACK_END macros are defined to
            be equal to the first and last members of the
            enum_session_state_type enumeration. The
            example code shown later in this section demonstrates this
            technique.
          
data: The address of a const
            char * variable. Following a successful call, this
            variable points to the returned data, which should be
            considered read only.
          
length: The address of a
            size_t variable. Following a successful
            call, this variable contains the length of the data pointed
            to by the data parameter.mysql: The connection handle.
          
type: The type of information to
            retrieve. Permitted values for this parameter are the
            members of the enum_session_state_type
            enumeration defined in mysql_com.h:
          
enum enum_session_state_type
{
  SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  SESSION_TRACK_SCHEMA,           /* Current schema */
  SESSION_TRACK_STATE_CHANGE      /* track session state changes */
  SESSION_TRACK_GTIDS,            /* track GTIDs/*
};

            To make it easy to loop over all possible types of session
            information, the SESSION_TRACK_BEGIN and
            SESSION_TRACK_END macros are defined to
            be equal to the first and last members of the
            enum_session_state_type enumeration. The
            example code shown later in this section demonstrates this
            technique.
          
data: The address of a const
            char * variable. Following a successful call, this
            variable points to the returned data, which should be
            considered read only.
          
length: The address of a
            size_t variable. Following a successful
            call, this variable contains the length of the data pointed
            to by the data parameter.mysql: The connection handle.mysql: The connection handle.mysqltype: The type of information to
            retrieve. Permitted values for this parameter are the
            members of the enum_session_state_type
            enumeration defined in mysql_com.h:
          
enum enum_session_state_type
{
  SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  SESSION_TRACK_SCHEMA,           /* Current schema */
  SESSION_TRACK_STATE_CHANGE      /* track session state changes */
  SESSION_TRACK_GTIDS,            /* track GTIDs/*
};

            To make it easy to loop over all possible types of session
            information, the SESSION_TRACK_BEGIN and
            SESSION_TRACK_END macros are defined to
            be equal to the first and last members of the
            enum_session_state_type enumeration. The
            example code shown later in this section demonstrates this
            technique.type: The type of information to
            retrieve. Permitted values for this parameter are the
            members of the enum_session_state_type
            enumeration defined in mysql_com.h:typeenum_session_state_typemysql_com.henum enum_session_state_type
{
  SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  SESSION_TRACK_SCHEMA,           /* Current schema */
  SESSION_TRACK_STATE_CHANGE      /* track session state changes */
  SESSION_TRACK_GTIDS,            /* track GTIDs/*
};To make it easy to loop over all possible types of session
            information, the SESSION_TRACK_BEGIN and
            SESSION_TRACK_END macros are defined to
            be equal to the first and last members of the
            enum_session_state_type enumeration. The
            example code shown later in this section demonstrates this
            technique.SESSION_TRACK_BEGINSESSION_TRACK_ENDenum_session_state_typedata: The address of a const
            char * variable. Following a successful call, this
            variable points to the returned data, which should be
            considered read only.data: The address of a const
            char * variable. Following a successful call, this
            variable points to the returned data, which should be
            considered read only.dataconst
            char *length: The address of a
            size_t variable. Following a successful
            call, this variable contains the length of the data pointed
            to by the data parameter.length: The address of a
            size_t variable. Following a successful
            call, this variable contains the length of the data pointed
            to by the data parameter.lengthsize_tdataFollowing a successful call, interpret the
        data and length values
        according to the type value, as follows:datalengthtypeSESSION_TRACK_SCHEMA:
            data is the new default schema name and
            length is the name length.
          
SESSION_TRACK_SYSTEM_VARIABLES: When a
            session system variable changes, two values per variable are
            returned (in separate calls). For the first call,
            data is the variable name and
            length is the name length. For the second
            call, data is the variable value and
            length is the value length. value Both
            data values are represented as strings.
          
SESSION_TRACK_STATE_CHANGE:
            data is a byte containing a boolean flag
            that indicates whether session state changes occurred and
            length should be 1. The flag is
            represented as an ASCII value, not a binary (for example,
            '1', not 0x01).SESSION_TRACK_SCHEMA:
            data is the new default schema name and
            length is the name length.
          
SESSION_TRACK_SYSTEM_VARIABLES: When a
            session system variable changes, two values per variable are
            returned (in separate calls). For the first call,
            data is the variable name and
            length is the name length. For the second
            call, data is the variable value and
            length is the value length. value Both
            data values are represented as strings.
          
SESSION_TRACK_STATE_CHANGE:
            data is a byte containing a boolean flag
            that indicates whether session state changes occurred and
            length should be 1. The flag is
            represented as an ASCII value, not a binary (for example,
            '1', not 0x01).SESSION_TRACK_SCHEMA:
            data is the new default schema name and
            length is the name length.SESSION_TRACK_SCHEMA:
            data is the new default schema name and
            length is the name length.SESSION_TRACK_SCHEMAdatalengthSESSION_TRACK_SYSTEM_VARIABLES: When a
            session system variable changes, two values per variable are
            returned (in separate calls). For the first call,
            data is the variable name and
            length is the name length. For the second
            call, data is the variable value and
            length is the value length. value Both
            data values are represented as strings.SESSION_TRACK_SYSTEM_VARIABLES: When a
            session system variable changes, two values per variable are
            returned (in separate calls). For the first call,
            data is the variable name and
            length is the name length. For the second
            call, data is the variable value and
            length is the value length. value Both
            data values are represented as strings.SESSION_TRACK_SYSTEM_VARIABLESdatalengthdatalengthSESSION_TRACK_STATE_CHANGE:
            data is a byte containing a boolean flag
            that indicates whether session state changes occurred and
            length should be 1. The flag is
            represented as an ASCII value, not a binary (for example,
            '1', not 0x01).SESSION_TRACK_STATE_CHANGE:
            data is a byte containing a boolean flag
            that indicates whether session state changes occurred and
            length should be 1. The flag is
            represented as an ASCII value, not a binary (for example,
            '1', not 0x01).SESSION_TRACK_STATE_CHANGEdatalength'1'0x01


Syntax

int mysql_session_track_get_first(MYSQL *mysql, enum
        enum_session_state_type type, const char **data, size_t
        *length)


Example

enum enum_session_state_type
{
  SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  SESSION_TRACK_SCHEMA,           /* Current schema */
  SESSION_TRACK_STATE_CHANGE      /* track session state changes */
  SESSION_TRACK_GTIDS,            /* track GTIDs/*
};


Output / Return Value

 Zero for success. Nonzero if an error occurred.


Limitations


Alternatives / See Also


Reference