MySQL  8.0.27
Source Code Documentation
udf_registration_types.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 2021, 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 Without limiting anything contained in the foregoing, this file,
15 which is part of C Driver for MySQL (Connector/C), is also subject to the
16 Universal FOSS Exception, version 1.0, a copy of which can be found at
17 http://oss.oracle.com/licenses/universal-foss-exception.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License, version 2.0, for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
27 
28 #ifndef UDF_REGISTRATION_TYPES_H
29 #define UDF_REGISTRATION_TYPES_H
30 
31 #ifndef MYSQL_ABI_CHECK
32 #include <stdbool.h>
33 #endif
34 
35 /**
36 Type of the user defined function return slot and arguments
37 */
39  INVALID_RESULT = -1, /** not valid for UDFs */
40  STRING_RESULT = 0, /** char * */
41  REAL_RESULT, /** double */
42  INT_RESULT, /** long long */
43  ROW_RESULT, /** not valid for UDFs */
44  DECIMAL_RESULT /** char *, to be converted to/from a decimal */
45 };
46 
47 typedef struct UDF_ARGS {
48  unsigned int arg_count; /**< Number of arguments */
49  enum Item_result *arg_type; /**< Pointer to item_results */
50  char **args; /**< Pointer to argument */
51  unsigned long *lengths; /**< Length of string arguments */
52  char *maybe_null; /**< Set to 1 for all maybe_null args */
53  char **attributes; /**< Pointer to attribute name */
54  unsigned long *attribute_lengths; /**< Length of attribute arguments */
55  void *extension;
57 
58 /**
59 Information about the result of a user defined function
60 
61 @todo add a notion for determinism of the UDF.
62 
63 @sa Item_udf_func::update_used_tables()
64 */
65 typedef struct UDF_INIT {
66  bool maybe_null; /** 1 if function can return NULL */
67  unsigned int decimals; /** for real functions */
68  unsigned long max_length; /** For string functions */
69  char *ptr; /** free pointer for function data */
70  bool const_item; /** 1 if function always returns the same value */
71  void *extension;
73 
75 
76 typedef void (*Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *);
77 typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *,
78  unsigned char *);
79 typedef void (*Udf_func_deinit)(UDF_INIT *);
80 typedef bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *);
81 typedef void (*Udf_func_any)(void);
82 typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *,
83  unsigned char *);
84 typedef long long (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *,
85  unsigned char *);
86 typedef char *(*Udf_func_string)(UDF_INIT *, UDF_ARGS *, char *,
87  unsigned long *, unsigned char *,
88  unsigned char *);
89 
90 #endif /* UDF_REGISTRATION_TYPES_H */
Definition: udf_registration_types.h:47
char ** args
Pointer to argument.
Definition: udf_registration_types.h:50
unsigned long * attribute_lengths
Length of attribute arguments.
Definition: udf_registration_types.h:54
char * maybe_null
Set to 1 for all maybe_null args.
Definition: udf_registration_types.h:52
char ** attributes
Pointer to attribute name.
Definition: udf_registration_types.h:53
void * extension
Definition: udf_registration_types.h:55
enum Item_result * arg_type
Pointer to item_results.
Definition: udf_registration_types.h:49
unsigned int arg_count
Number of arguments.
Definition: udf_registration_types.h:48
unsigned long * lengths
Length of string arguments.
Definition: udf_registration_types.h:51
Information about the result of a user defined function.
Definition: udf_registration_types.h:65
unsigned long max_length
for real functions
Definition: udf_registration_types.h:68
bool maybe_null
Definition: udf_registration_types.h:66
bool const_item
free pointer for function data
Definition: udf_registration_types.h:70
unsigned int decimals
1 if function can return NULL
Definition: udf_registration_types.h:67
void * extension
1 if function always returns the same value
Definition: udf_registration_types.h:71
char * ptr
For string functions.
Definition: udf_registration_types.h:69
long long(* Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:84
struct UDF_INIT UDF_INIT
Information about the result of a user defined function.
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:79
double(* Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:82
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:40
@ DECIMAL_RESULT
not valid for UDFs
Definition: udf_registration_types.h:44
@ REAL_RESULT
char *
Definition: udf_registration_types.h:41
@ INT_RESULT
double
Definition: udf_registration_types.h:42
@ INVALID_RESULT
Definition: udf_registration_types.h:39
@ ROW_RESULT
long long
Definition: udf_registration_types.h:43
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:80
void(* Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:76
struct UDF_ARGS UDF_ARGS
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
Item_udftype
Definition: udf_registration_types.h:74
@ UDFTYPE_FUNCTION
Definition: udf_registration_types.h:74
@ UDFTYPE_AGGREGATE
Definition: udf_registration_types.h:74