summaryrefslogtreecommitdiff
path: root/mysql-test/suite/storage_engine/type_float_indexes.test
blob: 0f1afc600a1ceace707589fc2ff77b083bff1ad9 (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#
# Float type 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 =
  f FLOAT $col_indexed_opts,
  r REAL(20,3) $col_opts,
  d DOUBLE $col_opts,
  dp DOUBLE PRECISION (64,10) $col_opts,
  $default_index f (f)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Float point types or PK
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 3 # 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (f,r,d,dp) VALUES
  (1.2345,1422.22,1.2345,1234567.89),
  (0,0,0,0),
  (-1,-1,-1,-1),
  (17.5843,4953453454.44,29229114.0,1111111.23),
  (4644,1422.22,466664.999,0.5);

  SELECT f FROM t1 ORDER BY f;

  DROP TABLE t1;
}


# PK, UNIQUE INDEX, INDEX

let $create_definition =
  f FLOAT $col_indexed_opts PRIMARY KEY,
  r REAL(20,3) $col_opts,
  d DOUBLE $col_opts,
  dp DOUBLE PRECISION (64,10) $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Float point types or PK
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;

  INSERT INTO t1 (f,r,d,dp) VALUES
  (1.2345,1422.22,1.2345,1234567.89),
  (0,0,0,0),
  (-1,-1,-1,-1),
  (17.5843,4953453454.44,29229114.0,1111111.23),
  (4644,1422.22,466664.999,0.5);

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT f FROM t1 ORDER BY f;
  SELECT f FROM t1 ORDER BY f;

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
  SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;


  --let $alter_definition = DROP PRIMARY KEY
  --source alter_table.inc
  if ($mysql_errname)
  {
    --let $my_last_stmt = $alter_statement
    --source unexpected_result.inc
  }
  if (!$mysql_errname)
  {
    --let $alter_definition = ADD UNIQUE KEY(d)
    --source alter_table.inc

    --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
    EXPLAIN SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
    SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
  }
  DROP TABLE t1;
}

let $create_definition =
  f FLOAT $col_opts,
  r REAL(20,3) $col_indexed_opts,
  d DOUBLE $col_opts,
  dp DOUBLE PRECISION (64,10) $col_indexed_opts,
  UNIQUE KEY r_dp (r,dp)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Float point types or unique keys or multi-part keys
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;
  
  INSERT INTO t1 (f,r,d,dp) VALUES
  (1.2345,1422.22,1.2345,1234567.89),
  (0,0,0,0),
  (-1,-1,-1,-1),
  (17.5843,4953453454.44,29229114.0,1111111.23),
  (4644,1422.22,466664.999,0.5);

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
  --sorted_result
  SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;

  DROP TABLE t1;
}

let $create_definition =
  f FLOAT $col_opts,
  r REAL(20,3) $col_opts,
  d DOUBLE $col_indexed_opts,
  dp DOUBLE PRECISION (64,10) $col_opts,
  UNIQUE KEY(d)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Float point types or unique keys
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;
  
  INSERT INTO t1 (f,r,d,dp) VALUES
  (1.2345,1422.22,1.2345,1234567.89),
  (0,0,0,0),
  (-1,-1,-1,-1),
  (17.5843,4953453454.44,29229114.0,1111111.23),
  (4644,1422.22,466664.999,0.5);

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
  SELECT DISTINCT d FROM t1 ORDER BY d;

  DROP TABLE t1;
}


let $create_definition =
  f FLOAT $col_opts,
  r REAL(20,3) $col_opts,
  d DOUBLE $col_indexed_opts,
  dp DOUBLE PRECISION (64,10) $col_opts,
  KEY(d)
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Float point types or non-unique keys
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 6 # 7 # 10 # 11 #
  SHOW INDEX IN t1;
  
  INSERT INTO t1 (f,r,d,dp) VALUES
  (1.2345,1422.22,1.2345,1234567.89),
  (0,0,0,0),
  (-1,-1,-1,-1),
  (17.5843,4953453454.44,29229114.0,1111111.23),
  (4644,1422.22,466664.999,0.5);

  --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
  EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
  SELECT DISTINCT d FROM t1 ORDER BY d;

  DROP TABLE t1;
}

--source cleanup_engine.inc