MySQL  8.0.22
Source Code Documentation
client_extensions_macros.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 /**
24  @file
25  helper macros to deal with MYSQL options
26 */
27 
28 #ifndef MYSQL_CLIENT_EXTENSIONS_MACROS_H_INCLUDED
29 #define MYSQL_CLIENT_EXTENSIONS_MACROS_H_INCLUDED
30 
32 
33 #define ALLOCATE_EXTENSIONS(OPTS) \
34  (OPTS)->extension = (struct st_mysql_options_extention *)my_malloc( \
35  key_memory_mysql_options, sizeof(struct st_mysql_options_extention), \
36  MYF(MY_WME | MY_ZEROFILL))
37 
38 #define ENSURE_EXTENSIONS_PRESENT(OPTS) \
39  do { \
40  if (!(OPTS)->extension) ALLOCATE_EXTENSIONS(OPTS); \
41  } while (0)
42 
43 #define EXTENSION_SET_STRING(OPTS, X, STR) \
44  do { \
45  if ((OPTS)->extension) \
46  my_free((OPTS)->extension->X); \
47  else \
48  ALLOCATE_EXTENSIONS(OPTS); \
49  (OPTS)->extension->X = \
50  ((STR) != nullptr) \
51  ? my_strdup(key_memory_mysql_options, (STR), MYF(MY_WME)) \
52  : NULL; \
53  } while (0)
54 
55 #define SET_OPTION(opt_var, arg) \
56  do { \
57  if (mysql->options.opt_var) my_free(mysql->options.opt_var); \
58  mysql->options.opt_var = \
59  arg ? my_strdup(key_memory_mysql_options, arg, MYF(MY_WME)) : NULL; \
60  } while (0)
61 
62 #define EXTENSION_SET_SSL_STRING(OPTS, X, STR, mode) \
63  do { \
64  EXTENSION_SET_STRING(OPTS, X, static_cast<const char *>(STR)); \
65  if ((OPTS)->extension->X) (OPTS)->extension->ssl_mode = mode; \
66  } while (0)
67 
68 #endif
PSI_memory_key key_memory_mysql_options
Definition: client.cc:152
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:46