summaryrefslogtreecommitdiff
path: root/mysql-test/suite/engines/rr_trx/t/rr_c_count_not_zero.test
blob: 167e000c929cab2113fc582ff706b1d1f7bf8578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
################################################################################
#
# Verify that  SELECT COUNT(*) FROM t1 is never 0.
# This should hold because we take care not to delete all rows from that table.
#
# There have been bugs in the past where this query sporadically has returned 
# 0 for non-empty tables.
#
################################################################################

SET autocommit = 0;
START TRANSACTION;
--echo *** Running query: SELECT COUNT(*) FROM t1
let $count= `SELECT COUNT(*) FROM t1`;
if (!$count)
{
    # count was zero (0)
    --echo FAIL! SELECT COUNT(*) returned 0 - this should neven happen.
}

# Check that the count of rows with pk divisible by 5 is constant.
# This should hold because
#  a) We do not delete rows with pk MOD 5 = 0
#  b) We cannot insert new pk's below the initial auto_increment counter (see init test).
SELECT COUNT(*) FROM t1 WHERE `pk` MOD 5 = 0 AND `pk` BETWEEN 1 AND 1000;
--sleep 1
SELECT COUNT(*) FROM t1 WHERE `pk` MOD 5 = 0 AND `pk` BETWEEN 1 AND 1000;
COMMIT;