• Marko Mäkelä's avatar
    MDEV-27208: Extend CRC32() and implement CRC32C() · 5b3ad94c
    Marko Mäkelä authored
    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.
    
    Often, a CRC is computed in pieces. To faciliate this, we introduce a
    2-ary variant of the function that inputs a previous CRC as the first
    argument: CRC32('MariaDB')=CRC32(CRC32('Maria'),'DB').
    
    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
    (Castagnoli).
    
    We introduce a native function that uses the Castagnoli polynomial:
    CRC32C('MariaDB')=CRC32C(CRC32C('Maria'),'DB'). This allows
    SELECT...INTO DUMPFILE to be used for the creation of files with
    valid checksums, such as a logically empty InnoDB redo log file
    ib_logfile0 corresponding to a particular log sequence number.
    5b3ad94c
item_strfunc.h 65.1 KB