00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/show.h>
00024 #include <drizzled/session.h>
00025 #include <drizzled/lock.h>
00026 #include <drizzled/statement/flush.h>
00027 #include <drizzled/sql_table.h>
00028 #include <drizzled/plugin/logging.h>
00029 #include <drizzled/plugin/storage_engine.h>
00030
00031 namespace drizzled
00032 {
00033
00034 bool statement::Flush::execute()
00035 {
00036
00037
00038
00039
00040 if (not reloadCache())
00041 {
00042 session().my_ok();
00043 }
00044
00045 return false;
00046 }
00047
00048 bool statement::Flush::reloadCache()
00049 {
00050 bool result= false;
00051 TableList *tables= (TableList *) lex().select_lex.table_list.first;
00052
00053 if (flush_log)
00054 {
00055 if (plugin::StorageEngine::flushLogs(NULL))
00056 {
00057 result= true;
00058 }
00059 }
00060
00061
00062
00063
00064 if (flush_tables || flush_tables_with_read_lock)
00065 {
00066 if (&session() && flush_tables_with_read_lock)
00067 {
00068 if (session().lockGlobalReadLock())
00069 {
00070 return true;
00071 }
00072 result= session().close_cached_tables(tables, true, true);
00073
00074 if (session().makeGlobalReadLockBlockCommit())
00075 {
00076
00077 session().unlockGlobalReadLock();
00078 return true;
00079 }
00080 }
00081 else
00082 {
00083 result= session().close_cached_tables(tables, true, false);
00084 }
00085 }
00086
00087 if (&session() && flush_status)
00088 {
00089 session().refresh_status();
00090 }
00091
00092 if (&session() && flush_global_status)
00093 {
00094 memset(¤t_global_counters, 0, sizeof(current_global_counters));
00095 plugin::Logging::resetStats(&session());
00096 session().refresh_status();
00097 }
00098
00099 return result;
00100 }
00101
00102 }