~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/flush.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
 
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
19
19
 */
20
20
 
21
21
#include "config.h"
 
22
 
22
23
#include <drizzled/show.h>
23
24
#include <drizzled/session.h>
24
25
#include <drizzled/lock.h>
25
26
#include <drizzled/statement/flush.h>
26
27
#include "drizzled/sql_table.h"
 
28
#include "drizzled/plugin/logging.h"
 
29
#include "drizzled/plugin/storage_engine.h"
27
30
 
28
31
namespace drizzled
29
32
{
34
37
   * reloadCache() will tell us if we are allowed to write to the
35
38
   * binlog or not.
36
39
   */
37
 
  if (! reloadCache())
 
40
  if (not reloadCache())
38
41
  {
39
42
    /*
40
43
     * We WANT to write and we CAN write.
42
45
     *
43
46
     * Presumably, RESET and binlog writing doesn't require synchronization
44
47
     */
45
 
    write_bin_log(session, session->query.c_str());
46
 
    session->my_ok();
 
48
    write_bin_log(getSession(), *getSession()->getQueryString());
 
49
    getSession()->my_ok();
47
50
  }
48
51
 
49
52
  return false;
52
55
bool statement::Flush::reloadCache()
53
56
{
54
57
  bool result= false;
55
 
  TableList *tables= (TableList *) session->lex->select_lex.table_list.first;
 
58
  TableList *tables= (TableList *) getSession()->lex->select_lex.table_list.first;
56
59
 
57
60
  if (flush_log)
58
61
  {
67
70
  */
68
71
  if (flush_tables || flush_tables_with_read_lock)
69
72
  {
70
 
    if (session && flush_tables_with_read_lock)
 
73
    if (getSession() && flush_tables_with_read_lock)
71
74
    {
72
 
      if (lock_global_read_lock(session))
 
75
      if (getSession()->lockGlobalReadLock())
73
76
      {
74
77
        return true; /* Killed */
75
78
      }
76
 
      result= session->close_cached_tables(tables, true, true);
 
79
      result= getSession()->close_cached_tables(tables, true, true);
77
80
 
78
 
      if (make_global_read_lock_block_commit(session)) /* Killed */
 
81
      if (getSession()->makeGlobalReadLockBlockCommit()) /* Killed */
79
82
      {
80
83
        /* Don't leave things in a half-locked state */
81
 
        unlock_global_read_lock(session);
 
84
        getSession()->unlockGlobalReadLock();
82
85
        return true;
83
86
      }
84
87
    }
85
88
    else
86
89
    {
87
 
      result= session->close_cached_tables(tables, true, false);
 
90
      result= getSession()->close_cached_tables(tables, true, false);
88
91
    }
89
92
  }
90
93
 
91
 
  if (session && flush_status)
92
 
  {
93
 
    session->refresh_status();
94
 
  }
95
 
 
96
 
 return result;
 
94
  if (getSession() && flush_status)
 
95
  {
 
96
    getSession()->refresh_status();
 
97
  }
 
98
 
 
99
  if (getSession() && flush_global_status)
 
100
  {
 
101
    memset(&current_global_counters, 0, sizeof(current_global_counters));
 
102
    plugin::Logging::resetStats(getSession());
 
103
    getSession()->refresh_status();
 
104
  }
 
105
 
 
106
  return result;
97
107
}
98
108
 
99
109
}