Debian Codegraph @

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

raw
1 SELECT @sum:=SUM(`int1` + `int1_key` + `int1_unique`
2 + `int2` + `int2_key` + `int2_unique`)
3 AS TotalSum
4 FROM t1;
5
6 # Get some diagnostics if sum is non-zero
7 if (`SELECT @sum`)
8 {
9 # Get sum of consistent rows (should be 0)
10 SELECT SUM(`int1` + `int1_key` + `int1_unique` + `int2` + `int2_key` + `int2_unique`) FROM t1 where `is_consistent` = 1;
11
12 # Get sum of inconsistent rows (should be non-0 if the total sum is to be non-0)
13 SELECT SUM(`int1` + `int1_key` + `int1_unique` + `int2` + `int2_key` + `int2_unique`) FROM t1 where `is_consistent` = 0;
14
15 # Get number of inconsistent rows
16 SELECT COUNT(*) FROM t1 WHERE `is_consistent` = 0;
17
18 # See if there is a single row which is the culprit
19 SELECT * FROM t1 WHERE `int1` + `int1_key` + `int1_unique` + `int2` + `int2_key` + `int2_unique` = @sum;
20
21 SELECT * FROM t1 WHERE `int1` + `int1_key` + `int1_unique` + `int2` + `int2_key` + `int2_unique` = -@sum;
22 }