summaryrefslogtreecommitdiff
path: root/mysql-test/suite/storage_engine/type_blob_indexes.test
blob: 7a3e09939bf4f54dcae6c8502d5d83ec0615e5da (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
# BLOB columns with indexes
#

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

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


# Default index as set in define_engine.inc

let $create_definition =
  b BLOB $col_indexed_opts,
  t TINYBLOB $col_opts,
  m MEDIUMBLOB $col_opts,
  l LONGBLOB $col_opts,
  $default_index b (b(32))
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = BLOB types or indexes
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 3 # 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (b,t,m,l) VALUES
  ('','','',''),
  ('a','b','c','d'),
  ('b','d','c','b'),
  ('test1','test2','test3','test4'),
  (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
  (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
  ('abc','def','ghi','jkl'),
  ('test2','test3','test4','test5'),
  ('test3','test4','test5','test6'),
  (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
  (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));

  SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
  SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;

  DROP TABLE t1;
}



# PK, UNIQUE INDEX, INDEX

let $create_definition =
  b BLOB $col_indexed_opts,
  t TINYBLOB $col_opts,
  m MEDIUMBLOB $col_opts,
  l LONGBLOB $col_opts,
  PRIMARY KEY b (b(32))
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = BLOB types or PK
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (b,t,m,l) VALUES
  ('','','',''),
  ('a','b','c','d'),
  ('b','d','c','b'),
  ('test1','test2','test3','test4'),
  (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
  (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
  ('abc','def','ghi','jkl'),
  ('test2','test3','test4','test5'),
  ('test3','test4','test5','test6'),
  (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
  (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
  SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
  SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;

  DROP TABLE t1;
}

let $create_definition =
  b BLOB $col_opts,
  t TINYBLOB $col_indexed_opts,
  m MEDIUMBLOB $col_opts,
  l LONGBLOB $col_indexed_opts,
  UNIQUE INDEX l_t (l(256),t(64))
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = BLOB types or unique indexes or multi-part indexes
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (b,t,m,l) VALUES
  ('','','',''),
  ('a','b','c','d'),
  ('b','d','c','b'),
  ('test1','test2','test3','test4'),
  (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
  (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
  ('abc','def','ghi','jkl'),
  ('test2','test3','test4','test5'),
  ('test3','test4','test5','test6'),
  (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
  (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));

  # Here we are getting possible key l_t, but not the final key
  --replace_column 1 # 2 # 3 # 4 # 6 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
  SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;

  --replace_column 1 # 2 # 3 # 4 # 6 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
  SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
  DROP TABLE t1;

}

let $create_definition =
  b BLOB $col_opts,
  t TINYBLOB $col_opts,
  m MEDIUMBLOB $col_indexed_opts,
  l LONGBLOB $col_opts,
  INDEX (m(128))
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = BLOB types or non-unique indexes
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (b,t,m,l) VALUES
  ('','','',''),
  ('a','b','c','d'),
  ('b','d','c','b'),
  ('test1','test2','test3','test4'),
  (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
  (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
  ('abc','def','ghi','jkl'),
  ('test2','test3','test4','test5'),
  ('test3','test4','test5','test6'),
  (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
  (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
  SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
  SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;

  DROP TABLE t1;
}

--source cleanup_engine.inc