~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/query_cache.cc

[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
revno: 1915
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6130
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6126
committer: marko
timestamp: Mon 2009-11-02 09:42:56 +0000
message:
  branches/zip: Free all resources at shutdown. Set pointers to NULL, so
  that Valgrind will not complain about freed data structures that are
  reachable via pointers.  This addresses Bug #45992 and Bug #46656.
  
  This patch is mostly based on changes copied from branches/embedded-1.0,
  mainly c5432, c3439, c3134, c2994, c2978, but also some other code was
  copied.  Some added cleanup code is specific to MySQL/InnoDB.
  
  rb://199 approved by Sunny Bains
modified:
  ChangeLog                      2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog
  btr/btr0sea.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0sea.c
  buf/buf0buf.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0buf.c
  dict/dict0dict.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0dict.c
  fil/fil0fil.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ffil%2Ffil0fil.c
  ibuf/ibuf0ibuf.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fibuf%2Fibuf0ibuf.c
  include/btr0sea.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0sea.h
  include/dict0dict.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.h
  include/fil0fil.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffil0fil.h
  include/ibuf0ibuf.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fibuf0ibuf.h
  include/lock0lock.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flock0lock.h
  include/log0log.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0log.h
  include/log0recv.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0recv.h
  include/mem0mem.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0mem.h
  include/mem0pool.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0pool.h
  include/os0file.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fos0file.h
  include/pars0pars.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fpars0pars.h
  include/srv0srv.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsrv0srv.h
  include/thr0loc.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fthr0loc.h
  include/trx0i_s.h              1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Finclude%2Ftrx0i_s.h
  include/trx0purge.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0purge.h
  include/trx0rseg.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0rseg.h
  include/trx0sys.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0sys.h
  include/trx0undo.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0undo.h
  include/usr0sess.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fusr0sess.h
  lock/lock0lock.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flock%2Flock0lock.c
  log/log0log.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0log.c
  log/log0recv.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0recv.c
  mem/mem0dbg.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0dbg.c
  mem/mem0pool.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0pool.c
  os/os0file.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0file.c
  os/os0sync.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0sync.c
  os/os0thread.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0thread.c
  pars/lexyy.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Flexyy.c
  pars/pars0lex.l                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Fpars0lex.l
  que/que0que.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fque%2Fque0que.c
  srv/srv0srv.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0srv.c
  srv/srv0start.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0start.c
  sync/sync0arr.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0arr.c
  sync/sync0sync.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0sync.c
  thr/thr0loc.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fthr%2Fthr0loc.c
  trx/trx0i_s.c                  1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Ftrx%2Ftrx0i_s.c
  trx/trx0purge.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0purge.c
  trx/trx0rseg.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0rseg.c
  trx/trx0sys.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0sys.c
  trx/trx0undo.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0undo.c
  usr/usr0sess.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fusr%2Fusr0sess.c
  ut/ut0mem.c                    2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fut%2Fut0mem.c
diff:
=== modified file 'ChangeLog'

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
class Session;
31
31
 
 
32
using namespace std;
 
33
 
32
34
namespace drizzled
33
35
{
34
 
typedef std::vector<plugin::QueryCache *> QueryCaches;
 
36
typedef vector<plugin::QueryCache *> QueryCaches;
35
37
QueryCaches all_query_cache;
36
38
 
37
39
/* Namespaces are here to prevent global symbol clashes with these classes */
38
40
 
39
41
class IsCachedIterate
40
 
 : public std::unary_function<plugin::QueryCache *, bool>
 
42
 : public unary_function<plugin::QueryCache *, bool>
41
43
{
42
44
  Session *session;
43
45
public:
44
46
  IsCachedIterate(Session* session_arg) :
45
 
    std::unary_function<plugin::QueryCache *, bool>(),
 
47
    unary_function<plugin::QueryCache *, bool>(),
46
48
    session(session_arg) { }
47
49
 
48
50
  inline result_type operator()(argument_type handler)
55
57
{
56
58
  /* Use find_if instead of foreach so that we can collect return codes */
57
59
  QueryCaches::iterator iter=
58
 
    std::find_if(all_query_cache.begin(), all_query_cache.end(),
 
60
    find_if(all_query_cache.begin(), all_query_cache.end(),
59
61
            IsCachedIterate(session));
60
62
  /* If iter is == end() here, that means that all of the plugins returned
61
63
   * false, which in this case means they all succeeded. Since we want to 
66
68
 
67
69
 
68
70
class SendCachedResultsetIterate
69
 
 : public std::unary_function<plugin::QueryCache *, bool>
 
71
 : public unary_function<plugin::QueryCache *, bool>
70
72
{
71
73
  Session *session;
72
74
public:
73
75
  SendCachedResultsetIterate(Session *session_arg) :
74
 
    std::unary_function<plugin::QueryCache *, bool>(),
 
76
    unary_function<plugin::QueryCache *, bool>(),
75
77
    session(session_arg) { }
76
78
 
77
79
  inline result_type operator()(argument_type handler)
83
85
{
84
86
  /* Use find_if instead of foreach so that we can collect return codes */
85
87
  QueryCaches::iterator iter=
86
 
    std::find_if(all_query_cache.begin(), all_query_cache.end(),
87
 
                 SendCachedResultsetIterate(session));
 
88
    find_if(all_query_cache.begin(), all_query_cache.end(),
 
89
            SendCachedResultsetIterate(session));
88
90
  /* If iter is == end() here, that means that all of the plugins returned
89
91
   * false, which in this case means they all succeeded. Since we want to 
90
92
   * return false on success, we return the value of the two being != 
92
94
  return iter != all_query_cache.end();
93
95
}
94
96
 
95
 
class PrepareResultsetIterate : public std::unary_function<plugin::QueryCache *, bool>
 
97
class PrepareResultsetIterate
 
98
 : public unary_function<plugin::QueryCache *, bool>
96
99
{
97
100
  Session *session;
98
101
public:
99
102
  PrepareResultsetIterate(Session *session_arg) :
100
 
    std::unary_function<plugin::QueryCache *, bool>(),
101
 
    session(session_arg) { }
 
103
    unary_function<plugin::QueryCache *, bool>(), session(session_arg) { }
102
104
 
103
105
  inline result_type operator()(argument_type handler)
104
106
  {
109
111
{
110
112
  /* Use find_if instead of foreach so that we can collect return codes */
111
113
  QueryCaches::iterator iter=
112
 
    std::find_if(all_query_cache.begin(), all_query_cache.end(),
113
 
                 PrepareResultsetIterate(session));
 
114
    find_if(all_query_cache.begin(), all_query_cache.end(),
 
115
            PrepareResultsetIterate(session));
114
116
  /* If iter is == end() here, that means that all of the plugins returned
115
117
   * false, which in this case means they all succeeded. Since we want to 
116
118
   * return false on success, we return the value of the two being != 
118
120
  return iter != all_query_cache.end();
119
121
}
120
122
 
121
 
class SetResultsetIterate : public std::unary_function<plugin::QueryCache *, bool>
 
123
class SetResultsetIterate
 
124
 : public unary_function<plugin::QueryCache *, bool>
122
125
{
123
126
  Session *session;
124
127
public:
125
128
  SetResultsetIterate(Session *session_arg) :
126
 
    std::unary_function<plugin::QueryCache *, bool>(),
 
129
    unary_function<plugin::QueryCache *, bool>(),
127
130
    session(session_arg) { }
128
131
 
129
132
  inline result_type operator()(argument_type handler)
136
139
{
137
140
  /* Use find_if instead of foreach so that we can collect return codes */
138
141
  QueryCaches::iterator iter=
139
 
    std::find_if(all_query_cache.begin(), all_query_cache.end(),
140
 
                 SetResultsetIterate(session));
 
142
    find_if(all_query_cache.begin(), all_query_cache.end(),
 
143
            SetResultsetIterate(session));
141
144
  /* If iter is == end() here, that means that all of the plugins returned
142
145
   * false, which in this case means they all succeeded. Since we want to 
143
146
   * return false on success, we return the value of the two being != 
146
149
}
147
150
 
148
151
class InsertRecordIterate
149
 
 : public std::unary_function<plugin::QueryCache *, bool>
 
152
 : public unary_function<plugin::QueryCache *, bool>
150
153
{
151
154
  Session *session;
152
155
  List<Item> &item;
153
156
public:
154
157
  InsertRecordIterate(Session *session_arg, List<Item> &item_arg) :
155
 
    std::unary_function<plugin::QueryCache *, bool>(),
 
158
    unary_function<plugin::QueryCache *, bool>(),
156
159
    session(session_arg), item(item_arg) { }
157
160
 
158
161
  inline result_type operator()(argument_type handler)
164
167
{
165
168
  /* Use find_if instead of foreach so that we can collect return codes */
166
169
  QueryCaches::iterator iter=
167
 
    std::find_if(all_query_cache.begin(), all_query_cache.end(),
168
 
                 InsertRecordIterate(session, items));
 
170
    find_if(all_query_cache.begin(), all_query_cache.end(),
 
171
            InsertRecordIterate(session, items));
169
172
  /* If iter is == end() here, that means that all of the plugins returned
170
173
   * false, which in this case means they all succeeded. Since we want to 
171
174
   * return false on success, we return the value of the two being != 
183
186
 
184
187
void plugin::QueryCache::removePlugin(plugin::QueryCache *handler)
185
188
{
186
 
  all_query_cache.erase(std::find(all_query_cache.begin(), all_query_cache.end(),
187
 
                                  handler));
 
189
  all_query_cache.erase(find(all_query_cache.begin(), all_query_cache.end(),
 
190
                        handler));
188
191
}
189
192
 
190
193
} /* namespace drizzled */