~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
################################################################################
2
# inc/partition_check_read1.inc                                                #
3
#                                                                              #
4
# Purpose:                                                                     #
5
#   Read rows from table t1 in different ways                                  #
6
#   This routine is only useful for the partition_<feature>_<engine> tests.    #
7
#                                                                              #
8
# The parameter                                                                #
9
#   @exp_row_count -- expected number of rows within t1                        #
10
# must be set before sourcing this routine.                                    #
11
#                                                                              #
12
#------------------------------------------------------------------------------#
13
# Original Author: mleich                                                      #
14
# Original Date: 2006-04-11                                                    #
15
# Change Author:                                                               #
16
# Change Date:                                                                 #
17
# Change:                                                                      #
18
################################################################################
19
20
## EXPLAIN PARTITIONS SELECT for one single row
21
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
22
23
## Check SELECT for one single row
24
let $success= 1;
25
if ($no_debug)
26
{
27
--disable_query_log
28
}
29
SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_date = '1000-02-10';
30
--enable_query_log
31
let $run= `SELECT @aux`;
32
if ($run)
33
{
34
   --echo #      Unexpected result on SELECT
35
   eval SELECT COUNT(*) <> 1 FROM t1 WHERE f_date = '1000-02-10';
36
   let $success= 0;
37
}
38
--echo # check read single success: $success
39
40
## Read all existing records in one step
41
let $success= 1;
42
if ($no_debug)
43
{
44
--disable_query_log
45
}
46
eval SELECT COUNT(*) <> @exp_row_count INTO @aux FROM t1;
47
--enable_query_log
48
let $run= `SELECT @aux`;
49
if ($run)
50
{
51
   --echo #      Unexpected result on SELECT
52
   eval SELECT COUNT(*) <> @exp_row_count FROM t1;
53
   let $success= 0;
54
}
55
--echo # check read all success: $success
56
57
## Read all existing records row by row
58
let $success= 1;
59
let $num= `SELECT @exp_row_count`;
60
while ($num)
61
{
62
   if ($no_debug)
63
   {
64
   --disable_query_log
65
   }
66
   eval SELECT COUNT(*) <> 1 INTO @aux FROM t1
67
        WHERE f_date = CONCAT(CAST(999 + $num AS CHAR),'-02-10');
68
   --enable_query_log
69
   let $run= `SELECT @aux`;
70
   if ($run)
71
   {
72
      --echo #      Unexpected result on SELECT
73
      eval SELECT COUNT(*) <> 1 FROM t1
74
           WHERE f_date = CONCAT(CAST(999 + $num AS CHAR),'-02-10');
75
      let $success= 0;
76
   }
77
   dec $num;
78
}
79
--echo # check read row by row success: $success