File: rr_c_count_not_zero.test

package info (click to toggle)
mysql-5.1 5.1.73-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 197,136 kB
  • ctags: 93,377
  • sloc: cpp: 579,952; ansic: 429,462; perl: 49,053; sh: 21,664; pascal: 21,272; yacc: 12,801; makefile: 4,545; xml: 4,114; sql: 3,297; lex: 1,265; asm: 1,023
file content (28 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download | duplicates (18)
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;