MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
keycaches.h
1 #ifndef KEYCACHES_INCLUDED
2 #define KEYCACHES_INCLUDED
3 
4 /* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
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; version 2 of the License.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software Foundation,
17  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
18 
19 #include "sql_list.h"
20 #include <keycache.h>
21 
22 extern "C"
23 {
24  typedef int (*process_key_cache_t) (const char *, KEY_CACHE *);
25 }
26 
30 class NAMED_ILINK :public ilink<NAMED_ILINK>
31 {
32 public:
33  const char *name;
34  uint name_length;
35  uchar* data;
36 
37  NAMED_ILINK(I_List<NAMED_ILINK> *links, const char *name_arg,
38  uint name_length_arg, uchar* data_arg)
39  :name_length(name_length_arg), data(data_arg)
40  {
41  name= my_strndup(name_arg, name_length, MYF(MY_WME));
42  links->push_back(this);
43  }
44 
45  bool cmp(const char *name_cmp, uint length)
46  {
47  return length == name_length && !memcmp(name, name_cmp, length);
48  }
49 
50  ~NAMED_ILINK()
51  {
52  my_free((void *) name);
53  }
54 };
55 
56 class NAMED_ILIST: public I_List<NAMED_ILINK>
57 {
58  public:
59  void delete_elements(void (*free_element)(const char*, uchar*));
60 };
61 
62 extern LEX_STRING default_key_cache_base;
63 extern KEY_CACHE zero_key_cache;
64 extern NAMED_ILIST key_caches;
65 
66 KEY_CACHE *create_key_cache(const char *name, uint length);
67 KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
68 KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
69 void free_key_cache(const char *name, KEY_CACHE *key_cache);
70 bool process_key_caches(process_key_cache_t func);
71 
72 #endif /* KEYCACHES_INCLUDED */