1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Pedantic config
use TokenStream;
pub use match_variant;
/// # Register exposed function names required for a UDF
///
/// This macro is applied to an `impl BasicUdf` block (and an `AggregateUdf`
/// block, if applicable) and exposed the C-callable functions that
/// `MariaDB`/`MySQL` expect.
///
/// Usage:
///
/// ```ignore
/// #[register]
/// impl BasicUdf for MyStruct {
/// ...
/// }
///
/// #[register]
/// impl AggregateUdf for MyStruct {
/// ...
/// }
/// ```
///
/// Its process is as follows:
///
/// - Convert the implemented struct's name to snake case to create the function
/// name
/// - Obtain the return type from the `Returns` type in `BasicUdf`
/// - Create functions `fn_name`, `fn_name_init`, and `fn_name_deinit` with
/// correct signatures and interfaces
/// - If applied on an `impl AggregateUdf` block, create `fn_name_clear` and
/// `fn_name_add`. `fn_name_remove` is also included if it is redefined
// Arguments don't yet work
//
// # Arguments
//
// - `#[udf::register(name = "new_name")]` will specify a name for your SQL
// function. If this is not specified, your struct name will be converted to
// snake case and used (e.g. `AddAllNumbers` would become `add_all_numbers`
// by default).
// #[cfg(not(test))] // Work around for rust-lang/rust#62127