MySQL 8.3.0
Source Code Documentation
client_extensions_macros.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2023, 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 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
33
34#define ALLOCATE_EXTENSIONS(OPTS) \
35 (OPTS)->extension = (struct st_mysql_options_extention *)my_malloc( \
36 key_memory_mysql_options, sizeof(struct st_mysql_options_extention), \
37 MYF(MY_WME | MY_ZEROFILL))
38
39#define ENSURE_EXTENSIONS_PRESENT(OPTS) \
40 do { \
41 if (!(OPTS)->extension) ALLOCATE_EXTENSIONS(OPTS); \
42 } while (0)
43
44#define EXTENSION_SET_STRING(OPTS, X, STR) \
45 do { \
46 if ((OPTS)->extension) \
47 my_free((OPTS)->extension->X); \
48 else \
49 ALLOCATE_EXTENSIONS(OPTS); \
50 (OPTS)->extension->X = \
51 ((STR) != nullptr) \
52 ? my_strdup(key_memory_mysql_options, (STR), MYF(MY_WME)) \
53 : NULL; \
54 } while (0)
55
56#define SET_OPTION(opt_var, arg) \
57 do { \
58 if (mysql->options.opt_var) my_free(mysql->options.opt_var); \
59 mysql->options.opt_var = \
60 arg ? my_strdup(key_memory_mysql_options, arg, MYF(MY_WME)) : NULL; \
61 } while (0)
62
63#define EXTENSION_SET_SSL_STRING(OPTS, X, STR, mode) \
64 do { \
65 EXTENSION_SET_STRING(OPTS, X, static_cast<const char *>(STR)); \
66 if ((OPTS)->extension->X) (OPTS)->extension->ssl_mode = mode; \
67 } while (0)
68
69#endif
PSI_memory_key key_memory_MYSQL
Definition: client.cc:166
PSI_memory_key key_memory_mysql_options
Definition: client.cc:164
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:48