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