MySQL  8.0.19
Source Code Documentation
udf_registration_types.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 2019, 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 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;
56 } UDF_ARGS;
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;
72 } UDF_INIT;
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 */
UDF_INIT::ptr
char * ptr
For string functions.
Definition: udf_registration_types.h:69
UDF_INIT
Information about the result of a user defined function.
Definition: udf_registration_types.h:65
Udf_func_deinit
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:79
UDF_ARGS::lengths
unsigned long * lengths
Length of string arguments.
Definition: udf_registration_types.h:51
STRING_RESULT
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:40
UDF_ARGS::arg_count
unsigned int arg_count
Number of arguments.
Definition: udf_registration_types.h:48
UDF_ARGS::attribute_lengths
unsigned long * attribute_lengths
Length of attribute arguments.
Definition: udf_registration_types.h:54
UDF_ARGS::maybe_null
char * maybe_null
Set to 1 for all maybe_null args.
Definition: udf_registration_types.h:52
INVALID_RESULT
@ INVALID_RESULT
Definition: udf_registration_types.h:39
Item_result
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
REAL_RESULT
@ REAL_RESULT
char *
Definition: udf_registration_types.h:41
ROW_RESULT
@ ROW_RESULT
long long
Definition: udf_registration_types.h:43
Udf_func_clear
void(* Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:76
Udf_func_double
double(* Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:82
UDF_ARGS::attributes
char ** attributes
Pointer to attribute name.
Definition: udf_registration_types.h:53
Udf_func_any
void(* Udf_func_any)(void)
Definition: udf_registration_types.h:81
Udf_func_longlong
long long(* Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:84
UDF_ARGS
Definition: udf_registration_types.h:47
UDF_INIT
struct UDF_INIT UDF_INIT
Information about the result of a user defined function.
UDFTYPE_AGGREGATE
@ UDFTYPE_AGGREGATE
Definition: udf_registration_types.h:74
UDF_INIT::extension
void * extension
1 if function always returns the same value
Definition: udf_registration_types.h:71
UDF_INIT::max_length
unsigned long max_length
for real functions
Definition: udf_registration_types.h:68
UDF_ARGS::extension
void * extension
Definition: udf_registration_types.h:55
bool
#define bool
Definition: config_static.h:42
UDF_ARGS::arg_type
enum Item_result * arg_type
Pointer to item_results.
Definition: udf_registration_types.h:49
DECIMAL_RESULT
@ DECIMAL_RESULT
not valid for UDFs
Definition: udf_registration_types.h:44
UDF_INIT::decimals
unsigned int decimals
1 if function can return NULL
Definition: udf_registration_types.h:67
Udf_func_init
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:80
UDFTYPE_FUNCTION
@ UDFTYPE_FUNCTION
Definition: udf_registration_types.h:74
UDF_ARGS
struct UDF_ARGS UDF_ARGS
INT_RESULT
@ INT_RESULT
double
Definition: udf_registration_types.h:42
Udf_func_add
void(* Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *)
Definition: udf_registration_types.h:77
UDF_INIT::maybe_null
bool maybe_null
Definition: udf_registration_types.h:66
Item_udftype
Item_udftype
Definition: udf_registration_types.h:74
UDF_INIT::const_item
bool const_item
free pointer for function data
Definition: udf_registration_types.h:70
UDF_ARGS::args
char ** args
Pointer to argument.
Definition: udf_registration_types.h:50