|
1 | 1 | #ifndef ITEM_UUIDFUNC_INCLUDED |
2 | 2 | #define ITEM_UUIDFUNC_INCLUDED |
3 | 3 |
|
4 | | -/* Copyright (c) 2019,2021, MariaDB Corporation |
| 4 | +/* Copyright (c) 2019,2024, MariaDB Corporation |
5 | 5 |
|
6 | 6 | This program is free software; you can redistribute it and/or modify |
7 | 7 | it under the terms of the GNU General Public License as published by |
|
18 | 18 |
|
19 | 19 |
|
20 | 20 | #include "item.h" |
21 | | -#include "sql_type_uuid.h" |
| 21 | +#include "sql_type_uuid_v1.h" |
| 22 | +#include "sql_type_uuid_v4.h" |
22 | 23 |
|
23 | 24 | class Item_func_sys_guid: public Item_str_func |
24 | 25 | { |
@@ -49,46 +50,54 @@ class Item_func_sys_guid: public Item_str_func |
49 | 50 | { return get_item_copy<Item_func_sys_guid>(thd, this); } |
50 | 51 | }; |
51 | 52 |
|
52 | | -class Item_func_uuid: public Type_handler_uuid_new::Item_fbt_func |
| 53 | + |
| 54 | +template<class UUIDvX> |
| 55 | +class Item_func_uuid_vx: public Type_handler_uuid_new::Item_fbt_func |
53 | 56 | { |
54 | 57 | public: |
55 | | - Item_func_uuid(THD *thd): Item_fbt_func(thd) { } |
| 58 | + using Item_fbt_func::Item_fbt_func; |
56 | 59 | bool const_item() const override { return false; } |
57 | 60 | table_map used_tables() const override { return RAND_TABLE_BIT; } |
58 | 61 | bool check_vcol_func_processor(void *arg) override |
59 | 62 | { |
60 | 63 | return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC); |
61 | 64 | } |
62 | | - LEX_CSTRING func_name_cstring() const override |
63 | | - { |
64 | | - static LEX_CSTRING name= {STRING_WITH_LEN("uuid") }; |
65 | | - return name; |
66 | | - } |
67 | 65 | String *val_str(String *str) override |
68 | 66 | { |
69 | 67 | DBUG_ASSERT(fixed()); |
70 | | - return UUIDv1().to_string(str) ? NULL : str; |
| 68 | + return UUIDvX().to_string(str) ? NULL : str; |
71 | 69 | } |
72 | 70 | bool val_native(THD *thd, Native *to) override |
73 | 71 | { |
74 | 72 | DBUG_ASSERT(fixed()); |
75 | | - return UUIDv1::construct_native(to); |
| 73 | + return UUIDvX::construct_native(to); |
| 74 | + } |
| 75 | +}; |
| 76 | + |
| 77 | + |
| 78 | +class Item_func_uuid: public Item_func_uuid_vx<UUIDv1> |
| 79 | +{ |
| 80 | +public: |
| 81 | + using Item_func_uuid_vx::Item_func_uuid_vx; |
| 82 | + LEX_CSTRING func_name_cstring() const override |
| 83 | + { |
| 84 | + static LEX_CSTRING name= {STRING_WITH_LEN("uuid") }; |
| 85 | + return name; |
76 | 86 | } |
77 | 87 | Item *do_get_copy(THD *thd) const override |
78 | 88 | { return get_item_copy<Item_func_uuid>(thd, this); } |
79 | 89 | }; |
80 | 90 |
|
81 | | -class Item_func_uuid_v4: public Item_func_uuid |
| 91 | + |
| 92 | +class Item_func_uuid_v4: public Item_func_uuid_vx<UUIDv4> |
82 | 93 | { |
83 | 94 | public: |
84 | | - Item_func_uuid_v4(THD *thd): Item_func_uuid(thd) { } |
| 95 | + using Item_func_uuid_vx::Item_func_uuid_vx; |
85 | 96 | LEX_CSTRING func_name_cstring() const override |
86 | 97 | { |
87 | 98 | static LEX_CSTRING name= {STRING_WITH_LEN("uuidv4") }; |
88 | 99 | return name; |
89 | 100 | } |
90 | | - String *val_str(String *) override; |
91 | | - bool val_native(THD *thd, Native *to) override; |
92 | 101 | Item *do_get_copy(THD *thd) const override |
93 | 102 | { return get_item_copy<Item_func_uuid_v4>(thd, this); } |
94 | 103 | }; |
|
0 commit comments