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