~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/flush.cc

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
merge lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
 
21
#include <config.h>
22
22
 
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>
30
31
 
31
 
namespace drizzled
32
 
{
 
32
namespace drizzled {
33
33
 
34
34
bool statement::Flush::execute()
35
35
{
39
39
   */
40
40
  if (not reloadCache())
41
41
  {
42
 
    /*
43
 
     * We WANT to write and we CAN write.
44
 
     * ! we write after unlocking the table.
45
 
     *
46
 
     * Presumably, RESET and binlog writing doesn't require synchronization
47
 
     */
48
 
    write_bin_log(getSession(), *getSession()->getQueryString());
49
 
    getSession()->my_ok();
 
42
    session().my_ok();
50
43
  }
51
44
 
52
45
  return false;
55
48
bool statement::Flush::reloadCache()
56
49
{
57
50
  bool result= false;
58
 
  TableList *tables= (TableList *) getSession()->lex->select_lex.table_list.first;
 
51
  TableList *tables= (TableList *) lex().select_lex.table_list.first;
59
52
 
60
53
  if (flush_log)
61
54
  {
70
63
  */
71
64
  if (flush_tables || flush_tables_with_read_lock)
72
65
  {
73
 
    if (getSession() && flush_tables_with_read_lock)
 
66
    if (&session() && flush_tables_with_read_lock)
74
67
    {
75
 
      if (getSession()->lockGlobalReadLock())
 
68
      if (session().lockGlobalReadLock())
76
69
      {
77
70
        return true; /* Killed */
78
71
      }
79
 
      result= getSession()->close_cached_tables(tables, true, true);
 
72
      result= session().close_cached_tables(tables, true, true);
80
73
 
81
 
      if (getSession()->makeGlobalReadLockBlockCommit()) /* Killed */
 
74
      if (session().makeGlobalReadLockBlockCommit()) /* Killed */
82
75
      {
83
76
        /* Don't leave things in a half-locked state */
84
 
        getSession()->unlockGlobalReadLock();
 
77
        session().unlockGlobalReadLock();
85
78
        return true;
86
79
      }
87
80
    }
88
81
    else
89
82
    {
90
 
      result= getSession()->close_cached_tables(tables, true, false);
 
83
      result= session().close_cached_tables(tables, true, false);
91
84
    }
92
85
  }
93
86
 
94
 
  if (getSession() && flush_status)
 
87
  if (&session() && flush_status)
95
88
  {
96
 
    getSession()->refresh_status();
 
89
    session().refresh_status();
97
90
  }
98
91
 
99
 
  if (getSession() && flush_global_status)
 
92
  if (&session() && flush_global_status)
100
93
  {
101
94
    memset(&current_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();
104
97
  }
105
98
 
106
99
  return result;