1 /*
2  Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights
3  reserved.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License, version 2.0,
7  as published by the Free Software Foundation.
8 
9  This program is also distributed with certain software (including
10  but not limited to OpenSSL) that is licensed under separate terms,
11  as designated in a particular file or component or in included license
12  documentation.  The authors of MySQL hereby grant you an additional
13  permission to link the program and your derivative works with the
14  separately licensed software that they have included with MySQL.
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
24  02110-1301  USA
25  */
26 
27 
28 
29 ndb_pipeline * get_my_pipeline_config(struct ndb_engine *);
30 
31 void read_cmdline_options(struct ndb_engine *, struct default_engine *,
32                           const char *);
33 
34 int fetch_core_settings(struct ndb_engine *, struct default_engine *);
35 
36 void release_and_free(struct workitem *);
37 
38 ENGINE_ERROR_CODE stats_menu(ADD_STAT add_stat, const void *cookie);
39 
40 /*************** Declarations of functions that implement
41                  the engine interface
42  *********************************************************/
43 static const engine_info* ndb_get_info(ENGINE_HANDLE* handle);
44 
45 static ENGINE_ERROR_CODE ndb_initialize(ENGINE_HANDLE* handle,
46                                         const char* config_str);
47 
48 static void ndb_destroy(ENGINE_HANDLE* handle, bool force);
49 
50 static ENGINE_ERROR_CODE ndb_allocate(ENGINE_HANDLE* handle,
51                                       const void* cookie,
52                                       item **item,
53                                       const void* key,
54                                       const size_t nkey,
55                                       const size_t nbytes,
56                                       const int flags,
57                                       const rel_time_t exptime);
58 
59 static ENGINE_ERROR_CODE ndb_remove(ENGINE_HANDLE* handle,
60                                     const void* cookie,
61                                     const void* key,
62                                     const size_t nkey,
63                                     uint64_t cas,
64                                     uint16_t vbucket);
65 
66 static void ndb_release(ENGINE_HANDLE* handle,
67                         const void *cookie,
68                         item* item);
69 
70 static ENGINE_ERROR_CODE ndb_get(ENGINE_HANDLE* handle,
71                                  const void* cookie,
72                                  item** item,
73                                  const void* key,
74                                  const int nkey,
75                                  uint16_t vbucket);
76 
77 static ENGINE_ERROR_CODE ndb_get_stats(ENGINE_HANDLE* handle,
78                                        const void *cookie,
79                                        const char *stat_key,
80                                        int nkey,
81                                        ADD_STAT add_stat);
82 
83 static void ndb_reset_stats(ENGINE_HANDLE* handle,
84                             const void *cookie);
85 
86 static ENGINE_ERROR_CODE ndb_store(ENGINE_HANDLE* handle,
87                                    const void *cookie,
88                                    item* item,
89                                    uint64_t *cas,
90                                    ENGINE_STORE_OPERATION operation,
91                                    uint16_t vbucket);
92 
93 static ENGINE_ERROR_CODE ndb_arithmetic(ENGINE_HANDLE* handle,
94                                         const void* cookie,
95                                         const void* key,
96                                         const int nkey,
97                                         const bool increment,
98                                         const bool create,
99                                         const uint64_t delta,
100                                         const uint64_t initial,
101                                         const rel_time_t exptime,
102                                         uint64_t *cas,
103                                         uint64_t *result,
104                                         uint16_t vbucket);
105 
106 static ENGINE_ERROR_CODE ndb_flush(ENGINE_HANDLE* handle,
107                                    const void* cookie,
108                                    time_t when);
109 
110 static ENGINE_ERROR_CODE ndb_unknown_command(ENGINE_HANDLE* handle,
111                                              const void* cookie,
112                                              protocol_binary_request_header *request,
113                                              ADD_RESPONSE response);
114 
115 static bool ndb_get_item_info(ENGINE_HANDLE *handle,
116                               const void *cookie,
117                               const item* item,
118                               item_info *item_info);
119 
120 ENGINE_ERROR_CODE default_engine_create_instance(uint64_t,
121                                                  GET_SERVER_API,
122                                                  ENGINE_HANDLE**);
123 
124