18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
23
#include <drizzled/show.h>
24
24
#include <drizzled/session.h>
25
25
#include <drizzled/lock.h>
26
26
#include <drizzled/statement/flush.h>
27
#include "drizzled/sql_table.h"
28
#include "drizzled/plugin/logging.h"
29
#include "drizzled/plugin/storage_engine.h"
27
#include <drizzled/sql_table.h>
28
#include <drizzled/plugin/logging.h>
29
#include <drizzled/plugin/storage_engine.h>
30
#include <drizzled/statistics_variables.h>
34
34
bool statement::Flush::execute()
40
40
if (not reloadCache())
43
* We WANT to write and we CAN write.
44
* ! we write after unlocking the table.
46
* Presumably, RESET and binlog writing doesn't require synchronization
48
write_bin_log(getSession(), *getSession()->getQueryString());
49
getSession()->my_ok();
71
64
if (flush_tables || flush_tables_with_read_lock)
73
if (getSession() && flush_tables_with_read_lock)
66
if (&session() && flush_tables_with_read_lock)
75
if (getSession()->lockGlobalReadLock())
68
if (session().lockGlobalReadLock())
77
70
return true; /* Killed */
79
result= getSession()->close_cached_tables(tables, true, true);
72
result= session().close_cached_tables(tables, true, true);
81
if (getSession()->makeGlobalReadLockBlockCommit()) /* Killed */
74
if (session().makeGlobalReadLockBlockCommit()) /* Killed */
83
76
/* Don't leave things in a half-locked state */
84
getSession()->unlockGlobalReadLock();
77
session().unlockGlobalReadLock();
90
result= getSession()->close_cached_tables(tables, true, false);
83
result= session().close_cached_tables(tables, true, false);
94
if (getSession() && flush_status)
87
if (&session() && flush_status)
96
getSession()->refresh_status();
89
session().refresh_status();
99
if (getSession() && flush_global_status)
92
if (&session() && flush_global_status)
101
94
memset(¤t_global_counters, 0, sizeof(current_global_counters));
102
plugin::Logging::resetStats(getSession());
103
getSession()->refresh_status();
95
plugin::Logging::resetStats(&session());
96
session().refresh_status();