Merge lp:~roccoblues/drizzle/port-constants-evalutation-fixes into lp:~drizzle-trunk/drizzle/development
- port-constants-evalutation-fixes
- Merge into development
Proposed by
Dennis Schön
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~roccoblues/drizzle/port-constants-evalutation-fixes |
Merge into: | lp:~drizzle-trunk/drizzle/development |
Diff against target: |
408 lines (+181/-11) 18 files modified
drizzled/item.cc (+59/-0) drizzled/item.h (+3/-0) drizzled/item/cache.h (+4/-0) drizzled/item/ref.h (+4/-1) drizzled/join.cc (+38/-0) drizzled/join.h (+2/-0) tests/r/errors.result (+4/-1) tests/r/func_in.result (+0/-1) tests/r/func_like.result (+1/-1) tests/r/func_str.result (+1/-1) tests/r/func_time.result (+0/-1) tests/r/select.result (+43/-0) tests/r/subselect.result (+1/-1) tests/r/subselect_no_mat.result (+1/-1) tests/r/subselect_no_mat_and_semi_join.result (+1/-1) tests/r/subselect_no_opts.result (+1/-1) tests/r/subselect_no_semijoin.result (+1/-1) tests/t/select.test (+17/-0) |
To merge this branch: | bzr merge lp:~roccoblues/drizzle/port-constants-evalutation-fixes |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Pipes (community) | Approve | ||
Review via email: mp+16242@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Dennis Schön (roccoblues) wrote : | # |
Revision history for this message
Jay Pipes (jaypipes) wrote : | # |
Looks good. I downloaded and all tests pass. Approved from me.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'drizzled/item.cc' | |||
2 | --- drizzled/item.cc 2009-12-05 23:29:59 +0000 | |||
3 | +++ drizzled/item.cc 2009-12-16 14:56:20 +0000 | |||
4 | @@ -1272,6 +1272,65 @@ | |||
5 | 1272 | return error; | 1272 | return error; |
6 | 1273 | } | 1273 | } |
7 | 1274 | 1274 | ||
8 | 1275 | /** | ||
9 | 1276 | Check if an item is a constant one and can be cached. | ||
10 | 1277 | |||
11 | 1278 | @param arg [out] TRUE <=> Cache this item. | ||
12 | 1279 | |||
13 | 1280 | @return TRUE Go deeper in item tree. | ||
14 | 1281 | @return FALSE Don't go deeper in item tree. | ||
15 | 1282 | */ | ||
16 | 1283 | |||
17 | 1284 | bool Item::cache_const_expr_analyzer(unsigned char **arg) | ||
18 | 1285 | { | ||
19 | 1286 | bool *cache_flag= (bool*)*arg; | ||
20 | 1287 | if (!*cache_flag) | ||
21 | 1288 | { | ||
22 | 1289 | Item *item= real_item(); | ||
23 | 1290 | /* | ||
24 | 1291 | Cache constant items unless it's a basic constant, constant field or | ||
25 | 1292 | a subselect (they use their own cache). | ||
26 | 1293 | */ | ||
27 | 1294 | if (const_item() && | ||
28 | 1295 | !(item->basic_const_item() || item->type() == Item::FIELD_ITEM || | ||
29 | 1296 | item->type() == SUBSELECT_ITEM || | ||
30 | 1297 | /* | ||
31 | 1298 | Do not cache GET_USER_VAR() function as its const_item() may | ||
32 | 1299 | return TRUE for the current thread but it still may change | ||
33 | 1300 | during the execution. | ||
34 | 1301 | */ | ||
35 | 1302 | (item->type() == Item::FUNC_ITEM && | ||
36 | 1303 | ((Item_func*)item)->functype() == Item_func::GUSERVAR_FUNC))) | ||
37 | 1304 | *cache_flag= true; | ||
38 | 1305 | return true; | ||
39 | 1306 | } | ||
40 | 1307 | return false; | ||
41 | 1308 | } | ||
42 | 1309 | |||
43 | 1310 | /** | ||
44 | 1311 | Cache item if needed. | ||
45 | 1312 | |||
46 | 1313 | @param arg TRUE <=> Cache this item. | ||
47 | 1314 | |||
48 | 1315 | @return cache if cache needed. | ||
49 | 1316 | @return this otherwise. | ||
50 | 1317 | */ | ||
51 | 1318 | |||
52 | 1319 | Item* Item::cache_const_expr_transformer(unsigned char *arg) | ||
53 | 1320 | { | ||
54 | 1321 | if (*(bool*)arg) | ||
55 | 1322 | { | ||
56 | 1323 | *((bool*)arg)= false; | ||
57 | 1324 | Item_cache *cache= Item_cache::get_cache(this); | ||
58 | 1325 | if (!cache) | ||
59 | 1326 | return NULL; | ||
60 | 1327 | cache->setup(this); | ||
61 | 1328 | cache->store(this); | ||
62 | 1329 | return cache; | ||
63 | 1330 | } | ||
64 | 1331 | return this; | ||
65 | 1332 | } | ||
66 | 1333 | |||
67 | 1275 | bool Item::send(plugin::Client *client, String *buffer) | 1334 | bool Item::send(plugin::Client *client, String *buffer) |
68 | 1276 | { | 1335 | { |
69 | 1277 | bool result= false; | 1336 | bool result= false; |
70 | 1278 | 1337 | ||
71 | === modified file 'drizzled/item.h' | |||
72 | --- drizzled/item.h 2009-12-05 20:06:30 +0000 | |||
73 | +++ drizzled/item.h 2009-12-16 14:56:20 +0000 | |||
74 | @@ -684,6 +684,9 @@ | |||
75 | 684 | virtual bool register_field_in_read_map(unsigned char *arg); | 684 | virtual bool register_field_in_read_map(unsigned char *arg); |
76 | 685 | virtual bool subst_argument_checker(unsigned char **arg); | 685 | virtual bool subst_argument_checker(unsigned char **arg); |
77 | 686 | 686 | ||
78 | 687 | virtual bool cache_const_expr_analyzer(unsigned char **arg); | ||
79 | 688 | virtual Item* cache_const_expr_transformer(unsigned char *arg); | ||
80 | 689 | |||
81 | 687 | virtual Item *equal_fields_propagator(unsigned char * arg); | 690 | virtual Item *equal_fields_propagator(unsigned char * arg); |
82 | 688 | virtual bool set_no_const_sub(unsigned char *arg); | 691 | virtual bool set_no_const_sub(unsigned char *arg); |
83 | 689 | virtual Item *replace_equal_field(unsigned char * arg); | 692 | virtual Item *replace_equal_field(unsigned char * arg); |
84 | 690 | 693 | ||
85 | === modified file 'drizzled/item/cache.h' | |||
86 | --- drizzled/item/cache.h 2009-12-04 23:47:14 +0000 | |||
87 | +++ drizzled/item/cache.h 2009-12-16 14:56:20 +0000 | |||
88 | @@ -78,6 +78,10 @@ | |||
89 | 78 | { | 78 | { |
90 | 79 | return this == item; | 79 | return this == item; |
91 | 80 | } | 80 | } |
92 | 81 | bool basic_const_item() const | ||
93 | 82 | { | ||
94 | 83 | return test(example && example->basic_const_item()); | ||
95 | 84 | } | ||
96 | 81 | }; | 85 | }; |
97 | 82 | 86 | ||
98 | 83 | #endif /* DRIZZLED_ITEM_CACHE_H */ | 87 | #endif /* DRIZZLED_ITEM_CACHE_H */ |
99 | 84 | 88 | ||
100 | === modified file 'drizzled/item/ref.h' | |||
101 | --- drizzled/item/ref.h 2009-12-05 23:13:49 +0000 | |||
102 | +++ drizzled/item/ref.h 2009-12-16 14:56:20 +0000 | |||
103 | @@ -146,7 +146,10 @@ | |||
104 | 146 | if (ref && result_type() == ROW_RESULT) | 146 | if (ref && result_type() == ROW_RESULT) |
105 | 147 | (*ref)->bring_value(); | 147 | (*ref)->bring_value(); |
106 | 148 | } | 148 | } |
108 | 149 | 149 | bool basic_const_item() const | |
109 | 150 | { | ||
110 | 151 | return (*ref)->basic_const_item(); | ||
111 | 152 | } | ||
112 | 150 | }; | 153 | }; |
113 | 151 | 154 | ||
114 | 152 | #endif /* DRIZZLED_ITEM_REF_H */ | 155 | #endif /* DRIZZLED_ITEM_REF_H */ |
115 | 153 | 156 | ||
116 | === modified file 'drizzled/join.cc' | |||
117 | --- drizzled/join.cc 2009-12-07 19:18:46 +0000 | |||
118 | +++ drizzled/join.cc 2009-12-16 14:56:20 +0000 | |||
119 | @@ -621,6 +621,7 @@ | |||
120 | 621 | { | 621 | { |
121 | 622 | conds=new Item_int((int64_t) 0,1); // Always false | 622 | conds=new Item_int((int64_t) 0,1); // Always false |
122 | 623 | } | 623 | } |
123 | 624 | |||
124 | 624 | if (make_join_select(this, select, conds)) | 625 | if (make_join_select(this, select, conds)) |
125 | 625 | { | 626 | { |
126 | 626 | zero_result_cause= | 627 | zero_result_cause= |
127 | @@ -828,6 +829,9 @@ | |||
128 | 828 | if (setup_subquery_materialization()) | 829 | if (setup_subquery_materialization()) |
129 | 829 | return 1; | 830 | return 1; |
130 | 830 | 831 | ||
131 | 832 | /* Cache constant expressions in WHERE, HAVING, ON clauses. */ | ||
132 | 833 | cache_const_exprs(); | ||
133 | 834 | |||
134 | 831 | /* | 835 | /* |
135 | 832 | is this simple IN subquery? | 836 | is this simple IN subquery? |
136 | 833 | */ | 837 | */ |
137 | @@ -2379,6 +2383,40 @@ | |||
138 | 2379 | } | 2383 | } |
139 | 2380 | 2384 | ||
140 | 2381 | /** | 2385 | /** |
141 | 2386 | Cache constant expressions in WHERE, HAVING, ON conditions. | ||
142 | 2387 | */ | ||
143 | 2388 | |||
144 | 2389 | void JOIN::cache_const_exprs() | ||
145 | 2390 | { | ||
146 | 2391 | bool cache_flag= false; | ||
147 | 2392 | bool *analyzer_arg= &cache_flag; | ||
148 | 2393 | |||
149 | 2394 | /* No need in cache if all tables are constant. */ | ||
150 | 2395 | if (const_tables == tables) | ||
151 | 2396 | return; | ||
152 | 2397 | |||
153 | 2398 | if (conds) | ||
154 | 2399 | conds->compile(&Item::cache_const_expr_analyzer, (unsigned char **)&analyzer_arg, | ||
155 | 2400 | &Item::cache_const_expr_transformer, (unsigned char *)&cache_flag); | ||
156 | 2401 | cache_flag= false; | ||
157 | 2402 | if (having) | ||
158 | 2403 | having->compile(&Item::cache_const_expr_analyzer, (unsigned char **)&analyzer_arg, | ||
159 | 2404 | &Item::cache_const_expr_transformer, (unsigned char *)&cache_flag); | ||
160 | 2405 | |||
161 | 2406 | for (JoinTable *tab= join_tab + const_tables; tab < join_tab + tables ; tab++) | ||
162 | 2407 | { | ||
163 | 2408 | if (*tab->on_expr_ref) | ||
164 | 2409 | { | ||
165 | 2410 | cache_flag= false; | ||
166 | 2411 | (*tab->on_expr_ref)->compile(&Item::cache_const_expr_analyzer, | ||
167 | 2412 | (unsigned char **)&analyzer_arg, | ||
168 | 2413 | &Item::cache_const_expr_transformer, | ||
169 | 2414 | (unsigned char *)&cache_flag); | ||
170 | 2415 | } | ||
171 | 2416 | } | ||
172 | 2417 | } | ||
173 | 2418 | |||
174 | 2419 | /** | ||
175 | 2382 | @brief | 2420 | @brief |
176 | 2383 | 2421 | ||
177 | 2384 | Process one record of the nested loop join. | 2422 | Process one record of the nested loop join. |
178 | 2385 | 2423 | ||
179 | === modified file 'drizzled/join.h' | |||
180 | --- drizzled/join.h 2009-12-07 19:18:46 +0000 | |||
181 | +++ drizzled/join.h 2009-12-16 14:56:20 +0000 | |||
182 | @@ -472,6 +472,8 @@ | |||
183 | 472 | sizeof(drizzled::optimizer::Position) * size); | 472 | sizeof(drizzled::optimizer::Position) * size); |
184 | 473 | } | 473 | } |
185 | 474 | 474 | ||
186 | 475 | void cache_const_exprs(); | ||
187 | 476 | |||
188 | 475 | /** | 477 | /** |
189 | 476 | * @param[in] index the index of the position to retrieve | 478 | * @param[in] index the index of the position to retrieve |
190 | 477 | * @return a reference to the specified position in the optimal | 479 | * @return a reference to the specified position in the optimal |
191 | 478 | 480 | ||
192 | === modified file 'tests/r/errors.result' | |||
193 | --- tests/r/errors.result 2008-12-16 07:07:50 +0000 | |||
194 | +++ tests/r/errors.result 2009-12-16 14:56:20 +0000 | |||
195 | @@ -30,17 +30,20 @@ | |||
196 | 30 | CREATE TABLE t1 (a INT); | 30 | CREATE TABLE t1 (a INT); |
197 | 31 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); | 31 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); |
198 | 32 | a | 32 | a |
199 | 33 | Warnings: | ||
200 | 34 | Error 1365 Division by 0 | ||
201 | 33 | INSERT INTO t1 VALUES(1); | 35 | INSERT INTO t1 VALUES(1); |
202 | 34 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); | 36 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); |
203 | 35 | a | 37 | a |
204 | 36 | 1 | 38 | 1 |
205 | 39 | Warnings: | ||
206 | 40 | Error 1365 Division by 0 | ||
207 | 37 | INSERT INTO t1 VALUES(2),(3); | 41 | INSERT INTO t1 VALUES(2),(3); |
208 | 38 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); | 42 | SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0))); |
209 | 39 | a | 43 | a |
210 | 40 | 1 | 44 | 1 |
211 | 41 | Warnings: | 45 | Warnings: |
212 | 42 | Error 1365 Division by 0 | 46 | Error 1365 Division by 0 |
213 | 43 | Error 1365 Division by 0 | ||
214 | 44 | DROP TABLE t1; | 47 | DROP TABLE t1; |
215 | 45 | CREATE TABLE t1( a INT ); | 48 | CREATE TABLE t1( a INT ); |
216 | 46 | SELECT b FROM t1; | 49 | SELECT b FROM t1; |
217 | 47 | 50 | ||
218 | === modified file 'tests/r/func_in.result' | |||
219 | --- tests/r/func_in.result 2009-07-27 23:00:57 +0000 | |||
220 | +++ tests/r/func_in.result 2009-12-16 14:56:20 +0000 | |||
221 | @@ -460,7 +460,6 @@ | |||
222 | 460 | id | 460 | id |
223 | 461 | Warnings: | 461 | Warnings: |
224 | 462 | Error 1365 Division by 0 | 462 | Error 1365 Division by 0 |
225 | 463 | Error 1365 Division by 0 | ||
226 | 464 | DROP TABLE t1; | 463 | DROP TABLE t1; |
227 | 465 | End of 5.0 tests | 464 | End of 5.0 tests |
228 | 466 | create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM; | 465 | create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM; |
229 | 467 | 466 | ||
230 | === modified file 'tests/r/func_like.result' | |||
231 | --- tests/r/func_like.result 2008-12-06 22:41:03 +0000 | |||
232 | +++ tests/r/func_like.result 2009-12-16 14:56:20 +0000 | |||
233 | @@ -10,7 +10,7 @@ | |||
234 | 10 | id select_type table type possible_keys key key_len ref rows filtered Extra | 10 | id select_type table type possible_keys key key_len ref rows filtered Extra |
235 | 11 | 1 SIMPLE t1 index a a 43 NULL 5 40.00 Using where; Using index | 11 | 1 SIMPLE t1 index a a 43 NULL 5 40.00 Using where; Using index |
236 | 12 | Warnings: | 12 | Warnings: |
238 | 13 | Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like concat('abc','%')) | 13 | Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like <cache>(concat('abc','%'))) |
239 | 14 | select * from t1 where a like "abc%"; | 14 | select * from t1 where a like "abc%"; |
240 | 15 | a | 15 | a |
241 | 16 | abc | 16 | abc |
242 | 17 | 17 | ||
243 | === modified file 'tests/r/func_str.result' | |||
244 | --- tests/r/func_str.result 2009-10-31 18:12:20 +0000 | |||
245 | +++ tests/r/func_str.result 2009-12-16 14:56:20 +0000 | |||
246 | @@ -847,7 +847,7 @@ | |||
247 | 847 | 1 SIMPLE t2 const PRIMARY PRIMARY 42 const 1 100.00 Using index | 847 | 1 SIMPLE t2 const PRIMARY PRIMARY 42 const 1 100.00 Using index |
248 | 848 | 1 SIMPLE t1 ref code code 43 const 2 100.00 Using where; Using index | 848 | 1 SIMPLE t1 ref code code 43 const 2 100.00 Using where; Using index |
249 | 849 | Warnings: | 849 | Warnings: |
251 | 850 | Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and ('a12' = 'a12') and ((length(`test`.`t1`.`code`) = 5) or ('a12' < 'a00'))) | 850 | Note 1003 select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and <cache>(('a12' = 'a12')) and ((length(`test`.`t1`.`code`) = 5) or <cache>(('a12' < 'a00')))) |
252 | 851 | DROP TABLE t1,t2; | 851 | DROP TABLE t1,t2; |
253 | 852 | select benchmark(-1, 1); | 852 | select benchmark(-1, 1); |
254 | 853 | benchmark(-1, 1) | 853 | benchmark(-1, 1) |
255 | 854 | 854 | ||
256 | === modified file 'tests/r/func_time.result' | |||
257 | --- tests/r/func_time.result 2009-06-16 00:53:22 +0000 | |||
258 | +++ tests/r/func_time.result 2009-12-16 14:56:20 +0000 | |||
259 | @@ -714,7 +714,6 @@ | |||
260 | 714 | f1 | 714 | f1 |
261 | 715 | Warnings: | 715 | Warnings: |
262 | 716 | Warning 1292 Incorrect datetime value: 'zzz' | 716 | Warning 1292 Incorrect datetime value: 'zzz' |
263 | 717 | Warning 1292 Incorrect datetime value: 'zzz' | ||
264 | 718 | select f1 from t1 where makedate(2006,1) between date(f1) and date(f3); | 717 | select f1 from t1 where makedate(2006,1) between date(f1) and date(f3); |
265 | 719 | f1 | 718 | f1 |
266 | 720 | 2006-01-01 | 719 | 2006-01-01 |
267 | 721 | 720 | ||
268 | === modified file 'tests/r/select.result' | |||
269 | --- tests/r/select.result 2009-11-13 00:56:59 +0000 | |||
270 | +++ tests/r/select.result 2009-12-16 14:56:20 +0000 | |||
271 | @@ -3661,3 +3661,46 @@ | |||
272 | 3661 | 4 | 3661 | 4 |
273 | 3662 | 5 | 3662 | 5 |
274 | 3663 | DROP TABLE t1; | 3663 | DROP TABLE t1; |
275 | 3664 | CREATE TABLE t1 (a INT); | ||
276 | 3665 | INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); | ||
277 | 3666 | CREATE TABLE t2 (b INT); | ||
278 | 3667 | INSERT INTO t2 VALUES (2); | ||
279 | 3668 | SELECT * FROM t1 WHERE a = 1 + 1; | ||
280 | 3669 | a | ||
281 | 3670 | 2 | ||
282 | 3671 | EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = 1 + 1; | ||
283 | 3672 | id select_type table type possible_keys key key_len ref rows filtered Extra | ||
284 | 3673 | 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where | ||
285 | 3674 | Warnings: | ||
286 | 3675 | Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = <cache>((1 + 1))) | ||
287 | 3676 | SELECT * FROM t1 HAVING a = 1 + 1; | ||
288 | 3677 | a | ||
289 | 3678 | 2 | ||
290 | 3679 | EXPLAIN EXTENDED SELECT * FROM t1 HAVING a = 1 + 1; | ||
291 | 3680 | id select_type table type possible_keys key key_len ref rows filtered Extra | ||
292 | 3681 | 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 | ||
293 | 3682 | Warnings: | ||
294 | 3683 | Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` having (`test`.`t1`.`a` = <cache>((1 + 1))) | ||
295 | 3684 | SELECT * FROM t1, t2 WHERE a = b + (1 + 1); | ||
296 | 3685 | a b | ||
297 | 3686 | 4 2 | ||
298 | 3687 | EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a = b + (1 + 1); | ||
299 | 3688 | id select_type table type possible_keys key key_len ref rows filtered Extra | ||
300 | 3689 | 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 | ||
301 | 3690 | 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer | ||
302 | 3691 | Warnings: | ||
303 | 3692 | Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = (`test`.`t2`.`b` + <cache>((1 + 1)))) | ||
304 | 3693 | SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; | ||
305 | 3694 | b a | ||
306 | 3695 | 2 3 | ||
307 | 3696 | EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; | ||
308 | 3697 | id select_type table type possible_keys key key_len ref rows filtered Extra | ||
309 | 3698 | 1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 | ||
310 | 3699 | 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 | ||
311 | 3700 | Warnings: | ||
312 | 3701 | Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where 1 | ||
313 | 3702 | EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); | ||
314 | 3703 | id select_type table type possible_keys key key_len ref rows filtered Extra | ||
315 | 3704 | 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where | ||
316 | 3705 | Warnings: | ||
317 | 3706 | Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(unix_timestamp('2009-03-10 00:00:00'))) | ||
318 | 3664 | 3707 | ||
319 | === modified file 'tests/r/subselect.result' | |||
320 | --- tests/r/subselect.result 2009-11-19 18:26:26 +0000 | |||
321 | +++ tests/r/subselect.result 2009-12-16 14:56:20 +0000 | |||
322 | @@ -720,7 +720,7 @@ | |||
323 | 720 | Warnings: | 720 | Warnings: |
324 | 721 | Note 1249 Select 3 was reduced during optimization | 721 | Note 1249 Select 3 was reduced during optimization |
325 | 722 | Note 1249 Select 2 was reduced during optimization | 722 | Note 1249 Select 2 was reduced during optimization |
327 | 723 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1)) | 723 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = <cache>((1 + 1))) |
328 | 724 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); | 724 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); |
329 | 725 | id select_type table type possible_keys key key_len ref rows filtered Extra | 725 | id select_type table type possible_keys key key_len ref rows filtered Extra |
330 | 726 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index | 726 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index |
331 | 727 | 727 | ||
332 | === modified file 'tests/r/subselect_no_mat.result' | |||
333 | --- tests/r/subselect_no_mat.result 2009-11-19 18:26:26 +0000 | |||
334 | +++ tests/r/subselect_no_mat.result 2009-12-16 14:56:20 +0000 | |||
335 | @@ -724,7 +724,7 @@ | |||
336 | 724 | Warnings: | 724 | Warnings: |
337 | 725 | Note 1249 Select 3 was reduced during optimization | 725 | Note 1249 Select 3 was reduced during optimization |
338 | 726 | Note 1249 Select 2 was reduced during optimization | 726 | Note 1249 Select 2 was reduced during optimization |
340 | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1)) | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = <cache>((1 + 1))) |
341 | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); |
342 | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra |
343 | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index |
344 | 731 | 731 | ||
345 | === modified file 'tests/r/subselect_no_mat_and_semi_join.result' | |||
346 | --- tests/r/subselect_no_mat_and_semi_join.result 2009-11-19 18:26:26 +0000 | |||
347 | +++ tests/r/subselect_no_mat_and_semi_join.result 2009-12-16 14:56:20 +0000 | |||
348 | @@ -724,7 +724,7 @@ | |||
349 | 724 | Warnings: | 724 | Warnings: |
350 | 725 | Note 1249 Select 3 was reduced during optimization | 725 | Note 1249 Select 3 was reduced during optimization |
351 | 726 | Note 1249 Select 2 was reduced during optimization | 726 | Note 1249 Select 2 was reduced during optimization |
353 | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1)) | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = <cache>((1 + 1))) |
354 | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); |
355 | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra |
356 | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index |
357 | 731 | 731 | ||
358 | === modified file 'tests/r/subselect_no_opts.result' | |||
359 | --- tests/r/subselect_no_opts.result 2009-11-19 18:26:26 +0000 | |||
360 | +++ tests/r/subselect_no_opts.result 2009-12-16 14:56:20 +0000 | |||
361 | @@ -724,7 +724,7 @@ | |||
362 | 724 | Warnings: | 724 | Warnings: |
363 | 725 | Note 1249 Select 3 was reduced during optimization | 725 | Note 1249 Select 3 was reduced during optimization |
364 | 726 | Note 1249 Select 2 was reduced during optimization | 726 | Note 1249 Select 2 was reduced during optimization |
366 | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1)) | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = <cache>((1 + 1))) |
367 | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); |
368 | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra |
369 | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index |
370 | 731 | 731 | ||
371 | === modified file 'tests/r/subselect_no_semijoin.result' | |||
372 | --- tests/r/subselect_no_semijoin.result 2009-11-19 18:26:26 +0000 | |||
373 | +++ tests/r/subselect_no_semijoin.result 2009-12-16 14:56:20 +0000 | |||
374 | @@ -724,7 +724,7 @@ | |||
375 | 724 | Warnings: | 724 | Warnings: |
376 | 725 | Note 1249 Select 3 was reduced during optimization | 725 | Note 1249 Select 3 was reduced during optimization |
377 | 726 | Note 1249 Select 2 was reduced during optimization | 726 | Note 1249 Select 2 was reduced during optimization |
379 | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = (1 + 1)) | 727 | Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where (`test`.`t2`.`id` = <cache>((1 + 1))) |
380 | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); | 728 | EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); |
381 | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra | 729 | id select_type table type possible_keys key key_len ref rows filtered Extra |
382 | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index | 730 | 1 PRIMARY t2 index NULL id 5 NULL 2 100.00 Using where; Using index |
383 | 731 | 731 | ||
384 | === modified file 'tests/t/select.test' | |||
385 | --- tests/t/select.test 2009-11-13 00:56:59 +0000 | |||
386 | +++ tests/t/select.test 2009-12-16 14:56:20 +0000 | |||
387 | @@ -3454,3 +3454,20 @@ | |||
388 | 3454 | SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; | 3454 | SELECT a FROM t1 ORDER BY a LIMIT 2,4294967296; |
389 | 3455 | SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; | 3455 | SELECT a FROM t1 ORDER BY a LIMIT 2,4294967297; |
390 | 3456 | DROP TABLE t1; | 3456 | DROP TABLE t1; |
391 | 3457 | |||
392 | 3458 | # | ||
393 | 3459 | # MySQL Bug#33546: Slowdown on re-evaluation of constant expressions. | ||
394 | 3460 | # | ||
395 | 3461 | CREATE TABLE t1 (a INT); | ||
396 | 3462 | INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); | ||
397 | 3463 | CREATE TABLE t2 (b INT); | ||
398 | 3464 | INSERT INTO t2 VALUES (2); | ||
399 | 3465 | SELECT * FROM t1 WHERE a = 1 + 1; | ||
400 | 3466 | EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = 1 + 1; | ||
401 | 3467 | SELECT * FROM t1 HAVING a = 1 + 1; | ||
402 | 3468 | EXPLAIN EXTENDED SELECT * FROM t1 HAVING a = 1 + 1; | ||
403 | 3469 | SELECT * FROM t1, t2 WHERE a = b + (1 + 1); | ||
404 | 3470 | EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a = b + (1 + 1); | ||
405 | 3471 | SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; | ||
406 | 3472 | EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; | ||
407 | 3473 | EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); | ||
408 | 3457 | \ No newline at end of file | 3474 | \ No newline at end of file |
This ports the fixes for MySQL Bug#33546 to drizzle. Test-suite passes.
One small thing I've noticed is that in the test result file this query
EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
leads to different results in drizzle and mysql:
MySQL:
EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where
Warnings:
Note 1003 select '2' AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t1` where 1
Drizzle:
EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
Warnings:
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t2` left join `test`.`t1` on((`test`.`t1`.`a` = (`test`.`t2`.`b` + 1))) where 1
I don't think that's because of my changes but please double check. Jay said on IRC: "might be some constant propogation in the optimizer that is not in Drizzle. I wouldn't worry about it too much. The case that is being optimized is pretty minimal."