MySQL 8.4.0
Source Code Documentation
udf_service_util.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#ifndef UDF_SERVICE_UTIL_H
25#define UDF_SERVICE_UTIL_H
26
28
29constexpr int MAX_CHARSET_LEN = 100;
30
31/*
32 This is a UDF utility class to set charset for arguments and
33 return values of UDF.
34
35 For usage please check sql/rpl_async_conn_failover_udf.cc.
36*/
38 private:
39 /* Name of service registry to be acquired. */
40 static std::string m_service_name;
41
42 /* The charset to be used for argument and return values. */
43 static std::string m_charset_name;
44
45 /*
46 The extension type used by UDF metadata
47 (sql/server_component/udf_metadata_imp.cc).
48 */
49 static std::string m_arg_type;
50
51 /**
52 Release the udf_metadata_service from the registry service.
53
54 @retval true if service could not be acquired
55 @retval false Otherwise
56 */
57 static bool deinit();
58
59 /**
60 Acquires the udf_metadata_service from the registry service.
61
62 @retval true if service could not be acquired
63 @retval false Otherwise
64 */
65 static bool init();
66
67 public:
69
71
72 /**
73 Get service name.
74
75 @return Service name.
76 */
77 static std::string get_service_name() { return m_service_name; }
78
79 /**
80 Set the specified character set.
81
82 @param[in] charset_name Character set that has to be set.
83 */
84 static void set_charset(std::string charset_name) {
85 m_charset_name = charset_name;
86 }
87
88 /**
89 Get the current character set getting used.
90
91 @retval Character set name.
92 */
93 std::string get_charset() { return m_charset_name; }
94
95 /**
96 Set the specified character set of UDF return value.
97
98 @param[in] initid UDF_INIT structure
99
100 @retval true Could not set the character set of return value
101 @retval false Otherwise
102 */
103 static bool set_return_value_charset(UDF_INIT *initid);
104
105 /**
106 Set the specified character set of all UDF arguments.
107
108 @param[in] args UDF_ARGS structure
109
110 @retval true Could not set the character set of any of the argument
111 @retval false Otherwise
112 */
113 static bool set_args_charset(UDF_ARGS *args);
114};
115
116#endif /* UDF_SERVICE_UTIL_H */
Definition: udf_service_util.h:37
static std::string m_service_name
Definition: udf_service_util.h:40
static std::string get_service_name()
Get service name.
Definition: udf_service_util.h:77
static std::string m_charset_name
Definition: udf_service_util.h:43
Udf_charset_service()=default
~Udf_charset_service()=default
static bool set_return_value_charset(UDF_INIT *initid)
Set the specified character set of UDF return value.
Definition: udf_service_util.cc:71
static bool deinit()
Release the udf_metadata_service from the registry service.
Definition: udf_service_util.cc:57
std::string get_charset()
Get the current character set getting used.
Definition: udf_service_util.h:93
static std::string m_arg_type
Definition: udf_service_util.h:49
static bool set_args_charset(UDF_ARGS *args)
Set the specified character set of all UDF arguments.
Definition: udf_service_util.cc:89
static bool init()
Acquires the udf_metadata_service from the registry service.
Definition: udf_service_util.cc:39
static void set_charset(std::string charset_name)
Set the specified character set.
Definition: udf_service_util.h:84
Definition: udf_registration_types.h:48
Information about the result of a user defined function.
Definition: udf_registration_types.h:66
constexpr int MAX_CHARSET_LEN
Definition: udf_service_util.h:29