MySQL 9.1.0
Source Code Documentation
sp_cache.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2/* Copyright (c) 2002, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef _SP_CACHE_H_
26#define _SP_CACHE_H_
27
28#include <sys/types.h>
29
30#include "my_inttypes.h"
31
32/*
33 Stored procedures/functions cache. This is used as follows:
34 * Each thread has its own cache.
35 * Each sp_head object is put into its thread cache before it is used, and
36 then remains in the cache until deleted.
37*/
38
39class sp_cache;
40class sp_head;
41class sp_name;
42
43/*
44 Cache usage scenarios:
45 1. SP execution in thread:
46 1.1 While holding sp_head* pointers:
47
48 // look up a routine in the cache (no checks if it is up to date or not)
49 sp_cache_lookup();
50
51 sp_cache_insert();
52 sp_cache_invalidate();
53
54 1.2 When not holding any sp_head* pointers:
55 sp_cache_flush_obsolete();
56
57 2. Before thread exit:
58 sp_cache_clear();
59*/
60
61void sp_cache_clear(sp_cache **cp);
62void sp_cache_insert(sp_cache **cp, sp_head *sp);
67void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
68
69/**
70 * @brief Check if the sp_cache contains the specified stored program.
71 *
72 * @note If the sp is part of a recursion, check if the first instance is part
73 * of the sp_cache
74 *
75 * @param[in] cp - the sp_cache that is to be checked.
76 * @param[in] sp - the stored program that needs to be part of that cache.
77 * @return true if the element is in the cache.
78 * @return false if not.
79 */
80bool sp_cache_has(sp_cache *cp, sp_head *sp);
81
82#endif /* _SP_CACHE_H_ */
Definition: sp_cache.cc:42
sp_head represents one instance of a stored program.
Definition: sp_head.h:383
Definition: sp_head.h:123
Some integer typedefs for easier portability.
int64_t int64
Definition: my_inttypes.h:68
sp_head * sp_cache_lookup(sp_cache **cp, const sp_name *name)
Definition: sp_cache.cc:167
void sp_cache_insert(sp_cache **cp, sp_head *sp)
Definition: sp_cache.cc:138
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp)
Remove an out-of-date SP from the cache.
Definition: sp_cache.cc:201
bool sp_cache_has(sp_cache *cp, sp_head *sp)
Check if the sp_cache contains the specified stored program.
Definition: sp_cache.cc:237
void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements)
Enforce that the current number of elements in the cache don't exceed the argument value by flushing ...
Definition: sp_cache.cc:222
int64 sp_cache_version()
Return the current global version of the cache.
Definition: sp_cache.cc:212
void sp_cache_invalidate()
Definition: sp_cache.cc:185
void sp_cache_clear(sp_cache **cp)
Definition: sp_cache.cc:115
case opt name
Definition: sslopt-case.h:29