Debian Codegraph @

mysql-test/suite/engines/rr_trx/t/rr_c_count_not_zero.test

raw
1 ################################################################################
2 #
3 # Verify that SELECT COUNT(*) FROM t1 is never 0.
4 # This should hold because we take care not to delete all rows from that table.
5 #
6 # There have been bugs in the past where this query sporadically has returned
7 # 0 for non-empty tables.
8 #
9 ################################################################################
10
11 SET autocommit = 0;
12 START TRANSACTION;
13 --echo *** Running query: SELECT COUNT(*) FROM t1
14 let $count= `SELECT COUNT(*) FROM t1`;
15 if (!$count)
16 {
17 # count was zero (0)
18 --echo FAIL! SELECT COUNT(*) returned 0 - this should neven happen.
19 }
20
21 # Check that the count of rows with pk divisible by 5 is constant.
22 # This should hold because
23 # a) We do not delete rows with pk MOD 5 = 0
24 # b) We cannot insert new pk's below the initial auto_increment counter (see init test).
25 SELECT COUNT(*) FROM t1 WHERE `pk` MOD 5 = 0 AND `pk` BETWEEN 1 AND 1000;
26 --sleep 1
27 SELECT COUNT(*) FROM t1 WHERE `pk` MOD 5 = 0 AND `pk` BETWEEN 1 AND 1000;
28 COMMIT;