1 /* -*- C++ -*- */
2 /* Copyright (c) 2002, 2021, 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 also distributed 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 included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software Foundation,
22    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
23 
24 #ifndef _SP_CACHE_H_
25 #define _SP_CACHE_H_
26 
27 #include "my_global.h"                          /* ulong */
28 
29 /*
30   Stored procedures/functions cache. This is used as follows:
31    * Each thread has its own cache.
32    * Each sp_head object is put into its thread cache before it is used, and
33      then remains in the cache until deleted.
34 */
35 
36 class sp_head;
37 class sp_cache;
38 class sp_name;
39 
40 /*
41   Cache usage scenarios:
42   1. SP execution in thread:
43   1.1 While holding sp_head* pointers:
44 
45     // look up a routine in the cache (no checks if it is up to date or not)
46     sp_cache_lookup();
47 
48     sp_cache_insert();
49     sp_cache_invalidate();
50 
51   1.2 When not holding any sp_head* pointers:
52     sp_cache_flush_obsolete();
53 
54   2. Before thread exit:
55     sp_cache_clear();
56 */
57 
58 void sp_cache_clear(sp_cache **cp);
59 void sp_cache_insert(sp_cache **cp, sp_head *sp);
60 sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name);
61 void sp_cache_invalidate();
62 void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp);
63 int64 sp_cache_version();
64 void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
65 
66 #endif /* _SP_CACHE_H_ */
67