diff --git a/mysql-test/suite/innodb_zip/r/cmp_per_index.result b/mysql-test/suite/innodb_zip/r/cmp_per_index.result index cdb81e7be8a..b4e34040630 100644 --- a/mysql-test/suite/innodb_zip/r/cmp_per_index.result +++ b/mysql-test/suite/innodb_zip/r/cmp_per_index.result @@ -1,3 +1,4 @@ +SET @save_enabled= @@GLOBAL.innodb_cmp_per_index_enabled; SET GLOBAL innodb_cmp_per_index_enabled=ON; SELECT * FROM information_schema.innodb_cmp_per_index; CREATE TABLE t ( @@ -70,33 +71,5 @@ index_name PRIMARY compress_ops 65 compress_ops_ok 65 uncompress_ops 0 -SHOW CREATE TABLE t; -Table t -Create Table CREATE TABLE `t` ( - `a` int(11) NOT NULL, - `b` varchar(512) DEFAULT NULL, - `c` varchar(16) DEFAULT NULL, - PRIMARY KEY (`a`), - KEY `b` (`b`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2 -SET GLOBAL innodb_cmp_per_index_enabled=ON; -SELECT COUNT(*) FROM t IGNORE INDEX(b); -COUNT(*) 128 -SELECT -database_name, -table_name, -index_name, -compress_ops, -compress_ops_ok, -CASE WHEN uncompress_ops=6 and @@innodb_compression_level IN (4,8,9) THEN 9 -ELSE uncompress_ops END as uncompress_ops -FROM information_schema.innodb_cmp_per_index -ORDER BY 1, 2, 3; -database_name test -table_name t -index_name PRIMARY -compress_ops 0 -compress_ops_ok 0 -uncompress_ops 4 DROP TABLE t; -SET GLOBAL innodb_cmp_per_index_enabled=default; +SET GLOBAL innodb_cmp_per_index_enabled=@save_enabled; diff --git a/mysql-test/suite/innodb_zip/t/cmp_per_index.test b/mysql-test/suite/innodb_zip/t/cmp_per_index.test index 8d66277a1bd..74ed17b1213 100644 --- a/mysql-test/suite/innodb_zip/t/cmp_per_index.test +++ b/mysql-test/suite/innodb_zip/t/cmp_per_index.test @@ -21,6 +21,7 @@ if (`SELECT @@innodb_log_compressed_pages = 0`) -- vertical_results +SET @save_enabled= @@GLOBAL.innodb_cmp_per_index_enabled; SET GLOBAL innodb_cmp_per_index_enabled=ON; # reset any leftover stats from previous tests @@ -92,29 +93,6 @@ ELSE compress_ops_ok END as compress_ops_ok, uncompress_ops FROM information_schema.innodb_cmp_per_index ORDER BY 1, 2, 3; - -# restart mysqld and see that uncompress ops also gets increased when -# selecting from the table again - --- source include/restart_mysqld.inc - -SHOW CREATE TABLE t; - -SET GLOBAL innodb_cmp_per_index_enabled=ON; - -SELECT COUNT(*) FROM t IGNORE INDEX(b); - -SELECT -database_name, -table_name, -index_name, -compress_ops, -compress_ops_ok, -CASE WHEN uncompress_ops=6 and @@innodb_compression_level IN (4,8,9) THEN 9 -ELSE uncompress_ops END as uncompress_ops -FROM information_schema.innodb_cmp_per_index -ORDER BY 1, 2, 3; - DROP TABLE t; -SET GLOBAL innodb_cmp_per_index_enabled=default; +SET GLOBAL innodb_cmp_per_index_enabled=@save_enabled; diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index fcab293b3b0..9af8687bfd0 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -32,28 +32,37 @@ Created 1/20/1994 Heikki Tuuri #ifndef UNIV_INNOCHECKSUM /** Seed value of ut_rnd_gen() */ -extern uint64_t ut_rnd_current; +extern int32 ut_rnd_current; -/** @return a pseudo-random 64-bit number */ -inline uint64_t ut_rnd_gen() +/** @return a pseudo-random 32-bit number */ +inline uint32_t ut_rnd_gen() { - /* - This is a linear congruential pseudo random number generator. - The formula and the constants - being used are: - X[n+1] = (a * X[n] + c) mod m - where: - X[0] = my_interval_timer() - a = 1103515245 (3^5 * 5 * 7 * 129749) - c = 12345 (3 * 5 * 823) - m = 18446744073709551616 (1<<64), implicit */ + /* This is a Galois linear-feedback shift register. + https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Galois_LFSRs + The generating primitive Galois Field polynomial is the Castagnoli + polynomial that was made popular by CRC-32C: + x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+ + x^19+x^18+x^14+x^13+x^11+x^10+x^9+x^8+x^6+1 */ + const uint32_t crc32c= 0x1edc6f41; - if (UNIV_UNLIKELY(!ut_rnd_current)) { - ut_rnd_current = my_interval_timer(); - } + uint32_t rnd= my_atomic_load32_explicit(&ut_rnd_current, + MY_MEMORY_ORDER_RELAXED); - ut_rnd_current = 1103515245 * ut_rnd_current + 12345; - return ut_rnd_current; + if (UNIV_UNLIKELY(rnd == 0)) + { + rnd= static_cast(my_interval_timer()); + if (!rnd) rnd= 1; + } + else + { + bool lsb= rnd & 1; + rnd>>= 1; + if (lsb) + rnd^= crc32c; + } + + my_atomic_store32_explicit(&ut_rnd_current, rnd, MY_MEMORY_ORDER_RELAXED); + return rnd; } /** @return a random number between 0 and n-1, inclusive */ diff --git a/storage/innobase/ut/ut0rnd.cc b/storage/innobase/ut/ut0rnd.cc index 856cb82e645..8265121ef2e 100644 --- a/storage/innobase/ut/ut0rnd.cc +++ b/storage/innobase/ut/ut0rnd.cc @@ -27,7 +27,7 @@ Created 5/11/1994 Heikki Tuuri #include "ut0rnd.h" /** Seed value of ut_rnd_gen() */ -uint64_t ut_rnd_current; +int32 ut_rnd_current; /** These random numbers are used in ut_find_prime */ /*@{*/