Re: [Maria-developers] 3617add6975: MDEV-27208: Extend CRC32() and implement CRC32C()
Hi, Marko! On Jan 03, Marko Mäkelä wrote:
revision-id: 3617add6975 (mariadb-10.6.1-252-g3617add6975) parent(s): bc90f5d6967 author: Marko Mäkelä committer: Sergei Golubchik timestamp: 2021-12-15 19:54:34 +0100 message:
MDEV-27208: Extend CRC32() and implement CRC32C()
We used to define a native unary function crc32() that computes the CRC-32 of a string using the ISO 3309 polynomial that is being used by zlib and many others.
Suggestions: 1. one class for both CRC functions, like class Item_func_crc32 :public Item_long_func { extern "C" unsigned (*crc_func)(unsigned int, const char *, size_t); and in the constructor crc_func= crc_variant ? my_crc32 : my_crc32c; there's no need to duplicate everything. 2. swap the arguments: CRC32(CRC32("Maria"), "DB") = CRC32("MariaDB") looks kind of better than CRC32("DB", CRC32("Maria")) = CRC32("MariaDB") Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
Hi, Sergei! On Mon, Jan 3, 2022 at 10:13 PM Sergei Golubchik <serg@mariadb.org> wrote:
1. one class for both CRC functions, like
class Item_func_crc32 :public Item_long_func { extern "C" unsigned (*crc_func)(unsigned int, const char *, size_t);
Done: uint32 (*const crc_func)(uint32, const void*, size_t); My compiler did not accept extern "C" inside a class definition. The declaration and generic definition of my_checksum were inconsistent with each other. I fixed the definition to match the declaration (and the my_crc32c declaration), to be on the safe side.
2. swap the arguments:
CRC32(CRC32("Maria"), "DB") = CRC32("MariaDB")
Done. I also added tests to cover type conversions that take place on argument type mismatch: CRC32C('5','')=5. Please find the revised change at https://github.com/MariaDB/server/commit/d30d31659903f45861afc2d7f966ab0580a... -- Marko Mäkelä, Lead Developer InnoDB MariaDB Corporation
participants (2)
-
Marko Mäkelä
-
Sergei Golubchik