diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-12-10 13:14:31 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-12-10 13:14:31 +0200 |
commit | 8a847f1bc97f94fda47856bbb0464b68949add86 (patch) | |
tree | 2fcc3d2f30fdd61f063b4414464f44412a1df634 /sql/item_create.cc | |
parent | ccdf5711a8fff0cd610a91fdcf37c8ff1182878c (diff) | |
download | mariadb-git-bb-10.8-MDEV-27208.tar.gz |
MDEV-27208: Implement the CRC32C() functionbb-10.8-MDEV-27208
The SQL parser defines the function crc32() that computes the CRC-32
of a string using the ISO 3309 polynomial that is being used by zlib
and many others.
InnoDB and MyRocks use a different polynomial, which was implemented
in SSE4.2 instructions that were introduced in the
Intel Nehalem microarchitecture. This is commonly called CRC-32C.
Defining a SQL built-in function CRC32C() would for example allow
the definition of a simple SQL function that would generate a logically
empty InnoDB redo log corresponding to a particular checkpoint LSN.
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 1aa7d02e76b..e8921b274ad 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -525,6 +525,19 @@ protected: }; +class Create_func_crc32c : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_crc32c s_singleton; + +protected: + Create_func_crc32c() {} + virtual ~Create_func_crc32c() {} +}; + + class Create_func_datediff : public Create_func_arg2 { public: @@ -3123,6 +3136,16 @@ Create_func_crc32::create_1_arg(THD *thd, Item *arg1) return new (thd->mem_root) Item_func_crc32(thd, arg1); } + +Create_func_crc32c Create_func_crc32c::s_singleton; + +Item* +Create_func_crc32c::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_crc32c(thd, arg1); +} + + Create_func_datediff Create_func_datediff::s_singleton; Item* @@ -5555,6 +5578,7 @@ Native_func_registry func_array[] = { { STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)}, { { STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)}, { { STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)}, + { { STRING_WITH_LEN("CRC32C") }, BUILDER(Create_func_crc32c)}, { { STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)}, { { STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)}, { { STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)}, |