# mysql\_session\_track\_get\_first

## Syntax

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

* `mysql` - mysql handle, which was previously allocated by [mysql\_init()](/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md) or [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md).
* `type` - type of information. Valid values are
  * `SESSION_TRACK_SYSTEM_VARIABLES`
  * `SESSION_TRACK_SCHEMA`
  * `SESSION_TRACK_STATE_CHANGE`
  * `SESSION_TRACK_GTIDS` (unsupported)
* `data` - pointer to data, which must be declared as `const char *`
* `length` - pointer to a `size_t` variable, which will contain the length of data

## Description

*`mysql_session_track_get_first()`* retrieves the first session status change information received from the server.

Depending on the specified type the read only data pointer will contain the following information:

* `SESSION_TRACK_SCHEMA`: The name of the default schema (database)
* `SESSION_TRACK_SYSTEM_VARIABLES`: If a session system variable is changed, the first call contains the name of the changed system variable, the second call contains the new value. Both name and value are represented as strings.
* `SESSION_TRACK_STATE_CHANGE`: shows whether the session status has changed. The value is changed as string "1" (changed) or "0" (unchanged).

Further data needs to be obtained by calling [mysql\_session\_track\_get\_next()](/docs/connectors/mariadb-connector-c/api-functions/mysql_session_track_get_next.md).

*`mysql_session_track_get_first()`* was added in Connector/C 3.0 and MariaDB Server 10.2.

## Returns

Zero for success, nonzero if an error occurred.

## See also

[mysql\_session\_track\_get\_next()](/docs/connectors/mariadb-connector-c/api-functions/mysql_session_track_get_next.md)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_session_track_get_first.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
