1/* -*- C++ -*- */
2/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
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 as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17#ifndef _SP_CACHE_H_
18#define _SP_CACHE_H_
19
20#ifdef USE_PRAGMA_INTERFACE
21#pragma interface /* gcc class implementation */
22#endif
23
24/*
25 Stored procedures/functions cache. This is used as follows:
26 * Each thread has its own cache.
27 * Each sp_head object is put into its thread cache before it is used, and
28 then remains in the cache until deleted.
29*/
30
31class sp_head;
32class sp_cache;
33class Database_qualified_name;
34
35/*
36 Cache usage scenarios:
37 1. Application-wide init:
38 sp_cache_init();
39
40 2. SP execution in thread:
41 2.1 While holding sp_head* pointers:
42
43 // look up a routine in the cache (no checks if it is up to date or not)
44 sp_cache_lookup();
45
46 sp_cache_insert();
47 sp_cache_invalidate();
48
49 2.2 When not holding any sp_head* pointers:
50 sp_cache_flush_obsolete();
51
52 3. Before thread exit:
53 sp_cache_clear();
54*/
55
56void sp_cache_init();
57void sp_cache_end();
58void sp_cache_clear(sp_cache **cp);
59void sp_cache_insert(sp_cache **cp, sp_head *sp);
60sp_head *sp_cache_lookup(sp_cache **cp, const Database_qualified_name *name);
61void sp_cache_invalidate();
62void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp);
63ulong sp_cache_version();
64void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
65
66#endif /* _SP_CACHE_H_ */
67