← Back to team overview

maria-developers team mailing list archive

Re: 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.


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")

VP of MariaDB Server Engineering
and security@xxxxxxxxxxx

Follow ups