Documentation Home
MySQL 5.7 C API Developer Guide
Download this Manual
PDF (US Ltr) - 1.1Mb
PDF (A4) - 1.1Mb


5.4.60 mysql_reset_connection()

intmysql_reset_connection(MYSQL *mysql)

Description

Resets the connection to clear the session state.

mysql_reset_connection() has effects similar tomysql_change_user() or an auto-reconnect except that the connection is not closed and reopened, and reauthentication is not done. SeeSection 5.4.3, “mysql_change_user()”, andSection 3.6.6, “Automatic Reconnection Control”.

mysql_reset_connection() affects the connection-related state as follows:

  • Rolls back any active transactions and resets autocommit mode.

  • Releases all table locks.

  • Closes (and drops) allTEMPORARY tables.

  • Reinitializes session system variables to the values of the corresponding global system variables, including system variables that are set implicitly by statements such asSET NAMES.

  • Loses user-defined variable settings.

  • Releases prepared statements.

  • ClosesHANDLER variables.

  • Resets the value ofLAST_INSERT_ID() to 0.

  • Releases locks acquired withGET_LOCK().

Return Values

Zero for success. Nonzero if an error occurred.