MySQL 9.1.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, 2024, 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 designed to work 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 either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include <string_view>
28
29#include "keycache.h"
30#include "lex_string.h"
31#include "my_inttypes.h"
32#include "my_sys.h"
34#include "sql/sql_list.h"
35#include "sql/thr_malloc.h"
36
37typedef int (*process_key_cache_t)(std::string_view, KEY_CACHE *);
38
39/**
40 ilink (intrusive list element) with a name
41*/
42class NAMED_ILINK : public ilink<NAMED_ILINK> {
43 public:
44 const std::string name; ///< case-sensitive, system character set
46
47 NAMED_ILINK(I_List<NAMED_ILINK> *links, const std::string_view &name_arg,
48 uchar *data_arg)
49 : name(name_arg), data(data_arg) {
50 links->push_back(this);
51 }
52
53 bool cmp(const char *name_cmp, size_t length) {
54 return length == name.size() && !memcmp(name.data(), name_cmp, length);
55 }
56};
57
58class NAMED_ILIST : public I_List<NAMED_ILINK> {
59 public:
60 void delete_elements();
61};
62
66
67/**
68 Create a MyISAM Multiple Key Cache
69
70 @param name Cache name (case insensitive, system character set).
71*/
72KEY_CACHE *create_key_cache(std::string_view name);
73/**
74 Resolve a MyISAM Multiple Key Cache by name.
75
76 @param cache_name Cache name (case insensitive, system character set).
77
78 @returns New key cache on success, otherwise nullptr.
79*/
80KEY_CACHE *get_key_cache(std::string_view cache_name);
81/**
82 Resolve an existent MyISAM Multiple Key Cache by name, otherwise create a
83 new one.
84
85 @param name Cache name (case insensitive, system character set)
86
87 @returns Key cache on success, otherwise nullptr.
88*/
89KEY_CACHE *get_or_create_key_cache(std::string_view name);
91
92#endif /* KEYCACHES_INCLUDED */
Definition: keycaches.h:58
void delete_elements()
Definition: keycaches.cc:50
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:808
Key cache variable structures.
NAMED_ILIST key_caches
Definition: keycaches.cc:35
const LEX_CSTRING default_key_cache_base
Definition: keycaches.cc:63
int(* process_key_cache_t)(std::string_view, KEY_CACHE *)
Definition: keycaches.h:37
bool process_key_caches(process_key_cache_t func)
Definition: keycaches.cc:110
KEY_CACHE * create_key_cache(std::string_view name)
Create a MyISAM Multiple Key Cache.
Definition: keycaches.cc:76
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:103
KEY_CACHE * get_key_cache(std::string_view cache_name)
Resolve a MyISAM Multiple Key Cache by name.
Definition: keycaches.cc:68
KEY_CACHE zero_key_cache
@nonexistent_cache.param->value_ptr() points here
Definition: keycaches.cc:66
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
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:76
case opt name
Definition: sslopt-case.h:29
Definition: keycache.h:73
Definition: mysql_lex_string.h:40