summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/storage_engine/cache_index.test
blob: 42ba9615a4077261e55fd58f104b22e914e74b0b (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# 
# CACHE INDEX and LOAD INDEX INTO CACHE
#

--source have_engine.inc
--source have_default_index.inc


# Due to ancient MySQL bug#16111 we need to generate a unique cache name
--let $cache_name = `SELECT CONNECTION_ID()`
--let $cache_name = my_cache_$cache_name

--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings

let $create_definition = 
  a $int_indexed_col,
  b $char_col,
  $default_index (a)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $functionality = Indexes on INT columns
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  let $create_definition =
    a $int_col,
    b $char_indexed_col,
    $default_index (b)
  ;
  let $table_name = t2;
  --source create_table.inc
  if ($mysql_errname)
  {
    --let $functionality = Indexes on CHAR columns
    --source unexpected_result.inc
  }
  if (!$mysql_errname)
  {
    --replace_result $cache_name <CACHE_NAME>
    --let $error_codes = ER_UNKNOWN_KEY_CACHE
    eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
    --source check_errors.inc
    if ($mysql_errname != ER_UNKNOWN_KEY_CACHE)
    {
      --let $functionality = Key cache or indexes
      --source unexpected_result.inc
    }

    --replace_result $cache_name <CACHE_NAME>
    eval SET GLOBAL $cache_name.key_buffer_size=128*1024;
    --replace_result $cache_name <CACHE_NAME>
    eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
    if ($mysql_errname)
    {
      --let $functionality = Indexes
      --source unexpected_result.inc
    }

    LOAD INDEX INTO CACHE t1, t2;
    if ($mysql_errname)
    {
      --let $functionality = Indexes
      --source unexpected_result.inc
    }

    INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
    --replace_result $cache_name <CACHE_NAME>
    eval SET GLOBAL $cache_name.key_buffer_size=8*1024;
    LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;

    --replace_result $cache_name <CACHE_NAME>
    eval SET GLOBAL $cache_name.key_cache_age_threshold = 100, $cache_name.key_cache_block_size = 512, $cache_name.key_cache_division_limit = 1, $cache_name.key_cache_segments=2;
    INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
    LOAD INDEX INTO CACHE t1;

    --replace_result $cache_name <CACHE_NAME>
    eval SET GLOBAL new_$cache_name.key_buffer_size=128*1024;
    --replace_result $cache_name <CACHE_NAME>
    eval CACHE INDEX t1  IN new_$cache_name;
    INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
    LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
    INSERT INTO t1 (a,b) VALUES (9,'i');
    DROP TABLE t2;
  }
  DROP TABLE t1;
}

let $create_definition = 
    a $int_indexed_col,
    b $char_indexed_col,
    $default_index (a),
    $default_index (b)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $functionality = Multiple keys or indexes on INT or CHAR columns
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_result $cache_name <CACHE_NAME>
  eval CACHE INDEX t1 IN $cache_name;
  INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
  LOAD INDEX INTO CACHE t1;

  DROP TABLE t1;
  let $create_definition =
      a $int_indexed_col,
      b $char_indexed_col,
      $default_index a_b (a,b)
  ;
  --source create_table.inc
  if ($mysql_errname)
  {
    --let $functionality = Multi-part keys
    --source unexpected_result.inc
  }

  --replace_result $cache_name <CACHE_NAME>
  eval CACHE INDEX t1 IN $cache_name;
  INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
  LOAD INDEX INTO CACHE t1;

  DROP TABLE t1;
}

# Cleanup

--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL $cache_name.key_buffer_size=0;
--replace_result $cache_name <CACHE_NAME>
eval SET GLOBAL new_$cache_name.key_buffer_size=0;


--source cleanup_engine.inc