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 /mysql-test/main/func_math.test | |
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 'mysql-test/main/func_math.test')
-rw-r--r-- | mysql-test/main/func_math.test | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index 572e0fd0f6b..9fd95279974 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -849,15 +849,16 @@ SELECT CRC32('01234567'), CRC32('012345678'); SELECT CRC32('~!@$%^*'), CRC32('-0.0001'); SELECT CRC32(99999999999999999999999999999999); SELECT CRC32(-99999999999999999999999999999999); +SELECT CRC32C(NULL), CRC32C(''), CRC32C('MariaDB'), CRC32C('mariadb'); # Test cases for using the function in aggregate functions, group-by, having # and order-by clauses DROP TABLE IF EXISTS t; CREATE TABLE t(a INT, b VARCHAR(2)); INSERT INTO t VALUES (1,'a'), (2,'qw'), (1,'t'), (3,'t'); -SELECT crc32(SUM(a)) FROM t; -SELECT crc32(AVG(a)) FROM t GROUP BY b; -SELECT crc32(MAX(b)) FROM t GROUP BY a; +SELECT crc32(SUM(a)),crc32c(SUM(a)) FROM t; +SELECT crc32(AVG(a)),crc32c(AVG(a)) FROM t GROUP BY b; +SELECT crc32(MAX(b)),crc32c(MAX(b)) FROM t GROUP BY a; SELECT a, b, crc32(a) FROM t GROUP BY a,b HAVING crc32(MAX(a))=450215437; SELECT a,b,concat(a,b),crc32(concat(a,b)) FROM t ORDER BY crc32(concat(a,b)); DROP TABLE t; |