Debian Codegraph @

unittest/gunit/fake_costmodel.h

raw symbols SCIP
1 #ifndef FAKE_COSTMODEL_INCLUDED
2 #define FAKE_COSTMODEL_INCLUDED
3
4 /*
5 Copyright (c) 2014, 2026, Oracle and/or its affiliates.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License, version 2.0,
9 as published by the Free Software Foundation.
10
11 This program is designed to work with certain software (including
12 but not limited to OpenSSL) that is licensed under separate terms,
13 as designated in a particular file or component or in included license
14 documentation. The authors of MySQL hereby grant you an additional
15 permission to link the program and your derivative works with the
16 separately licensed software that they have either included with
17 the program or referenced in the documentation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License, version 2.0, for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
27
28 #include <stddef.h>
29
30 #include "sql/opt_costconstants.h"
31 #include "sql/opt_costmodel.h"
32
33 /**
34 This is is a "fake" cost model that can be used in unit tests that
35 do not link with the server libraries.
36 */
37
38 class Fake_Cost_model_server : public Cost_model_server {
39 public:
40 Fake_Cost_model_server() {
41 // Create default values for server cost constants
42 m_server_cost_constants = new Server_cost_constants();
43 #if !defined(NDEBUG)
44 m_initialized = true;
45 #endif
46 }
47
48 ~Fake_Cost_model_server() override {
49 delete m_server_cost_constants;
50 m_server_cost_constants = nullptr;
51 }
52 };
53
54 class Fake_Cost_model_table : public Cost_model_table {
55 public:
56 Fake_Cost_model_table() {
57 // Create a fake cost model server object that will provide
58 // cost constants for server operations
59 m_cost_model_server = new Fake_Cost_model_server();
60
61 // Allocate cost constants for operations on tables
62 m_se_cost_constants = new SE_cost_constants();
63
64 #if !defined(NDEBUG)
65 m_initialized = true;
66 #endif
67 }
68
69 ~Fake_Cost_model_table() {
70 delete m_cost_model_server;
71 m_cost_model_server = nullptr;
72 delete m_se_cost_constants;
73 m_se_cost_constants = nullptr;
74 }
75 };
76
77 #endif /* FAKE_COSTMODEL_INCLUDED */