MySQL  8.0.21
Source Code Documentation
udf_registration.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 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 #ifndef UDF_REGISTRATION_H
24 #define UDF_REGISTRATION_H
25 
28 
29 /**
30  Service for adding and removing UDF functions
31 */
32 BEGIN_SERVICE_DEFINITION(udf_registration)
33 /**
34  Registers a UDF function with a given name.
35 
36  The name must be unique. Does not store in any table, just
37  updates the global function list.
38  Plugins/components need to handle registration deregistration
39  during their initialization and deinitialization.
40  Registers a scalar UDF by default.
41  @sa udf_aggregates
42 
43  @param name name of the function
44  @param return_type return type.
45  @param func function to call
46  @param init_func function to call at query start
47  @param deinit_func function to call at query cleanup
48  @return Status of performed operation
49  @retval false success
50  @retval true failure
51 */
52 DECLARE_BOOL_METHOD(udf_register,
53  (const char *func_name, enum Item_result return_type,
54  Udf_func_any func, Udf_func_init init_func,
55  Udf_func_deinit deinit_func));
56 
57 /**
58  Unregisters a UDF function with a given name.
59 
60  Does not store in any table, just updates the global function list.
61  Plugins/components need to handle registration deregistration
62  during their initialization and deinitialization.
63 
64  @param name name of the function
65  @param[out] was_present set to non-zero if the UDF was present, but locked
66  @return Status of performed operation
67  @retval false success
68  @retval true failure
69 */
70 DECLARE_BOOL_METHOD(udf_unregister, (const char *name, int *was_present));
71 END_SERVICE_DEFINITION(udf_registration)
72 
73 /**
74  Service for turning
75 */
76 BEGIN_SERVICE_DEFINITION(udf_registration_aggregate)
77 /**
78  Registers an aggregate UDF function with a given name.
79 
80  The name must be unique. Does not store in any table, just
81  updates the global function list.
82  Plugins/components need to handle registration deregistration
83  during their initialization and deinitialization.
84  You can use udf_registration::unregister to unregister the
85  function.
86 
87  @sa udf_registration
88 
89  @param name name of the function
90  @param return_type return type.
91  @param func function to call
92  @param init_func function to call at query start
93  @param deinit_func function to call at query cleanup
94  @param add_func function to call at adding a row to the current aggregate
95  @param clear_func function to call at the start of a new aggregate group
96  @return Status of performed operation
97  @retval false success
98  @retval true failure
99 */
100 DECLARE_BOOL_METHOD(udf_register,
101  (const char *func_name, enum Item_result return_type,
102  Udf_func_any func, Udf_func_init init_func,
103  Udf_func_deinit deinit_func, Udf_func_add add_func,
104  Udf_func_clear clear_func));
105 
106 /**
107  Unregisters an aggregate UDF function with a given name.
108 
109  Does not store in any table, just updates the global function list.
110  Plugins/components need to handle registration deregistration
111  during their initialization and deinitialization.
112 
113  Currently it's a synonym for udf_registration::udf_unregister.
114 
115  @param name name of the function
116  @param[out] was_present set to non-zero if the UDF was present, but locked
117  @return Status of performed operation
118  @retval false success
119  @retval true failure
120 */
121 DECLARE_BOOL_METHOD(udf_unregister, (const char *name, int *was_present));
122 END_SERVICE_DEFINITION(udf_registration_aggregate)
123 #endif
void(* Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:76
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
void(* Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:77
void(* Udf_func_any)(void)
Definition: udf_registration_types.h:81
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:80
case opt name
Definition: sslopt-case.h:32
#define END_SERVICE_DEFINITION(name)
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:79
#define BEGIN_SERVICE_DEFINITION(name)
#define DECLARE_BOOL_METHOD(name, args)