summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r--sql/item_strfunc.h92
1 files changed, 53 insertions, 39 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 258c0e26bad..86a095a39e6 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -3,7 +3,7 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2021, MariaDB
+ Copyright (c) 2009, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -271,6 +271,25 @@ public:
{ return get_item_copy<Item_func_aes_decrypt>(thd, this); }
};
+class Item_func_natural_sort_key : public Item_str_func
+{
+public:
+ Item_func_natural_sort_key(THD *thd, Item *a)
+ : Item_str_func(thd, a){};
+ String *val_str(String *) override;
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("natural_sort_key")};
+ return name;
+ }
+ bool fix_length_and_dec(void) override;
+ Item *get_copy(THD *thd) override
+ {
+ return get_item_copy<Item_func_natural_sort_key>(thd, this);
+ }
+
+ bool check_vcol_func_processor(void *arg) override;
+};
class Item_func_concat :public Item_str_func
{
@@ -587,6 +606,23 @@ public:
{ return get_item_copy<Item_func_substr>(thd, this); }
};
+class Item_func_sformat :public Item_str_func
+{
+ String *val_arg;
+public:
+ Item_func_sformat(THD *thd, List<Item> &list);
+ ~Item_func_sformat() { delete [] val_arg; }
+ String *val_str(String*) override;
+ bool fix_length_and_dec() override;
+ LEX_CSTRING func_name_cstring() const override
+ {
+ static LEX_CSTRING name= {STRING_WITH_LEN("sformat") };
+ return name;
+ }
+ Item *get_copy(THD *thd) override
+ { return get_item_copy<Item_func_sformat>(thd, this); }
+};
+
class Item_func_substr_oracle :public Item_func_substr
{
protected:
@@ -1909,15 +1945,27 @@ public:
class Item_func_crc32 :public Item_long_func
{
bool check_arguments() const override
- { return args[0]->check_type_can_return_str(func_name_cstring()); }
+ {
+ return args[0]->check_type_can_return_str(func_name_cstring()) &&
+ (arg_count == 1 ||
+ args[1]->check_type_can_return_int(func_name_cstring()));
+ }
String value;
+ uint32 (*const crc_func)(uint32, const void*, size_t);
public:
- Item_func_crc32(THD *thd, Item *a): Item_long_func(thd, a)
+ Item_func_crc32(THD *thd, bool Castagnoli, Item *a) :
+ Item_long_func(thd, a),
+ crc_func(Castagnoli ? my_crc32c : my_checksum)
+ { unsigned_flag= 1; }
+ Item_func_crc32(THD *thd, bool Castagnoli, Item *a, Item *b) :
+ Item_long_func(thd, a, b),
+ crc_func(Castagnoli ? my_crc32c : my_checksum)
{ unsigned_flag= 1; }
LEX_CSTRING func_name_cstring() const override
{
- static LEX_CSTRING name= {STRING_WITH_LEN("crc32") };
- return name;
+ static LEX_CSTRING crc32_name= {STRING_WITH_LEN("crc32") };
+ static LEX_CSTRING crc32c_name= {STRING_WITH_LEN("crc32c") };
+ return crc_func == my_crc32c ? crc32c_name : crc32_name;
}
bool fix_length_and_dec() override { max_length=10; return FALSE; }
longlong val_int() override;
@@ -1996,40 +2044,6 @@ public:
};
-class Item_func_uuid: public Item_str_func
-{
- /* Set if uuid should be returned without separators (Oracle sys_guid) */
- bool without_separators;
-public:
-Item_func_uuid(THD *thd, bool without_separators_arg): Item_str_func(thd),
- without_separators(without_separators_arg)
- {}
- bool fix_length_and_dec() override
- {
- collation.set(DTCollation_numeric());
- fix_char_length(without_separators ? MY_UUID_ORACLE_STRING_LENGTH :
- MY_UUID_STRING_LENGTH);
- return FALSE;
- }
- bool const_item() const override { return false; }
- table_map used_tables() const override { return RAND_TABLE_BIT; }
- LEX_CSTRING func_name_cstring() const override
- {
- static LEX_CSTRING mariadb_name= {STRING_WITH_LEN("uuid") };
- static LEX_CSTRING oracle_name= {STRING_WITH_LEN("sys_guid") };
- return without_separators ? oracle_name : mariadb_name;
- }
- String *val_str(String *) override;
- bool check_vcol_func_processor(void *arg) override
- {
- return mark_unsupported_function(func_name(), "()", arg,
- VCOL_NON_DETERMINISTIC);
- }
- Item *get_copy(THD *thd) override
- { return get_item_copy<Item_func_uuid>(thd, this); }
-};
-
-
class Item_func_dyncol_create: public Item_str_func
{
protected: