MySQL  8.0.17
Source Code Documentation
keycaches.h
Go to the documentation of this file.
1 #ifndef KEYCACHES_INCLUDED
2 #define KEYCACHES_INCLUDED
3 
4 /* Copyright (c) 2002, 2019, 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, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 #include <string.h>
27 
28 #include "keycache.h"
29 #include "lex_string.h"
30 #include "my_inttypes.h"
31 #include "my_sys.h"
33 #include "sql/sql_list.h"
34 #include "sql/thr_malloc.h"
35 
37 typedef int (*process_key_cache_t)(const char *, KEY_CACHE *);
38 
39 /**
40  ilink (intrusive list element) with a name
41 */
42 class NAMED_ILINK : public ilink<NAMED_ILINK> {
43  public:
44  const char *name;
45  size_t name_length;
47 
48  NAMED_ILINK(I_List<NAMED_ILINK> *links, const char *name_arg,
49  size_t name_length_arg, uchar *data_arg)
50  : name_length(name_length_arg), data(data_arg) {
52  MYF(MY_WME));
53  links->push_back(this);
54  }
55 
56  bool cmp(const char *name_cmp, size_t length) {
57  return length == name_length && !memcmp(name, name_cmp, length);
58  }
59 
60  ~NAMED_ILINK() { my_free((void *)name); }
61 };
62 
63 class NAMED_ILIST : public I_List<NAMED_ILINK> {
64  public:
65  void delete_elements();
66 };
67 
70 extern NAMED_ILIST key_caches;
71 
72 KEY_CACHE *create_key_cache(const char *name, size_t length);
73 KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name);
74 KEY_CACHE *get_or_create_key_cache(const char *name, size_t length);
76 
77 #endif /* KEYCACHES_INCLUDED */
unsigned char uchar
Definition: my_inttypes.h:51
PSI_memory_key key_memory_NAMED_ILINK_name
Definition: psi_memory_key.cc:63
KEY_CACHE * get_or_create_key_cache(const char *name, size_t length)
Definition: keycaches.cc:100
#define MY_WME
Definition: my_sys.h:115
const string name("\ame\)
Definition: keycache.h:70
Some integer typedefs for easier portability.
void push_back(T *a)
Pushes new element to the end of the list, i.e. in front of the sentinel.
Definition: sql_list.h:735
Definition: mysql_lex_string.h:39
KEY_CACHE zero_key_cache
@nonexistent_cache.param->value_ptr() points here
Definition: keycaches.cc:66
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46
int(* process_key_cache_t)(const char *, KEY_CACHE *)
Definition: keycaches.h:37
LEX_CSTRING default_key_cache_base
Definition: keycaches.cc:63
NAMED_ILIST key_caches
Definition: keycaches.cc:34
#define MYF(v)
Definition: my_inttypes.h:124
bool process_key_caches(process_key_cache_t func)
Definition: keycaches.cc:111
Common header for many mysys elements.
KEY_CACHE * create_key_cache(const char *name, size_t length)
Definition: keycaches.cc:74
Definition: keycaches.h:63
char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags)
Definition: my_malloc.cc:300
Key cache variable structures.
void delete_elements()
Definition: keycaches.cc:49
KEY_CACHE * get_key_cache(const LEX_CSTRING *cache_name)
Definition: keycaches.cc:68
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75