| 1780 | */ |
| 1781 | |
| 1782 | void THD::free_connection() |
| 1783 | { |
| 1784 | DBUG_ENTER("free_connection"); |
| 1785 | DBUG_ASSERT(free_connection_done == 0); |
| 1786 | my_free(const_cast<char*>(db.str)); |
| 1787 | db= null_clex_str; |
| 1788 | #ifndef EMBEDDED_LIBRARY |
| 1789 | if (net.vio) |
| 1790 | vio_delete(net.vio); |
| 1791 | net.vio= nullptr; |
| 1792 | net_end(&net); |
| 1793 | delete(rgi_fake); |
| 1794 | rgi_fake= NULL; |
| 1795 | delete(rli_fake); |
| 1796 | rli_fake= NULL; |
| 1797 | #endif |
| 1798 | if (!cleanup_done) |
| 1799 | cleanup(); |
| 1800 | ha_close_connection(this); |
| 1801 | plugin_thdvar_cleanup(this); |
| 1802 | mysql_audit_free_thd(this); |
| 1803 | main_security_ctx.destroy(); |
| 1804 | /* close all prepared statements, to save memory */ |
| 1805 | stmt_map.reset(); |
| 1806 | free_connection_done= 1; |
| 1807 | #if defined(ENABLED_PROFILING) |
| 1808 | profiling.restart(); // Reset profiling |
| 1809 | #endif |
| 1810 | debug_sync_reset_thread(this); |
| 1811 | DBUG_ASSERT(status_var.tmp_space_used == 0 || |
| 1812 | !debug_assert_on_not_freed_memory); |
| 1813 | DBUG_VOID_RETURN; |
| 1814 | } |
| 1815 | |
| 1816 | /* |
| 1817 | Reset thd for reuse by another connection |
no test coverage detected