Drizzled Public API Documentation

flush.cc
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2009 Sun Microsystems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <config.h>
22 
23 #include <drizzled/show.h>
24 #include <drizzled/session.h>
25 #include <drizzled/lock.h>
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>
30 #include <drizzled/statistics_variables.h>
31 
32 namespace drizzled {
33 
35 {
36  if (not reloadCache())
37  {
38  session().my_ok();
39  }
40 
41  return false;
42 }
43 
45 {
46  bool result= false;
47  TableList *tables= (TableList *) lex().select_lex.table_list.first;
48 
49  if (flush_log)
50  {
51  if (plugin::StorageEngine::flushLogs(NULL))
52  {
53  result= true;
54  }
55  }
56  /*
57  Note that if REFRESH_READ_LOCK bit is set then REFRESH_TABLES is set too
58  (see sql_yacc.yy)
59  */
60  if (flush_tables || flush_tables_with_read_lock)
61  {
62  if (&session() && flush_tables_with_read_lock)
63  {
64  if (session().lockGlobalReadLock())
65  {
66  return true; /* Killed */
67  }
68  result= session().close_cached_tables(tables, true, true);
69 
70  if (session().makeGlobalReadLockBlockCommit()) /* Killed */
71  {
72  /* Don't leave things in a half-locked state */
73  session().unlockGlobalReadLock();
74  return true;
75  }
76  }
77  else
78  {
79  result= session().close_cached_tables(tables, true, false);
80  }
81  }
82 
83  if (&session() && flush_status)
84  {
85  session().refresh_status();
86  }
87 
88  if (&session() && flush_global_status)
89  {
90  memset(&current_global_counters, 0, sizeof(current_global_counters));
91  plugin::Logging::resetStats(&session());
92  session().refresh_status();
93  }
94 
95  return result;
96 }
97 
98 }
void my_ok(ha_rows affected_rows=0, ha_rows found_rows_arg=0, uint64_t passed_id=0, const char *message=NULL)
Definition: session.cc:1877
Select_Lex * select_lex
Definition: table_list.h:208
TODO: Rename this file - func.h is stupid.