| 1865 | |
| 1866 | |
| 1867 | THD::~THD() |
| 1868 | { |
| 1869 | THD *orig_thd= current_thd; |
| 1870 | THD_CHECK_SENTRY(this); |
| 1871 | DBUG_ENTER("~THD()"); |
| 1872 | /* Make sure threads are not available via server_threads. */ |
| 1873 | assert_not_linked(); |
| 1874 | if (m_psi) |
| 1875 | PSI_CALL_set_thread_THD(m_psi, 0); |
| 1876 | |
| 1877 | /* |
| 1878 | In error cases, thd may not be current thd. We have to fix this so |
| 1879 | that memory allocation counting is done correctly |
| 1880 | */ |
| 1881 | set_current_thd(this); |
| 1882 | if (!status_in_global) |
| 1883 | add_status_to_global(); |
| 1884 | |
| 1885 | /* |
| 1886 | Other threads may have a lock on LOCK_thd_kill to ensure that this |
| 1887 | THD is not deleted while they access it. The following mutex_lock |
| 1888 | ensures that no one else is using this THD and it's now safe to delete |
| 1889 | */ |
| 1890 | mysql_mutex_lock(&LOCK_thd_kill); |
| 1891 | mysql_mutex_unlock(&LOCK_thd_kill); |
| 1892 | |
| 1893 | #ifdef WITH_WSREP |
| 1894 | delete wsrep_rgi; |
| 1895 | #endif |
| 1896 | if (!free_connection_done) |
| 1897 | free_connection(); |
| 1898 | |
| 1899 | #ifdef WITH_WSREP |
| 1900 | mysql_cond_destroy(&COND_wsrep_thd); |
| 1901 | my_free(wsrep_abort_by_kill_err); |
| 1902 | wsrep_abort_by_kill_err= 0; |
| 1903 | #endif |
| 1904 | mdl_context.destroy(); |
| 1905 | |
| 1906 | transaction->free(); |
| 1907 | mysql_cond_destroy(&COND_wakeup_ready); |
| 1908 | mysql_mutex_destroy(&LOCK_wakeup_ready); |
| 1909 | mysql_mutex_destroy(&LOCK_thd_data); |
| 1910 | mysql_mutex_destroy(&LOCK_thd_kill); |
| 1911 | #ifdef DBUG_ASSERT_EXISTS |
| 1912 | dbug_sentry= THD_SENTRY_GONE; |
| 1913 | #endif |
| 1914 | #ifndef EMBEDDED_LIBRARY |
| 1915 | if (rgi_slave) |
| 1916 | rgi_slave->cleanup_after_session(); |
| 1917 | |
| 1918 | statement_rcontext_reinit(); |
| 1919 | |
| 1920 | my_free(semisync_info); |
| 1921 | #endif |
| 1922 | main_lex.free_set_stmt_mem_root(); |
| 1923 | free_root(&main_mem_root, MYF(0)); |
| 1924 | my_free(m_token_array); |
nothing calls this directly
no test coverage detected