MySQL 9.0.0
Source Code Documentation
client_extensions_macros.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
13 the program or referenced in the documentation.
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
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file
26 helper macros to deal with MYSQL options
27*/
28
29#ifndef MYSQL_CLIENT_EXTENSIONS_MACROS_H_INCLUDED
30#define MYSQL_CLIENT_EXTENSIONS_MACROS_H_INCLUDED
31
34
35#define ALLOCATE_EXTENSIONS(OPTS) \
36 (OPTS)->extension = (struct st_mysql_options_extention *)my_malloc( \
37 key_memory_mysql_options, sizeof(struct st_mysql_options_extention), \
38 MYF(MY_WME | MY_ZEROFILL))
39
40#define ENSURE_EXTENSIONS_PRESENT(OPTS) \
41 do { \
42 if (!(OPTS)->extension) ALLOCATE_EXTENSIONS(OPTS); \
43 } while (0)
44
45#define EXTENSION_SET_STRING(OPTS, X, STR) \
46 do { \
47 if ((OPTS)->extension) \
48 my_free((OPTS)->extension->X); \
49 else \
50 ALLOCATE_EXTENSIONS(OPTS); \
51 (OPTS)->extension->X = \
52 ((STR) != nullptr) \
53 ? my_strdup(key_memory_mysql_options, (STR), MYF(MY_WME)) \
54 : NULL; \
55 } while (0)
56
57#define SET_OPTION(opt_var, arg) \
58 do { \
59 if (mysql->options.opt_var) my_free(mysql->options.opt_var); \
60 mysql->options.opt_var = \
61 arg ? my_strdup(key_memory_mysql_options, arg, MYF(MY_WME)) : NULL; \
62 } while (0)
63
64#define EXTENSION_SET_SSL_STRING(OPTS, X, STR, mode) \
65 do { \
66 EXTENSION_SET_STRING(OPTS, X, static_cast<const char *>(STR)); \
67 if ((OPTS)->extension->X) (OPTS)->extension->ssl_mode = mode; \
68 } while (0)
69
70#endif
PSI_memory_key key_memory_MYSQL
Definition: client.cc:167
PSI_memory_key key_memory_mysql_options
Definition: client.cc:165
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49