MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
part_blocked_sql_funcs_main.inc
1 ################################################################################
2 # t/partition_blocked_sql_funcs_main.inc #
3 # #
4 # Purpose: #
5 # Tests around sql functions #
6 # #
7 # #
8 #------------------------------------------------------------------------------#
9 # Original Author: HH #
10 # Original Date: 2006-11-22 #
11 # Change Author: #
12 # Change Date: #
13 # Change: #
14 ################################################################################
15 
16 --echo -------------------------------------------------------------------------
17 --echo --- All SQL functions should be rejected, otherwise BUG (see 18198)
18 --echo -------------------------------------------------------------------------
19 
20 let $sqlfunc = ascii(col1);
21 let $valsqlfunc = ascii('a');
22 let $coltype = char(30);
23 --source suite/parts/inc/partition_blocked_sql_funcs.inc
24 
25 let $sqlfunc = ord(col1);
26 let $valsqlfunc = ord('a');
27 let $coltype = char(30);
28 --source suite/parts/inc/partition_blocked_sql_funcs.inc
29 
30 let $sqlfunc = greatest(col1,15);
31 let $valsqlfunc = greatest(1,15);
32 let $coltype = int;
33 --source suite/parts/inc/partition_blocked_sql_funcs.inc
34 
35 let $sqlfunc = isnull(col1);
36 let $valsqlfunc = isnull(15);
37 let $coltype = int;
38 --source suite/parts/inc/partition_blocked_sql_funcs.inc
39 
40 let $sqlfunc = least(col1,15);
41 let $valsqlfunc = least(15,30);
42 let $coltype = int;
43 --source suite/parts/inc/partition_blocked_sql_funcs.inc
44 
45 let $sqlfunc = case when col1>15 then 20 else 10 end;
46 let $valsqlfunc = case when 1>30 then 20 else 15 end;
47 let $coltype = int;
48 --source suite/parts/inc/partition_blocked_sql_funcs.inc
49 
50 let $sqlfunc = ifnull(col1,30);
51 let $valsqlfunc = ifnull(1,30);
52 let $coltype = int;
53 --source suite/parts/inc/partition_blocked_sql_funcs.inc
54 
55 let $sqlfunc = nullif(col1,30);
56 let $valsqlfunc = nullif(1,30);
57 let $coltype = int;
58 --source suite/parts/inc/partition_blocked_sql_funcs.inc
59 
60 let $sqlfunc = bit_length(col1);
61 let $valsqlfunc = bit_length(255);
62 let $coltype = int;
63 --source suite/parts/inc/partition_blocked_sql_funcs.inc
64 let $coltype = char(30);
65 --source suite/parts/inc/partition_blocked_sql_funcs.inc
66 
67 let $sqlfunc = char_length(col1);
68 let $valsqlfunc = char_length('a');
69 #let $coltype = int;
70 #--source suite/parts/inc/partition_blocked_sql_funcs.inc
71 let $coltype = char(30);
72 --source suite/parts/inc/partition_blocked_sql_funcs.inc
73 
74 let $sqlfunc = character_length(col1);
75 let $valsqlfunc = character_length('a');
76 let $coltype = char(30)
77 --source suite/parts/inc/partition_blocked_sql_funcs.inc
78 
79 let $sqlfunc = find_in_set(col1,'1,2,3,4,5,6,7,8,9');
80 let $valsqlfunc = find_in_set('i','a,b,c,d,e,f,g,h,i');
81 let $coltype = int;
82 --source suite/parts/inc/partition_blocked_sql_funcs.inc
83 let $coltype = char(30);
84 --source suite/parts/inc/partition_blocked_sql_funcs.inc
85 
86 let $sqlfunc = instr(col1,'acb');
87 let $valsqlfunc = instr('i','a,b,c,d,e,f,g,h,i');
88 let $coltype = int;
89 --source suite/parts/inc/partition_blocked_sql_funcs.inc
90 let $coltype = char(30);
91 --source suite/parts/inc/partition_blocked_sql_funcs.inc
92 
93 let $sqlfunc = length(col1);
94 let $valsqlfunc = length('a,b,c,d,e,f,g,h,i');
95 let $coltype = int;
96 --source suite/parts/inc/partition_blocked_sql_funcs.inc
97 
98 let $sqlfunc = locate('a',col1);
99 let $valsqlfunc = locate('i','a,b,c,d,e,f,g,h,i');
100 let $coltype = int;
101 --source suite/parts/inc/partition_blocked_sql_funcs.inc
102 let $coltype = char(30);
103 --source suite/parts/inc/partition_blocked_sql_funcs.inc
104 
105 let $sqlfunc = octet_length(col1);
106 let $valsqlfunc = octet_length('a,b,c,d,e,f,g,h,i');
107 --source suite/parts/inc/partition_blocked_sql_funcs.inc
108 
109 let $sqlfunc = position('a' in col1);
110 let $valsqlfunc = position('i' in 'a,b,c,d,e,f,g,h,i');
111 let $coltype = int;
112 --source suite/parts/inc/partition_blocked_sql_funcs.inc
113 let $coltype = char(30);
114 --source suite/parts/inc/partition_blocked_sql_funcs.inc
115 
116 let $sqlfunc = strcmp(col1,'acb');
117 let $valsqlfunc = strcmp('i','a,b,c,d,e,f,g,h,i');
118 let $coltype = int;
119 --source suite/parts/inc/partition_blocked_sql_funcs.inc
120 let $coltype = char(30);
121 --source suite/parts/inc/partition_blocked_sql_funcs.inc
122 
123 let $sqlfunc = crc32(col1);
124 let $valsqlfunc = crc32('a,b,c,d,e,f,g,h,i');
125 let $coltype = char(30);
126 --source suite/parts/inc/partition_blocked_sql_funcs.inc
127 
128 let $sqlfunc = round(col1);
129 let $valsqlfunc = round(15);
130 let $coltype = int;
131 --source suite/parts/inc/partition_blocked_sql_funcs.inc
132 
133 let $sqlfunc = sign(col1);
134 let $valsqlfunc = sign(123);
135 let $coltype = int;
136 --source suite/parts/inc/partition_blocked_sql_funcs.inc
137 
138 let $sqlfunc = period_add(col1,5);
139 let $valsqlfunc = period_add(9804,5);
140 let $coltype = datetime;
141 --source suite/parts/inc/partition_blocked_sql_funcs.inc
142 
143 let $sqlfunc = period_diff(col1,col2);
144 let $valsqlfunc = period_diff(9809,199907);
145 let $coltype = datetime,col2 datetime;
146 --source suite/parts/inc/partition_blocked_sql_funcs.inc
147 let $coltype = int,col2 int;
148 --source suite/parts/inc/partition_blocked_sql_funcs.inc
149 
150 let $sqlfunc = timestampdiff(day,5,col1);
151 let $valsqlfunc = timestampdiff(YEAR,'2002-05-01','2001-01-01');
152 let $coltype = datetime;
153 --source suite/parts/inc/partition_blocked_sql_funcs.inc
154 
155 ################################################################################
156 # After the fix for bug #42849 the server behavior does not fit into this test's
157 # architecture: for UNIX_TIMESTAMP() some of the queries in
158 # suite/parts/inc/partition_blocked_sql_funcs.inc will fail with a different
159 # error (ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR) and some will succeed where
160 ################################################################################
161 #let $sqlfunc = unix_timestamp(col1);
162 #let $valsqlfunc = unix_timestamp ('2002-05-01');
163 #let $coltype = date;
164 #--source suite/parts/inc/partition_blocked_sql_funcs.inc
165 
166 let $sqlfunc = week(col1);
167 let $valsqlfunc = week('2002-05-01');
168 let $coltype = datetime;
169 --source suite/parts/inc/partition_blocked_sql_funcs.inc
170 
171 let $sqlfunc = weekofyear(col1);
172 let $valsqlfunc = weekofyear('2002-05-01');
173 let $coltype = datetime;
174 --source suite/parts/inc/partition_blocked_sql_funcs.inc
175 
176 let $sqlfunc = cast(col1 as signed);
177 let $valsqlfunc = cast(123 as signed);
178 let $coltype = varchar(30);
179 --source suite/parts/inc/partition_blocked_sql_funcs.inc
180 
181 let $sqlfunc = convert(col1,unsigned);
182 let $valsqlfunc = convert(123,unsigned);
183 let $coltype = varchar(30);
184 --source suite/parts/inc/partition_blocked_sql_funcs.inc
185 
186 let $sqlfunc = col1 | 20;
187 let $valsqlfunc = 10 | 20;
188 let $coltype = int;
189 --source suite/parts/inc/partition_blocked_sql_funcs.inc
190 
191 let $sqlfunc = col1 & 20;
192 let $valsqlfunc = 10 & 20;
193 let $coltype = int;
194 --source suite/parts/inc/partition_blocked_sql_funcs.inc
195 
196 let $sqlfunc = col1 ^ 20;
197 let $valsqlfunc = 10 ^ 20;
198 let $coltype = int;
199 --source suite/parts/inc/partition_blocked_sql_funcs.inc
200 
201 let $sqlfunc = col1 << 20;
202 let $valsqlfunc = 10 << 20;
203 let $coltype = int;
204 --source suite/parts/inc/partition_blocked_sql_funcs.inc
205 
206 let $sqlfunc = col1 >> 20;
207 let $valsqlfunc = 10 >> 20;
208 let $coltype = int;
209 --source suite/parts/inc/partition_blocked_sql_funcs.inc
210 
211 let $sqlfunc = ~col1;
212 let $valsqlfunc = ~20;
213 let $coltype = int;
214 --source suite/parts/inc/partition_blocked_sql_funcs.inc
215 
216 let $sqlfunc = bit_count(col1);
217 let $valsqlfunc = bit_count(20);
218 let $coltype = int;
219 --source suite/parts/inc/partition_blocked_sql_funcs.inc
220 
221 let $sqlfunc = inet_aton(col1);
222 let $valsqlfunc = inet_aton('192.168.1.1');
223 let $coltype = int;
224 --source suite/parts/inc/partition_blocked_sql_funcs.inc
225 
226 set @var =20;
227 let $sqlfunc = bit_length(col1)+@var-@var;
228 let $valsqlfunc = bit_length(20)+@var-@var;
229 let $coltype = int;
230 --source suite/parts/inc/partition_blocked_sql_funcs.inc
231 
232 
233 delimiter //;
234 create function getmaxsigned_t1(col int) returns int
235 begin
236  declare done int default 0;
237  declare v4 int;
238  declare max int;
239  declare cur1 cursor for
240  select col from t1;
241  declare continue handler for sqlstate '01000' set done = 1;
242  declare continue handler for sqlstate '02000' set done = 1;
243  open cur1;
244  set max = 0;
245  fetch cur1 into v4;
246  wl_loop: WHILE NOT done DO
247  fetch cur1 into v4;
248  IF v4 > max
249  then set max = v4;
250  END IF;
251  END WHILE wl_loop;
252  close cur1;
253  return max;
254  end//
255 delimiter ;//
256 
257 let $sqlfunc = getmaxsigned_t1(col1);
258 let $valsqlfunc = getmaxsigned(10);
259 let $coltype = int;
260 --source suite/parts/inc/partition_blocked_sql_funcs.inc
261 drop function if exists getmaxsigned_t1;