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*/
39enum Item_result {
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;
57} UDF_ARGS;
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;
73} UDF_INIT;
74
75enum Item_udftype { UDFTYPE_FUNCTION = 1, UDFTYPE_AGGREGATE };
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 */
92

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of include/mysql/udf_registration_types.h