MySQL 8.2.0
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, 2023, Oracle and/or its affiliates.
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_view>
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
36typedef int (*process_key_cache_t)(std::string_view, KEY_CACHE *);
37
38/**
39 ilink (intrusive list element) with a name
40*/
41class NAMED_ILINK : public ilink<NAMED_ILINK> {
42 public:
43 const std::string name; ///< case-sensitive, system character set
45
46 NAMED_ILINK(I_List<NAMED_ILINK> *links, const std::string_view &name_arg,
47 uchar *data_arg)
48 : name(name_arg), data(data_arg) {
49 links->push_back(this);
50 }
51
52 bool cmp(const char *name_cmp, size_t length) {
53 return length == name.size() && !memcmp(name.data(), name_cmp, length);
54 }
55};
56
57class NAMED_ILIST : public I_List<NAMED_ILINK> {
58 public:
59 void delete_elements();
60};
61
65
66/**
67 Create a MyISAM Multiple Key Cache
68
69 @param name Cache name (case insensitive, system character set).
70*/
71KEY_CACHE *create_key_cache(std::string_view name);
72/**
73 Resolve a MyISAM Multiple Key Cache by name.
74
75 @param cache_name Cache name (case insensitive, system character set).
76
77 @returns New key cache on success, otherwise nullptr.
78*/
79KEY_CACHE *get_key_cache(std::string_view cache_name);
80/**
81 Resolve an existent MyISAM Multiple Key Cache by name, otherwise create a
82 new one.
83
84 @param name Cache name (case insensitive, system character set)
85
86 @returns Key cache on success, otherwise nullptr.
87*/
88KEY_CACHE *get_or_create_key_cache(std::string_view name);
90
91#endif /* KEYCACHES_INCLUDED */
Definition: keycaches.h:57
void delete_elements()
Definition: keycaches.cc:49
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:747
Key cache variable structures.
NAMED_ILIST key_caches
Definition: keycaches.cc:34
const LEX_CSTRING default_key_cache_base
Definition: keycaches.cc:62
int(* process_key_cache_t)(std::string_view, KEY_CACHE *)
Definition: keycaches.h:36
bool process_key_caches(process_key_cache_t func)
Definition: keycaches.cc:109
KEY_CACHE * create_key_cache(std::string_view name)
Create a MyISAM Multiple Key Cache.
Definition: keycaches.cc:75
KEY_CACHE * get_or_create_key_cache(std::string_view name)
Resolve an existent MyISAM Multiple Key Cache by name, otherwise create a new one.
Definition: keycaches.cc:102
KEY_CACHE * get_key_cache(std::string_view cache_name)
Resolve a MyISAM Multiple Key Cache by name.
Definition: keycaches.cc:67
KEY_CACHE zero_key_cache
@nonexistent_cache.param->value_ptr() points here
Definition: keycaches.cc:65
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
Common header for many mysys elements.
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
case opt name
Definition: sslopt-case.h:32
Definition: keycache.h:72
Definition: mysql_lex_string.h:39