1select * from information_schema.OPTIMIZER_TRACE;
2QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
3set optimizer_trace_max_mem_size=1048576;
4set @@session.optimizer_trace="enabled=on";
5select * from information_schema.OPTIMIZER_TRACE;
6QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7CREATE TABLE t5 (c int);
8INSERT INTO t5 VALUES (NULL);
9CREATE TABLE t6 (d int , KEY (d));
10INSERT INTO t6 VALUES (NULL),(NULL);
11SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 ;
12RESULT
13NULL
14select * from information_schema.OPTIMIZER_TRACE;
15QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
16SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5	{
17  "steps": [
18    {
19      "join_preparation": {
20        "select#": 1,
21        "steps": [
22          {
23            "join_preparation": {
24              "select#": 2,
25              "steps": [
26                {
27                  "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)"
28                }
29              ]
30            }
31          },
32          {
33            "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)) AS `RESULT` from `t5`"
34          }
35        ]
36      }
37    },
38    {
39      "join_optimization": {
40        "select#": 1,
41        "steps": [
42          {
43            "table_dependencies": [
44              {
45                "table": "`t5`",
46                "row_may_be_null": false,
47                "map_bit": 0,
48                "depends_on_map_bits": [
49                ]
50              }
51            ]
52          },
53          {
54            "rows_estimation": [
55              {
56                "table": "`t5`",
57                "rows": 1,
58                "cost": 1,
59                "table_type": "system",
60                "empty": false
61              }
62            ]
63          },
64          {
65            "attaching_conditions_to_tables": {
66              "original_condition": null,
67              "attached_conditions_computation": [
68              ],
69              "attached_conditions_summary": [
70              ]
71            }
72          },
73          {
74            "refine_plan": [
75            ]
76          }
77        ]
78      }
79    },
80    {
81      "join_optimization": {
82        "select#": 2,
83        "steps": [
84          {
85            "condition_processing": {
86              "condition": "WHERE",
87              "original_condition": "(`t6`.`d` = NULL)",
88              "steps": [
89                {
90                  "transformation": "equality_propagation",
91                  "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
92                },
93                {
94                  "transformation": "constant_propagation",
95                  "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
96                },
97                {
98                  "transformation": "trivial_condition_removal",
99                  "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
100                }
101              ]
102            }
103          },
104          {
105            "substitute_generated_columns": {
106            }
107          },
108          {
109            "table_dependencies": [
110              {
111                "table": "`t6`",
112                "row_may_be_null": false,
113                "map_bit": 0,
114                "depends_on_map_bits": [
115                ]
116              }
117            ]
118          },
119          {
120            "ref_optimizer_key_uses": [
121              {
122                "table": "`t6`",
123                "field": "d",
124                "equals": "NULL",
125                "null_rejecting": true
126              }
127            ]
128          },
129          {
130            "rows_estimation": [
131              {
132                "table": "`t6`",
133                "range_analysis": {
134                  "table_scan": {
135                    "rows": 2,
136                    "cost": 4.5034
137                  },
138                  "potential_range_indexes": [
139                    {
140                      "index": "d",
141                      "usable": true,
142                      "key_parts": [
143                        "d"
144                      ]
145                    }
146                  ],
147                  "best_covering_index_scan": {
148                    "index": "d",
149                    "cost": 1.4233,
150                    "chosen": true
151                  },
152                  "setup_range_conditions": [
153                    {
154                      "impossible_condition": {
155                        "cause": "comparison_with_null_always_false"
156                      }
157                    }
158                  ],
159                  "impossible_range": true
160                },
161                "rows": 0,
162                "cause": "impossible_where_condition"
163              }
164            ]
165          }
166        ],
167        "empty_result": {
168          "cause": "no matching row in const table"
169        }
170      }
171    },
172    {
173      "join_execution": {
174        "select#": 1,
175        "steps": [
176          {
177            "subselect_execution": {
178              "select#": 2,
179              "steps": [
180                {
181                  "join_execution": {
182                    "select#": 2,
183                    "steps": [
184                    ]
185                  }
186                }
187              ]
188            }
189          }
190        ]
191      }
192    }
193  ]
194}	0	0
195select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
196from information_schema.OPTIMIZER_TRACE;
197(1-length(replace(TRACE, " ", ""))/length(TRACE))*100
19853.9648
199set optimizer_trace="one_line=on";
200SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 ;
201RESULT
202NULL
203select * from information_schema.OPTIMIZER_TRACE;
204QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
205SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5	{"steps": [{"join_preparation": {"select#": 1,"steps": [{"join_preparation": {"select#": 2,"steps": [{"expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)"}]}},{"expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)) AS `RESULT` from `t5`"}]}},{"join_optimization": {"select#": 1,"steps": [{"table_dependencies": [{"table": "`t5`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"rows_estimation": [{"table": "`t5`","rows": 1,"cost": 1,"table_type": "system","empty": false}]},{"attaching_conditions_to_tables": {"original_condition": null,"attached_conditions_computation": [],"attached_conditions_summary": []}},{"refine_plan": []}]}},{"join_optimization": {"select#": 2,"steps": [{"condition_processing": {"condition": "WHERE","original_condition": "(`t6`.`d` = NULL)","steps": [{"transformation": "equality_propagation","resulting_condition": "multiple equal(NULL, `t6`.`d`)"},{"transformation": "constant_propagation","resulting_condition": "multiple equal(NULL, `t6`.`d`)"},{"transformation": "trivial_condition_removal","resulting_condition": "multiple equal(NULL, `t6`.`d`)"}]}},{"substitute_generated_columns": {}},{"table_dependencies": [{"table": "`t6`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"ref_optimizer_key_uses": [{"table": "`t6`","field": "d","equals": "NULL","null_rejecting": true}]},{"rows_estimation": [{"table": "`t6`","range_analysis": {"table_scan": {"rows": 2,"cost": 4.5034},"potential_range_indexes": [{"index": "d","usable": true,"key_parts": ["d"]}],"best_covering_index_scan": {"index": "d","cost": 1.4233,"chosen": true},"setup_range_conditions": [{"impossible_condition": {"cause": "comparison_with_null_always_false"}}],"impossible_range": true},"rows": 0,"cause": "impossible_where_condition"}]}],"empty_result": {"cause": "no matching row in const table"}}},{"join_execution": {"select#": 1,"steps": [{"subselect_execution": {"select#": 2,"steps": [{"join_execution": {"select#": 2,"steps": []}}]}}]}}]}	0	0
206select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
207from information_schema.OPTIMIZER_TRACE;
208(1-length(replace(TRACE, " ", ""))/length(TRACE))*100
2096.0048
210set end_markers_in_json=on;
211set optimizer_trace="one_line=off";
212EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
213id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
2141	PRIMARY	t5	NULL	system	NULL	NULL	NULL	NULL	1	100.00	NULL
2152	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	no matching row in const table
216Warnings:
217Note	1276	Field or reference 'test.t5.c' of SELECT #2 was resolved in SELECT #1
218Note	1003	/* select#1 */ select (/* select#2 */ select 1 from `test`.`t6` where (`test`.`t6`.`d` = ifnull(NULL,NULL))) AS `RESULT` from dual
219select * from information_schema.OPTIMIZER_TRACE;
220QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
221EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5	{
222  "steps": [
223    {
224      "join_preparation": {
225        "select#": 1,
226        "steps": [
227          {
228            "join_preparation": {
229              "select#": 2,
230              "steps": [
231                {
232                  "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
233                }
234              ] /* steps */
235            } /* join_preparation */
236          },
237          {
238            "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
239          }
240        ] /* steps */
241      } /* join_preparation */
242    },
243    {
244      "join_optimization": {
245        "select#": 1,
246        "steps": [
247          {
248            "table_dependencies": [
249              {
250                "table": "`t5`",
251                "row_may_be_null": false,
252                "map_bit": 0,
253                "depends_on_map_bits": [
254                ] /* depends_on_map_bits */
255              }
256            ] /* table_dependencies */
257          },
258          {
259            "rows_estimation": [
260              {
261                "table": "`t5`",
262                "rows": 1,
263                "cost": 1,
264                "table_type": "system",
265                "empty": false
266              }
267            ] /* rows_estimation */
268          },
269          {
270            "attaching_conditions_to_tables": {
271              "original_condition": null,
272              "attached_conditions_computation": [
273              ] /* attached_conditions_computation */,
274              "attached_conditions_summary": [
275              ] /* attached_conditions_summary */
276            } /* attaching_conditions_to_tables */
277          },
278          {
279            "refine_plan": [
280            ] /* refine_plan */
281          }
282        ] /* steps */
283      } /* join_optimization */
284    },
285    {
286      "join_optimization": {
287        "select#": 2,
288        "steps": [
289          {
290            "condition_processing": {
291              "condition": "WHERE",
292              "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
293              "steps": [
294                {
295                  "transformation": "equality_propagation",
296                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
297                },
298                {
299                  "transformation": "constant_propagation",
300                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
301                },
302                {
303                  "transformation": "trivial_condition_removal",
304                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
305                }
306              ] /* steps */
307            } /* condition_processing */
308          },
309          {
310            "substitute_generated_columns": {
311            } /* substitute_generated_columns */
312          },
313          {
314            "table_dependencies": [
315              {
316                "table": "`t6`",
317                "row_may_be_null": false,
318                "map_bit": 0,
319                "depends_on_map_bits": [
320                ] /* depends_on_map_bits */
321              }
322            ] /* table_dependencies */
323          },
324          {
325            "ref_optimizer_key_uses": [
326              {
327                "table": "`t6`",
328                "field": "d",
329                "equals": "ifnull(NULL,NULL)",
330                "null_rejecting": false
331              }
332            ] /* ref_optimizer_key_uses */
333          },
334          {
335            "rows_estimation": [
336              {
337                "table": "`t6`",
338                "range_analysis": {
339                  "table_scan": {
340                    "rows": 2,
341                    "cost": 4.5034
342                  } /* table_scan */,
343                  "potential_range_indexes": [
344                    {
345                      "index": "d",
346                      "usable": true,
347                      "key_parts": [
348                        "d"
349                      ] /* key_parts */
350                    }
351                  ] /* potential_range_indexes */,
352                  "best_covering_index_scan": {
353                    "index": "d",
354                    "cost": 1.4233,
355                    "chosen": true
356                  } /* best_covering_index_scan */,
357                  "setup_range_conditions": [
358                    {
359                      "impossible_condition": {
360                        "cause": "comparison_with_null_always_false"
361                      } /* impossible_condition */
362                    }
363                  ] /* setup_range_conditions */,
364                  "impossible_range": true
365                } /* range_analysis */,
366                "rows": 0,
367                "cause": "impossible_where_condition"
368              }
369            ] /* rows_estimation */
370          }
371        ] /* steps */,
372        "empty_result": {
373          "cause": "no matching row in const table"
374        } /* empty_result */
375      } /* join_optimization */
376    },
377    {
378      "join_explain": {
379        "select#": 1,
380        "steps": [
381          {
382            "join_explain": {
383              "select#": 2,
384              "steps": [
385              ] /* steps */
386            } /* join_explain */
387          }
388        ] /* steps */
389      } /* join_explain */
390    }
391  ] /* steps */
392}	0	0
393SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
394RESULT
395NULL
396select * from information_schema.OPTIMIZER_TRACE;
397QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
398SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5	{
399  "steps": [
400    {
401      "join_preparation": {
402        "select#": 1,
403        "steps": [
404          {
405            "join_preparation": {
406              "select#": 2,
407              "steps": [
408                {
409                  "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
410                }
411              ] /* steps */
412            } /* join_preparation */
413          },
414          {
415            "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
416          }
417        ] /* steps */
418      } /* join_preparation */
419    },
420    {
421      "join_optimization": {
422        "select#": 1,
423        "steps": [
424          {
425            "table_dependencies": [
426              {
427                "table": "`t5`",
428                "row_may_be_null": false,
429                "map_bit": 0,
430                "depends_on_map_bits": [
431                ] /* depends_on_map_bits */
432              }
433            ] /* table_dependencies */
434          },
435          {
436            "rows_estimation": [
437              {
438                "table": "`t5`",
439                "rows": 1,
440                "cost": 1,
441                "table_type": "system",
442                "empty": false
443              }
444            ] /* rows_estimation */
445          },
446          {
447            "attaching_conditions_to_tables": {
448              "original_condition": null,
449              "attached_conditions_computation": [
450              ] /* attached_conditions_computation */,
451              "attached_conditions_summary": [
452              ] /* attached_conditions_summary */
453            } /* attaching_conditions_to_tables */
454          },
455          {
456            "refine_plan": [
457            ] /* refine_plan */
458          }
459        ] /* steps */
460      } /* join_optimization */
461    },
462    {
463      "join_optimization": {
464        "select#": 2,
465        "steps": [
466          {
467            "condition_processing": {
468              "condition": "WHERE",
469              "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
470              "steps": [
471                {
472                  "transformation": "equality_propagation",
473                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
474                },
475                {
476                  "transformation": "constant_propagation",
477                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
478                },
479                {
480                  "transformation": "trivial_condition_removal",
481                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
482                }
483              ] /* steps */
484            } /* condition_processing */
485          },
486          {
487            "substitute_generated_columns": {
488            } /* substitute_generated_columns */
489          },
490          {
491            "table_dependencies": [
492              {
493                "table": "`t6`",
494                "row_may_be_null": false,
495                "map_bit": 0,
496                "depends_on_map_bits": [
497                ] /* depends_on_map_bits */
498              }
499            ] /* table_dependencies */
500          },
501          {
502            "ref_optimizer_key_uses": [
503              {
504                "table": "`t6`",
505                "field": "d",
506                "equals": "ifnull(NULL,NULL)",
507                "null_rejecting": false
508              }
509            ] /* ref_optimizer_key_uses */
510          },
511          {
512            "rows_estimation": [
513              {
514                "table": "`t6`",
515                "range_analysis": {
516                  "table_scan": {
517                    "rows": 2,
518                    "cost": 4.5034
519                  } /* table_scan */,
520                  "potential_range_indexes": [
521                    {
522                      "index": "d",
523                      "usable": true,
524                      "key_parts": [
525                        "d"
526                      ] /* key_parts */
527                    }
528                  ] /* potential_range_indexes */,
529                  "best_covering_index_scan": {
530                    "index": "d",
531                    "cost": 1.4233,
532                    "chosen": true
533                  } /* best_covering_index_scan */,
534                  "setup_range_conditions": [
535                    {
536                      "impossible_condition": {
537                        "cause": "comparison_with_null_always_false"
538                      } /* impossible_condition */
539                    }
540                  ] /* setup_range_conditions */,
541                  "impossible_range": true
542                } /* range_analysis */,
543                "rows": 0,
544                "cause": "impossible_where_condition"
545              }
546            ] /* rows_estimation */
547          }
548        ] /* steps */,
549        "empty_result": {
550          "cause": "no matching row in const table"
551        } /* empty_result */
552      } /* join_optimization */
553    },
554    {
555      "join_execution": {
556        "select#": 1,
557        "steps": [
558          {
559            "subselect_execution": {
560              "select#": 2,
561              "steps": [
562                {
563                  "join_execution": {
564                    "select#": 2,
565                    "steps": [
566                    ] /* steps */
567                  } /* join_execution */
568                }
569              ] /* steps */
570            } /* subselect_execution */
571          }
572        ] /* steps */
573      } /* join_execution */
574    }
575  ] /* steps */
576}	0	0
577set @@session.optimizer_trace="enabled=off";
578SELECT /* bug if you see this*/ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
579RESULT
580NULL
581select QUERY from information_schema.OPTIMIZER_TRACE;
582QUERY
583SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5
584set @@session.optimizer_trace="enabled=on";
585SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
586RESULT
587NULL
588select * from information_schema.OPTIMIZER_TRACE;
589QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
590SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5	{
591  "steps": [
592    {
593      "join_preparation": {
594        "select#": 1,
595        "steps": [
596          {
597            "join_preparation": {
598              "select#": 2,
599              "steps": [
600                {
601                  "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
602                }
603              ] /* steps */
604            } /* join_preparation */
605          },
606          {
607            "join_preparation": {
608              "select#": 3,
609              "steps": [
610                {
611                  "expanded_query": "/* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
612                }
613              ] /* steps */
614            } /* join_preparation */
615          },
616          {
617            "creating_tmp_table": {
618              "tmp_table_info": {
619                "table": "intermediate_tmp_table",
620                "row_length": 9,
621                "key_length": 8,
622                "unique_constraint": false,
623                "location": "memory (heap)",
624                "row_limit_estimate": 116508
625              } /* tmp_table_info */
626            } /* creating_tmp_table */
627          },
628          {
629            "join_preparation": {
630              "select#": "fake",
631              "steps": [
632                {
633                  "expanded_query": "/* select#fake */ select `1` from dual"
634                }
635              ] /* steps */
636            } /* join_preparation */
637          },
638          {
639            "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL)) union /* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
640          }
641        ] /* steps */
642      } /* join_preparation */
643    },
644    {
645      "join_optimization": {
646        "select#": 1,
647        "steps": [
648          {
649            "table_dependencies": [
650              {
651                "table": "`t5`",
652                "row_may_be_null": false,
653                "map_bit": 0,
654                "depends_on_map_bits": [
655                ] /* depends_on_map_bits */
656              }
657            ] /* table_dependencies */
658          },
659          {
660            "rows_estimation": [
661              {
662                "table": "`t5`",
663                "rows": 1,
664                "cost": 1,
665                "table_type": "system",
666                "empty": false
667              }
668            ] /* rows_estimation */
669          },
670          {
671            "attaching_conditions_to_tables": {
672              "original_condition": null,
673              "attached_conditions_computation": [
674              ] /* attached_conditions_computation */,
675              "attached_conditions_summary": [
676              ] /* attached_conditions_summary */
677            } /* attaching_conditions_to_tables */
678          },
679          {
680            "refine_plan": [
681            ] /* refine_plan */
682          }
683        ] /* steps */
684      } /* join_optimization */
685    },
686    {
687      "join_optimization": {
688        "select#": 2,
689        "steps": [
690          {
691            "condition_processing": {
692              "condition": "WHERE",
693              "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
694              "steps": [
695                {
696                  "transformation": "equality_propagation",
697                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
698                },
699                {
700                  "transformation": "constant_propagation",
701                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
702                },
703                {
704                  "transformation": "trivial_condition_removal",
705                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
706                }
707              ] /* steps */
708            } /* condition_processing */
709          },
710          {
711            "substitute_generated_columns": {
712            } /* substitute_generated_columns */
713          },
714          {
715            "table_dependencies": [
716              {
717                "table": "`t6`",
718                "row_may_be_null": false,
719                "map_bit": 0,
720                "depends_on_map_bits": [
721                ] /* depends_on_map_bits */
722              }
723            ] /* table_dependencies */
724          },
725          {
726            "ref_optimizer_key_uses": [
727              {
728                "table": "`t6`",
729                "field": "d",
730                "equals": "ifnull(NULL,NULL)",
731                "null_rejecting": false
732              }
733            ] /* ref_optimizer_key_uses */
734          },
735          {
736            "rows_estimation": [
737              {
738                "table": "`t6`",
739                "range_analysis": {
740                  "table_scan": {
741                    "rows": 2,
742                    "cost": 4.5034
743                  } /* table_scan */,
744                  "potential_range_indexes": [
745                    {
746                      "index": "d",
747                      "usable": true,
748                      "key_parts": [
749                        "d"
750                      ] /* key_parts */
751                    }
752                  ] /* potential_range_indexes */,
753                  "best_covering_index_scan": {
754                    "index": "d",
755                    "cost": 1.4233,
756                    "chosen": true
757                  } /* best_covering_index_scan */,
758                  "setup_range_conditions": [
759                    {
760                      "impossible_condition": {
761                        "cause": "comparison_with_null_always_false"
762                      } /* impossible_condition */
763                    }
764                  ] /* setup_range_conditions */,
765                  "impossible_range": true
766                } /* range_analysis */,
767                "rows": 0,
768                "cause": "impossible_where_condition"
769              }
770            ] /* rows_estimation */
771          }
772        ] /* steps */,
773        "empty_result": {
774          "cause": "no matching row in const table"
775        } /* empty_result */
776      } /* join_optimization */
777    },
778    {
779      "join_optimization": {
780        "select#": 3,
781        "steps": [
782          {
783            "condition_processing": {
784              "condition": "WHERE",
785              "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
786              "steps": [
787                {
788                  "transformation": "equality_propagation",
789                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
790                },
791                {
792                  "transformation": "constant_propagation",
793                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
794                },
795                {
796                  "transformation": "trivial_condition_removal",
797                  "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
798                }
799              ] /* steps */
800            } /* condition_processing */
801          },
802          {
803            "substitute_generated_columns": {
804            } /* substitute_generated_columns */
805          },
806          {
807            "table_dependencies": [
808              {
809                "table": "`t6`",
810                "row_may_be_null": false,
811                "map_bit": 0,
812                "depends_on_map_bits": [
813                ] /* depends_on_map_bits */
814              }
815            ] /* table_dependencies */
816          },
817          {
818            "ref_optimizer_key_uses": [
819              {
820                "table": "`t6`",
821                "field": "d",
822                "equals": "ifnull(NULL,NULL)",
823                "null_rejecting": false
824              }
825            ] /* ref_optimizer_key_uses */
826          },
827          {
828            "rows_estimation": [
829              {
830                "table": "`t6`",
831                "range_analysis": {
832                  "table_scan": {
833                    "rows": 2,
834                    "cost": 4.5034
835                  } /* table_scan */,
836                  "potential_range_indexes": [
837                    {
838                      "index": "d",
839                      "usable": true,
840                      "key_parts": [
841                        "d"
842                      ] /* key_parts */
843                    }
844                  ] /* potential_range_indexes */,
845                  "best_covering_index_scan": {
846                    "index": "d",
847                    "cost": 1.4233,
848                    "chosen": true
849                  } /* best_covering_index_scan */,
850                  "setup_range_conditions": [
851                    {
852                      "impossible_condition": {
853                        "cause": "comparison_with_null_always_false"
854                      } /* impossible_condition */
855                    }
856                  ] /* setup_range_conditions */,
857                  "impossible_range": true
858                } /* range_analysis */,
859                "rows": 0,
860                "cause": "impossible_where_condition"
861              }
862            ] /* rows_estimation */
863          }
864        ] /* steps */,
865        "empty_result": {
866          "cause": "no matching row in const table"
867        } /* empty_result */
868      } /* join_optimization */
869    },
870    {
871      "join_optimization": {
872        "select#": "fake",
873        "steps": [
874          {
875            "table_dependencies": [
876              {
877                "table": "``.``",
878                "row_may_be_null": false,
879                "map_bit": 0,
880                "depends_on_map_bits": [
881                ] /* depends_on_map_bits */
882              }
883            ] /* table_dependencies */
884          },
885          {
886            "rows_estimation": [
887              {
888                "table": "``.``",
889                "table_scan": {
890                  "rows": 0,
891                  "cost": 10
892                } /* table_scan */
893              }
894            ] /* rows_estimation */
895          },
896          {
897            "considered_execution_plans": [
898              {
899                "plan_prefix": [
900                ] /* plan_prefix */,
901                "table": "``.``",
902                "best_access_path": {
903                  "considered_access_paths": [
904                    {
905                      "rows_to_scan": 0,
906                      "access_type": "scan",
907                      "resulting_rows": 0,
908                      "cost": 10,
909                      "chosen": true
910                    }
911                  ] /* considered_access_paths */
912                } /* best_access_path */,
913                "condition_filtering_pct": 100,
914                "rows_for_plan": 0,
915                "cost_for_plan": 10,
916                "chosen": true
917              }
918            ] /* considered_execution_plans */
919          },
920          {
921            "attaching_conditions_to_tables": {
922              "original_condition": null,
923              "attached_conditions_computation": [
924              ] /* attached_conditions_computation */,
925              "attached_conditions_summary": [
926                {
927                  "table": "``.``",
928                  "attached": null
929                }
930              ] /* attached_conditions_summary */
931            } /* attaching_conditions_to_tables */
932          },
933          {
934            "refine_plan": [
935              {
936                "table": "``.``"
937              }
938            ] /* refine_plan */
939          }
940        ] /* steps */
941      } /* join_optimization */
942    },
943    {
944      "join_execution": {
945        "select#": 1,
946        "steps": [
947          {
948            "subselect_execution": {
949              "select#": 2,
950              "steps": [
951                {
952                  "join_execution": {
953                    "select#": 2,
954                    "steps": [
955                    ] /* steps */
956                  } /* join_execution */
957                },
958                {
959                  "join_execution": {
960                    "select#": 3,
961                    "steps": [
962                    ] /* steps */
963                  } /* join_execution */
964                },
965                {
966                  "join_execution": {
967                    "select#": "fake",
968                    "steps": [
969                    ] /* steps */
970                  } /* join_execution */
971                }
972              ] /* steps */
973            } /* subselect_execution */
974          }
975        ] /* steps */
976      } /* join_execution */
977    }
978  ] /* steps */
979}	0	0
980SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null));
981c
982select * from information_schema.OPTIMIZER_TRACE;
983QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
984SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null))	{
985  "steps": [
986    {
987      "join_preparation": {
988        "select#": 1,
989        "steps": [
990          {
991            "join_preparation": {
992              "select#": 2,
993              "steps": [
994                {
995                  "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
996                },
997                {
998                  "transformation": {
999                    "select#": 2,
1000                    "from": "IN (SELECT)",
1001                    "to": "semijoin",
1002                    "chosen": false
1003                  } /* transformation */
1004                },
1005                {
1006                  "transformation": {
1007                    "select#": 2,
1008                    "from": "IN (SELECT)",
1009                    "to": "EXISTS (CORRELATED SELECT)",
1010                    "chosen": true,
1011                    "evaluating_constant_where_conditions": [
1012                    ] /* evaluating_constant_where_conditions */
1013                  } /* transformation */
1014                }
1015              ] /* steps */
1016            } /* join_preparation */
1017          },
1018          {
1019            "join_preparation": {
1020              "select#": 3,
1021              "steps": [
1022                {
1023                  "expanded_query": "/* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
1024                },
1025                {
1026                  "transformation": {
1027                    "select#": 3,
1028                    "from": "IN (SELECT)",
1029                    "to": "semijoin",
1030                    "chosen": false
1031                  } /* transformation */
1032                },
1033                {
1034                  "transformation": {
1035                    "select#": 3,
1036                    "from": "IN (SELECT)",
1037                    "to": "EXISTS (CORRELATED SELECT)",
1038                    "chosen": true,
1039                    "evaluating_constant_where_conditions": [
1040                    ] /* evaluating_constant_where_conditions */
1041                  } /* transformation */
1042                }
1043              ] /* steps */
1044            } /* join_preparation */
1045          },
1046          {
1047            "creating_tmp_table": {
1048              "tmp_table_info": {
1049                "table": "intermediate_tmp_table",
1050                "row_length": 9,
1051                "key_length": 8,
1052                "unique_constraint": false,
1053                "location": "memory (heap)",
1054                "row_limit_estimate": 116508
1055              } /* tmp_table_info */
1056            } /* creating_tmp_table */
1057          },
1058          {
1059            "join_preparation": {
1060              "select#": "fake",
1061              "steps": [
1062                {
1063                  "expanded_query": "/* select#fake */ select `1` from dual"
1064                }
1065              ] /* steps */
1066            } /* join_preparation */
1067          },
1068          {
1069            "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where <in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1070          }
1071        ] /* steps */
1072      } /* join_preparation */
1073    },
1074    {
1075      "join_optimization": {
1076        "select#": 1,
1077        "steps": [
1078          {
1079            "condition_processing": {
1080              "condition": "WHERE",
1081              "original_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))",
1082              "steps": [
1083                {
1084                  "transformation": "equality_propagation",
1085                  "subselect_evaluation": [
1086                  ] /* subselect_evaluation */,
1087                  "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1088                },
1089                {
1090                  "transformation": "constant_propagation",
1091                  "subselect_evaluation": [
1092                  ] /* subselect_evaluation */,
1093                  "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1094                },
1095                {
1096                  "transformation": "trivial_condition_removal",
1097                  "subselect_evaluation": [
1098                  ] /* subselect_evaluation */,
1099                  "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1100                }
1101              ] /* steps */
1102            } /* condition_processing */
1103          },
1104          {
1105            "substitute_generated_columns": {
1106            } /* substitute_generated_columns */
1107          },
1108          {
1109            "table_dependencies": [
1110              {
1111                "table": "`t5`",
1112                "row_may_be_null": false,
1113                "map_bit": 0,
1114                "depends_on_map_bits": [
1115                ] /* depends_on_map_bits */
1116              }
1117            ] /* table_dependencies */
1118          },
1119          {
1120            "ref_optimizer_key_uses": [
1121            ] /* ref_optimizer_key_uses */
1122          },
1123          {
1124            "rows_estimation": [
1125              {
1126                "table": "`t5`",
1127                "rows": 1,
1128                "cost": 1,
1129                "table_type": "system",
1130                "empty": false
1131              }
1132            ] /* rows_estimation */
1133          },
1134          {
1135            "subselect_execution": {
1136              "select#": 2,
1137              "steps": [
1138                {
1139                  "join_optimization": {
1140                    "select#": 2,
1141                    "steps": [
1142                      {
1143                        "condition_processing": {
1144                          "condition": "WHERE",
1145                          "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))",
1146                          "steps": [
1147                            {
1148                              "transformation": "equality_propagation",
1149                              "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))"
1150                            },
1151                            {
1152                              "transformation": "constant_propagation",
1153                              "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 1))"
1154                            },
1155                            {
1156                              "transformation": "trivial_condition_removal",
1157                              "resulting_condition": null
1158                            }
1159                          ] /* steps */
1160                        } /* condition_processing */
1161                      }
1162                    ] /* steps */,
1163                    "empty_result": {
1164                      "cause": "Impossible WHERE"
1165                    } /* empty_result */
1166                  } /* join_optimization */
1167                },
1168                {
1169                  "join_optimization": {
1170                    "select#": 3,
1171                    "steps": [
1172                      {
1173                        "condition_processing": {
1174                          "condition": "WHERE",
1175                          "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))",
1176                          "steps": [
1177                            {
1178                              "transformation": "equality_propagation",
1179                              "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))"
1180                            },
1181                            {
1182                              "transformation": "constant_propagation",
1183                              "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 2))"
1184                            },
1185                            {
1186                              "transformation": "trivial_condition_removal",
1187                              "resulting_condition": null
1188                            }
1189                          ] /* steps */
1190                        } /* condition_processing */
1191                      }
1192                    ] /* steps */,
1193                    "empty_result": {
1194                      "cause": "Impossible WHERE"
1195                    } /* empty_result */
1196                  } /* join_optimization */
1197                },
1198                {
1199                  "join_optimization": {
1200                    "select#": "fake",
1201                    "steps": [
1202                      {
1203                        "table_dependencies": [
1204                          {
1205                            "table": "``.``",
1206                            "row_may_be_null": false,
1207                            "map_bit": 0,
1208                            "depends_on_map_bits": [
1209                            ] /* depends_on_map_bits */
1210                          }
1211                        ] /* table_dependencies */
1212                      },
1213                      {
1214                        "rows_estimation": [
1215                          {
1216                            "table": "``.``",
1217                            "table_scan": {
1218                              "rows": 0,
1219                              "cost": 10
1220                            } /* table_scan */
1221                          }
1222                        ] /* rows_estimation */
1223                      },
1224                      {
1225                        "considered_execution_plans": [
1226                          {
1227                            "plan_prefix": [
1228                            ] /* plan_prefix */,
1229                            "table": "``.``",
1230                            "best_access_path": {
1231                              "considered_access_paths": [
1232                                {
1233                                  "rows_to_scan": 0,
1234                                  "access_type": "scan",
1235                                  "resulting_rows": 0,
1236                                  "cost": 10,
1237                                  "chosen": true
1238                                }
1239                              ] /* considered_access_paths */
1240                            } /* best_access_path */,
1241                            "condition_filtering_pct": 100,
1242                            "rows_for_plan": 0,
1243                            "cost_for_plan": 10,
1244                            "chosen": true
1245                          }
1246                        ] /* considered_execution_plans */
1247                      },
1248                      {
1249                        "transformation": {
1250                          "select#": "fake",
1251                          "from": "IN (SELECT)",
1252                          "to": "EXISTS (CORRELATED SELECT)",
1253                          "put_1_in_SELECT_list": true
1254                        } /* transformation */
1255                      },
1256                      {
1257                        "attaching_conditions_to_tables": {
1258                          "original_condition": null,
1259                          "attached_conditions_computation": [
1260                          ] /* attached_conditions_computation */,
1261                          "attached_conditions_summary": [
1262                            {
1263                              "table": "``.``",
1264                              "attached": null
1265                            }
1266                          ] /* attached_conditions_summary */
1267                        } /* attaching_conditions_to_tables */
1268                      },
1269                      {
1270                        "refine_plan": [
1271                          {
1272                            "table": "``.``"
1273                          }
1274                        ] /* refine_plan */
1275                      }
1276                    ] /* steps */
1277                  } /* join_optimization */
1278                },
1279                {
1280                  "join_execution": {
1281                    "select#": 2,
1282                    "steps": [
1283                    ] /* steps */
1284                  } /* join_execution */
1285                },
1286                {
1287                  "join_execution": {
1288                    "select#": 3,
1289                    "steps": [
1290                    ] /* steps */
1291                  } /* join_execution */
1292                },
1293                {
1294                  "join_execution": {
1295                    "select#": "fake",
1296                    "steps": [
1297                    ] /* steps */
1298                  } /* join_execution */
1299                }
1300              ] /* steps */
1301            } /* subselect_execution */
1302          },
1303          {
1304            "condition_on_constant_tables": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where 0 union /* select#3 */ select 2 from `t6` where 0))",
1305            "condition_value": false
1306          }
1307        ] /* steps */,
1308        "empty_result": {
1309          "cause": "Impossible WHERE noticed after reading const tables"
1310        } /* empty_result */
1311      } /* join_optimization */
1312    },
1313    {
1314      "join_execution": {
1315        "select#": 1,
1316        "steps": [
1317        ] /* steps */
1318      } /* join_execution */
1319    }
1320  ] /* steps */
1321}	0	0
1322select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1323(@query:=QUERY)+NULL	(@trace:=TRACE)+NULL
1324NULL	NULL
1325select length(@trace);
1326length(@trace)
132713598
1328set @max_mem_size=13900;
1329set optimizer_trace_max_mem_size=@max_mem_size;
1330select length(@query)+length(@trace) > @@optimizer_trace_max_mem_size;
1331length(@query)+length(@trace) > @@optimizer_trace_max_mem_size
13320
1333SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null));
1334c
1335select (@missing_bytes:=missing_bytes_beyond_max_mem_size) from information_schema.OPTIMIZER_TRACE;
1336(@missing_bytes:=missing_bytes_beyond_max_mem_size)
13370
1338select (@query2:=QUERY)+NULL,(@trace2:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1339(@query2:=QUERY)+NULL	(@trace2:=TRACE)+NULL
1340NULL	NULL
1341select length(@trace2),
1342(length(@trace2) + @missing_bytes) = length(@trace),
1343@query2 = @query;
1344length(@trace2)	(length(@trace2) + @missing_bytes) = length(@trace)	@query2 = @query
134513598	1	1
1346select length(@query2) + length(@trace2)
1347between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200);
1348length(@query2) + length(@trace2)
1349between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200)
13501
1351select instr(@trace, @trace2) = 1;
1352instr(@trace, @trace2) = 1
13531
1354set optimizer_trace_max_mem_size=1;
1355select 1;
13561
13571
1358select * from information_schema.OPTIMIZER_TRACE;
1359QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
1360select 1		521	0
1361set optimizer_trace_max_mem_size=0;
1362select 1;
13631
13641
1365select * from information_schema.OPTIMIZER_TRACE;
1366QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
1367		529	0
1368set optimizer_trace_max_mem_size=1048576;
1369explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1370id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
13711	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
13722	DEPENDENT SUBQUERY	t6	NULL	ref	d	d	5	const	1	100.00	Using where; Using index
1373Warnings:
1374Note	1003	/* select#1 */ select NULL AS `c` from dual where <in_optimizer>((NULL + 1),<exists>(/* select#2 */ select 1 from `test`.`t6` where (isnull(`test`.`t6`.`d`) and (<cache>((NULL + 1)) = (`test`.`t6`.`d` + 1)))))
1375select * from information_schema.OPTIMIZER_TRACE;
1376QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
1377explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null)	{
1378  "steps": [
1379    {
1380      "join_preparation": {
1381        "select#": 1,
1382        "steps": [
1383          {
1384            "join_preparation": {
1385              "select#": 2,
1386              "steps": [
1387                {
1388                  "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where isnull(`t6`.`d`)"
1389                },
1390                {
1391                  "transformation": {
1392                    "select#": 2,
1393                    "from": "IN (SELECT)",
1394                    "to": "semijoin",
1395                    "chosen": false
1396                  } /* transformation */
1397                },
1398                {
1399                  "transformation": {
1400                    "select#": 2,
1401                    "from": "IN (SELECT)",
1402                    "to": "EXISTS (CORRELATED SELECT)",
1403                    "chosen": true,
1404                    "evaluating_constant_where_conditions": [
1405                    ] /* evaluating_constant_where_conditions */
1406                  } /* transformation */
1407                }
1408              ] /* steps */
1409            } /* join_preparation */
1410          },
1411          {
1412            "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where <in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1413          }
1414        ] /* steps */
1415      } /* join_preparation */
1416    },
1417    {
1418      "join_optimization": {
1419        "select#": 1,
1420        "steps": [
1421          {
1422            "condition_processing": {
1423              "condition": "WHERE",
1424              "original_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))",
1425              "steps": [
1426                {
1427                  "transformation": "equality_propagation",
1428                  "subselect_evaluation": [
1429                  ] /* subselect_evaluation */,
1430                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1431                },
1432                {
1433                  "transformation": "constant_propagation",
1434                  "subselect_evaluation": [
1435                  ] /* subselect_evaluation */,
1436                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1437                },
1438                {
1439                  "transformation": "trivial_condition_removal",
1440                  "subselect_evaluation": [
1441                  ] /* subselect_evaluation */,
1442                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1443                }
1444              ] /* steps */
1445            } /* condition_processing */
1446          },
1447          {
1448            "substitute_generated_columns": {
1449            } /* substitute_generated_columns */
1450          },
1451          {
1452            "table_dependencies": [
1453              {
1454                "table": "`t5`",
1455                "row_may_be_null": false,
1456                "map_bit": 0,
1457                "depends_on_map_bits": [
1458                ] /* depends_on_map_bits */
1459              }
1460            ] /* table_dependencies */
1461          },
1462          {
1463            "ref_optimizer_key_uses": [
1464            ] /* ref_optimizer_key_uses */
1465          },
1466          {
1467            "rows_estimation": [
1468              {
1469                "table": "`t5`",
1470                "rows": 1,
1471                "cost": 1,
1472                "table_type": "system",
1473                "empty": false
1474              }
1475            ] /* rows_estimation */
1476          },
1477          {
1478            "condition_on_constant_tables": "<in_optimizer>((NULL + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))))",
1479            "condition_value": false
1480          }
1481        ] /* steps */,
1482        "empty_result": {
1483          "cause": "Impossible WHERE noticed after reading const tables"
1484        } /* empty_result */
1485      } /* join_optimization */
1486    },
1487    {
1488      "join_optimization": {
1489        "select#": 2,
1490        "steps": [
1491          {
1492            "condition_processing": {
1493              "condition": "WHERE",
1494              "original_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))",
1495              "steps": [
1496                {
1497                  "transformation": "equality_propagation",
1498                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1499                },
1500                {
1501                  "transformation": "constant_propagation",
1502                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1503                },
1504                {
1505                  "transformation": "trivial_condition_removal",
1506                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1507                }
1508              ] /* steps */
1509            } /* condition_processing */
1510          },
1511          {
1512            "substitute_generated_columns": {
1513            } /* substitute_generated_columns */
1514          },
1515          {
1516            "table_dependencies": [
1517              {
1518                "table": "`t6`",
1519                "row_may_be_null": false,
1520                "map_bit": 0,
1521                "depends_on_map_bits": [
1522                ] /* depends_on_map_bits */
1523              }
1524            ] /* table_dependencies */
1525          },
1526          {
1527            "ref_optimizer_key_uses": [
1528              {
1529                "table": "`t6`",
1530                "field": "d",
1531                "equals": "NULL",
1532                "null_rejecting": false
1533              }
1534            ] /* ref_optimizer_key_uses */
1535          },
1536          {
1537            "rows_estimation": [
1538              {
1539                "table": "`t6`",
1540                "range_analysis": {
1541                  "table_scan": {
1542                    "rows": 2,
1543                    "cost": 4.5034
1544                  } /* table_scan */,
1545                  "potential_range_indexes": [
1546                    {
1547                      "index": "d",
1548                      "usable": true,
1549                      "key_parts": [
1550                        "d"
1551                      ] /* key_parts */
1552                    }
1553                  ] /* potential_range_indexes */,
1554                  "best_covering_index_scan": {
1555                    "index": "d",
1556                    "cost": 1.4233,
1557                    "chosen": true
1558                  } /* best_covering_index_scan */,
1559                  "setup_range_conditions": [
1560                  ] /* setup_range_conditions */,
1561                  "group_index_range": {
1562                    "chosen": false,
1563                    "cause": "not_group_by_or_distinct"
1564                  } /* group_index_range */,
1565                  "analyzing_range_alternatives": {
1566                    "range_scan_alternatives": [
1567                      {
1568                        "index": "d",
1569                        "ranges": [
1570                          "NULL <= d <= NULL"
1571                        ] /* ranges */,
1572                        "index_dives_for_eq_ranges": true,
1573                        "rowid_ordered": true,
1574                        "using_mrr": false,
1575                        "index_only": true,
1576                        "rows": 1,
1577                        "cost": 1.21,
1578                        "chosen": true
1579                      }
1580                    ] /* range_scan_alternatives */,
1581                    "analyzing_roworder_intersect": {
1582                      "usable": false,
1583                      "cause": "too_few_roworder_scans"
1584                    } /* analyzing_roworder_intersect */
1585                  } /* analyzing_range_alternatives */,
1586                  "chosen_range_access_summary": {
1587                    "range_access_plan": {
1588                      "type": "range_scan",
1589                      "index": "d",
1590                      "rows": 1,
1591                      "ranges": [
1592                        "NULL <= d <= NULL"
1593                      ] /* ranges */
1594                    } /* range_access_plan */,
1595                    "rows_for_plan": 1,
1596                    "cost_for_plan": 1.21,
1597                    "chosen": true
1598                  } /* chosen_range_access_summary */
1599                } /* range_analysis */
1600              }
1601            ] /* rows_estimation */
1602          },
1603          {
1604            "considered_execution_plans": [
1605              {
1606                "plan_prefix": [
1607                ] /* plan_prefix */,
1608                "table": "`t6`",
1609                "best_access_path": {
1610                  "considered_access_paths": [
1611                    {
1612                      "access_type": "ref",
1613                      "index": "d",
1614                      "rows": 1,
1615                      "cost": 1.2,
1616                      "chosen": true
1617                    },
1618                    {
1619                      "access_type": "range",
1620                      "range_details": {
1621                        "used_index": "d"
1622                      } /* range_details */,
1623                      "chosen": false,
1624                      "cause": "heuristic_index_cheaper"
1625                    }
1626                  ] /* considered_access_paths */
1627                } /* best_access_path */,
1628                "condition_filtering_pct": 100,
1629                "rows_for_plan": 1,
1630                "cost_for_plan": 1.2,
1631                "chosen": true
1632              }
1633            ] /* considered_execution_plans */
1634          },
1635          {
1636            "transformation": {
1637              "select#": 2,
1638              "from": "IN (SELECT)",
1639              "to": "EXISTS (CORRELATED SELECT)",
1640              "put_1_in_SELECT_list": true
1641            } /* transformation */
1642          },
1643          {
1644            "attaching_conditions_to_tables": {
1645              "original_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))",
1646              "attached_conditions_computation": [
1647              ] /* attached_conditions_computation */,
1648              "attached_conditions_summary": [
1649                {
1650                  "table": "`t6`",
1651                  "attached": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1652                }
1653              ] /* attached_conditions_summary */
1654            } /* attaching_conditions_to_tables */
1655          },
1656          {
1657            "refine_plan": [
1658              {
1659                "table": "`t6`"
1660              }
1661            ] /* refine_plan */
1662          }
1663        ] /* steps */
1664      } /* join_optimization */
1665    },
1666    {
1667      "join_explain": {
1668        "select#": 1,
1669        "steps": [
1670          {
1671            "join_explain": {
1672              "select#": 2,
1673              "steps": [
1674              ] /* steps */
1675            } /* join_explain */
1676          }
1677        ] /* steps */
1678      } /* join_explain */
1679    }
1680  ] /* steps */
1681}	0	0
1682set @old_opt_switch=@@optimizer_switch;
1683explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1684id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
16851	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
16862	DEPENDENT SUBQUERY	t6	NULL	ref	d	d	5	const	1	100.00	Using where; Using index
1687Warnings:
1688Note	1003	/* select#1 */ select NULL AS `c` from dual where <in_optimizer>((NULL + 1),<exists>(/* select#2 */ select 1 from `test`.`t6` where (isnull(`test`.`t6`.`d`) and (<cache>((NULL + 1)) = (`test`.`t6`.`d` + 1)))))
1689select * from information_schema.OPTIMIZER_TRACE;
1690QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
1691explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null)	{
1692  "steps": [
1693    {
1694      "join_preparation": {
1695        "select#": 1,
1696        "steps": [
1697          {
1698            "join_preparation": {
1699              "select#": 2,
1700              "steps": [
1701                {
1702                  "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where isnull(`t6`.`d`)"
1703                },
1704                {
1705                  "transformation": {
1706                    "select#": 2,
1707                    "from": "IN (SELECT)",
1708                    "to": "semijoin",
1709                    "chosen": false
1710                  } /* transformation */
1711                },
1712                {
1713                  "transformation": {
1714                    "select#": 2,
1715                    "from": "IN (SELECT)",
1716                    "to": "EXISTS (CORRELATED SELECT)",
1717                    "chosen": true,
1718                    "evaluating_constant_where_conditions": [
1719                    ] /* evaluating_constant_where_conditions */
1720                  } /* transformation */
1721                }
1722              ] /* steps */
1723            } /* join_preparation */
1724          },
1725          {
1726            "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where <in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1727          }
1728        ] /* steps */
1729      } /* join_preparation */
1730    },
1731    {
1732      "join_optimization": {
1733        "select#": 1,
1734        "steps": [
1735          {
1736            "condition_processing": {
1737              "condition": "WHERE",
1738              "original_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))",
1739              "steps": [
1740                {
1741                  "transformation": "equality_propagation",
1742                  "subselect_evaluation": [
1743                  ] /* subselect_evaluation */,
1744                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1745                },
1746                {
1747                  "transformation": "constant_propagation",
1748                  "subselect_evaluation": [
1749                  ] /* subselect_evaluation */,
1750                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1751                },
1752                {
1753                  "transformation": "trivial_condition_removal",
1754                  "subselect_evaluation": [
1755                  ] /* subselect_evaluation */,
1756                  "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1757                }
1758              ] /* steps */
1759            } /* condition_processing */
1760          },
1761          {
1762            "substitute_generated_columns": {
1763            } /* substitute_generated_columns */
1764          },
1765          {
1766            "table_dependencies": [
1767              {
1768                "table": "`t5`",
1769                "row_may_be_null": false,
1770                "map_bit": 0,
1771                "depends_on_map_bits": [
1772                ] /* depends_on_map_bits */
1773              }
1774            ] /* table_dependencies */
1775          },
1776          {
1777            "ref_optimizer_key_uses": [
1778            ] /* ref_optimizer_key_uses */
1779          },
1780          {
1781            "rows_estimation": [
1782              {
1783                "table": "`t5`",
1784                "rows": 1,
1785                "cost": 1,
1786                "table_type": "system",
1787                "empty": false
1788              }
1789            ] /* rows_estimation */
1790          },
1791          {
1792            "condition_on_constant_tables": "<in_optimizer>((NULL + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where (isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))))",
1793            "condition_value": false
1794          }
1795        ] /* steps */,
1796        "empty_result": {
1797          "cause": "Impossible WHERE noticed after reading const tables"
1798        } /* empty_result */
1799      } /* join_optimization */
1800    },
1801    {
1802      "join_optimization": {
1803        "select#": 2,
1804        "steps": [
1805          {
1806            "condition_processing": {
1807              "condition": "WHERE",
1808              "original_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))",
1809              "steps": [
1810                {
1811                  "transformation": "equality_propagation",
1812                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1813                },
1814                {
1815                  "transformation": "constant_propagation",
1816                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1817                },
1818                {
1819                  "transformation": "trivial_condition_removal",
1820                  "resulting_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1821                }
1822              ] /* steps */
1823            } /* condition_processing */
1824          },
1825          {
1826            "substitute_generated_columns": {
1827            } /* substitute_generated_columns */
1828          },
1829          {
1830            "table_dependencies": [
1831              {
1832                "table": "`t6`",
1833                "row_may_be_null": false,
1834                "map_bit": 0,
1835                "depends_on_map_bits": [
1836                ] /* depends_on_map_bits */
1837              }
1838            ] /* table_dependencies */
1839          },
1840          {
1841            "ref_optimizer_key_uses": [
1842              {
1843                "table": "`t6`",
1844                "field": "d",
1845                "equals": "NULL",
1846                "null_rejecting": false
1847              }
1848            ] /* ref_optimizer_key_uses */
1849          },
1850          {
1851            "rows_estimation": [
1852              {
1853                "table": "`t6`",
1854                "range_analysis": {
1855                  "table_scan": {
1856                    "rows": 2,
1857                    "cost": 4.5034
1858                  } /* table_scan */,
1859                  "potential_range_indexes": [
1860                    {
1861                      "index": "d",
1862                      "usable": true,
1863                      "key_parts": [
1864                        "d"
1865                      ] /* key_parts */
1866                    }
1867                  ] /* potential_range_indexes */,
1868                  "best_covering_index_scan": {
1869                    "index": "d",
1870                    "cost": 1.4233,
1871                    "chosen": true
1872                  } /* best_covering_index_scan */,
1873                  "setup_range_conditions": [
1874                  ] /* setup_range_conditions */,
1875                  "group_index_range": {
1876                    "chosen": false,
1877                    "cause": "not_group_by_or_distinct"
1878                  } /* group_index_range */,
1879                  "analyzing_range_alternatives": {
1880                    "range_scan_alternatives": [
1881                      {
1882                        "index": "d",
1883                        "ranges": [
1884                          "NULL <= d <= NULL"
1885                        ] /* ranges */,
1886                        "index_dives_for_eq_ranges": true,
1887                        "rowid_ordered": true,
1888                        "using_mrr": false,
1889                        "index_only": true,
1890                        "rows": 1,
1891                        "cost": 1.21,
1892                        "chosen": true
1893                      }
1894                    ] /* range_scan_alternatives */,
1895                    "analyzing_roworder_intersect": {
1896                      "usable": false,
1897                      "cause": "too_few_roworder_scans"
1898                    } /* analyzing_roworder_intersect */
1899                  } /* analyzing_range_alternatives */,
1900                  "chosen_range_access_summary": {
1901                    "range_access_plan": {
1902                      "type": "range_scan",
1903                      "index": "d",
1904                      "rows": 1,
1905                      "ranges": [
1906                        "NULL <= d <= NULL"
1907                      ] /* ranges */
1908                    } /* range_access_plan */,
1909                    "rows_for_plan": 1,
1910                    "cost_for_plan": 1.21,
1911                    "chosen": true
1912                  } /* chosen_range_access_summary */
1913                } /* range_analysis */
1914              }
1915            ] /* rows_estimation */
1916          },
1917          {
1918            "considered_execution_plans": [
1919              {
1920                "plan_prefix": [
1921                ] /* plan_prefix */,
1922                "table": "`t6`",
1923                "best_access_path": {
1924                  "considered_access_paths": [
1925                    {
1926                      "access_type": "ref",
1927                      "index": "d",
1928                      "rows": 1,
1929                      "cost": 1.2,
1930                      "chosen": true
1931                    },
1932                    {
1933                      "access_type": "range",
1934                      "range_details": {
1935                        "used_index": "d"
1936                      } /* range_details */,
1937                      "chosen": false,
1938                      "cause": "heuristic_index_cheaper"
1939                    }
1940                  ] /* considered_access_paths */
1941                } /* best_access_path */,
1942                "condition_filtering_pct": 100,
1943                "rows_for_plan": 1,
1944                "cost_for_plan": 1.2,
1945                "chosen": true
1946              }
1947            ] /* considered_execution_plans */
1948          },
1949          {
1950            "transformation": {
1951              "select#": 2,
1952              "from": "IN (SELECT)",
1953              "to": "EXISTS (CORRELATED SELECT)",
1954              "put_1_in_SELECT_list": true
1955            } /* transformation */
1956          },
1957          {
1958            "attaching_conditions_to_tables": {
1959              "original_condition": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))",
1960              "attached_conditions_computation": [
1961              ] /* attached_conditions_computation */,
1962              "attached_conditions_summary": [
1963                {
1964                  "table": "`t6`",
1965                  "attached": "(isnull(`t6`.`d`) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1966                }
1967              ] /* attached_conditions_summary */
1968            } /* attaching_conditions_to_tables */
1969          },
1970          {
1971            "refine_plan": [
1972              {
1973                "table": "`t6`"
1974              }
1975            ] /* refine_plan */
1976          }
1977        ] /* steps */
1978      } /* join_optimization */
1979    },
1980    {
1981      "join_explain": {
1982        "select#": 1,
1983        "steps": [
1984          {
1985            "join_explain": {
1986              "select#": 2,
1987              "steps": [
1988              ] /* steps */
1989            } /* join_explain */
1990          }
1991        ] /* steps */
1992      } /* join_explain */
1993    }
1994  ] /* steps */
1995}	0	0
1996set optimizer_switch=@old_opt_switch;
1997CREATE TABLE t1 (s1 CHAR(5),
1998s2 CHAR(5));
1999INSERT INTO t1 VALUES ('z','?'),('y','!');
2000explain extended select * from t1 where s1 > any (select s2 from t1);
2001id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
20021	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where
20032	SUBQUERY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
2004Warnings:
2005Warning	1681	'EXTENDED' is deprecated and will be removed in a future release.
2006Note	1003	/* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <nop>((`test`.`t1`.`s1` > (/* select#2 */ select min(`test`.`t1`.`s2`) from `test`.`t1`)))
2007select * from information_schema.OPTIMIZER_TRACE;
2008QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
2009explain extended select * from t1 where s1 > any (select s2 from t1)	{
2010  "steps": [
2011    {
2012      "join_preparation": {
2013        "select#": 1,
2014        "steps": [
2015          {
2016            "join_preparation": {
2017              "select#": 2,
2018              "steps": [
2019                {
2020                  "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
2021                },
2022                {
2023                  "transformation": {
2024                    "select#": 2,
2025                    "from": "> ALL/ANY (SELECT)",
2026                    "to": "SELECT(MIN)",
2027                    "chosen": true
2028                  } /* transformation */
2029                }
2030              ] /* steps */
2031            } /* join_preparation */
2032          },
2033          {
2034            "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
2035          }
2036        ] /* steps */
2037      } /* join_preparation */
2038    },
2039    {
2040      "join_optimization": {
2041        "select#": 1,
2042        "steps": [
2043          {
2044            "condition_processing": {
2045              "condition": "WHERE",
2046              "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
2047              "steps": [
2048                {
2049                  "transformation": "equality_propagation",
2050                  "subselect_evaluation": [
2051                  ] /* subselect_evaluation */,
2052                  "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
2053                },
2054                {
2055                  "transformation": "constant_propagation",
2056                  "subselect_evaluation": [
2057                  ] /* subselect_evaluation */,
2058                  "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
2059                },
2060                {
2061                  "transformation": "trivial_condition_removal",
2062                  "subselect_evaluation": [
2063                  ] /* subselect_evaluation */,
2064                  "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
2065                }
2066              ] /* steps */
2067            } /* condition_processing */
2068          },
2069          {
2070            "substitute_generated_columns": {
2071            } /* substitute_generated_columns */
2072          },
2073          {
2074            "table_dependencies": [
2075              {
2076                "table": "`t1`",
2077                "row_may_be_null": false,
2078                "map_bit": 0,
2079                "depends_on_map_bits": [
2080                ] /* depends_on_map_bits */
2081              }
2082            ] /* table_dependencies */
2083          },
2084          {
2085            "ref_optimizer_key_uses": [
2086            ] /* ref_optimizer_key_uses */
2087          },
2088          {
2089            "rows_estimation": [
2090              {
2091                "table": "`t1`",
2092                "table_scan": {
2093                  "rows": 2,
2094                  "cost": 2
2095                } /* table_scan */
2096              }
2097            ] /* rows_estimation */
2098          },
2099          {
2100            "considered_execution_plans": [
2101              {
2102                "plan_prefix": [
2103                ] /* plan_prefix */,
2104                "table": "`t1`",
2105                "best_access_path": {
2106                  "considered_access_paths": [
2107                    {
2108                      "rows_to_scan": 2,
2109                      "access_type": "scan",
2110                      "resulting_rows": 1,
2111                      "cost": 2.4054,
2112                      "chosen": true
2113                    }
2114                  ] /* considered_access_paths */
2115                } /* best_access_path */,
2116                "condition_filtering_pct": 100,
2117                "rows_for_plan": 1,
2118                "cost_for_plan": 2.4054,
2119                "chosen": true
2120              }
2121            ] /* considered_execution_plans */
2122          },
2123          {
2124            "attaching_conditions_to_tables": {
2125              "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
2126              "attached_conditions_computation": [
2127              ] /* attached_conditions_computation */,
2128              "attached_conditions_summary": [
2129                {
2130                  "table": "`t1`",
2131                  "attached": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
2132                }
2133              ] /* attached_conditions_summary */
2134            } /* attaching_conditions_to_tables */
2135          },
2136          {
2137            "refine_plan": [
2138              {
2139                "table": "`t1`"
2140              }
2141            ] /* refine_plan */
2142          }
2143        ] /* steps */
2144      } /* join_optimization */
2145    },
2146    {
2147      "join_optimization": {
2148        "select#": 2,
2149        "steps": [
2150          {
2151            "table_dependencies": [
2152              {
2153                "table": "`t1`",
2154                "row_may_be_null": false,
2155                "map_bit": 0,
2156                "depends_on_map_bits": [
2157                ] /* depends_on_map_bits */
2158              }
2159            ] /* table_dependencies */
2160          },
2161          {
2162            "rows_estimation": [
2163              {
2164                "table": "`t1`",
2165                "table_scan": {
2166                  "rows": 2,
2167                  "cost": 2
2168                } /* table_scan */
2169              }
2170            ] /* rows_estimation */
2171          },
2172          {
2173            "considered_execution_plans": [
2174              {
2175                "plan_prefix": [
2176                ] /* plan_prefix */,
2177                "table": "`t1`",
2178                "best_access_path": {
2179                  "considered_access_paths": [
2180                    {
2181                      "rows_to_scan": 2,
2182                      "access_type": "scan",
2183                      "resulting_rows": 2,
2184                      "cost": 2.4054,
2185                      "chosen": true
2186                    }
2187                  ] /* considered_access_paths */
2188                } /* best_access_path */,
2189                "condition_filtering_pct": 100,
2190                "rows_for_plan": 2,
2191                "cost_for_plan": 2.4054,
2192                "chosen": true
2193              }
2194            ] /* considered_execution_plans */
2195          },
2196          {
2197            "attaching_conditions_to_tables": {
2198              "original_condition": null,
2199              "attached_conditions_computation": [
2200              ] /* attached_conditions_computation */,
2201              "attached_conditions_summary": [
2202                {
2203                  "table": "`t1`",
2204                  "attached": null
2205                }
2206              ] /* attached_conditions_summary */
2207            } /* attaching_conditions_to_tables */
2208          },
2209          {
2210            "refine_plan": [
2211              {
2212                "table": "`t1`"
2213              }
2214            ] /* refine_plan */
2215          }
2216        ] /* steps */
2217      } /* join_optimization */
2218    },
2219    {
2220      "join_explain": {
2221        "select#": 1,
2222        "steps": [
2223          {
2224            "join_explain": {
2225              "select#": 2,
2226              "steps": [
2227              ] /* steps */
2228            } /* join_explain */
2229          }
2230        ] /* steps */
2231      } /* join_explain */
2232    }
2233  ] /* steps */
2234}	0	0
2235explain extended select * from t1 where s1 > any (select max(s2) from t1);
2236id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
22371	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where
22382	SUBQUERY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
2239Warnings:
2240Warning	1681	'EXTENDED' is deprecated and will be removed in a future release.
2241Note	1003	/* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <nop>((`test`.`t1`.`s1` > <min>(/* select#2 */ select max(`test`.`t1`.`s2`) from `test`.`t1`)))
2242select * from information_schema.OPTIMIZER_TRACE;
2243QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
2244explain extended select * from t1 where s1 > any (select max(s2) from t1)	{
2245  "steps": [
2246    {
2247      "join_preparation": {
2248        "select#": 1,
2249        "steps": [
2250          {
2251            "join_preparation": {
2252              "select#": 2,
2253              "steps": [
2254                {
2255                  "expanded_query": "/* select#2 */ select max(`t1`.`s2`) from `t1`"
2256                },
2257                {
2258                  "transformation": {
2259                    "select#": 2,
2260                    "from": "> ALL/ANY (SELECT)",
2261                    "to": "MIN (SELECT)",
2262                    "chosen": true
2263                  } /* transformation */
2264                }
2265              ] /* steps */
2266            } /* join_preparation */
2267          },
2268          {
2269            "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2270          }
2271        ] /* steps */
2272      } /* join_preparation */
2273    },
2274    {
2275      "join_optimization": {
2276        "select#": 1,
2277        "steps": [
2278          {
2279            "condition_processing": {
2280              "condition": "WHERE",
2281              "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2282              "steps": [
2283                {
2284                  "transformation": "equality_propagation",
2285                  "subselect_evaluation": [
2286                  ] /* subselect_evaluation */,
2287                  "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2288                },
2289                {
2290                  "transformation": "constant_propagation",
2291                  "subselect_evaluation": [
2292                  ] /* subselect_evaluation */,
2293                  "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2294                },
2295                {
2296                  "transformation": "trivial_condition_removal",
2297                  "subselect_evaluation": [
2298                  ] /* subselect_evaluation */,
2299                  "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2300                }
2301              ] /* steps */
2302            } /* condition_processing */
2303          },
2304          {
2305            "substitute_generated_columns": {
2306            } /* substitute_generated_columns */
2307          },
2308          {
2309            "table_dependencies": [
2310              {
2311                "table": "`t1`",
2312                "row_may_be_null": false,
2313                "map_bit": 0,
2314                "depends_on_map_bits": [
2315                ] /* depends_on_map_bits */
2316              }
2317            ] /* table_dependencies */
2318          },
2319          {
2320            "ref_optimizer_key_uses": [
2321            ] /* ref_optimizer_key_uses */
2322          },
2323          {
2324            "rows_estimation": [
2325              {
2326                "table": "`t1`",
2327                "table_scan": {
2328                  "rows": 2,
2329                  "cost": 2
2330                } /* table_scan */
2331              }
2332            ] /* rows_estimation */
2333          },
2334          {
2335            "considered_execution_plans": [
2336              {
2337                "plan_prefix": [
2338                ] /* plan_prefix */,
2339                "table": "`t1`",
2340                "best_access_path": {
2341                  "considered_access_paths": [
2342                    {
2343                      "rows_to_scan": 2,
2344                      "access_type": "scan",
2345                      "resulting_rows": 1,
2346                      "cost": 2.4054,
2347                      "chosen": true
2348                    }
2349                  ] /* considered_access_paths */
2350                } /* best_access_path */,
2351                "condition_filtering_pct": 100,
2352                "rows_for_plan": 1,
2353                "cost_for_plan": 2.4054,
2354                "chosen": true
2355              }
2356            ] /* considered_execution_plans */
2357          },
2358          {
2359            "attaching_conditions_to_tables": {
2360              "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2361              "attached_conditions_computation": [
2362              ] /* attached_conditions_computation */,
2363              "attached_conditions_summary": [
2364                {
2365                  "table": "`t1`",
2366                  "attached": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2367                }
2368              ] /* attached_conditions_summary */
2369            } /* attaching_conditions_to_tables */
2370          },
2371          {
2372            "refine_plan": [
2373              {
2374                "table": "`t1`"
2375              }
2376            ] /* refine_plan */
2377          }
2378        ] /* steps */
2379      } /* join_optimization */
2380    },
2381    {
2382      "join_optimization": {
2383        "select#": 2,
2384        "steps": [
2385          {
2386            "table_dependencies": [
2387              {
2388                "table": "`t1`",
2389                "row_may_be_null": false,
2390                "map_bit": 0,
2391                "depends_on_map_bits": [
2392                ] /* depends_on_map_bits */
2393              }
2394            ] /* table_dependencies */
2395          },
2396          {
2397            "rows_estimation": [
2398              {
2399                "table": "`t1`",
2400                "table_scan": {
2401                  "rows": 2,
2402                  "cost": 2
2403                } /* table_scan */
2404              }
2405            ] /* rows_estimation */
2406          },
2407          {
2408            "considered_execution_plans": [
2409              {
2410                "plan_prefix": [
2411                ] /* plan_prefix */,
2412                "table": "`t1`",
2413                "best_access_path": {
2414                  "considered_access_paths": [
2415                    {
2416                      "rows_to_scan": 2,
2417                      "access_type": "scan",
2418                      "resulting_rows": 2,
2419                      "cost": 2.4054,
2420                      "chosen": true
2421                    }
2422                  ] /* considered_access_paths */
2423                } /* best_access_path */,
2424                "condition_filtering_pct": 100,
2425                "rows_for_plan": 2,
2426                "cost_for_plan": 2.4054,
2427                "chosen": true
2428              }
2429            ] /* considered_execution_plans */
2430          },
2431          {
2432            "attaching_conditions_to_tables": {
2433              "original_condition": null,
2434              "attached_conditions_computation": [
2435              ] /* attached_conditions_computation */,
2436              "attached_conditions_summary": [
2437                {
2438                  "table": "`t1`",
2439                  "attached": null
2440                }
2441              ] /* attached_conditions_summary */
2442            } /* attaching_conditions_to_tables */
2443          },
2444          {
2445            "refine_plan": [
2446              {
2447                "table": "`t1`"
2448              }
2449            ] /* refine_plan */
2450          }
2451        ] /* steps */
2452      } /* join_optimization */
2453    },
2454    {
2455      "join_explain": {
2456        "select#": 1,
2457        "steps": [
2458          {
2459            "join_explain": {
2460              "select#": 2,
2461              "steps": [
2462              ] /* steps */
2463            } /* join_explain */
2464          }
2465        ] /* steps */
2466      } /* join_explain */
2467    }
2468  ] /* steps */
2469}	0	0
2470explain extended select * from t1 where s1 in (select s2 from t1);
2471id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
24721	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
24732	DEPENDENT SUBQUERY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where
2474Warnings:
2475Warning	1681	'EXTENDED' is deprecated and will be removed in a future release.
2476Note	1003	/* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select 1 from `test`.`t1` where (<cache>(`test`.`t1`.`s1`) = `test`.`t1`.`s2`)))
2477select * from information_schema.OPTIMIZER_TRACE;
2478QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
2479explain extended select * from t1 where s1 in (select s2 from t1)	{
2480  "steps": [
2481    {
2482      "join_preparation": {
2483        "select#": 1,
2484        "steps": [
2485          {
2486            "join_preparation": {
2487              "select#": 2,
2488              "steps": [
2489                {
2490                  "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
2491                },
2492                {
2493                  "transformation": {
2494                    "select#": 2,
2495                    "from": "IN (SELECT)",
2496                    "to": "semijoin",
2497                    "chosen": false
2498                  } /* transformation */
2499                },
2500                {
2501                  "transformation": {
2502                    "select#": 2,
2503                    "from": "IN (SELECT)",
2504                    "to": "EXISTS (CORRELATED SELECT)",
2505                    "chosen": true,
2506                    "evaluating_constant_where_conditions": [
2507                    ] /* evaluating_constant_where_conditions */
2508                  } /* transformation */
2509                }
2510              ] /* steps */
2511            } /* join_preparation */
2512          },
2513          {
2514            "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2515          }
2516        ] /* steps */
2517      } /* join_preparation */
2518    },
2519    {
2520      "join_optimization": {
2521        "select#": 1,
2522        "steps": [
2523          {
2524            "condition_processing": {
2525              "condition": "WHERE",
2526              "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2527              "steps": [
2528                {
2529                  "transformation": "equality_propagation",
2530                  "subselect_evaluation": [
2531                  ] /* subselect_evaluation */,
2532                  "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2533                },
2534                {
2535                  "transformation": "constant_propagation",
2536                  "subselect_evaluation": [
2537                  ] /* subselect_evaluation */,
2538                  "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2539                },
2540                {
2541                  "transformation": "trivial_condition_removal",
2542                  "subselect_evaluation": [
2543                  ] /* subselect_evaluation */,
2544                  "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2545                }
2546              ] /* steps */
2547            } /* condition_processing */
2548          },
2549          {
2550            "substitute_generated_columns": {
2551            } /* substitute_generated_columns */
2552          },
2553          {
2554            "table_dependencies": [
2555              {
2556                "table": "`t1`",
2557                "row_may_be_null": false,
2558                "map_bit": 0,
2559                "depends_on_map_bits": [
2560                ] /* depends_on_map_bits */
2561              }
2562            ] /* table_dependencies */
2563          },
2564          {
2565            "ref_optimizer_key_uses": [
2566            ] /* ref_optimizer_key_uses */
2567          },
2568          {
2569            "rows_estimation": [
2570              {
2571                "table": "`t1`",
2572                "table_scan": {
2573                  "rows": 2,
2574                  "cost": 2
2575                } /* table_scan */
2576              }
2577            ] /* rows_estimation */
2578          },
2579          {
2580            "considered_execution_plans": [
2581              {
2582                "plan_prefix": [
2583                ] /* plan_prefix */,
2584                "table": "`t1`",
2585                "best_access_path": {
2586                  "considered_access_paths": [
2587                    {
2588                      "rows_to_scan": 2,
2589                      "access_type": "scan",
2590                      "resulting_rows": 2,
2591                      "cost": 2.4054,
2592                      "chosen": true
2593                    }
2594                  ] /* considered_access_paths */
2595                } /* best_access_path */,
2596                "condition_filtering_pct": 100,
2597                "rows_for_plan": 2,
2598                "cost_for_plan": 2.4054,
2599                "chosen": true
2600              }
2601            ] /* considered_execution_plans */
2602          },
2603          {
2604            "attaching_conditions_to_tables": {
2605              "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2606              "attached_conditions_computation": [
2607              ] /* attached_conditions_computation */,
2608              "attached_conditions_summary": [
2609                {
2610                  "table": "`t1`",
2611                  "attached": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2612                }
2613              ] /* attached_conditions_summary */
2614            } /* attaching_conditions_to_tables */
2615          },
2616          {
2617            "refine_plan": [
2618              {
2619                "table": "`t1`"
2620              }
2621            ] /* refine_plan */
2622          }
2623        ] /* steps */
2624      } /* join_optimization */
2625    },
2626    {
2627      "join_optimization": {
2628        "select#": 2,
2629        "steps": [
2630          {
2631            "condition_processing": {
2632              "condition": "WHERE",
2633              "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2634              "steps": [
2635                {
2636                  "transformation": "equality_propagation",
2637                  "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2638                },
2639                {
2640                  "transformation": "constant_propagation",
2641                  "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2642                },
2643                {
2644                  "transformation": "trivial_condition_removal",
2645                  "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2646                }
2647              ] /* steps */
2648            } /* condition_processing */
2649          },
2650          {
2651            "substitute_generated_columns": {
2652            } /* substitute_generated_columns */
2653          },
2654          {
2655            "table_dependencies": [
2656              {
2657                "table": "`t1`",
2658                "row_may_be_null": false,
2659                "map_bit": 0,
2660                "depends_on_map_bits": [
2661                ] /* depends_on_map_bits */
2662              }
2663            ] /* table_dependencies */
2664          },
2665          {
2666            "ref_optimizer_key_uses": [
2667            ] /* ref_optimizer_key_uses */
2668          },
2669          {
2670            "rows_estimation": [
2671              {
2672                "table": "`t1`",
2673                "table_scan": {
2674                  "rows": 2,
2675                  "cost": 2
2676                } /* table_scan */
2677              }
2678            ] /* rows_estimation */
2679          },
2680          {
2681            "considered_execution_plans": [
2682              {
2683                "plan_prefix": [
2684                ] /* plan_prefix */,
2685                "table": "`t1`",
2686                "best_access_path": {
2687                  "considered_access_paths": [
2688                    {
2689                      "rows_to_scan": 2,
2690                      "access_type": "scan",
2691                      "resulting_rows": 2,
2692                      "cost": 2.4054,
2693                      "chosen": true
2694                    }
2695                  ] /* considered_access_paths */
2696                } /* best_access_path */,
2697                "condition_filtering_pct": 50,
2698                "rows_for_plan": 1,
2699                "cost_for_plan": 2.4054,
2700                "chosen": true
2701              }
2702            ] /* considered_execution_plans */
2703          },
2704          {
2705            "transformation": {
2706              "select#": 2,
2707              "from": "IN (SELECT)",
2708              "to": "EXISTS (CORRELATED SELECT)",
2709              "put_1_in_SELECT_list": true
2710            } /* transformation */
2711          },
2712          {
2713            "attaching_conditions_to_tables": {
2714              "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2715              "attached_conditions_computation": [
2716              ] /* attached_conditions_computation */,
2717              "attached_conditions_summary": [
2718                {
2719                  "table": "`t1`",
2720                  "attached": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2721                }
2722              ] /* attached_conditions_summary */
2723            } /* attaching_conditions_to_tables */
2724          },
2725          {
2726            "refine_plan": [
2727              {
2728                "table": "`t1`"
2729              }
2730            ] /* refine_plan */
2731          }
2732        ] /* steps */
2733      } /* join_optimization */
2734    },
2735    {
2736      "join_explain": {
2737        "select#": 1,
2738        "steps": [
2739          {
2740            "join_explain": {
2741              "select#": 2,
2742              "steps": [
2743              ] /* steps */
2744            } /* join_explain */
2745          }
2746        ] /* steps */
2747      } /* join_explain */
2748    }
2749  ] /* steps */
2750}	0	0
2751explain extended select * from t1 where (s1,s2) in (select s2,s1 from t1);
2752id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
27531	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
27542	DEPENDENT SUBQUERY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where
2755Warnings:
2756Warning	1681	'EXTENDED' is deprecated and will be removed in a future release.
2757Note	1003	/* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`s1`,`test`.`t1`.`s2`),<exists>(/* select#2 */ select 1,1 from `test`.`t1` where ((<cache>(`test`.`t1`.`s1`) = `test`.`t1`.`s2`) and (<cache>(`test`.`t1`.`s2`) = `test`.`t1`.`s1`))))
2758select * from information_schema.OPTIMIZER_TRACE;
2759QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
2760explain extended select * from t1 where (s1,s2) in (select s2,s1 from t1)	{
2761  "steps": [
2762    {
2763      "join_preparation": {
2764        "select#": 1,
2765        "steps": [
2766          {
2767            "join_preparation": {
2768              "select#": 2,
2769              "steps": [
2770                {
2771                  "expanded_query": "/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1`"
2772                },
2773                {
2774                  "transformation": {
2775                    "select#": 2,
2776                    "from": "IN (SELECT)",
2777                    "to": "semijoin",
2778                    "chosen": false
2779                  } /* transformation */
2780                },
2781                {
2782                  "transformation": {
2783                    "select#": 2,
2784                    "from": "IN (SELECT)",
2785                    "to": "EXISTS (CORRELATED SELECT)",
2786                    "chosen": true,
2787                    "evaluating_constant_where_conditions": [
2788                    ] /* evaluating_constant_where_conditions */
2789                  } /* transformation */
2790                }
2791              ] /* steps */
2792            } /* join_preparation */
2793          },
2794          {
2795            "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2796          }
2797        ] /* steps */
2798      } /* join_preparation */
2799    },
2800    {
2801      "join_optimization": {
2802        "select#": 1,
2803        "steps": [
2804          {
2805            "condition_processing": {
2806              "condition": "WHERE",
2807              "original_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))",
2808              "steps": [
2809                {
2810                  "transformation": "equality_propagation",
2811                  "subselect_evaluation": [
2812                  ] /* subselect_evaluation */,
2813                  "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2814                },
2815                {
2816                  "transformation": "constant_propagation",
2817                  "subselect_evaluation": [
2818                  ] /* subselect_evaluation */,
2819                  "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2820                },
2821                {
2822                  "transformation": "trivial_condition_removal",
2823                  "subselect_evaluation": [
2824                  ] /* subselect_evaluation */,
2825                  "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2826                }
2827              ] /* steps */
2828            } /* condition_processing */
2829          },
2830          {
2831            "substitute_generated_columns": {
2832            } /* substitute_generated_columns */
2833          },
2834          {
2835            "table_dependencies": [
2836              {
2837                "table": "`t1`",
2838                "row_may_be_null": false,
2839                "map_bit": 0,
2840                "depends_on_map_bits": [
2841                ] /* depends_on_map_bits */
2842              }
2843            ] /* table_dependencies */
2844          },
2845          {
2846            "ref_optimizer_key_uses": [
2847            ] /* ref_optimizer_key_uses */
2848          },
2849          {
2850            "rows_estimation": [
2851              {
2852                "table": "`t1`",
2853                "table_scan": {
2854                  "rows": 2,
2855                  "cost": 2
2856                } /* table_scan */
2857              }
2858            ] /* rows_estimation */
2859          },
2860          {
2861            "considered_execution_plans": [
2862              {
2863                "plan_prefix": [
2864                ] /* plan_prefix */,
2865                "table": "`t1`",
2866                "best_access_path": {
2867                  "considered_access_paths": [
2868                    {
2869                      "rows_to_scan": 2,
2870                      "access_type": "scan",
2871                      "resulting_rows": 2,
2872                      "cost": 2.4054,
2873                      "chosen": true
2874                    }
2875                  ] /* considered_access_paths */
2876                } /* best_access_path */,
2877                "condition_filtering_pct": 100,
2878                "rows_for_plan": 2,
2879                "cost_for_plan": 2.4054,
2880                "chosen": true
2881              }
2882            ] /* considered_execution_plans */
2883          },
2884          {
2885            "attaching_conditions_to_tables": {
2886              "original_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))",
2887              "attached_conditions_computation": [
2888              ] /* attached_conditions_computation */,
2889              "attached_conditions_summary": [
2890                {
2891                  "table": "`t1`",
2892                  "attached": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2893                }
2894              ] /* attached_conditions_summary */
2895            } /* attaching_conditions_to_tables */
2896          },
2897          {
2898            "refine_plan": [
2899              {
2900                "table": "`t1`"
2901              }
2902            ] /* refine_plan */
2903          }
2904        ] /* steps */
2905      } /* join_optimization */
2906    },
2907    {
2908      "join_optimization": {
2909        "select#": 2,
2910        "steps": [
2911          {
2912            "condition_processing": {
2913              "condition": "WHERE",
2914              "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2915              "steps": [
2916                {
2917                  "transformation": "equality_propagation",
2918                  "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2919                },
2920                {
2921                  "transformation": "constant_propagation",
2922                  "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2923                },
2924                {
2925                  "transformation": "trivial_condition_removal",
2926                  "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2927                }
2928              ] /* steps */
2929            } /* condition_processing */
2930          },
2931          {
2932            "substitute_generated_columns": {
2933            } /* substitute_generated_columns */
2934          },
2935          {
2936            "table_dependencies": [
2937              {
2938                "table": "`t1`",
2939                "row_may_be_null": false,
2940                "map_bit": 0,
2941                "depends_on_map_bits": [
2942                ] /* depends_on_map_bits */
2943              }
2944            ] /* table_dependencies */
2945          },
2946          {
2947            "ref_optimizer_key_uses": [
2948            ] /* ref_optimizer_key_uses */
2949          },
2950          {
2951            "rows_estimation": [
2952              {
2953                "table": "`t1`",
2954                "table_scan": {
2955                  "rows": 2,
2956                  "cost": 2
2957                } /* table_scan */
2958              }
2959            ] /* rows_estimation */
2960          },
2961          {
2962            "considered_execution_plans": [
2963              {
2964                "plan_prefix": [
2965                ] /* plan_prefix */,
2966                "table": "`t1`",
2967                "best_access_path": {
2968                  "considered_access_paths": [
2969                    {
2970                      "rows_to_scan": 2,
2971                      "access_type": "scan",
2972                      "resulting_rows": 2,
2973                      "cost": 2.4054,
2974                      "chosen": true
2975                    }
2976                  ] /* considered_access_paths */
2977                } /* best_access_path */,
2978                "condition_filtering_pct": 50,
2979                "rows_for_plan": 1,
2980                "cost_for_plan": 2.4054,
2981                "chosen": true
2982              }
2983            ] /* considered_execution_plans */
2984          },
2985          {
2986            "transformation": {
2987              "select#": 2,
2988              "from": "IN (SELECT)",
2989              "to": "EXISTS (CORRELATED SELECT)",
2990              "put_1_in_SELECT_list": true
2991            } /* transformation */
2992          },
2993          {
2994            "attaching_conditions_to_tables": {
2995              "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2996              "attached_conditions_computation": [
2997              ] /* attached_conditions_computation */,
2998              "attached_conditions_summary": [
2999                {
3000                  "table": "`t1`",
3001                  "attached": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
3002                }
3003              ] /* attached_conditions_summary */
3004            } /* attaching_conditions_to_tables */
3005          },
3006          {
3007            "refine_plan": [
3008              {
3009                "table": "`t1`"
3010              }
3011            ] /* refine_plan */
3012          }
3013        ] /* steps */
3014      } /* join_optimization */
3015    },
3016    {
3017      "join_explain": {
3018        "select#": 1,
3019        "steps": [
3020          {
3021            "join_explain": {
3022              "select#": 2,
3023              "steps": [
3024              ] /* steps */
3025            } /* join_explain */
3026          }
3027        ] /* steps */
3028      } /* join_explain */
3029    }
3030  ] /* steps */
3031}	0	0
3032set optimizer_switch=@old_opt_switch;
3033drop table t1;
3034create table t1(a int);
3035create table t2(a int);
3036insert into t1 values(1),(2),(3);
3037insert into t2 values(1),(2);
3038set @@session.optimizer_prune_level=0;
3039explain select * from t1,t2;
3040id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
30411	SIMPLE	t2	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
30421	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using join buffer (Block Nested Loop)
3043Warnings:
3044Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
3045select * from information_schema.OPTIMIZER_TRACE;
3046QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
3047explain select * from t1,t2	{
3048  "steps": [
3049    {
3050      "join_preparation": {
3051        "select#": 1,
3052        "steps": [
3053          {
3054            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
3055          }
3056        ] /* steps */
3057      } /* join_preparation */
3058    },
3059    {
3060      "join_optimization": {
3061        "select#": 1,
3062        "steps": [
3063          {
3064            "table_dependencies": [
3065              {
3066                "table": "`t1`",
3067                "row_may_be_null": false,
3068                "map_bit": 0,
3069                "depends_on_map_bits": [
3070                ] /* depends_on_map_bits */
3071              },
3072              {
3073                "table": "`t2`",
3074                "row_may_be_null": false,
3075                "map_bit": 1,
3076                "depends_on_map_bits": [
3077                ] /* depends_on_map_bits */
3078              }
3079            ] /* table_dependencies */
3080          },
3081          {
3082            "rows_estimation": [
3083              {
3084                "table": "`t1`",
3085                "table_scan": {
3086                  "rows": 3,
3087                  "cost": 2
3088                } /* table_scan */
3089              },
3090              {
3091                "table": "`t2`",
3092                "table_scan": {
3093                  "rows": 2,
3094                  "cost": 2
3095                } /* table_scan */
3096              }
3097            ] /* rows_estimation */
3098          },
3099          {
3100            "considered_execution_plans": [
3101              {
3102                "plan_prefix": [
3103                ] /* plan_prefix */,
3104                "table": "`t2`",
3105                "best_access_path": {
3106                  "considered_access_paths": [
3107                    {
3108                      "rows_to_scan": 2,
3109                      "access_type": "scan",
3110                      "resulting_rows": 2,
3111                      "cost": 2.4034,
3112                      "chosen": true
3113                    }
3114                  ] /* considered_access_paths */
3115                } /* best_access_path */,
3116                "condition_filtering_pct": 100,
3117                "rows_for_plan": 2,
3118                "cost_for_plan": 2.4034,
3119                "rest_of_plan": [
3120                  {
3121                    "plan_prefix": [
3122                      "`t2`"
3123                    ] /* plan_prefix */,
3124                    "table": "`t1`",
3125                    "best_access_path": {
3126                      "considered_access_paths": [
3127                        {
3128                          "rows_to_scan": 3,
3129                          "access_type": "scan",
3130                          "using_join_cache": true,
3131                          "buffers_needed": 1,
3132                          "resulting_rows": 3,
3133                          "cost": 3.2052,
3134                          "chosen": true
3135                        }
3136                      ] /* considered_access_paths */
3137                    } /* best_access_path */,
3138                    "condition_filtering_pct": 100,
3139                    "rows_for_plan": 6,
3140                    "cost_for_plan": 5.6086,
3141                    "chosen": true
3142                  }
3143                ] /* rest_of_plan */
3144              },
3145              {
3146                "plan_prefix": [
3147                ] /* plan_prefix */,
3148                "table": "`t1`",
3149                "best_access_path": {
3150                  "considered_access_paths": [
3151                    {
3152                      "rows_to_scan": 3,
3153                      "access_type": "scan",
3154                      "resulting_rows": 3,
3155                      "cost": 2.6051,
3156                      "chosen": true
3157                    }
3158                  ] /* considered_access_paths */
3159                } /* best_access_path */,
3160                "condition_filtering_pct": 100,
3161                "rows_for_plan": 3,
3162                "cost_for_plan": 2.6051,
3163                "rest_of_plan": [
3164                  {
3165                    "plan_prefix": [
3166                      "`t1`"
3167                    ] /* plan_prefix */,
3168                    "table": "`t2`",
3169                    "best_access_path": {
3170                      "considered_access_paths": [
3171                        {
3172                          "rows_to_scan": 2,
3173                          "access_type": "scan",
3174                          "using_join_cache": true,
3175                          "buffers_needed": 1,
3176                          "resulting_rows": 2,
3177                          "cost": 3.2035,
3178                          "chosen": true
3179                        }
3180                      ] /* considered_access_paths */
3181                    } /* best_access_path */,
3182                    "condition_filtering_pct": 100,
3183                    "rows_for_plan": 6,
3184                    "cost_for_plan": 5.8087,
3185                    "pruned_by_cost": true
3186                  }
3187                ] /* rest_of_plan */
3188              }
3189            ] /* considered_execution_plans */
3190          },
3191          {
3192            "attaching_conditions_to_tables": {
3193              "original_condition": null,
3194              "attached_conditions_computation": [
3195              ] /* attached_conditions_computation */,
3196              "attached_conditions_summary": [
3197                {
3198                  "table": "`t2`",
3199                  "attached": null
3200                },
3201                {
3202                  "table": "`t1`",
3203                  "attached": null
3204                }
3205              ] /* attached_conditions_summary */
3206            } /* attaching_conditions_to_tables */
3207          },
3208          {
3209            "refine_plan": [
3210              {
3211                "table": "`t2`"
3212              },
3213              {
3214                "table": "`t1`"
3215              }
3216            ] /* refine_plan */
3217          }
3218        ] /* steps */
3219      } /* join_optimization */
3220    },
3221    {
3222      "join_explain": {
3223        "select#": 1,
3224        "steps": [
3225        ] /* steps */
3226      } /* join_explain */
3227    }
3228  ] /* steps */
3229}	0	0
3230select @@optimizer_trace_features;
3231@@optimizer_trace_features
3232greedy_search=on,range_optimizer=on,dynamic_range=on,repeated_subselect=on
3233set @@optimizer_trace_features="greedy_search=off";
3234explain select * from t1,t2;
3235id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
32361	SIMPLE	t2	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
32371	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using join buffer (Block Nested Loop)
3238Warnings:
3239Note	1003	/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
3240select * from information_schema.OPTIMIZER_TRACE;
3241QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
3242explain select * from t1,t2	{
3243  "steps": [
3244    {
3245      "join_preparation": {
3246        "select#": 1,
3247        "steps": [
3248          {
3249            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
3250          }
3251        ] /* steps */
3252      } /* join_preparation */
3253    },
3254    {
3255      "join_optimization": {
3256        "select#": 1,
3257        "steps": [
3258          {
3259            "table_dependencies": [
3260              {
3261                "table": "`t1`",
3262                "row_may_be_null": false,
3263                "map_bit": 0,
3264                "depends_on_map_bits": [
3265                ] /* depends_on_map_bits */
3266              },
3267              {
3268                "table": "`t2`",
3269                "row_may_be_null": false,
3270                "map_bit": 1,
3271                "depends_on_map_bits": [
3272                ] /* depends_on_map_bits */
3273              }
3274            ] /* table_dependencies */
3275          },
3276          {
3277            "rows_estimation": [
3278              {
3279                "table": "`t1`",
3280                "table_scan": {
3281                  "rows": 3,
3282                  "cost": 2
3283                } /* table_scan */
3284              },
3285              {
3286                "table": "`t2`",
3287                "table_scan": {
3288                  "rows": 2,
3289                  "cost": 2
3290                } /* table_scan */
3291              }
3292            ] /* rows_estimation */
3293          },
3294          {
3295            "considered_execution_plans": "..."
3296          },
3297          {
3298            "attaching_conditions_to_tables": {
3299              "original_condition": null,
3300              "attached_conditions_computation": [
3301              ] /* attached_conditions_computation */,
3302              "attached_conditions_summary": [
3303                {
3304                  "table": "`t2`",
3305                  "attached": null
3306                },
3307                {
3308                  "table": "`t1`",
3309                  "attached": null
3310                }
3311              ] /* attached_conditions_summary */
3312            } /* attaching_conditions_to_tables */
3313          },
3314          {
3315            "refine_plan": [
3316              {
3317                "table": "`t2`"
3318              },
3319              {
3320                "table": "`t1`"
3321              }
3322            ] /* refine_plan */
3323          }
3324        ] /* steps */
3325      } /* join_optimization */
3326    },
3327    {
3328      "join_explain": {
3329        "select#": 1,
3330        "steps": [
3331        ] /* steps */
3332      } /* join_explain */
3333    }
3334  ] /* steps */
3335}	0	0
3336set @@optimizer_trace_features=default;
3337set @@session.optimizer_prune_level=default;
3338drop table t1, t2;
3339set @prefix_len = 6;
3340set @blob_len = 16;
3341set @suffix_len = @blob_len - @prefix_len;
3342create table t1_16 (a1 blob(16), a2 blob(16));
3343create table t2_16 (b1 blob(16), b2 blob(16));
3344create table t3_16 (c1 blob(16), c2 blob(16));
3345insert into t1_16 values
3346(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3347insert into t1_16 values
3348(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3349insert into t1_16 values
3350(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3351insert into t2_16 values
3352(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3353insert into t2_16 values
3354(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3355insert into t2_16 values
3356(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3357insert into t3_16 values
3358(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3359insert into t3_16 values
3360(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3361insert into t3_16 values
3362(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3363insert into t3_16 values
3364(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3365explain extended select left(a1,7), left(a2,7)
3366from t1_16
3367where a1 in (select b1 from t2_16 where b1 > '0');
3368id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
33691	PRIMARY	t1_16	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
33702	DEPENDENT SUBQUERY	t2_16	NULL	ALL	NULL	NULL	NULL	NULL	3	33.33	Using where
3371Warnings:
3372Warning	1681	'EXTENDED' is deprecated and will be removed in a future release.
3373Note	1003	/* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`))))
3374select * from information_schema.OPTIMIZER_TRACE;
3375QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
3376explain extended select left(a1,7), left(a2,7)
3377from t1_16
3378where a1 in (select b1 from t2_16 where b1 > '0')	{
3379  "steps": [
3380    {
3381      "join_preparation": {
3382        "select#": 1,
3383        "steps": [
3384          {
3385            "join_preparation": {
3386              "select#": 2,
3387              "steps": [
3388                {
3389                  "expanded_query": "/* select#2 */ select `t2_16`.`b1` from `t2_16` where (`t2_16`.`b1` > '0')"
3390                },
3391                {
3392                  "transformation": {
3393                    "select#": 2,
3394                    "from": "IN (SELECT)",
3395                    "to": "semijoin",
3396                    "chosen": false
3397                  } /* transformation */
3398                },
3399                {
3400                  "transformation": {
3401                    "select#": 2,
3402                    "from": "IN (SELECT)",
3403                    "to": "EXISTS (CORRELATED SELECT)",
3404                    "chosen": true,
3405                    "evaluating_constant_where_conditions": [
3406                    ] /* evaluating_constant_where_conditions */
3407                  } /* transformation */
3408                }
3409              ] /* steps */
3410            } /* join_preparation */
3411          },
3412          {
3413            "expanded_query": "/* select#1 */ select left(`t1_16`.`a1`,7) AS `left(a1,7)`,left(`t1_16`.`a2`,7) AS `left(a2,7)` from `t1_16` where <in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3414          }
3415        ] /* steps */
3416      } /* join_preparation */
3417    },
3418    {
3419      "join_optimization": {
3420        "select#": 1,
3421        "steps": [
3422          {
3423            "condition_processing": {
3424              "condition": "WHERE",
3425              "original_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))",
3426              "steps": [
3427                {
3428                  "transformation": "equality_propagation",
3429                  "subselect_evaluation": [
3430                  ] /* subselect_evaluation */,
3431                  "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3432                },
3433                {
3434                  "transformation": "constant_propagation",
3435                  "subselect_evaluation": [
3436                  ] /* subselect_evaluation */,
3437                  "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3438                },
3439                {
3440                  "transformation": "trivial_condition_removal",
3441                  "subselect_evaluation": [
3442                  ] /* subselect_evaluation */,
3443                  "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3444                }
3445              ] /* steps */
3446            } /* condition_processing */
3447          },
3448          {
3449            "substitute_generated_columns": {
3450            } /* substitute_generated_columns */
3451          },
3452          {
3453            "table_dependencies": [
3454              {
3455                "table": "`t1_16`",
3456                "row_may_be_null": false,
3457                "map_bit": 0,
3458                "depends_on_map_bits": [
3459                ] /* depends_on_map_bits */
3460              }
3461            ] /* table_dependencies */
3462          },
3463          {
3464            "ref_optimizer_key_uses": [
3465            ] /* ref_optimizer_key_uses */
3466          },
3467          {
3468            "rows_estimation": [
3469              {
3470                "table": "`t1_16`",
3471                "table_scan": {
3472                  "rows": 3,
3473                  "cost": 2
3474                } /* table_scan */
3475              }
3476            ] /* rows_estimation */
3477          },
3478          {
3479            "considered_execution_plans": [
3480              {
3481                "plan_prefix": [
3482                ] /* plan_prefix */,
3483                "table": "`t1_16`",
3484                "best_access_path": {
3485                  "considered_access_paths": [
3486                    {
3487                      "rows_to_scan": 3,
3488                      "access_type": "scan",
3489                      "resulting_rows": 3,
3490                      "cost": 2.6293,
3491                      "chosen": true
3492                    }
3493                  ] /* considered_access_paths */
3494                } /* best_access_path */,
3495                "condition_filtering_pct": 100,
3496                "rows_for_plan": 3,
3497                "cost_for_plan": 2.6293,
3498                "chosen": true
3499              }
3500            ] /* considered_execution_plans */
3501          },
3502          {
3503            "attaching_conditions_to_tables": {
3504              "original_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))",
3505              "attached_conditions_computation": [
3506              ] /* attached_conditions_computation */,
3507              "attached_conditions_summary": [
3508                {
3509                  "table": "`t1_16`",
3510                  "attached": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3511                }
3512              ] /* attached_conditions_summary */
3513            } /* attaching_conditions_to_tables */
3514          },
3515          {
3516            "refine_plan": [
3517              {
3518                "table": "`t1_16`"
3519              }
3520            ] /* refine_plan */
3521          }
3522        ] /* steps */
3523      } /* join_optimization */
3524    },
3525    {
3526      "join_optimization": {
3527        "select#": 2,
3528        "steps": [
3529          {
3530            "condition_processing": {
3531              "condition": "WHERE",
3532              "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3533              "steps": [
3534                {
3535                  "transformation": "equality_propagation",
3536                  "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3537                },
3538                {
3539                  "transformation": "constant_propagation",
3540                  "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3541                },
3542                {
3543                  "transformation": "trivial_condition_removal",
3544                  "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3545                }
3546              ] /* steps */
3547            } /* condition_processing */
3548          },
3549          {
3550            "substitute_generated_columns": {
3551            } /* substitute_generated_columns */
3552          },
3553          {
3554            "table_dependencies": [
3555              {
3556                "table": "`t2_16`",
3557                "row_may_be_null": false,
3558                "map_bit": 0,
3559                "depends_on_map_bits": [
3560                ] /* depends_on_map_bits */
3561              }
3562            ] /* table_dependencies */
3563          },
3564          {
3565            "ref_optimizer_key_uses": [
3566            ] /* ref_optimizer_key_uses */
3567          },
3568          {
3569            "rows_estimation": [
3570              {
3571                "table": "`t2_16`",
3572                "table_scan": {
3573                  "rows": 3,
3574                  "cost": 2
3575                } /* table_scan */
3576              }
3577            ] /* rows_estimation */
3578          },
3579          {
3580            "considered_execution_plans": [
3581              {
3582                "plan_prefix": [
3583                ] /* plan_prefix */,
3584                "table": "`t2_16`",
3585                "best_access_path": {
3586                  "considered_access_paths": [
3587                    {
3588                      "rows_to_scan": 3,
3589                      "access_type": "scan",
3590                      "resulting_rows": 1,
3591                      "cost": 2.6293,
3592                      "chosen": true
3593                    }
3594                  ] /* considered_access_paths */
3595                } /* best_access_path */,
3596                "condition_filtering_pct": 100,
3597                "rows_for_plan": 1,
3598                "cost_for_plan": 2.6293,
3599                "chosen": true
3600              }
3601            ] /* considered_execution_plans */
3602          },
3603          {
3604            "transformation": {
3605              "select#": 2,
3606              "from": "IN (SELECT)",
3607              "to": "EXISTS (CORRELATED SELECT)",
3608              "put_1_in_SELECT_list": true
3609            } /* transformation */
3610          },
3611          {
3612            "attaching_conditions_to_tables": {
3613              "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3614              "attached_conditions_computation": [
3615              ] /* attached_conditions_computation */,
3616              "attached_conditions_summary": [
3617                {
3618                  "table": "`t2_16`",
3619                  "attached": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3620                }
3621              ] /* attached_conditions_summary */
3622            } /* attaching_conditions_to_tables */
3623          },
3624          {
3625            "refine_plan": [
3626              {
3627                "table": "`t2_16`"
3628              }
3629            ] /* refine_plan */
3630          }
3631        ] /* steps */
3632      } /* join_optimization */
3633    },
3634    {
3635      "join_explain": {
3636        "select#": 1,
3637        "steps": [
3638          {
3639            "join_explain": {
3640              "select#": 2,
3641              "steps": [
3642              ] /* steps */
3643            } /* join_explain */
3644          }
3645        ] /* steps */
3646      } /* join_explain */
3647    }
3648  ] /* steps */
3649}	0	0
3650drop table t1_16,t2_16,t3_16;
3651set @@optimizer_switch=@old_opt_switch;
3652CREATE table t1 ( c1 integer );
3653INSERT INTO t1 VALUES ( 1 );
3654INSERT INTO t1 VALUES ( 2 );
3655INSERT INTO t1 VALUES ( 3 );
3656CREATE TABLE t2 ( c2 integer );
3657INSERT INTO t2 VALUES ( 1 );
3658INSERT INTO t2 VALUES ( 4 );
3659INSERT INTO t2 VALUES ( 5 );
3660SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3661WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
3662c1	c2
36631	1
3664select * from information_schema.OPTIMIZER_TRACE;
3665QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
3666SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3667WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) )	{
3668  "steps": [
3669    {
3670      "join_preparation": {
3671        "select#": 1,
3672        "steps": [
3673          {
3674            "join_preparation": {
3675              "select#": 2,
3676              "steps": [
3677                {
3678                  "expanded_query": "/* select#2 */ select `t2`.`c2` from `t2` where (`t2`.`c2` = 1)"
3679                },
3680                {
3681                  "transformation": {
3682                    "select#": 2,
3683                    "from": "IN (SELECT)",
3684                    "to": "semijoin",
3685                    "chosen": false
3686                  } /* transformation */
3687                },
3688                {
3689                  "transformation": {
3690                    "select#": 2,
3691                    "from": "IN (SELECT)",
3692                    "to": "EXISTS (CORRELATED SELECT)",
3693                    "chosen": true,
3694                    "evaluating_constant_where_conditions": [
3695                    ] /* evaluating_constant_where_conditions */
3696                  } /* transformation */
3697                }
3698              ] /* steps */
3699            } /* join_preparation */
3700          },
3701          {
3702            "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t2`.`c2` AS `c2` from (`t1` left join `t2` on((`t1`.`c1` = `t2`.`c2`))) where <in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`))))"
3703          },
3704          {
3705            "transformations_to_nested_joins": {
3706              "transformations": [
3707                "outer_join_to_inner_join",
3708                "JOIN_condition_to_WHERE",
3709                "parenthesis_removal"
3710              ] /* transformations */,
3711              "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t2`.`c2` AS `c2` from `t1` join `t2` where (<in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))) and (`t1`.`c1` = `t2`.`c2`))"
3712            } /* transformations_to_nested_joins */
3713          }
3714        ] /* steps */
3715      } /* join_preparation */
3716    },
3717    {
3718      "join_optimization": {
3719        "select#": 1,
3720        "steps": [
3721          {
3722            "condition_processing": {
3723              "condition": "WHERE",
3724              "original_condition": "(<in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))) and (`t1`.`c1` = `t2`.`c2`))",
3725              "steps": [
3726                {
3727                  "transformation": "equality_propagation",
3728                  "subselect_evaluation": [
3729                  ] /* subselect_evaluation */,
3730                  "resulting_condition": "(<in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))) and multiple equal(`t1`.`c1`, `t2`.`c2`))"
3731                },
3732                {
3733                  "transformation": "constant_propagation",
3734                  "subselect_evaluation": [
3735                  ] /* subselect_evaluation */,
3736                  "resulting_condition": "(<in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))) and multiple equal(`t1`.`c1`, `t2`.`c2`))"
3737                },
3738                {
3739                  "transformation": "trivial_condition_removal",
3740                  "subselect_evaluation": [
3741                  ] /* subselect_evaluation */,
3742                  "resulting_condition": "(<in_optimizer>(`t2`.`c2`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))) and multiple equal(`t1`.`c1`, `t2`.`c2`))"
3743                }
3744              ] /* steps */
3745            } /* condition_processing */
3746          },
3747          {
3748            "substitute_generated_columns": {
3749            } /* substitute_generated_columns */
3750          },
3751          {
3752            "table_dependencies": [
3753              {
3754                "table": "`t1`",
3755                "row_may_be_null": false,
3756                "map_bit": 0,
3757                "depends_on_map_bits": [
3758                ] /* depends_on_map_bits */
3759              },
3760              {
3761                "table": "`t2`",
3762                "row_may_be_null": true,
3763                "map_bit": 1,
3764                "depends_on_map_bits": [
3765                ] /* depends_on_map_bits */
3766              }
3767            ] /* table_dependencies */
3768          },
3769          {
3770            "ref_optimizer_key_uses": [
3771            ] /* ref_optimizer_key_uses */
3772          },
3773          {
3774            "rows_estimation": [
3775              {
3776                "table": "`t1`",
3777                "table_scan": {
3778                  "rows": 3,
3779                  "cost": 2
3780                } /* table_scan */
3781              },
3782              {
3783                "table": "`t2`",
3784                "table_scan": {
3785                  "rows": 3,
3786                  "cost": 2
3787                } /* table_scan */
3788              }
3789            ] /* rows_estimation */
3790          },
3791          {
3792            "considered_execution_plans": [
3793              {
3794                "plan_prefix": [
3795                ] /* plan_prefix */,
3796                "table": "`t1`",
3797                "best_access_path": {
3798                  "considered_access_paths": [
3799                    {
3800                      "rows_to_scan": 3,
3801                      "access_type": "scan",
3802                      "resulting_rows": 3,
3803                      "cost": 2.6051,
3804                      "chosen": true
3805                    }
3806                  ] /* considered_access_paths */
3807                } /* best_access_path */,
3808                "condition_filtering_pct": 100,
3809                "rows_for_plan": 3,
3810                "cost_for_plan": 2.6051,
3811                "rest_of_plan": [
3812                  {
3813                    "plan_prefix": [
3814                      "`t1`"
3815                    ] /* plan_prefix */,
3816                    "table": "`t2`",
3817                    "best_access_path": {
3818                      "considered_access_paths": [
3819                        {
3820                          "rows_to_scan": 3,
3821                          "access_type": "scan",
3822                          "using_join_cache": true,
3823                          "buffers_needed": 1,
3824                          "resulting_rows": 3,
3825                          "cost": 3.8052,
3826                          "chosen": true
3827                        }
3828                      ] /* considered_access_paths */
3829                    } /* best_access_path */,
3830                    "condition_filtering_pct": 100,
3831                    "rows_for_plan": 9,
3832                    "cost_for_plan": 6.4104,
3833                    "chosen": true
3834                  }
3835                ] /* rest_of_plan */
3836              },
3837              {
3838                "plan_prefix": [
3839                ] /* plan_prefix */,
3840                "table": "`t2`",
3841                "best_access_path": {
3842                  "considered_access_paths": [
3843                    {
3844                      "rows_to_scan": 3,
3845                      "access_type": "scan",
3846                      "resulting_rows": 3,
3847                      "cost": 2.6051,
3848                      "chosen": true
3849                    }
3850                  ] /* considered_access_paths */
3851                } /* best_access_path */,
3852                "condition_filtering_pct": 100,
3853                "rows_for_plan": 3,
3854                "cost_for_plan": 2.6051,
3855                "pruned_by_heuristic": true
3856              }
3857            ] /* considered_execution_plans */
3858          },
3859          {
3860            "attaching_conditions_to_tables": {
3861              "original_condition": "((`t2`.`c2` = `t1`.`c1`) and <in_optimizer>(`t1`.`c1`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`)))))",
3862              "attached_conditions_computation": [
3863              ] /* attached_conditions_computation */,
3864              "attached_conditions_summary": [
3865                {
3866                  "table": "`t1`",
3867                  "attached": "<in_optimizer>(`t1`.`c1`,<exists>(/* select#2 */ select `t2`.`c2` from `t2` where ((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`))))"
3868                },
3869                {
3870                  "table": "`t2`",
3871                  "attached": "(`t2`.`c2` = `t1`.`c1`)"
3872                }
3873              ] /* attached_conditions_summary */
3874            } /* attaching_conditions_to_tables */
3875          },
3876          {
3877            "refine_plan": [
3878              {
3879                "table": "`t1`"
3880              },
3881              {
3882                "table": "`t2`"
3883              }
3884            ] /* refine_plan */
3885          }
3886        ] /* steps */
3887      } /* join_optimization */
3888    },
3889    {
3890      "join_optimization": {
3891        "select#": 2,
3892        "steps": [
3893          {
3894            "condition_processing": {
3895              "condition": "WHERE",
3896              "original_condition": "((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = `t2`.`c2`))",
3897              "steps": [
3898                {
3899                  "transformation": "equality_propagation",
3900                  "resulting_condition": "((<cache>(`t2`.`c2`) = 1) and multiple equal(1, `t2`.`c2`))"
3901                },
3902                {
3903                  "transformation": "constant_propagation",
3904                  "resulting_condition": "((<cache>(`t2`.`c2`) = 1) and multiple equal(1, `t2`.`c2`))"
3905                },
3906                {
3907                  "transformation": "trivial_condition_removal",
3908                  "resulting_condition": "((<cache>(`t2`.`c2`) = 1) and multiple equal(1, `t2`.`c2`))"
3909                }
3910              ] /* steps */
3911            } /* condition_processing */
3912          },
3913          {
3914            "substitute_generated_columns": {
3915            } /* substitute_generated_columns */
3916          },
3917          {
3918            "table_dependencies": [
3919              {
3920                "table": "`t2`",
3921                "row_may_be_null": false,
3922                "map_bit": 0,
3923                "depends_on_map_bits": [
3924                ] /* depends_on_map_bits */
3925              }
3926            ] /* table_dependencies */
3927          },
3928          {
3929            "ref_optimizer_key_uses": [
3930            ] /* ref_optimizer_key_uses */
3931          },
3932          {
3933            "rows_estimation": [
3934              {
3935                "table": "`t2`",
3936                "table_scan": {
3937                  "rows": 3,
3938                  "cost": 2
3939                } /* table_scan */
3940              }
3941            ] /* rows_estimation */
3942          },
3943          {
3944            "considered_execution_plans": [
3945              {
3946                "plan_prefix": [
3947                ] /* plan_prefix */,
3948                "table": "`t2`",
3949                "best_access_path": {
3950                  "considered_access_paths": [
3951                    {
3952                      "rows_to_scan": 3,
3953                      "access_type": "scan",
3954                      "resulting_rows": 1,
3955                      "cost": 2.6051,
3956                      "chosen": true
3957                    }
3958                  ] /* considered_access_paths */
3959                } /* best_access_path */,
3960                "condition_filtering_pct": 100,
3961                "rows_for_plan": 1,
3962                "cost_for_plan": 2.6051,
3963                "chosen": true
3964              }
3965            ] /* considered_execution_plans */
3966          },
3967          {
3968            "transformation": {
3969              "select#": 2,
3970              "from": "IN (SELECT)",
3971              "to": "EXISTS (CORRELATED SELECT)",
3972              "put_1_in_SELECT_list": true
3973            } /* transformation */
3974          },
3975          {
3976            "attaching_conditions_to_tables": {
3977              "original_condition": "((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = 1))",
3978              "attached_conditions_computation": [
3979              ] /* attached_conditions_computation */,
3980              "attached_conditions_summary": [
3981                {
3982                  "table": "`t2`",
3983                  "attached": "((`t2`.`c2` = 1) and (<cache>(`t2`.`c2`) = 1))"
3984                }
3985              ] /* attached_conditions_summary */
3986            } /* attaching_conditions_to_tables */
3987          },
3988          {
3989            "refine_plan": [
3990              {
3991                "table": "`t2`"
3992              }
3993            ] /* refine_plan */
3994          }
3995        ] /* steps */
3996      } /* join_optimization */
3997    },
3998    {
3999      "join_execution": {
4000        "select#": 1,
4001        "steps": [
4002          {
4003            "subselect_execution": {
4004              "select#": 2,
4005              "steps": [
4006                {
4007                  "join_execution": {
4008                    "select#": 2,
4009                    "steps": [
4010                    ] /* steps */
4011                  } /* join_execution */
4012                }
4013              ] /* steps */
4014            } /* subselect_execution */
4015          },
4016          {
4017            "subselect_execution": {
4018              "select#": 2,
4019              "steps": [
4020                {
4021                  "join_execution": {
4022                    "select#": 2,
4023                    "steps": [
4024                    ] /* steps */
4025                  } /* join_execution */
4026                }
4027              ] /* steps */
4028            } /* subselect_execution */
4029          },
4030          {
4031            "subselect_execution": {
4032              "select#": 2,
4033              "steps": [
4034                {
4035                  "join_execution": {
4036                    "select#": 2,
4037                    "steps": [
4038                    ] /* steps */
4039                  } /* join_execution */
4040                }
4041              ] /* steps */
4042            } /* subselect_execution */
4043          }
4044        ] /* steps */
4045      } /* join_execution */
4046    }
4047  ] /* steps */
4048}	0	0
4049SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5;
4050c1
40515
4052select * from information_schema.OPTIMIZER_TRACE;
4053QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
4054SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5	{
4055  "steps": [
4056    {
4057      "join_preparation": {
4058        "select#": 1,
4059        "steps": [
4060          {
4061            "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1` from `t1` where (`t1`.`c1` = 5)"
4062          }
4063        ] /* steps */
4064      } /* join_preparation */
4065    },
4066    {
4067      "join_preparation": {
4068        "select#": 2,
4069        "steps": [
4070          {
4071            "expanded_query": "/* select#2 */ select `t2`.`c2` AS `c2` from `t2` where (`t2`.`c2` = 5)"
4072          }
4073        ] /* steps */
4074      } /* join_preparation */
4075    },
4076    {
4077      "creating_tmp_table": {
4078        "tmp_table_info": {
4079          "table": "intermediate_tmp_table",
4080          "row_length": 5,
4081          "key_length": 5,
4082          "unique_constraint": false,
4083          "location": "memory (heap)",
4084          "row_limit_estimate": 209715
4085        } /* tmp_table_info */
4086      } /* creating_tmp_table */
4087    },
4088    {
4089      "join_preparation": {
4090        "select#": "fake",
4091        "steps": [
4092          {
4093            "expanded_query": "/* select#fake */ select `c1` AS `c1` from dual"
4094          }
4095        ] /* steps */
4096      } /* join_preparation */
4097    },
4098    {
4099      "join_optimization": {
4100        "select#": 1,
4101        "steps": [
4102          {
4103            "condition_processing": {
4104              "condition": "WHERE",
4105              "original_condition": "(`t1`.`c1` = 5)",
4106              "steps": [
4107                {
4108                  "transformation": "equality_propagation",
4109                  "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4110                },
4111                {
4112                  "transformation": "constant_propagation",
4113                  "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4114                },
4115                {
4116                  "transformation": "trivial_condition_removal",
4117                  "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4118                }
4119              ] /* steps */
4120            } /* condition_processing */
4121          },
4122          {
4123            "substitute_generated_columns": {
4124            } /* substitute_generated_columns */
4125          },
4126          {
4127            "table_dependencies": [
4128              {
4129                "table": "`t1`",
4130                "row_may_be_null": false,
4131                "map_bit": 0,
4132                "depends_on_map_bits": [
4133                ] /* depends_on_map_bits */
4134              }
4135            ] /* table_dependencies */
4136          },
4137          {
4138            "ref_optimizer_key_uses": [
4139            ] /* ref_optimizer_key_uses */
4140          },
4141          {
4142            "rows_estimation": [
4143              {
4144                "table": "`t1`",
4145                "table_scan": {
4146                  "rows": 3,
4147                  "cost": 2
4148                } /* table_scan */
4149              }
4150            ] /* rows_estimation */
4151          },
4152          {
4153            "considered_execution_plans": [
4154              {
4155                "plan_prefix": [
4156                ] /* plan_prefix */,
4157                "table": "`t1`",
4158                "best_access_path": {
4159                  "considered_access_paths": [
4160                    {
4161                      "rows_to_scan": 3,
4162                      "access_type": "scan",
4163                      "resulting_rows": 3,
4164                      "cost": 2.6051,
4165                      "chosen": true
4166                    }
4167                  ] /* considered_access_paths */
4168                } /* best_access_path */,
4169                "condition_filtering_pct": 100,
4170                "rows_for_plan": 3,
4171                "cost_for_plan": 2.6051,
4172                "chosen": true
4173              }
4174            ] /* considered_execution_plans */
4175          },
4176          {
4177            "attaching_conditions_to_tables": {
4178              "original_condition": "(`t1`.`c1` = 5)",
4179              "attached_conditions_computation": [
4180              ] /* attached_conditions_computation */,
4181              "attached_conditions_summary": [
4182                {
4183                  "table": "`t1`",
4184                  "attached": "(`t1`.`c1` = 5)"
4185                }
4186              ] /* attached_conditions_summary */
4187            } /* attaching_conditions_to_tables */
4188          },
4189          {
4190            "refine_plan": [
4191              {
4192                "table": "`t1`"
4193              }
4194            ] /* refine_plan */
4195          }
4196        ] /* steps */
4197      } /* join_optimization */
4198    },
4199    {
4200      "join_optimization": {
4201        "select#": 2,
4202        "steps": [
4203          {
4204            "condition_processing": {
4205              "condition": "WHERE",
4206              "original_condition": "(`t2`.`c2` = 5)",
4207              "steps": [
4208                {
4209                  "transformation": "equality_propagation",
4210                  "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4211                },
4212                {
4213                  "transformation": "constant_propagation",
4214                  "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4215                },
4216                {
4217                  "transformation": "trivial_condition_removal",
4218                  "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4219                }
4220              ] /* steps */
4221            } /* condition_processing */
4222          },
4223          {
4224            "substitute_generated_columns": {
4225            } /* substitute_generated_columns */
4226          },
4227          {
4228            "table_dependencies": [
4229              {
4230                "table": "`t2`",
4231                "row_may_be_null": false,
4232                "map_bit": 0,
4233                "depends_on_map_bits": [
4234                ] /* depends_on_map_bits */
4235              }
4236            ] /* table_dependencies */
4237          },
4238          {
4239            "ref_optimizer_key_uses": [
4240            ] /* ref_optimizer_key_uses */
4241          },
4242          {
4243            "rows_estimation": [
4244              {
4245                "table": "`t2`",
4246                "table_scan": {
4247                  "rows": 3,
4248                  "cost": 2
4249                } /* table_scan */
4250              }
4251            ] /* rows_estimation */
4252          },
4253          {
4254            "considered_execution_plans": [
4255              {
4256                "plan_prefix": [
4257                ] /* plan_prefix */,
4258                "table": "`t2`",
4259                "best_access_path": {
4260                  "considered_access_paths": [
4261                    {
4262                      "rows_to_scan": 3,
4263                      "access_type": "scan",
4264                      "resulting_rows": 3,
4265                      "cost": 2.6051,
4266                      "chosen": true
4267                    }
4268                  ] /* considered_access_paths */
4269                } /* best_access_path */,
4270                "condition_filtering_pct": 100,
4271                "rows_for_plan": 3,
4272                "cost_for_plan": 2.6051,
4273                "chosen": true
4274              }
4275            ] /* considered_execution_plans */
4276          },
4277          {
4278            "attaching_conditions_to_tables": {
4279              "original_condition": "(`t2`.`c2` = 5)",
4280              "attached_conditions_computation": [
4281              ] /* attached_conditions_computation */,
4282              "attached_conditions_summary": [
4283                {
4284                  "table": "`t2`",
4285                  "attached": "(`t2`.`c2` = 5)"
4286                }
4287              ] /* attached_conditions_summary */
4288            } /* attaching_conditions_to_tables */
4289          },
4290          {
4291            "refine_plan": [
4292              {
4293                "table": "`t2`"
4294              }
4295            ] /* refine_plan */
4296          }
4297        ] /* steps */
4298      } /* join_optimization */
4299    },
4300    {
4301      "join_optimization": {
4302        "select#": "fake",
4303        "steps": [
4304          {
4305            "table_dependencies": [
4306              {
4307                "table": "``.``",
4308                "row_may_be_null": false,
4309                "map_bit": 0,
4310                "depends_on_map_bits": [
4311                ] /* depends_on_map_bits */
4312              }
4313            ] /* table_dependencies */
4314          },
4315          {
4316            "rows_estimation": [
4317              {
4318                "table": "``.``",
4319                "table_scan": {
4320                  "rows": 0,
4321                  "cost": 10
4322                } /* table_scan */
4323              }
4324            ] /* rows_estimation */
4325          },
4326          {
4327            "considered_execution_plans": [
4328              {
4329                "plan_prefix": [
4330                ] /* plan_prefix */,
4331                "table": "``.``",
4332                "best_access_path": {
4333                  "considered_access_paths": [
4334                    {
4335                      "rows_to_scan": 0,
4336                      "access_type": "scan",
4337                      "resulting_rows": 0,
4338                      "cost": 10,
4339                      "chosen": true
4340                    }
4341                  ] /* considered_access_paths */
4342                } /* best_access_path */,
4343                "condition_filtering_pct": 100,
4344                "rows_for_plan": 0,
4345                "cost_for_plan": 10,
4346                "chosen": true
4347              }
4348            ] /* considered_execution_plans */
4349          },
4350          {
4351            "attaching_conditions_to_tables": {
4352              "original_condition": null,
4353              "attached_conditions_computation": [
4354              ] /* attached_conditions_computation */,
4355              "attached_conditions_summary": [
4356                {
4357                  "table": "``.``",
4358                  "attached": null
4359                }
4360              ] /* attached_conditions_summary */
4361            } /* attaching_conditions_to_tables */
4362          },
4363          {
4364            "refine_plan": [
4365              {
4366                "table": "``.``"
4367              }
4368            ] /* refine_plan */
4369          }
4370        ] /* steps */
4371      } /* join_optimization */
4372    },
4373    {
4374      "join_execution": {
4375        "select#": 1,
4376        "steps": [
4377        ] /* steps */
4378      } /* join_execution */
4379    },
4380    {
4381      "join_execution": {
4382        "select#": 2,
4383        "steps": [
4384        ] /* steps */
4385      } /* join_execution */
4386    },
4387    {
4388      "join_execution": {
4389        "select#": "fake",
4390        "steps": [
4391        ] /* steps */
4392      } /* join_execution */
4393    }
4394  ] /* steps */
4395}	0	0
4396explain
4397select * from t1
4398where concat(c1,'x') IN
4399(select left(c2,8) from t2)
4400and
4401concat(c1,'y') IN
4402(select left(c2,9) from t2);
4403id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
44041	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
44053	DEPENDENT SUBQUERY	t2	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
44062	DEPENDENT SUBQUERY	t2	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
4407Warnings:
4408Note	1003	/* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (<in_optimizer>(concat(`test`.`t1`.`c1`,'x'),<exists>(/* select#2 */ select 1 from `test`.`t2` where (<cache>(concat(`test`.`t1`.`c1`,'x')) = left(`test`.`t2`.`c2`,8)))) and <in_optimizer>(concat(`test`.`t1`.`c1`,'y'),<exists>(/* select#3 */ select 1 from `test`.`t2` where (<cache>(concat(`test`.`t1`.`c1`,'y')) = left(`test`.`t2`.`c2`,9)))))
4409select * from information_schema.OPTIMIZER_TRACE;
4410QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
4411explain
4412select * from t1
4413where concat(c1,'x') IN
4414(select left(c2,8) from t2)
4415and
4416concat(c1,'y') IN
4417(select left(c2,9) from t2)	{
4418  "steps": [
4419    {
4420      "join_preparation": {
4421        "select#": 1,
4422        "steps": [
4423          {
4424            "join_preparation": {
4425              "select#": 2,
4426              "steps": [
4427                {
4428                  "expanded_query": "/* select#2 */ select left(`t2`.`c2`,8) from `t2`"
4429                },
4430                {
4431                  "transformation": {
4432                    "select#": 2,
4433                    "from": "IN (SELECT)",
4434                    "to": "semijoin",
4435                    "chosen": false
4436                  } /* transformation */
4437                },
4438                {
4439                  "transformation": {
4440                    "select#": 2,
4441                    "from": "IN (SELECT)",
4442                    "to": "EXISTS (CORRELATED SELECT)",
4443                    "chosen": true,
4444                    "evaluating_constant_where_conditions": [
4445                    ] /* evaluating_constant_where_conditions */
4446                  } /* transformation */
4447                }
4448              ] /* steps */
4449            } /* join_preparation */
4450          },
4451          {
4452            "join_preparation": {
4453              "select#": 3,
4454              "steps": [
4455                {
4456                  "expanded_query": "/* select#3 */ select left(`t2`.`c2`,9) from `t2`"
4457                },
4458                {
4459                  "transformation": {
4460                    "select#": 3,
4461                    "from": "IN (SELECT)",
4462                    "to": "semijoin",
4463                    "chosen": false
4464                  } /* transformation */
4465                },
4466                {
4467                  "transformation": {
4468                    "select#": 3,
4469                    "from": "IN (SELECT)",
4470                    "to": "EXISTS (CORRELATED SELECT)",
4471                    "chosen": true,
4472                    "evaluating_constant_where_conditions": [
4473                    ] /* evaluating_constant_where_conditions */
4474                  } /* transformation */
4475                }
4476              ] /* steps */
4477            } /* join_preparation */
4478          },
4479          {
4480            "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1` from `t1` where (<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4481          }
4482        ] /* steps */
4483      } /* join_preparation */
4484    },
4485    {
4486      "join_optimization": {
4487        "select#": 1,
4488        "steps": [
4489          {
4490            "condition_processing": {
4491              "condition": "WHERE",
4492              "original_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))",
4493              "steps": [
4494                {
4495                  "transformation": "equality_propagation",
4496                  "subselect_evaluation": [
4497                  ] /* subselect_evaluation */,
4498                  "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4499                },
4500                {
4501                  "transformation": "constant_propagation",
4502                  "subselect_evaluation": [
4503                  ] /* subselect_evaluation */,
4504                  "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4505                },
4506                {
4507                  "transformation": "trivial_condition_removal",
4508                  "subselect_evaluation": [
4509                  ] /* subselect_evaluation */,
4510                  "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4511                }
4512              ] /* steps */
4513            } /* condition_processing */
4514          },
4515          {
4516            "substitute_generated_columns": {
4517            } /* substitute_generated_columns */
4518          },
4519          {
4520            "table_dependencies": [
4521              {
4522                "table": "`t1`",
4523                "row_may_be_null": false,
4524                "map_bit": 0,
4525                "depends_on_map_bits": [
4526                ] /* depends_on_map_bits */
4527              }
4528            ] /* table_dependencies */
4529          },
4530          {
4531            "ref_optimizer_key_uses": [
4532            ] /* ref_optimizer_key_uses */
4533          },
4534          {
4535            "rows_estimation": [
4536              {
4537                "table": "`t1`",
4538                "table_scan": {
4539                  "rows": 3,
4540                  "cost": 2
4541                } /* table_scan */
4542              }
4543            ] /* rows_estimation */
4544          },
4545          {
4546            "considered_execution_plans": [
4547              {
4548                "plan_prefix": [
4549                ] /* plan_prefix */,
4550                "table": "`t1`",
4551                "best_access_path": {
4552                  "considered_access_paths": [
4553                    {
4554                      "rows_to_scan": 3,
4555                      "access_type": "scan",
4556                      "resulting_rows": 3,
4557                      "cost": 2.6051,
4558                      "chosen": true
4559                    }
4560                  ] /* considered_access_paths */
4561                } /* best_access_path */,
4562                "condition_filtering_pct": 100,
4563                "rows_for_plan": 3,
4564                "cost_for_plan": 2.6051,
4565                "chosen": true
4566              }
4567            ] /* considered_execution_plans */
4568          },
4569          {
4570            "attaching_conditions_to_tables": {
4571              "original_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))",
4572              "attached_conditions_computation": [
4573              ] /* attached_conditions_computation */,
4574              "attached_conditions_summary": [
4575                {
4576                  "table": "`t1`",
4577                  "attached": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4578                }
4579              ] /* attached_conditions_summary */
4580            } /* attaching_conditions_to_tables */
4581          },
4582          {
4583            "refine_plan": [
4584              {
4585                "table": "`t1`"
4586              }
4587            ] /* refine_plan */
4588          }
4589        ] /* steps */
4590      } /* join_optimization */
4591    },
4592    {
4593      "join_optimization": {
4594        "select#": 3,
4595        "steps": [
4596          {
4597            "condition_processing": {
4598              "condition": "WHERE",
4599              "original_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))",
4600              "steps": [
4601                {
4602                  "transformation": "equality_propagation",
4603                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4604                },
4605                {
4606                  "transformation": "constant_propagation",
4607                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4608                },
4609                {
4610                  "transformation": "trivial_condition_removal",
4611                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4612                }
4613              ] /* steps */
4614            } /* condition_processing */
4615          },
4616          {
4617            "substitute_generated_columns": {
4618            } /* substitute_generated_columns */
4619          },
4620          {
4621            "table_dependencies": [
4622              {
4623                "table": "`t2`",
4624                "row_may_be_null": false,
4625                "map_bit": 0,
4626                "depends_on_map_bits": [
4627                ] /* depends_on_map_bits */
4628              }
4629            ] /* table_dependencies */
4630          },
4631          {
4632            "ref_optimizer_key_uses": [
4633            ] /* ref_optimizer_key_uses */
4634          },
4635          {
4636            "rows_estimation": [
4637              {
4638                "table": "`t2`",
4639                "table_scan": {
4640                  "rows": 3,
4641                  "cost": 2
4642                } /* table_scan */
4643              }
4644            ] /* rows_estimation */
4645          },
4646          {
4647            "considered_execution_plans": [
4648              {
4649                "plan_prefix": [
4650                ] /* plan_prefix */,
4651                "table": "`t2`",
4652                "best_access_path": {
4653                  "considered_access_paths": [
4654                    {
4655                      "rows_to_scan": 3,
4656                      "access_type": "scan",
4657                      "resulting_rows": 3,
4658                      "cost": 2.6051,
4659                      "chosen": true
4660                    }
4661                  ] /* considered_access_paths */
4662                } /* best_access_path */,
4663                "condition_filtering_pct": 100,
4664                "rows_for_plan": 3,
4665                "cost_for_plan": 2.6051,
4666                "chosen": true
4667              }
4668            ] /* considered_execution_plans */
4669          },
4670          {
4671            "transformation": {
4672              "select#": 3,
4673              "from": "IN (SELECT)",
4674              "to": "EXISTS (CORRELATED SELECT)",
4675              "put_1_in_SELECT_list": true
4676            } /* transformation */
4677          },
4678          {
4679            "attaching_conditions_to_tables": {
4680              "original_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))",
4681              "attached_conditions_computation": [
4682              ] /* attached_conditions_computation */,
4683              "attached_conditions_summary": [
4684                {
4685                  "table": "`t2`",
4686                  "attached": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4687                }
4688              ] /* attached_conditions_summary */
4689            } /* attaching_conditions_to_tables */
4690          },
4691          {
4692            "refine_plan": [
4693              {
4694                "table": "`t2`"
4695              }
4696            ] /* refine_plan */
4697          }
4698        ] /* steps */
4699      } /* join_optimization */
4700    },
4701    {
4702      "join_optimization": {
4703        "select#": 2,
4704        "steps": [
4705          {
4706            "condition_processing": {
4707              "condition": "WHERE",
4708              "original_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))",
4709              "steps": [
4710                {
4711                  "transformation": "equality_propagation",
4712                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4713                },
4714                {
4715                  "transformation": "constant_propagation",
4716                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4717                },
4718                {
4719                  "transformation": "trivial_condition_removal",
4720                  "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4721                }
4722              ] /* steps */
4723            } /* condition_processing */
4724          },
4725          {
4726            "substitute_generated_columns": {
4727            } /* substitute_generated_columns */
4728          },
4729          {
4730            "table_dependencies": [
4731              {
4732                "table": "`t2`",
4733                "row_may_be_null": false,
4734                "map_bit": 0,
4735                "depends_on_map_bits": [
4736                ] /* depends_on_map_bits */
4737              }
4738            ] /* table_dependencies */
4739          },
4740          {
4741            "ref_optimizer_key_uses": [
4742            ] /* ref_optimizer_key_uses */
4743          },
4744          {
4745            "rows_estimation": [
4746              {
4747                "table": "`t2`",
4748                "table_scan": {
4749                  "rows": 3,
4750                  "cost": 2
4751                } /* table_scan */
4752              }
4753            ] /* rows_estimation */
4754          },
4755          {
4756            "considered_execution_plans": [
4757              {
4758                "plan_prefix": [
4759                ] /* plan_prefix */,
4760                "table": "`t2`",
4761                "best_access_path": {
4762                  "considered_access_paths": [
4763                    {
4764                      "rows_to_scan": 3,
4765                      "access_type": "scan",
4766                      "resulting_rows": 3,
4767                      "cost": 2.6051,
4768                      "chosen": true
4769                    }
4770                  ] /* considered_access_paths */
4771                } /* best_access_path */,
4772                "condition_filtering_pct": 100,
4773                "rows_for_plan": 3,
4774                "cost_for_plan": 2.6051,
4775                "chosen": true
4776              }
4777            ] /* considered_execution_plans */
4778          },
4779          {
4780            "transformation": {
4781              "select#": 2,
4782              "from": "IN (SELECT)",
4783              "to": "EXISTS (CORRELATED SELECT)",
4784              "put_1_in_SELECT_list": true
4785            } /* transformation */
4786          },
4787          {
4788            "attaching_conditions_to_tables": {
4789              "original_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))",
4790              "attached_conditions_computation": [
4791              ] /* attached_conditions_computation */,
4792              "attached_conditions_summary": [
4793                {
4794                  "table": "`t2`",
4795                  "attached": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4796                }
4797              ] /* attached_conditions_summary */
4798            } /* attaching_conditions_to_tables */
4799          },
4800          {
4801            "refine_plan": [
4802              {
4803                "table": "`t2`"
4804              }
4805            ] /* refine_plan */
4806          }
4807        ] /* steps */
4808      } /* join_optimization */
4809    },
4810    {
4811      "join_explain": {
4812        "select#": 1,
4813        "steps": [
4814          {
4815            "join_explain": {
4816              "select#": 3,
4817              "steps": [
4818              ] /* steps */
4819            } /* join_explain */
4820          },
4821          {
4822            "join_explain": {
4823              "select#": 2,
4824              "steps": [
4825              ] /* steps */
4826            } /* join_explain */
4827          }
4828        ] /* steps */
4829      } /* join_explain */
4830    }
4831  ] /* steps */
4832}	0	0
4833set optimizer_switch=@old_opt_switch;
4834DROP TABLE t1,t2;
4835create table t1 (a int);
4836insert into t1 values(1);
4837create table t2 (a int);
4838insert into t2 values(1);
4839select * from t1,t2;
4840a	a
48411	1
4842select * from information_schema.OPTIMIZER_TRACE;
4843QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
4844select * from t1,t2	{
4845  "steps": [
4846    {
4847      "join_preparation": {
4848        "select#": 1,
4849        "steps": [
4850          {
4851            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
4852          }
4853        ] /* steps */
4854      } /* join_preparation */
4855    },
4856    {
4857      "join_optimization": {
4858        "select#": 1,
4859        "steps": [
4860          {
4861            "table_dependencies": [
4862              {
4863                "table": "`t1`",
4864                "row_may_be_null": false,
4865                "map_bit": 0,
4866                "depends_on_map_bits": [
4867                ] /* depends_on_map_bits */
4868              },
4869              {
4870                "table": "`t2`",
4871                "row_may_be_null": false,
4872                "map_bit": 1,
4873                "depends_on_map_bits": [
4874                ] /* depends_on_map_bits */
4875              }
4876            ] /* table_dependencies */
4877          },
4878          {
4879            "rows_estimation": [
4880              {
4881                "table": "`t1`",
4882                "rows": 1,
4883                "cost": 1,
4884                "table_type": "system",
4885                "empty": false
4886              },
4887              {
4888                "table": "`t2`",
4889                "rows": 1,
4890                "cost": 1,
4891                "table_type": "system",
4892                "empty": false
4893              }
4894            ] /* rows_estimation */
4895          },
4896          {
4897            "attaching_conditions_to_tables": {
4898              "original_condition": null,
4899              "attached_conditions_computation": [
4900              ] /* attached_conditions_computation */,
4901              "attached_conditions_summary": [
4902              ] /* attached_conditions_summary */
4903            } /* attaching_conditions_to_tables */
4904          },
4905          {
4906            "refine_plan": [
4907            ] /* refine_plan */
4908          }
4909        ] /* steps */
4910      } /* join_optimization */
4911    },
4912    {
4913      "join_execution": {
4914        "select#": 1,
4915        "steps": [
4916        ] /* steps */
4917      } /* join_execution */
4918    }
4919  ] /* steps */
4920}	0	0
4921create table t3 (a int, b int);
4922create table t4 (a int primary key);
4923insert into t4 values(1),(2);
4924prepare stmt from 'select * from t3 where (a,a,b) in (select * from t1,t2,t4)';
4925select trace from information_schema.OPTIMIZER_TRACE;
4926trace
4927{
4928  "steps": [
4929    {
4930      "join_preparation": {
4931        "select#": 1,
4932        "steps": [
4933          {
4934            "join_preparation": {
4935              "select#": 2,
4936              "steps": [
4937                {
4938                  "expanded_query": "/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`"
4939                },
4940                {
4941                  "transformation": {
4942                    "select#": 2,
4943                    "from": "IN (SELECT)",
4944                    "to": "semijoin",
4945                    "chosen": false
4946                  } /* transformation */
4947                },
4948                {
4949                  "transformation": {
4950                    "select#": 2,
4951                    "from": "IN (SELECT)",
4952                    "to": "EXISTS (CORRELATED SELECT)",
4953                    "chosen": true,
4954                    "evaluating_constant_where_conditions": [
4955                    ] /* evaluating_constant_where_conditions */
4956                  } /* transformation */
4957                }
4958              ] /* steps */
4959            } /* join_preparation */
4960          },
4961          {
4962            "expanded_query": "/* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from `t3` where <in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
4963          }
4964        ] /* steps */
4965      } /* join_preparation */
4966    }
4967  ] /* steps */
4968}
4969execute stmt;
4970a	b
4971select trace from information_schema.OPTIMIZER_TRACE;
4972trace
4973{
4974  "steps": [
4975    {
4976      "join_preparation": {
4977        "select#": 1,
4978        "steps": [
4979          {
4980            "join_preparation": {
4981              "select#": 2,
4982              "steps": [
4983                {
4984                  "expanded_query": "/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))"
4985                },
4986                {
4987                  "transformation": {
4988                    "select#": 2,
4989                    "from": "IN (SELECT)",
4990                    "to": "semijoin",
4991                    "chosen": false
4992                  } /* transformation */
4993                }
4994              ] /* steps */
4995            } /* join_preparation */
4996          },
4997          {
4998            "expanded_query": "/* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from `t3` where <in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
4999          }
5000        ] /* steps */
5001      } /* join_preparation */
5002    },
5003    {
5004      "join_optimization": {
5005        "select#": 1,
5006        "steps": [
5007          {
5008            "condition_processing": {
5009              "condition": "WHERE",
5010              "original_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))",
5011              "steps": [
5012                {
5013                  "transformation": "equality_propagation",
5014                  "subselect_evaluation": [
5015                  ] /* subselect_evaluation */,
5016                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5017                },
5018                {
5019                  "transformation": "constant_propagation",
5020                  "subselect_evaluation": [
5021                  ] /* subselect_evaluation */,
5022                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5023                },
5024                {
5025                  "transformation": "trivial_condition_removal",
5026                  "subselect_evaluation": [
5027                  ] /* subselect_evaluation */,
5028                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5029                }
5030              ] /* steps */
5031            } /* condition_processing */
5032          },
5033          {
5034            "substitute_generated_columns": {
5035            } /* substitute_generated_columns */
5036          },
5037          {
5038            "table_dependencies": [
5039              {
5040                "table": "`t3`",
5041                "row_may_be_null": false,
5042                "map_bit": 0,
5043                "depends_on_map_bits": [
5044                ] /* depends_on_map_bits */
5045              }
5046            ] /* table_dependencies */
5047          },
5048          {
5049            "ref_optimizer_key_uses": [
5050            ] /* ref_optimizer_key_uses */
5051          },
5052          {
5053            "rows_estimation": [
5054              {
5055                "table": "`t3`",
5056                "rows": 1,
5057                "cost": 1,
5058                "table_type": "system",
5059                "empty": true
5060              }
5061            ] /* rows_estimation */
5062          }
5063        ] /* steps */,
5064        "empty_result": {
5065          "cause": "no matching row in const table"
5066        } /* empty_result */
5067      } /* join_optimization */
5068    },
5069    {
5070      "join_optimization": {
5071        "select#": 2,
5072        "steps": [
5073          {
5074            "condition_processing": {
5075              "condition": "WHERE",
5076              "original_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))",
5077              "steps": [
5078                {
5079                  "transformation": "equality_propagation",
5080                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5081                },
5082                {
5083                  "transformation": "constant_propagation",
5084                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5085                },
5086                {
5087                  "transformation": "trivial_condition_removal",
5088                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5089                }
5090              ] /* steps */
5091            } /* condition_processing */
5092          },
5093          {
5094            "substitute_generated_columns": {
5095            } /* substitute_generated_columns */
5096          },
5097          {
5098            "table_dependencies": [
5099              {
5100                "table": "`t1`",
5101                "row_may_be_null": false,
5102                "map_bit": 0,
5103                "depends_on_map_bits": [
5104                ] /* depends_on_map_bits */
5105              },
5106              {
5107                "table": "`t2`",
5108                "row_may_be_null": false,
5109                "map_bit": 1,
5110                "depends_on_map_bits": [
5111                ] /* depends_on_map_bits */
5112              },
5113              {
5114                "table": "`t4`",
5115                "row_may_be_null": false,
5116                "map_bit": 2,
5117                "depends_on_map_bits": [
5118                ] /* depends_on_map_bits */
5119              }
5120            ] /* table_dependencies */
5121          },
5122          {
5123            "ref_optimizer_key_uses": [
5124              {
5125                "table": "`t4`",
5126                "field": "a",
5127                "equals": "<cache>(NULL)",
5128                "null_rejecting": false
5129              }
5130            ] /* ref_optimizer_key_uses */
5131          },
5132          {
5133            "rows_estimation": [
5134              {
5135                "table": "`t1`",
5136                "rows": 1,
5137                "cost": 1,
5138                "table_type": "system",
5139                "empty": false
5140              },
5141              {
5142                "table": "`t2`",
5143                "rows": 1,
5144                "cost": 1,
5145                "table_type": "system",
5146                "empty": false
5147              },
5148              {
5149                "table": "`t4`",
5150                "table_scan": {
5151                  "rows": 2,
5152                  "cost": 2
5153                } /* table_scan */
5154              }
5155            ] /* rows_estimation */
5156          },
5157          {
5158            "considered_execution_plans": [
5159              {
5160                "plan_prefix": [
5161                  "`t1`",
5162                  "`t2`"
5163                ] /* plan_prefix */,
5164                "table": "`t4`",
5165                "best_access_path": {
5166                  "considered_access_paths": [
5167                    {
5168                      "access_type": "eq_ref",
5169                      "index": "PRIMARY",
5170                      "rows": 1,
5171                      "cost": 1.2,
5172                      "chosen": true
5173                    },
5174                    {
5175                      "access_type": "scan",
5176                      "cost": 2.4,
5177                      "rows": 2,
5178                      "chosen": false,
5179                      "cause": "cost"
5180                    }
5181                  ] /* considered_access_paths */
5182                } /* best_access_path */,
5183                "condition_filtering_pct": 100,
5184                "rows_for_plan": 1,
5185                "cost_for_plan": 1.2,
5186                "chosen": true
5187              }
5188            ] /* considered_execution_plans */
5189          },
5190          {
5191            "attaching_conditions_to_tables": {
5192              "original_condition": "((<cache>(NULL) = '1') and (<cache>(NULL) = '1') and (<cache>(NULL) = `t4`.`a`))",
5193              "attached_conditions_computation": [
5194              ] /* attached_conditions_computation */,
5195              "attached_conditions_summary": [
5196                {
5197                  "table": "`t4`",
5198                  "attached": "((<cache>(NULL) = '1') and (<cache>(NULL) = '1'))"
5199                }
5200              ] /* attached_conditions_summary */
5201            } /* attaching_conditions_to_tables */
5202          },
5203          {
5204            "refine_plan": [
5205              {
5206                "table": "`t4`"
5207              }
5208            ] /* refine_plan */
5209          }
5210        ] /* steps */
5211      } /* join_optimization */
5212    },
5213    {
5214      "join_execution": {
5215        "select#": 1,
5216        "steps": [
5217        ] /* steps */
5218      } /* join_execution */
5219    }
5220  ] /* steps */
5221}
5222execute stmt;
5223a	b
5224select trace from information_schema.OPTIMIZER_TRACE;
5225trace
5226{
5227  "steps": [
5228    {
5229      "join_preparation": {
5230        "select#": 1,
5231        "steps": [
5232          {
5233            "join_preparation": {
5234              "select#": 2,
5235              "steps": [
5236                {
5237                  "expanded_query": "/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))"
5238                },
5239                {
5240                  "transformation": {
5241                    "select#": 2,
5242                    "from": "IN (SELECT)",
5243                    "to": "semijoin",
5244                    "chosen": false
5245                  } /* transformation */
5246                }
5247              ] /* steps */
5248            } /* join_preparation */
5249          },
5250          {
5251            "expanded_query": "/* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from `t3` where <in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5252          }
5253        ] /* steps */
5254      } /* join_preparation */
5255    },
5256    {
5257      "join_optimization": {
5258        "select#": 1,
5259        "steps": [
5260          {
5261            "condition_processing": {
5262              "condition": "WHERE",
5263              "original_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))",
5264              "steps": [
5265                {
5266                  "transformation": "equality_propagation",
5267                  "subselect_evaluation": [
5268                  ] /* subselect_evaluation */,
5269                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5270                },
5271                {
5272                  "transformation": "constant_propagation",
5273                  "subselect_evaluation": [
5274                  ] /* subselect_evaluation */,
5275                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5276                },
5277                {
5278                  "transformation": "trivial_condition_removal",
5279                  "subselect_evaluation": [
5280                  ] /* subselect_evaluation */,
5281                  "resulting_condition": "<in_optimizer>((`t3`.`a`,`t3`.`a`,`t3`.`b`),<exists>(/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t4` where ((<cache>(`t3`.`a`) = `t1`.`a`) and (<cache>(`t3`.`a`) = `t2`.`a`) and (<cache>(`t3`.`b`) = `t4`.`a`))))"
5282                }
5283              ] /* steps */
5284            } /* condition_processing */
5285          },
5286          {
5287            "substitute_generated_columns": {
5288            } /* substitute_generated_columns */
5289          },
5290          {
5291            "table_dependencies": [
5292              {
5293                "table": "`t3`",
5294                "row_may_be_null": false,
5295                "map_bit": 0,
5296                "depends_on_map_bits": [
5297                ] /* depends_on_map_bits */
5298              }
5299            ] /* table_dependencies */
5300          },
5301          {
5302            "ref_optimizer_key_uses": [
5303            ] /* ref_optimizer_key_uses */
5304          },
5305          {
5306            "rows_estimation": [
5307              {
5308                "table": "`t3`",
5309                "rows": 1,
5310                "cost": 1,
5311                "table_type": "system",
5312                "empty": true
5313              }
5314            ] /* rows_estimation */
5315          }
5316        ] /* steps */,
5317        "empty_result": {
5318          "cause": "no matching row in const table"
5319        } /* empty_result */
5320      } /* join_optimization */
5321    },
5322    {
5323      "join_optimization": {
5324        "select#": 2,
5325        "steps": [
5326          {
5327            "condition_processing": {
5328              "condition": "WHERE",
5329              "original_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))",
5330              "steps": [
5331                {
5332                  "transformation": "equality_propagation",
5333                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5334                },
5335                {
5336                  "transformation": "constant_propagation",
5337                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5338                },
5339                {
5340                  "transformation": "trivial_condition_removal",
5341                  "resulting_condition": "((<cache>(NULL) = `t1`.`a`) and (<cache>(NULL) = `t2`.`a`) and (<cache>(NULL) = `t4`.`a`))"
5342                }
5343              ] /* steps */
5344            } /* condition_processing */
5345          },
5346          {
5347            "substitute_generated_columns": {
5348            } /* substitute_generated_columns */
5349          },
5350          {
5351            "table_dependencies": [
5352              {
5353                "table": "`t1`",
5354                "row_may_be_null": false,
5355                "map_bit": 0,
5356                "depends_on_map_bits": [
5357                ] /* depends_on_map_bits */
5358              },
5359              {
5360                "table": "`t2`",
5361                "row_may_be_null": false,
5362                "map_bit": 1,
5363                "depends_on_map_bits": [
5364                ] /* depends_on_map_bits */
5365              },
5366              {
5367                "table": "`t4`",
5368                "row_may_be_null": false,
5369                "map_bit": 2,
5370                "depends_on_map_bits": [
5371                ] /* depends_on_map_bits */
5372              }
5373            ] /* table_dependencies */
5374          },
5375          {
5376            "ref_optimizer_key_uses": [
5377              {
5378                "table": "`t4`",
5379                "field": "a",
5380                "equals": "<cache>(NULL)",
5381                "null_rejecting": false
5382              }
5383            ] /* ref_optimizer_key_uses */
5384          },
5385          {
5386            "rows_estimation": [
5387              {
5388                "table": "`t1`",
5389                "rows": 1,
5390                "cost": 1,
5391                "table_type": "system",
5392                "empty": false
5393              },
5394              {
5395                "table": "`t2`",
5396                "rows": 1,
5397                "cost": 1,
5398                "table_type": "system",
5399                "empty": false
5400              },
5401              {
5402                "table": "`t4`",
5403                "table_scan": {
5404                  "rows": 2,
5405                  "cost": 2
5406                } /* table_scan */
5407              }
5408            ] /* rows_estimation */
5409          },
5410          {
5411            "considered_execution_plans": [
5412              {
5413                "plan_prefix": [
5414                  "`t1`",
5415                  "`t2`"
5416                ] /* plan_prefix */,
5417                "table": "`t4`",
5418                "best_access_path": {
5419                  "considered_access_paths": [
5420                    {
5421                      "access_type": "eq_ref",
5422                      "index": "PRIMARY",
5423                      "rows": 1,
5424                      "cost": 1.2,
5425                      "chosen": true
5426                    },
5427                    {
5428                      "access_type": "scan",
5429                      "cost": 2.4,
5430                      "rows": 2,
5431                      "chosen": false,
5432                      "cause": "cost"
5433                    }
5434                  ] /* considered_access_paths */
5435                } /* best_access_path */,
5436                "condition_filtering_pct": 100,
5437                "rows_for_plan": 1,
5438                "cost_for_plan": 1.2,
5439                "chosen": true
5440              }
5441            ] /* considered_execution_plans */
5442          },
5443          {
5444            "attaching_conditions_to_tables": {
5445              "original_condition": "((<cache>(NULL) = '1') and (<cache>(NULL) = '1') and (<cache>(NULL) = `t4`.`a`))",
5446              "attached_conditions_computation": [
5447              ] /* attached_conditions_computation */,
5448              "attached_conditions_summary": [
5449                {
5450                  "table": "`t4`",
5451                  "attached": "((<cache>(NULL) = '1') and (<cache>(NULL) = '1'))"
5452                }
5453              ] /* attached_conditions_summary */
5454            } /* attaching_conditions_to_tables */
5455          },
5456          {
5457            "refine_plan": [
5458              {
5459                "table": "`t4`"
5460              }
5461            ] /* refine_plan */
5462          }
5463        ] /* steps */
5464      } /* join_optimization */
5465    },
5466    {
5467      "join_execution": {
5468        "select#": 1,
5469        "steps": [
5470        ] /* steps */
5471      } /* join_execution */
5472    }
5473  ] /* steps */
5474}
5475DROP TABLE t1,t2,t3,t4;
5476create table t1(a int);
5477insert into t1 values(1),(1);
5478create table t2(a int);
5479insert into t2 values(1),(1);
5480select * from t1 left join t2 on t2.a=500 where t2.a is NULL;
5481a	a
54821	NULL
54831	NULL
5484select * from information_schema.OPTIMIZER_TRACE;
5485QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
5486select * from t1 left join t2 on t2.a=500 where t2.a is NULL	{
5487  "steps": [
5488    {
5489      "join_preparation": {
5490        "select#": 1,
5491        "steps": [
5492          {
5493            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from (`t1` left join `t2` on((`t2`.`a` = 500))) where isnull(`t2`.`a`)"
5494          },
5495          {
5496            "transformations_to_nested_joins": {
5497              "transformations": [
5498                "parenthesis_removal"
5499              ] /* transformations */,
5500              "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` left join `t2` on((`t2`.`a` = 500)) where isnull(`t2`.`a`)"
5501            } /* transformations_to_nested_joins */
5502          }
5503        ] /* steps */
5504      } /* join_preparation */
5505    },
5506    {
5507      "join_optimization": {
5508        "select#": 1,
5509        "steps": [
5510          {
5511            "condition_processing": {
5512              "condition": "WHERE",
5513              "original_condition": "isnull(`t2`.`a`)",
5514              "steps": [
5515                {
5516                  "transformation": "equality_propagation",
5517                  "resulting_condition": "isnull(`t2`.`a`)"
5518                },
5519                {
5520                  "transformation": "constant_propagation",
5521                  "resulting_condition": "isnull(`t2`.`a`)"
5522                },
5523                {
5524                  "transformation": "trivial_condition_removal",
5525                  "resulting_condition": "isnull(`t2`.`a`)"
5526                }
5527              ] /* steps */
5528            } /* condition_processing */
5529          },
5530          {
5531            "substitute_generated_columns": {
5532            } /* substitute_generated_columns */
5533          },
5534          {
5535            "table_dependencies": [
5536              {
5537                "table": "`t1`",
5538                "row_may_be_null": false,
5539                "map_bit": 0,
5540                "depends_on_map_bits": [
5541                ] /* depends_on_map_bits */
5542              },
5543              {
5544                "table": "`t2`",
5545                "row_may_be_null": true,
5546                "map_bit": 1,
5547                "depends_on_map_bits": [
5548                  0
5549                ] /* depends_on_map_bits */
5550              }
5551            ] /* table_dependencies */
5552          },
5553          {
5554            "ref_optimizer_key_uses": [
5555            ] /* ref_optimizer_key_uses */
5556          },
5557          {
5558            "rows_estimation": [
5559              {
5560                "table": "`t1`",
5561                "table_scan": {
5562                  "rows": 2,
5563                  "cost": 2
5564                } /* table_scan */
5565              },
5566              {
5567                "table": "`t2`",
5568                "table_scan": {
5569                  "rows": 2,
5570                  "cost": 2
5571                } /* table_scan */
5572              }
5573            ] /* rows_estimation */
5574          },
5575          {
5576            "considered_execution_plans": [
5577              {
5578                "plan_prefix": [
5579                ] /* plan_prefix */,
5580                "table": "`t1`",
5581                "best_access_path": {
5582                  "considered_access_paths": [
5583                    {
5584                      "rows_to_scan": 2,
5585                      "access_type": "scan",
5586                      "resulting_rows": 2,
5587                      "cost": 2.4034,
5588                      "chosen": true
5589                    }
5590                  ] /* considered_access_paths */
5591                } /* best_access_path */,
5592                "condition_filtering_pct": 100,
5593                "rows_for_plan": 2,
5594                "cost_for_plan": 2.4034,
5595                "rest_of_plan": [
5596                  {
5597                    "plan_prefix": [
5598                      "`t1`"
5599                    ] /* plan_prefix */,
5600                    "table": "`t2`",
5601                    "best_access_path": {
5602                      "considered_access_paths": [
5603                        {
5604                          "rows_to_scan": 2,
5605                          "access_type": "scan",
5606                          "using_join_cache": true,
5607                          "buffers_needed": 1,
5608                          "resulting_rows": 1,
5609                          "cost": 2.6035,
5610                          "chosen": true
5611                        }
5612                      ] /* considered_access_paths */
5613                    } /* best_access_path */,
5614                    "condition_filtering_pct": 100,
5615                    "rows_for_plan": 2,
5616                    "cost_for_plan": 5.0069,
5617                    "chosen": true
5618                  }
5619                ] /* rest_of_plan */
5620              }
5621            ] /* considered_execution_plans */
5622          },
5623          {
5624            "attaching_conditions_to_tables": {
5625              "original_condition": "isnull(`t2`.`a`)",
5626              "attached_conditions_computation": [
5627              ] /* attached_conditions_computation */,
5628              "attached_conditions_summary": [
5629                {
5630                  "table": "`t1`",
5631                  "attached": null
5632                },
5633                {
5634                  "table": "`t2`",
5635                  "attached": "(<if>(found_match(t2), isnull(`t2`.`a`), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))"
5636                }
5637              ] /* attached_conditions_summary */
5638            } /* attaching_conditions_to_tables */
5639          },
5640          {
5641            "refine_plan": [
5642              {
5643                "table": "`t1`"
5644              },
5645              {
5646                "table": "`t2`"
5647              }
5648            ] /* refine_plan */
5649          }
5650        ] /* steps */
5651      } /* join_optimization */
5652    },
5653    {
5654      "join_execution": {
5655        "select#": 1,
5656        "steps": [
5657        ] /* steps */
5658      } /* join_execution */
5659    }
5660  ] /* steps */
5661}	0	0
5662drop table t1,t2;
5663create table t1(a int, b int);
5664insert into t1 values(1,NULL),(NULL,2);
5665create table t2(c int, d int);
5666insert into t2 values(1,1),(2,2);
5667select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0);
5668a	b
5669select * from information_schema.OPTIMIZER_TRACE;
5670QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
5671select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0)	{
5672  "steps": [
5673    {
5674      "join_preparation": {
5675        "select#": 1,
5676        "steps": [
5677          {
5678            "join_preparation": {
5679              "select#": 2,
5680              "steps": [
5681                {
5682                  "expanded_query": "/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where (`t2`.`c` > 0)"
5683                },
5684                {
5685                  "transformation": {
5686                    "select#": 2,
5687                    "from": "IN (SELECT)",
5688                    "to": "semijoin",
5689                    "chosen": false
5690                  } /* transformation */
5691                },
5692                {
5693                  "transformation": {
5694                    "select#": 2,
5695                    "from": "IN (SELECT)",
5696                    "to": "EXISTS (CORRELATED SELECT)",
5697                    "chosen": true,
5698                    "evaluating_constant_where_conditions": [
5699                    ] /* evaluating_constant_where_conditions */,
5700                    "evaluating_constant_having_conditions": [
5701                    ] /* evaluating_constant_having_conditions */
5702                  } /* transformation */
5703                }
5704              ] /* steps */
5705            } /* join_preparation */
5706          },
5707          {
5708            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where (not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))"
5709          }
5710        ] /* steps */
5711      } /* join_preparation */
5712    },
5713    {
5714      "join_optimization": {
5715        "select#": 1,
5716        "steps": [
5717          {
5718            "condition_processing": {
5719              "condition": "WHERE",
5720              "original_condition": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))",
5721              "steps": [
5722                {
5723                  "transformation": "equality_propagation",
5724                  "subselect_evaluation": [
5725                  ] /* subselect_evaluation */,
5726                  "resulting_condition": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))"
5727                },
5728                {
5729                  "transformation": "constant_propagation",
5730                  "subselect_evaluation": [
5731                  ] /* subselect_evaluation */,
5732                  "resulting_condition": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))"
5733                },
5734                {
5735                  "transformation": "trivial_condition_removal",
5736                  "subselect_evaluation": [
5737                  ] /* subselect_evaluation */,
5738                  "resulting_condition": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))"
5739                }
5740              ] /* steps */
5741            } /* condition_processing */
5742          },
5743          {
5744            "substitute_generated_columns": {
5745            } /* substitute_generated_columns */
5746          },
5747          {
5748            "table_dependencies": [
5749              {
5750                "table": "`t1`",
5751                "row_may_be_null": false,
5752                "map_bit": 0,
5753                "depends_on_map_bits": [
5754                ] /* depends_on_map_bits */
5755              }
5756            ] /* table_dependencies */
5757          },
5758          {
5759            "ref_optimizer_key_uses": [
5760            ] /* ref_optimizer_key_uses */
5761          },
5762          {
5763            "rows_estimation": [
5764              {
5765                "table": "`t1`",
5766                "table_scan": {
5767                  "rows": 2,
5768                  "cost": 2
5769                } /* table_scan */
5770              }
5771            ] /* rows_estimation */
5772          },
5773          {
5774            "considered_execution_plans": [
5775              {
5776                "plan_prefix": [
5777                ] /* plan_prefix */,
5778                "table": "`t1`",
5779                "best_access_path": {
5780                  "considered_access_paths": [
5781                    {
5782                      "rows_to_scan": 2,
5783                      "access_type": "scan",
5784                      "resulting_rows": 2,
5785                      "cost": 2.4044,
5786                      "chosen": true
5787                    }
5788                  ] /* considered_access_paths */
5789                } /* best_access_path */,
5790                "condition_filtering_pct": 100,
5791                "rows_for_plan": 2,
5792                "cost_for_plan": 2.4044,
5793                "chosen": true
5794              }
5795            ] /* considered_execution_plans */
5796          },
5797          {
5798            "attaching_conditions_to_tables": {
5799              "original_condition": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))",
5800              "attached_conditions_computation": [
5801              ] /* attached_conditions_computation */,
5802              "attached_conditions_summary": [
5803                {
5804                  "table": "`t1`",
5805                  "attached": "(not(<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))))))"
5806                }
5807              ] /* attached_conditions_summary */
5808            } /* attaching_conditions_to_tables */
5809          },
5810          {
5811            "refine_plan": [
5812              {
5813                "table": "`t1`"
5814              }
5815            ] /* refine_plan */
5816          }
5817        ] /* steps */
5818      } /* join_optimization */
5819    },
5820    {
5821      "join_optimization": {
5822        "select#": 2,
5823        "steps": [
5824          {
5825            "condition_processing": {
5826              "condition": "WHERE",
5827              "original_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))",
5828              "steps": [
5829                {
5830                  "transformation": "equality_propagation",
5831                  "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))"
5832                },
5833                {
5834                  "transformation": "constant_propagation",
5835                  "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))"
5836                },
5837                {
5838                  "transformation": "trivial_condition_removal",
5839                  "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))"
5840                }
5841              ] /* steps */
5842            } /* condition_processing */
5843          },
5844          {
5845            "condition_processing": {
5846              "condition": "HAVING",
5847              "original_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))",
5848              "steps": [
5849                {
5850                  "transformation": "constant_propagation",
5851                  "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))"
5852                },
5853                {
5854                  "transformation": "trivial_condition_removal",
5855                  "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))"
5856                }
5857              ] /* steps */
5858            } /* condition_processing */
5859          },
5860          {
5861            "substitute_generated_columns": {
5862            } /* substitute_generated_columns */
5863          },
5864          {
5865            "table_dependencies": [
5866              {
5867                "table": "`t2`",
5868                "row_may_be_null": false,
5869                "map_bit": 0,
5870                "depends_on_map_bits": [
5871                ] /* depends_on_map_bits */
5872              }
5873            ] /* table_dependencies */
5874          },
5875          {
5876            "ref_optimizer_key_uses": [
5877            ] /* ref_optimizer_key_uses */
5878          },
5879          {
5880            "rows_estimation": [
5881              {
5882                "table": "`t2`",
5883                "table_scan": {
5884                  "rows": 2,
5885                  "cost": 2
5886                } /* table_scan */
5887              }
5888            ] /* rows_estimation */
5889          },
5890          {
5891            "considered_execution_plans": [
5892              {
5893                "plan_prefix": [
5894                ] /* plan_prefix */,
5895                "table": "`t2`",
5896                "best_access_path": {
5897                  "considered_access_paths": [
5898                    {
5899                      "rows_to_scan": 2,
5900                      "access_type": "scan",
5901                      "resulting_rows": 1,
5902                      "cost": 2.4044,
5903                      "chosen": true
5904                    }
5905                  ] /* considered_access_paths */
5906                } /* best_access_path */,
5907                "condition_filtering_pct": 100,
5908                "rows_for_plan": 1,
5909                "cost_for_plan": 2.4044,
5910                "chosen": true
5911              }
5912            ] /* considered_execution_plans */
5913          },
5914          {
5915            "transformation": {
5916              "select#": 2,
5917              "from": "IN (SELECT)",
5918              "to": "EXISTS (CORRELATED SELECT)",
5919              "put_1_in_SELECT_list": true
5920            } /* transformation */
5921          },
5922          {
5923            "attaching_conditions_to_tables": {
5924              "original_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))",
5925              "attached_conditions_computation": [
5926              ] /* attached_conditions_computation */,
5927              "attached_conditions_summary": [
5928                {
5929                  "table": "`t2`",
5930                  "attached": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or isnull(`t2`.`c`)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or isnull(`t2`.`d`)), true))"
5931                }
5932              ] /* attached_conditions_summary */
5933            } /* attaching_conditions_to_tables */
5934          },
5935          {
5936            "refine_plan": [
5937              {
5938                "table": "`t2`"
5939              }
5940            ] /* refine_plan */
5941          }
5942        ] /* steps */
5943      } /* join_optimization */
5944    },
5945    {
5946      "join_execution": {
5947        "select#": 1,
5948        "steps": [
5949          {
5950            "subselect_execution": {
5951              "select#": 2,
5952              "steps": [
5953                {
5954                  "join_execution": {
5955                    "select#": 2,
5956                    "steps": [
5957                    ] /* steps */
5958                  } /* join_execution */
5959                }
5960              ] /* steps */
5961            } /* subselect_execution */
5962          },
5963          {
5964            "subselect_execution": {
5965              "select#": 2,
5966              "steps": [
5967                {
5968                  "join_execution": {
5969                    "select#": 2,
5970                    "steps": [
5971                    ] /* steps */
5972                  } /* join_execution */
5973                }
5974              ] /* steps */
5975            } /* subselect_execution */
5976          }
5977        ] /* steps */
5978      } /* join_execution */
5979    }
5980  ] /* steps */
5981}	0	0
5982select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
5983group by t1.a having moyenne<>0;
5984a	moyenne
5985NULL	1.5000
59861	1.5000
5987select trace from information_schema.OPTIMIZER_TRACE;
5988trace
5989{
5990  "steps": [
5991    {
5992      "join_preparation": {
5993        "select#": 1,
5994        "steps": [
5995          {
5996            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,avg(`t2`.`c`) AS `moyenne` from `t1` join `t2` where (`t2`.`c` > -(1)) group by `t1`.`a` having (`moyenne` <> 0)"
5997          }
5998        ] /* steps */
5999      } /* join_preparation */
6000    },
6001    {
6002      "join_optimization": {
6003        "select#": 1,
6004        "steps": [
6005          {
6006            "condition_processing": {
6007              "condition": "WHERE",
6008              "original_condition": "(`t2`.`c` > -(1))",
6009              "steps": [
6010                {
6011                  "transformation": "equality_propagation",
6012                  "resulting_condition": "(`t2`.`c` > -(1))"
6013                },
6014                {
6015                  "transformation": "constant_propagation",
6016                  "resulting_condition": "(`t2`.`c` > -(1))"
6017                },
6018                {
6019                  "transformation": "trivial_condition_removal",
6020                  "resulting_condition": "(`t2`.`c` > -(1))"
6021                }
6022              ] /* steps */
6023            } /* condition_processing */
6024          },
6025          {
6026            "condition_processing": {
6027              "condition": "HAVING",
6028              "original_condition": "(`moyenne` <> 0)",
6029              "steps": [
6030                {
6031                  "transformation": "constant_propagation",
6032                  "resulting_condition": "(`moyenne` <> 0)"
6033                },
6034                {
6035                  "transformation": "trivial_condition_removal",
6036                  "resulting_condition": "(`moyenne` <> 0)"
6037                }
6038              ] /* steps */
6039            } /* condition_processing */
6040          },
6041          {
6042            "substitute_generated_columns": {
6043            } /* substitute_generated_columns */
6044          },
6045          {
6046            "table_dependencies": [
6047              {
6048                "table": "`t1`",
6049                "row_may_be_null": false,
6050                "map_bit": 0,
6051                "depends_on_map_bits": [
6052                ] /* depends_on_map_bits */
6053              },
6054              {
6055                "table": "`t2`",
6056                "row_may_be_null": false,
6057                "map_bit": 1,
6058                "depends_on_map_bits": [
6059                ] /* depends_on_map_bits */
6060              }
6061            ] /* table_dependencies */
6062          },
6063          {
6064            "ref_optimizer_key_uses": [
6065            ] /* ref_optimizer_key_uses */
6066          },
6067          {
6068            "rows_estimation": [
6069              {
6070                "table": "`t1`",
6071                "table_scan": {
6072                  "rows": 2,
6073                  "cost": 2
6074                } /* table_scan */
6075              },
6076              {
6077                "table": "`t2`",
6078                "table_scan": {
6079                  "rows": 2,
6080                  "cost": 2
6081                } /* table_scan */
6082              }
6083            ] /* rows_estimation */
6084          },
6085          {
6086            "considered_execution_plans": [
6087              {
6088                "plan_prefix": [
6089                ] /* plan_prefix */,
6090                "table": "`t1`",
6091                "best_access_path": {
6092                  "considered_access_paths": [
6093                    {
6094                      "rows_to_scan": 2,
6095                      "access_type": "scan",
6096                      "resulting_rows": 2,
6097                      "cost": 2.4044,
6098                      "chosen": true,
6099                      "use_tmp_table": true
6100                    }
6101                  ] /* considered_access_paths */
6102                } /* best_access_path */,
6103                "condition_filtering_pct": 100,
6104                "rows_for_plan": 2,
6105                "cost_for_plan": 2.4044,
6106                "rest_of_plan": [
6107                  {
6108                    "plan_prefix": [
6109                      "`t1`"
6110                    ] /* plan_prefix */,
6111                    "table": "`t2`",
6112                    "best_access_path": {
6113                      "considered_access_paths": [
6114                        {
6115                          "rows_to_scan": 2,
6116                          "access_type": "scan",
6117                          "using_join_cache": true,
6118                          "buffers_needed": 1,
6119                          "resulting_rows": 1,
6120                          "cost": 2.6045,
6121                          "chosen": true
6122                        }
6123                      ] /* considered_access_paths */
6124                    } /* best_access_path */,
6125                    "condition_filtering_pct": 100,
6126                    "rows_for_plan": 2,
6127                    "cost_for_plan": 5.0089,
6128                    "sort_cost": 2,
6129                    "new_cost_for_plan": 7.0089,
6130                    "chosen": true
6131                  }
6132                ] /* rest_of_plan */
6133              },
6134              {
6135                "plan_prefix": [
6136                ] /* plan_prefix */,
6137                "table": "`t2`",
6138                "best_access_path": {
6139                  "considered_access_paths": [
6140                    {
6141                      "rows_to_scan": 2,
6142                      "access_type": "scan",
6143                      "resulting_rows": 1,
6144                      "cost": 2.4044,
6145                      "chosen": true
6146                    }
6147                  ] /* considered_access_paths */
6148                } /* best_access_path */,
6149                "condition_filtering_pct": 100,
6150                "rows_for_plan": 1,
6151                "cost_for_plan": 2.4044,
6152                "rest_of_plan": [
6153                  {
6154                    "plan_prefix": [
6155                      "`t2`"
6156                    ] /* plan_prefix */,
6157                    "table": "`t1`",
6158                    "best_access_path": {
6159                      "considered_access_paths": [
6160                        {
6161                          "rows_to_scan": 2,
6162                          "access_type": "scan",
6163                          "using_join_cache": true,
6164                          "buffers_needed": 1,
6165                          "resulting_rows": 2,
6166                          "cost": 2.4044,
6167                          "chosen": true
6168                        }
6169                      ] /* considered_access_paths */
6170                    } /* best_access_path */,
6171                    "condition_filtering_pct": 100,
6172                    "rows_for_plan": 2,
6173                    "cost_for_plan": 4.8088,
6174                    "sort_cost": 2,
6175                    "new_cost_for_plan": 6.8088,
6176                    "chosen": true
6177                  }
6178                ] /* rest_of_plan */
6179              }
6180            ] /* considered_execution_plans */
6181          },
6182          {
6183            "attaching_conditions_to_tables": {
6184              "original_condition": "(`t2`.`c` > -(1))",
6185              "attached_conditions_computation": [
6186              ] /* attached_conditions_computation */,
6187              "attached_conditions_summary": [
6188                {
6189                  "table": "`t2`",
6190                  "attached": "(`t2`.`c` > -(1))"
6191                },
6192                {
6193                  "table": "`t1`",
6194                  "attached": null
6195                }
6196              ] /* attached_conditions_summary */
6197            } /* attaching_conditions_to_tables */
6198          },
6199          {
6200            "clause_processing": {
6201              "clause": "GROUP BY",
6202              "original_clause": "`t1`.`a`",
6203              "items": [
6204                {
6205                  "item": "`t1`.`a`"
6206                }
6207              ] /* items */,
6208              "resulting_clause_is_simple": false,
6209              "resulting_clause": "`t1`.`a`"
6210            } /* clause_processing */
6211          },
6212          {
6213            "refine_plan": [
6214              {
6215                "table": "`t2`"
6216              },
6217              {
6218                "table": "`t1`"
6219              }
6220            ] /* refine_plan */
6221          },
6222          {
6223            "sort_using_internal_table": {
6224              "condition_for_sort": "(`moyenne` <> 0)",
6225              "having_after_sort": null
6226            } /* sort_using_internal_table */
6227          }
6228        ] /* steps */
6229      } /* join_optimization */
6230    },
6231    {
6232      "join_execution": {
6233        "select#": 1,
6234        "steps": [
6235          {
6236            "creating_tmp_table": {
6237              "tmp_table_info": {
6238                "table": "intermediate_tmp_table",
6239                "row_length": 30,
6240                "key_length": 5,
6241                "unique_constraint": false,
6242                "location": "memory (heap)",
6243                "row_limit_estimate": 34952
6244              } /* tmp_table_info */
6245            } /* creating_tmp_table */
6246          },
6247          {
6248            "filesort_information": [
6249              {
6250                "direction": "asc",
6251                "table": "intermediate_tmp_table",
6252                "field": "a"
6253              }
6254            ] /* filesort_information */,
6255            "filesort_priority_queue_optimization": {
6256              "usable": false,
6257              "cause": "not applicable (no LIMIT)"
6258            } /* filesort_priority_queue_optimization */,
6259            "filesort_execution": [
6260            ] /* filesort_execution */,
6261            "filesort_summary": {
6262              "rows": 2,
6263              "examined_rows": 2,
6264              "number_of_tmp_files": 0,
6265              "sort_buffer_size": "NNN",
6266              "sort_mode": "<sort_key, rowid>"
6267            } /* filesort_summary */
6268          }
6269        ] /* steps */
6270      } /* join_execution */
6271    }
6272  ] /* steps */
6273}
6274select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
6275group by t1.a having 4=5;
6276a	moyenne
6277select trace from information_schema.OPTIMIZER_TRACE;
6278trace
6279{
6280  "steps": [
6281    {
6282      "join_preparation": {
6283        "select#": 1,
6284        "steps": [
6285          {
6286            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,avg(`t2`.`c`) AS `moyenne` from `t1` join `t2` where (`t2`.`c` > -(1)) group by `t1`.`a` having (4 = 5)"
6287          }
6288        ] /* steps */
6289      } /* join_preparation */
6290    },
6291    {
6292      "join_optimization": {
6293        "select#": 1,
6294        "steps": [
6295          {
6296            "condition_processing": {
6297              "condition": "WHERE",
6298              "original_condition": "(`t2`.`c` > -(1))",
6299              "steps": [
6300                {
6301                  "transformation": "equality_propagation",
6302                  "resulting_condition": "(`t2`.`c` > -(1))"
6303                },
6304                {
6305                  "transformation": "constant_propagation",
6306                  "resulting_condition": "(`t2`.`c` > -(1))"
6307                },
6308                {
6309                  "transformation": "trivial_condition_removal",
6310                  "resulting_condition": "(`t2`.`c` > -(1))"
6311                }
6312              ] /* steps */
6313            } /* condition_processing */
6314          },
6315          {
6316            "condition_processing": {
6317              "condition": "HAVING",
6318              "original_condition": "(4 = 5)",
6319              "steps": [
6320                {
6321                  "transformation": "constant_propagation",
6322                  "resulting_condition": "(4 = 5)"
6323                },
6324                {
6325                  "transformation": "trivial_condition_removal",
6326                  "resulting_condition": null
6327                }
6328              ] /* steps */
6329            } /* condition_processing */
6330          }
6331        ] /* steps */,
6332        "empty_result": {
6333          "cause": "Impossible HAVING"
6334        } /* empty_result */
6335      } /* join_optimization */
6336    },
6337    {
6338      "join_execution": {
6339        "select#": 1,
6340        "steps": [
6341        ] /* steps */
6342      } /* join_execution */
6343    }
6344  ] /* steps */
6345}
6346drop table t1,t2;
6347update t6 set d=5 where d is NULL;
6348select * from information_schema.OPTIMIZER_TRACE;
6349QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6350update t6 set d=5 where d is NULL	{
6351  "steps": [
6352    {
6353      "substitute_generated_columns": {
6354      } /* substitute_generated_columns */
6355    },
6356    {
6357      "condition_processing": {
6358        "condition": "WHERE",
6359        "original_condition": "isnull(`t6`.`d`)",
6360        "steps": [
6361          {
6362            "transformation": "equality_propagation",
6363            "resulting_condition": "isnull(`t6`.`d`)"
6364          },
6365          {
6366            "transformation": "constant_propagation",
6367            "resulting_condition": "isnull(`t6`.`d`)"
6368          },
6369          {
6370            "transformation": "trivial_condition_removal",
6371            "resulting_condition": "isnull(`t6`.`d`)"
6372          }
6373        ] /* steps */
6374      } /* condition_processing */
6375    },
6376    {
6377      "table": "`t6`",
6378      "range_analysis": {
6379        "table_scan": {
6380          "rows": 2,
6381          "cost": 4.5034
6382        } /* table_scan */,
6383        "potential_range_indexes": [
6384          {
6385            "index": "d",
6386            "usable": true,
6387            "key_parts": [
6388              "d"
6389            ] /* key_parts */
6390          }
6391        ] /* potential_range_indexes */,
6392        "setup_range_conditions": [
6393        ] /* setup_range_conditions */,
6394        "group_index_range": {
6395          "chosen": false,
6396          "cause": "no_join"
6397        } /* group_index_range */,
6398        "analyzing_range_alternatives": {
6399          "range_scan_alternatives": [
6400            {
6401              "index": "d",
6402              "ranges": [
6403                "NULL <= d <= NULL"
6404              ] /* ranges */,
6405              "index_dives_for_eq_ranges": true,
6406              "rowid_ordered": true,
6407              "using_mrr": false,
6408              "index_only": false,
6409              "rows": 1,
6410              "cost": 2.21,
6411              "chosen": true
6412            }
6413          ] /* range_scan_alternatives */,
6414          "analyzing_roworder_intersect": {
6415            "usable": false,
6416            "cause": "too_few_roworder_scans"
6417          } /* analyzing_roworder_intersect */
6418        } /* analyzing_range_alternatives */,
6419        "chosen_range_access_summary": {
6420          "range_access_plan": {
6421            "type": "range_scan",
6422            "index": "d",
6423            "rows": 1,
6424            "ranges": [
6425              "NULL <= d <= NULL"
6426            ] /* ranges */
6427          } /* range_access_plan */,
6428          "rows_for_plan": 1,
6429          "cost_for_plan": 2.21,
6430          "chosen": true
6431        } /* chosen_range_access_summary */
6432      } /* range_analysis */
6433    }
6434  ] /* steps */
6435}	0	0
6436delete from t6 where d=5;
6437select * from information_schema.OPTIMIZER_TRACE;
6438QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6439delete from t6 where d=5	{
6440  "steps": [
6441    {
6442      "substitute_generated_columns": {
6443      } /* substitute_generated_columns */
6444    },
6445    {
6446      "condition_processing": {
6447        "condition": "WHERE",
6448        "original_condition": "(`t6`.`d` = 5)",
6449        "steps": [
6450          {
6451            "transformation": "equality_propagation",
6452            "resulting_condition": "multiple equal(5, `t6`.`d`)"
6453          },
6454          {
6455            "transformation": "constant_propagation",
6456            "resulting_condition": "multiple equal(5, `t6`.`d`)"
6457          },
6458          {
6459            "transformation": "trivial_condition_removal",
6460            "resulting_condition": "multiple equal(5, `t6`.`d`)"
6461          }
6462        ] /* steps */
6463      } /* condition_processing */
6464    },
6465    {
6466      "table": "`t6`",
6467      "range_analysis": {
6468        "table_scan": {
6469          "rows": 2,
6470          "cost": 4.5034
6471        } /* table_scan */,
6472        "potential_range_indexes": [
6473          {
6474            "index": "d",
6475            "usable": true,
6476            "key_parts": [
6477              "d"
6478            ] /* key_parts */
6479          }
6480        ] /* potential_range_indexes */,
6481        "setup_range_conditions": [
6482        ] /* setup_range_conditions */,
6483        "group_index_range": {
6484          "chosen": false,
6485          "cause": "no_join"
6486        } /* group_index_range */,
6487        "analyzing_range_alternatives": {
6488          "range_scan_alternatives": [
6489            {
6490              "index": "d",
6491              "ranges": [
6492                "5 <= d <= 5"
6493              ] /* ranges */,
6494              "index_dives_for_eq_ranges": true,
6495              "rowid_ordered": true,
6496              "using_mrr": false,
6497              "index_only": false,
6498              "rows": 1,
6499              "cost": 2.21,
6500              "chosen": true
6501            }
6502          ] /* range_scan_alternatives */
6503        } /* analyzing_range_alternatives */,
6504        "chosen_range_access_summary": {
6505          "range_access_plan": {
6506            "type": "range_scan",
6507            "index": "d",
6508            "rows": 1,
6509            "ranges": [
6510              "5 <= d <= 5"
6511            ] /* ranges */
6512          } /* range_access_plan */,
6513          "rows_for_plan": 1,
6514          "cost_for_plan": 2.21,
6515          "chosen": true
6516        } /* chosen_range_access_summary */
6517      } /* range_analysis */
6518    }
6519  ] /* steps */
6520}	0	0
6521insert into t6 values(6),(7),(8);
6522select * from information_schema.OPTIMIZER_TRACE;
6523QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6524insert into t6 values(6),(7),(8)	{
6525  "steps": [
6526  ] /* steps */
6527}	0	0
6528insert into t6 select * from t6 where d>7;
6529select * from information_schema.OPTIMIZER_TRACE;
6530QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6531insert into t6 select * from t6 where d>7	{
6532  "steps": [
6533    {
6534      "join_preparation": {
6535        "select#": 1,
6536        "steps": [
6537          {
6538            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where (`t6`.`d` > 7)"
6539          }
6540        ] /* steps */
6541      } /* join_preparation */
6542    },
6543    {
6544      "join_optimization": {
6545        "select#": 1,
6546        "steps": [
6547          {
6548            "condition_processing": {
6549              "condition": "WHERE",
6550              "original_condition": "(`t6`.`d` > 7)",
6551              "steps": [
6552                {
6553                  "transformation": "equality_propagation",
6554                  "resulting_condition": "(`t6`.`d` > 7)"
6555                },
6556                {
6557                  "transformation": "constant_propagation",
6558                  "resulting_condition": "(`t6`.`d` > 7)"
6559                },
6560                {
6561                  "transformation": "trivial_condition_removal",
6562                  "resulting_condition": "(`t6`.`d` > 7)"
6563                }
6564              ] /* steps */
6565            } /* condition_processing */
6566          },
6567          {
6568            "substitute_generated_columns": {
6569            } /* substitute_generated_columns */
6570          },
6571          {
6572            "table_dependencies": [
6573              {
6574                "table": "`t6`",
6575                "row_may_be_null": false,
6576                "map_bit": 0,
6577                "depends_on_map_bits": [
6578                ] /* depends_on_map_bits */
6579              }
6580            ] /* table_dependencies */
6581          },
6582          {
6583            "ref_optimizer_key_uses": [
6584            ] /* ref_optimizer_key_uses */
6585          },
6586          {
6587            "rows_estimation": [
6588              {
6589                "table": "`t6`",
6590                "range_analysis": {
6591                  "table_scan": {
6592                    "rows": 3,
6593                    "cost": 4.7051
6594                  } /* table_scan */,
6595                  "potential_range_indexes": [
6596                    {
6597                      "index": "d",
6598                      "usable": true,
6599                      "key_parts": [
6600                        "d"
6601                      ] /* key_parts */
6602                    }
6603                  ] /* potential_range_indexes */,
6604                  "best_covering_index_scan": {
6605                    "index": "d",
6606                    "cost": 1.6465,
6607                    "chosen": true
6608                  } /* best_covering_index_scan */,
6609                  "setup_range_conditions": [
6610                  ] /* setup_range_conditions */,
6611                  "group_index_range": {
6612                    "chosen": false,
6613                    "cause": "not_group_by_or_distinct"
6614                  } /* group_index_range */,
6615                  "analyzing_range_alternatives": {
6616                    "range_scan_alternatives": [
6617                      {
6618                        "index": "d",
6619                        "ranges": [
6620                          "7 < d"
6621                        ] /* ranges */,
6622                        "index_dives_for_eq_ranges": true,
6623                        "rowid_ordered": false,
6624                        "using_mrr": false,
6625                        "index_only": true,
6626                        "rows": 2,
6627                        "cost": 1.4333,
6628                        "chosen": true
6629                      }
6630                    ] /* range_scan_alternatives */,
6631                    "analyzing_roworder_intersect": {
6632                      "usable": false,
6633                      "cause": "too_few_roworder_scans"
6634                    } /* analyzing_roworder_intersect */
6635                  } /* analyzing_range_alternatives */,
6636                  "chosen_range_access_summary": {
6637                    "range_access_plan": {
6638                      "type": "range_scan",
6639                      "index": "d",
6640                      "rows": 2,
6641                      "ranges": [
6642                        "7 < d"
6643                      ] /* ranges */
6644                    } /* range_access_plan */,
6645                    "rows_for_plan": 2,
6646                    "cost_for_plan": 1.4333,
6647                    "chosen": true
6648                  } /* chosen_range_access_summary */
6649                } /* range_analysis */
6650              }
6651            ] /* rows_estimation */
6652          },
6653          {
6654            "considered_execution_plans": [
6655              {
6656                "plan_prefix": [
6657                ] /* plan_prefix */,
6658                "table": "`t6`",
6659                "best_access_path": {
6660                  "considered_access_paths": [
6661                    {
6662                      "rows_to_scan": 2,
6663                      "access_type": "range",
6664                      "range_details": {
6665                        "used_index": "d"
6666                      } /* range_details */,
6667                      "resulting_rows": 2,
6668                      "cost": 1.8333,
6669                      "chosen": true
6670                    }
6671                  ] /* considered_access_paths */
6672                } /* best_access_path */,
6673                "condition_filtering_pct": 100,
6674                "rows_for_plan": 2,
6675                "cost_for_plan": 1.8333,
6676                "chosen": true
6677              }
6678            ] /* considered_execution_plans */
6679          },
6680          {
6681            "attaching_conditions_to_tables": {
6682              "original_condition": "(`t6`.`d` > 7)",
6683              "attached_conditions_computation": [
6684              ] /* attached_conditions_computation */,
6685              "attached_conditions_summary": [
6686                {
6687                  "table": "`t6`",
6688                  "attached": "(`t6`.`d` > 7)"
6689                }
6690              ] /* attached_conditions_summary */
6691            } /* attaching_conditions_to_tables */
6692          },
6693          {
6694            "refine_plan": [
6695              {
6696                "table": "`t6`"
6697              }
6698            ] /* refine_plan */
6699          }
6700        ] /* steps */
6701      } /* join_optimization */
6702    },
6703    {
6704      "join_execution": {
6705        "select#": 1,
6706        "steps": [
6707          {
6708            "creating_tmp_table": {
6709              "tmp_table_info": {
6710                "table": "intermediate_tmp_table",
6711                "row_length": 5,
6712                "key_length": 0,
6713                "unique_constraint": false,
6714                "location": "memory (heap)",
6715                "row_limit_estimate": 209715
6716              } /* tmp_table_info */
6717            } /* creating_tmp_table */
6718          }
6719        ] /* steps */
6720      } /* join_execution */
6721    }
6722  ] /* steps */
6723}	0	0
6724update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000;
6725select * from information_schema.OPTIMIZER_TRACE;
6726QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6727update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000	{
6728  "steps": [
6729    {
6730      "join_preparation": {
6731        "select#": 1,
6732        "steps": [
6733          {
6734            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t5` join `t6` where (`t6`.`d` > 7000)"
6735          }
6736        ] /* steps */
6737      } /* join_preparation */
6738    },
6739    {
6740      "join_optimization": {
6741        "select#": 1,
6742        "steps": [
6743          {
6744            "condition_processing": {
6745              "condition": "WHERE",
6746              "original_condition": "(`t6`.`d` > 7000)",
6747              "steps": [
6748                {
6749                  "transformation": "equality_propagation",
6750                  "resulting_condition": "(`t6`.`d` > 7000)"
6751                },
6752                {
6753                  "transformation": "constant_propagation",
6754                  "resulting_condition": "(`t6`.`d` > 7000)"
6755                },
6756                {
6757                  "transformation": "trivial_condition_removal",
6758                  "resulting_condition": "(`t6`.`d` > 7000)"
6759                }
6760              ] /* steps */
6761            } /* condition_processing */
6762          },
6763          {
6764            "substitute_generated_columns": {
6765            } /* substitute_generated_columns */
6766          },
6767          {
6768            "table_dependencies": [
6769              {
6770                "table": "`t5`",
6771                "row_may_be_null": false,
6772                "map_bit": 0,
6773                "depends_on_map_bits": [
6774                ] /* depends_on_map_bits */
6775              },
6776              {
6777                "table": "`t6`",
6778                "row_may_be_null": false,
6779                "map_bit": 1,
6780                "depends_on_map_bits": [
6781                ] /* depends_on_map_bits */
6782              }
6783            ] /* table_dependencies */
6784          },
6785          {
6786            "ref_optimizer_key_uses": [
6787            ] /* ref_optimizer_key_uses */
6788          },
6789          {
6790            "rows_estimation": [
6791              {
6792                "table": "`t5`",
6793                "rows": 1,
6794                "cost": 1,
6795                "table_type": "system",
6796                "empty": false
6797              },
6798              {
6799                "table": "`t6`",
6800                "range_analysis": {
6801                  "table_scan": {
6802                    "rows": 4,
6803                    "cost": 4.9068
6804                  } /* table_scan */,
6805                  "potential_range_indexes": [
6806                    {
6807                      "index": "d",
6808                      "usable": true,
6809                      "key_parts": [
6810                        "d"
6811                      ] /* key_parts */
6812                    }
6813                  ] /* potential_range_indexes */,
6814                  "setup_range_conditions": [
6815                  ] /* setup_range_conditions */,
6816                  "group_index_range": {
6817                    "chosen": false,
6818                    "cause": "not_single_table"
6819                  } /* group_index_range */,
6820                  "analyzing_range_alternatives": {
6821                    "range_scan_alternatives": [
6822                      {
6823                        "index": "d",
6824                        "ranges": [
6825                          "7000 < d"
6826                        ] /* ranges */,
6827                        "index_dives_for_eq_ranges": true,
6828                        "rowid_ordered": false,
6829                        "using_mrr": false,
6830                        "index_only": false,
6831                        "rows": 1,
6832                        "cost": 2.21,
6833                        "chosen": true
6834                      }
6835                    ] /* range_scan_alternatives */,
6836                    "analyzing_roworder_intersect": {
6837                      "usable": false,
6838                      "cause": "too_few_roworder_scans"
6839                    } /* analyzing_roworder_intersect */
6840                  } /* analyzing_range_alternatives */,
6841                  "chosen_range_access_summary": {
6842                    "range_access_plan": {
6843                      "type": "range_scan",
6844                      "index": "d",
6845                      "rows": 1,
6846                      "ranges": [
6847                        "7000 < d"
6848                      ] /* ranges */
6849                    } /* range_access_plan */,
6850                    "rows_for_plan": 1,
6851                    "cost_for_plan": 2.21,
6852                    "chosen": true
6853                  } /* chosen_range_access_summary */
6854                } /* range_analysis */
6855              }
6856            ] /* rows_estimation */
6857          },
6858          {
6859            "considered_execution_plans": [
6860              {
6861                "plan_prefix": [
6862                  "`t5`"
6863                ] /* plan_prefix */,
6864                "table": "`t6`",
6865                "best_access_path": {
6866                  "considered_access_paths": [
6867                    {
6868                      "rows_to_scan": 1,
6869                      "access_type": "range",
6870                      "range_details": {
6871                        "used_index": "d"
6872                      } /* range_details */,
6873                      "resulting_rows": 1,
6874                      "cost": 2.41,
6875                      "chosen": true
6876                    }
6877                  ] /* considered_access_paths */
6878                } /* best_access_path */,
6879                "condition_filtering_pct": 100,
6880                "rows_for_plan": 1,
6881                "cost_for_plan": 2.41,
6882                "chosen": true
6883              }
6884            ] /* considered_execution_plans */
6885          },
6886          {
6887            "attaching_conditions_to_tables": {
6888              "original_condition": "(`t6`.`d` > 7000)",
6889              "attached_conditions_computation": [
6890              ] /* attached_conditions_computation */,
6891              "attached_conditions_summary": [
6892                {
6893                  "table": "`t6`",
6894                  "attached": "(`t6`.`d` > 7000)"
6895                }
6896              ] /* attached_conditions_summary */
6897            } /* attaching_conditions_to_tables */
6898          },
6899          {
6900            "creating_tmp_table": {
6901              "tmp_table_info": {
6902                "table": "intermediate_tmp_table",
6903                "row_length": 13,
6904                "key_length": 9,
6905                "unique_constraint": false,
6906                "location": "memory (heap)",
6907                "row_limit_estimate": 80659
6908              } /* tmp_table_info */
6909            } /* creating_tmp_table */
6910          },
6911          {
6912            "refine_plan": [
6913              {
6914                "table": "`t6`"
6915              }
6916            ] /* refine_plan */
6917          }
6918        ] /* steps */
6919      } /* join_optimization */
6920    },
6921    {
6922      "join_execution": {
6923        "select#": 1,
6924        "steps": [
6925        ] /* steps */
6926      } /* join_execution */
6927    }
6928  ] /* steps */
6929}	0	0
6930delete t6 from t5, t6 where d>7000;
6931select * from information_schema.OPTIMIZER_TRACE;
6932QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
6933delete t6 from t5, t6 where d>7000	{
6934  "steps": [
6935    {
6936      "join_preparation": {
6937        "select#": 1,
6938        "steps": [
6939          {
6940            "expanded_query": "/* select#1 */ select NULL AS `NULL` from `t5` join `t6` where (`t6`.`d` > 7000)"
6941          }
6942        ] /* steps */
6943      } /* join_preparation */
6944    },
6945    {
6946      "join_optimization": {
6947        "select#": 1,
6948        "steps": [
6949          {
6950            "condition_processing": {
6951              "condition": "WHERE",
6952              "original_condition": "(`t6`.`d` > 7000)",
6953              "steps": [
6954                {
6955                  "transformation": "equality_propagation",
6956                  "resulting_condition": "(`t6`.`d` > 7000)"
6957                },
6958                {
6959                  "transformation": "constant_propagation",
6960                  "resulting_condition": "(`t6`.`d` > 7000)"
6961                },
6962                {
6963                  "transformation": "trivial_condition_removal",
6964                  "resulting_condition": "(`t6`.`d` > 7000)"
6965                }
6966              ] /* steps */
6967            } /* condition_processing */
6968          },
6969          {
6970            "substitute_generated_columns": {
6971            } /* substitute_generated_columns */
6972          },
6973          {
6974            "table_dependencies": [
6975              {
6976                "table": "`t5`",
6977                "row_may_be_null": false,
6978                "map_bit": 0,
6979                "depends_on_map_bits": [
6980                ] /* depends_on_map_bits */
6981              },
6982              {
6983                "table": "`t6`",
6984                "row_may_be_null": false,
6985                "map_bit": 1,
6986                "depends_on_map_bits": [
6987                ] /* depends_on_map_bits */
6988              }
6989            ] /* table_dependencies */
6990          },
6991          {
6992            "ref_optimizer_key_uses": [
6993            ] /* ref_optimizer_key_uses */
6994          },
6995          {
6996            "rows_estimation": [
6997              {
6998                "table": "`t5`",
6999                "rows": 1,
7000                "cost": 1,
7001                "table_type": "system",
7002                "empty": false
7003              },
7004              {
7005                "table": "`t6`",
7006                "range_analysis": {
7007                  "table_scan": {
7008                    "rows": 4,
7009                    "cost": 4.9068
7010                  } /* table_scan */,
7011                  "potential_range_indexes": [
7012                    {
7013                      "index": "d",
7014                      "usable": true,
7015                      "key_parts": [
7016                        "d"
7017                      ] /* key_parts */
7018                    }
7019                  ] /* potential_range_indexes */,
7020                  "best_covering_index_scan": {
7021                    "index": "d",
7022                    "cost": 1.8698,
7023                    "chosen": true
7024                  } /* best_covering_index_scan */,
7025                  "setup_range_conditions": [
7026                  ] /* setup_range_conditions */,
7027                  "group_index_range": {
7028                    "chosen": false,
7029                    "cause": "not_single_table"
7030                  } /* group_index_range */,
7031                  "analyzing_range_alternatives": {
7032                    "range_scan_alternatives": [
7033                      {
7034                        "index": "d",
7035                        "ranges": [
7036                          "7000 < d"
7037                        ] /* ranges */,
7038                        "index_dives_for_eq_ranges": true,
7039                        "rowid_ordered": false,
7040                        "using_mrr": false,
7041                        "index_only": true,
7042                        "rows": 1,
7043                        "cost": 1.21,
7044                        "chosen": true
7045                      }
7046                    ] /* range_scan_alternatives */,
7047                    "analyzing_roworder_intersect": {
7048                      "usable": false,
7049                      "cause": "too_few_roworder_scans"
7050                    } /* analyzing_roworder_intersect */
7051                  } /* analyzing_range_alternatives */,
7052                  "chosen_range_access_summary": {
7053                    "range_access_plan": {
7054                      "type": "range_scan",
7055                      "index": "d",
7056                      "rows": 1,
7057                      "ranges": [
7058                        "7000 < d"
7059                      ] /* ranges */
7060                    } /* range_access_plan */,
7061                    "rows_for_plan": 1,
7062                    "cost_for_plan": 1.21,
7063                    "chosen": true
7064                  } /* chosen_range_access_summary */
7065                } /* range_analysis */
7066              }
7067            ] /* rows_estimation */
7068          },
7069          {
7070            "considered_execution_plans": [
7071              {
7072                "plan_prefix": [
7073                  "`t5`"
7074                ] /* plan_prefix */,
7075                "table": "`t6`",
7076                "best_access_path": {
7077                  "considered_access_paths": [
7078                    {
7079                      "rows_to_scan": 1,
7080                      "access_type": "range",
7081                      "range_details": {
7082                        "used_index": "d"
7083                      } /* range_details */,
7084                      "resulting_rows": 1,
7085                      "cost": 1.41,
7086                      "chosen": true
7087                    }
7088                  ] /* considered_access_paths */
7089                } /* best_access_path */,
7090                "condition_filtering_pct": 100,
7091                "rows_for_plan": 1,
7092                "cost_for_plan": 1.41,
7093                "chosen": true
7094              }
7095            ] /* considered_execution_plans */
7096          },
7097          {
7098            "attaching_conditions_to_tables": {
7099              "original_condition": "(`t6`.`d` > 7000)",
7100              "attached_conditions_computation": [
7101              ] /* attached_conditions_computation */,
7102              "attached_conditions_summary": [
7103                {
7104                  "table": "`t6`",
7105                  "attached": "(`t6`.`d` > 7000)"
7106                }
7107              ] /* attached_conditions_summary */
7108            } /* attaching_conditions_to_tables */
7109          },
7110          {
7111            "refine_plan": [
7112              {
7113                "table": "`t6`"
7114              }
7115            ] /* refine_plan */
7116          }
7117        ] /* steps */
7118      } /* join_optimization */
7119    },
7120    {
7121      "join_execution": {
7122        "select#": 1,
7123        "steps": [
7124        ] /* steps */
7125      } /* join_execution */
7126    }
7127  ] /* steps */
7128}	0	0
7129set optimizer_trace_offset=2,optimizer_trace_limit=2;
7130select * from information_schema.OPTIMIZER_TRACE;
7131QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7132select 1;
71331
71341
7135select 2;
71362
71372
7138select 3;
71393
71403
7141select 4;
71424
71434
7144select 5;
71455
71465
7147select * from information_schema.OPTIMIZER_TRACE;
7148QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7149select 3	{
7150  "steps": [
7151    {
7152      "join_preparation": {
7153        "select#": 1,
7154        "steps": [
7155          {
7156            "expanded_query": "/* select#1 */ select 3 AS `3`"
7157          }
7158        ] /* steps */
7159      } /* join_preparation */
7160    },
7161    {
7162      "join_optimization": {
7163        "select#": 1,
7164        "steps": [
7165        ] /* steps */
7166      } /* join_optimization */
7167    },
7168    {
7169      "join_execution": {
7170        "select#": 1,
7171        "steps": [
7172        ] /* steps */
7173      } /* join_execution */
7174    }
7175  ] /* steps */
7176}	0	0
7177select 4	{
7178  "steps": [
7179    {
7180      "join_preparation": {
7181        "select#": 1,
7182        "steps": [
7183          {
7184            "expanded_query": "/* select#1 */ select 4 AS `4`"
7185          }
7186        ] /* steps */
7187      } /* join_preparation */
7188    },
7189    {
7190      "join_optimization": {
7191        "select#": 1,
7192        "steps": [
7193        ] /* steps */
7194      } /* join_optimization */
7195    },
7196    {
7197      "join_execution": {
7198        "select#": 1,
7199        "steps": [
7200        ] /* steps */
7201      } /* join_execution */
7202    }
7203  ] /* steps */
7204}	0	0
7205set optimizer_trace_offset=-2,optimizer_trace_limit=2;
7206select * from information_schema.OPTIMIZER_TRACE;
7207QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7208select 1;
72091
72101
7211select 2;
72122
72132
7214select 3;
72153
72163
7217select 4;
72184
72194
7220select 5;
72215
72225
7223select * from information_schema.OPTIMIZER_TRACE;
7224QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7225select 4	{
7226  "steps": [
7227    {
7228      "join_preparation": {
7229        "select#": 1,
7230        "steps": [
7231          {
7232            "expanded_query": "/* select#1 */ select 4 AS `4`"
7233          }
7234        ] /* steps */
7235      } /* join_preparation */
7236    },
7237    {
7238      "join_optimization": {
7239        "select#": 1,
7240        "steps": [
7241        ] /* steps */
7242      } /* join_optimization */
7243    },
7244    {
7245      "join_execution": {
7246        "select#": 1,
7247        "steps": [
7248        ] /* steps */
7249      } /* join_execution */
7250    }
7251  ] /* steps */
7252}	0	0
7253select 5	{
7254  "steps": [
7255    {
7256      "join_preparation": {
7257        "select#": 1,
7258        "steps": [
7259          {
7260            "expanded_query": "/* select#1 */ select 5 AS `5`"
7261          }
7262        ] /* steps */
7263      } /* join_preparation */
7264    },
7265    {
7266      "join_optimization": {
7267        "select#": 1,
7268        "steps": [
7269        ] /* steps */
7270      } /* join_optimization */
7271    },
7272    {
7273      "join_execution": {
7274        "select#": 1,
7275        "steps": [
7276        ] /* steps */
7277      } /* join_execution */
7278    }
7279  ] /* steps */
7280}	0	0
7281set optimizer_trace_offset=default,optimizer_trace_limit=default;
7282select * from information_schema.OPTIMIZER_TRACE;
7283QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7284create table t1 (
7285id   char(16) not null default '',
7286data int not null
7287);
7288create table t2 (
7289s   char(16),
7290i   int,
7291d   double
7292);
7293insert into t1 values ("a", 1), ("b", 2) |
7294insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0), ("d", 4, 4.0) |
7295create function f1() returns int
7296begin
7297declare ret int;
7298insert into t1 values("z",0);
7299delete from t1 where id="z";
7300select sum(data) into ret from t1;
7301return ret;
7302end|
7303select f1()|
7304f1()
73053
7306select * from information_schema.OPTIMIZER_TRACE|
7307QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7308freturn 3 ret@0	{
7309  "steps": [
7310  ] /* steps */
7311}	0	0
7312select s, f1() from t2 order by s desc|
7313s	f1()
7314d	3
7315c	3
7316b	3
7317a	3
7318select * from information_schema.OPTIMIZER_TRACE|
7319QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7320freturn 3 ret@0	{
7321  "steps": [
7322  ] /* steps */
7323}	0	0
7324select * from t6 where d in (select f1() from t2 where s="c")|
7325d
7326select * from information_schema.OPTIMIZER_TRACE|
7327QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7328freturn 3 ret@0	{
7329  "steps": [
7330  ] /* steps */
7331}	0	0
7332set @old_opt_switch=@@optimizer_switch;
7333# Test was created when sj-mat-scan could not handle this query...
7334set optimizer_switch="materialization=off";
7335set optimizer_trace_offset=-60, optimizer_trace_limit=60|
7336select * from t6 where d in (select f1() from t2 where s="c")|
7337d
7338select * from information_schema.OPTIMIZER_TRACE|
7339QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
7340select * from t6 where d in (select f1() from t2 where s="c")	{
7341  "steps": [
7342    {
7343      "join_preparation": {
7344        "select#": 1,
7345        "steps": [
7346          {
7347            "join_preparation": {
7348              "select#": 2,
7349              "steps": [
7350                {
7351                  "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c')"
7352                },
7353                {
7354                  "transformation": {
7355                    "select#": 2,
7356                    "from": "IN (SELECT)",
7357                    "to": "semijoin",
7358                    "chosen": false
7359                  } /* transformation */
7360                },
7361                {
7362                  "transformation": {
7363                    "select#": 2,
7364                    "from": "IN (SELECT)",
7365                    "to": "EXISTS (CORRELATED SELECT)",
7366                    "chosen": true,
7367                    "evaluating_constant_where_conditions": [
7368                    ] /* evaluating_constant_where_conditions */
7369                  } /* transformation */
7370                }
7371              ] /* steps */
7372            } /* join_preparation */
7373          },
7374          {
7375            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where <in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))"
7376          }
7377        ] /* steps */
7378      } /* join_preparation */
7379    },
7380    {
7381      "join_optimization": {
7382        "select#": 1,
7383        "steps": [
7384          {
7385            "condition_processing": {
7386              "condition": "WHERE",
7387              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))",
7388              "steps": [
7389                {
7390                  "transformation": "equality_propagation",
7391                  "subselect_evaluation": [
7392                  ] /* subselect_evaluation */,
7393                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))"
7394                },
7395                {
7396                  "transformation": "constant_propagation",
7397                  "subselect_evaluation": [
7398                  ] /* subselect_evaluation */,
7399                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))"
7400                },
7401                {
7402                  "transformation": "trivial_condition_removal",
7403                  "subselect_evaluation": [
7404                  ] /* subselect_evaluation */,
7405                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))"
7406                }
7407              ] /* steps */
7408            } /* condition_processing */
7409          },
7410          {
7411            "substitute_generated_columns": {
7412            } /* substitute_generated_columns */
7413          },
7414          {
7415            "table_dependencies": [
7416              {
7417                "table": "`t6`",
7418                "row_may_be_null": false,
7419                "map_bit": 0,
7420                "depends_on_map_bits": [
7421                ] /* depends_on_map_bits */
7422              }
7423            ] /* table_dependencies */
7424          },
7425          {
7426            "ref_optimizer_key_uses": [
7427            ] /* ref_optimizer_key_uses */
7428          },
7429          {
7430            "rows_estimation": [
7431              {
7432                "table": "`t6`",
7433                "table_scan": {
7434                  "rows": 4,
7435                  "cost": 2
7436                } /* table_scan */
7437              }
7438            ] /* rows_estimation */
7439          },
7440          {
7441            "considered_execution_plans": [
7442              {
7443                "plan_prefix": [
7444                ] /* plan_prefix */,
7445                "table": "`t6`",
7446                "best_access_path": {
7447                  "considered_access_paths": [
7448                    {
7449                      "rows_to_scan": 4,
7450                      "access_type": "scan",
7451                      "resulting_rows": 4,
7452                      "cost": 2.8068,
7453                      "chosen": true
7454                    }
7455                  ] /* considered_access_paths */
7456                } /* best_access_path */,
7457                "condition_filtering_pct": 100,
7458                "rows_for_plan": 4,
7459                "cost_for_plan": 2.8068,
7460                "chosen": true
7461              }
7462            ] /* considered_execution_plans */
7463          },
7464          {
7465            "attaching_conditions_to_tables": {
7466              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))",
7467              "attached_conditions_computation": [
7468              ] /* attached_conditions_computation */,
7469              "attached_conditions_summary": [
7470                {
7471                  "table": "`t6`",
7472                  "attached": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))))"
7473                }
7474              ] /* attached_conditions_summary */
7475            } /* attaching_conditions_to_tables */
7476          },
7477          {
7478            "refine_plan": [
7479              {
7480                "table": "`t6`"
7481              }
7482            ] /* refine_plan */
7483          }
7484        ] /* steps */
7485      } /* join_optimization */
7486    },
7487    {
7488      "join_optimization": {
7489        "select#": 2,
7490        "steps": [
7491          {
7492            "condition_processing": {
7493              "condition": "WHERE",
7494              "original_condition": "((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))",
7495              "steps": [
7496                {
7497                  "transformation": "equality_propagation",
7498                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal('c', `t2`.`s`))"
7499                },
7500                {
7501                  "transformation": "constant_propagation",
7502                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal('c', `t2`.`s`))"
7503                },
7504                {
7505                  "transformation": "trivial_condition_removal",
7506                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal('c', `t2`.`s`))"
7507                }
7508              ] /* steps */
7509            } /* condition_processing */
7510          },
7511          {
7512            "substitute_generated_columns": {
7513            } /* substitute_generated_columns */
7514          },
7515          {
7516            "table_dependencies": [
7517              {
7518                "table": "`t2`",
7519                "row_may_be_null": false,
7520                "map_bit": 0,
7521                "depends_on_map_bits": [
7522                ] /* depends_on_map_bits */
7523              }
7524            ] /* table_dependencies */
7525          },
7526          {
7527            "ref_optimizer_key_uses": [
7528            ] /* ref_optimizer_key_uses */
7529          },
7530          {
7531            "rows_estimation": [
7532              {
7533                "table": "`t2`",
7534                "table_scan": {
7535                  "rows": 4,
7536                  "cost": 2
7537                } /* table_scan */
7538              }
7539            ] /* rows_estimation */
7540          },
7541          {
7542            "considered_execution_plans": [
7543              {
7544                "plan_prefix": [
7545                ] /* plan_prefix */,
7546                "table": "`t2`",
7547                "best_access_path": {
7548                  "considered_access_paths": [
7549                    {
7550                      "rows_to_scan": 4,
7551                      "access_type": "scan",
7552                      "resulting_rows": 1,
7553                      "cost": 2.8283,
7554                      "chosen": true
7555                    }
7556                  ] /* considered_access_paths */
7557                } /* best_access_path */,
7558                "condition_filtering_pct": 100,
7559                "rows_for_plan": 1,
7560                "cost_for_plan": 2.8283,
7561                "chosen": true
7562              }
7563            ] /* considered_execution_plans */
7564          },
7565          {
7566            "transformation": {
7567              "select#": 2,
7568              "from": "IN (SELECT)",
7569              "to": "EXISTS (CORRELATED SELECT)",
7570              "put_1_in_SELECT_list": true
7571            } /* transformation */
7572          },
7573          {
7574            "attaching_conditions_to_tables": {
7575              "original_condition": "((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))",
7576              "attached_conditions_computation": [
7577              ] /* attached_conditions_computation */,
7578              "attached_conditions_summary": [
7579                {
7580                  "table": "`t2`",
7581                  "attached": "((`t2`.`s` = 'c') and (<cache>(`t6`.`d`) = `f1`()))"
7582                }
7583              ] /* attached_conditions_summary */
7584            } /* attaching_conditions_to_tables */
7585          },
7586          {
7587            "refine_plan": [
7588              {
7589                "table": "`t2`"
7590              }
7591            ] /* refine_plan */
7592          }
7593        ] /* steps */
7594      } /* join_optimization */
7595    },
7596    {
7597      "join_execution": {
7598        "select#": 1,
7599        "steps": [
7600          {
7601            "subselect_execution": {
7602              "select#": 2,
7603              "steps": [
7604                {
7605                  "join_execution": {
7606                    "select#": 2,
7607                    "steps": [
7608                    ] /* steps */
7609                  } /* join_execution */
7610                }
7611              ] /* steps */
7612            } /* subselect_execution */
7613          },
7614          {
7615            "subselect_execution": {
7616              "select#": 2,
7617              "steps": [
7618                {
7619                  "join_execution": {
7620                    "select#": 2,
7621                    "steps": [
7622                    ] /* steps */
7623                  } /* join_execution */
7624                }
7625              ] /* steps */
7626            } /* subselect_execution */
7627          },
7628          {
7629            "subselect_execution": {
7630              "select#": 2,
7631              "steps": [
7632                {
7633                  "join_execution": {
7634                    "select#": 2,
7635                    "steps": [
7636                    ] /* steps */
7637                  } /* join_execution */
7638                }
7639              ] /* steps */
7640            } /* subselect_execution */
7641          },
7642          {
7643            "subselect_execution": {
7644              "select#": 2,
7645              "steps": [
7646                {
7647                  "join_execution": {
7648                    "select#": 2,
7649                    "steps": [
7650                    ] /* steps */
7651                  } /* join_execution */
7652                }
7653              ] /* steps */
7654            } /* subselect_execution */
7655          }
7656        ] /* steps */
7657      } /* join_execution */
7658    }
7659  ] /* steps */
7660}	0	0
7661set ret@0 NULL	{
7662  "steps": [
7663  ] /* steps */
7664}	0	0
7665insert into t1 values("z",0)	{
7666  "steps": [
7667  ] /* steps */
7668}	0	0
7669delete from t1 where id="z"	{
7670  "steps": [
7671    {
7672      "substitute_generated_columns": {
7673      } /* substitute_generated_columns */
7674    },
7675    {
7676      "condition_processing": {
7677        "condition": "WHERE",
7678        "original_condition": "(`t1`.`id` = 'z')",
7679        "steps": [
7680          {
7681            "transformation": "equality_propagation",
7682            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7683          },
7684          {
7685            "transformation": "constant_propagation",
7686            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7687          },
7688          {
7689            "transformation": "trivial_condition_removal",
7690            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7691          }
7692        ] /* steps */
7693      } /* condition_processing */
7694    },
7695    {
7696      "table": "`t1`",
7697      "range_analysis": {
7698        "table_scan": {
7699          "rows": 3,
7700          "cost": 4.7154
7701        } /* table_scan */
7702      } /* range_analysis */
7703    }
7704  ] /* steps */
7705}	0	0
7706select sum(data) into ret from t1	{
7707  "steps": [
7708    {
7709      "join_preparation": {
7710        "select#": 1,
7711        "steps": [
7712          {
7713            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
7714          }
7715        ] /* steps */
7716      } /* join_preparation */
7717    },
7718    {
7719      "join_optimization": {
7720        "select#": 1,
7721        "steps": [
7722          {
7723            "table_dependencies": [
7724              {
7725                "table": "`t1`",
7726                "row_may_be_null": false,
7727                "map_bit": 0,
7728                "depends_on_map_bits": [
7729                ] /* depends_on_map_bits */
7730              }
7731            ] /* table_dependencies */
7732          },
7733          {
7734            "rows_estimation": [
7735              {
7736                "table": "`t1`",
7737                "table_scan": {
7738                  "rows": 2,
7739                  "cost": 2
7740                } /* table_scan */
7741              }
7742            ] /* rows_estimation */
7743          },
7744          {
7745            "considered_execution_plans": [
7746              {
7747                "plan_prefix": [
7748                ] /* plan_prefix */,
7749                "table": "`t1`",
7750                "best_access_path": {
7751                  "considered_access_paths": [
7752                    {
7753                      "rows_to_scan": 2,
7754                      "access_type": "scan",
7755                      "resulting_rows": 2,
7756                      "cost": 2.4154,
7757                      "chosen": true
7758                    }
7759                  ] /* considered_access_paths */
7760                } /* best_access_path */,
7761                "condition_filtering_pct": 100,
7762                "rows_for_plan": 2,
7763                "cost_for_plan": 2.4154,
7764                "chosen": true
7765              }
7766            ] /* considered_execution_plans */
7767          },
7768          {
7769            "attaching_conditions_to_tables": {
7770              "original_condition": null,
7771              "attached_conditions_computation": [
7772              ] /* attached_conditions_computation */,
7773              "attached_conditions_summary": [
7774                {
7775                  "table": "`t1`",
7776                  "attached": null
7777                }
7778              ] /* attached_conditions_summary */
7779            } /* attaching_conditions_to_tables */
7780          },
7781          {
7782            "refine_plan": [
7783              {
7784                "table": "`t1`"
7785              }
7786            ] /* refine_plan */
7787          }
7788        ] /* steps */
7789      } /* join_optimization */
7790    },
7791    {
7792      "join_execution": {
7793        "select#": 1,
7794        "steps": [
7795        ] /* steps */
7796      } /* join_execution */
7797    }
7798  ] /* steps */
7799}	0	0
7800freturn 3 ret@0	{
7801  "steps": [
7802  ] /* steps */
7803}	0	0
7804set ret@0 NULL	{
7805  "steps": [
7806  ] /* steps */
7807}	0	0
7808insert into t1 values("z",0)	{
7809  "steps": [
7810  ] /* steps */
7811}	0	0
7812delete from t1 where id="z"	{
7813  "steps": [
7814    {
7815      "substitute_generated_columns": {
7816      } /* substitute_generated_columns */
7817    },
7818    {
7819      "condition_processing": {
7820        "condition": "WHERE",
7821        "original_condition": "(`t1`.`id` = 'z')",
7822        "steps": [
7823          {
7824            "transformation": "equality_propagation",
7825            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7826          },
7827          {
7828            "transformation": "constant_propagation",
7829            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7830          },
7831          {
7832            "transformation": "trivial_condition_removal",
7833            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7834          }
7835        ] /* steps */
7836      } /* condition_processing */
7837    },
7838    {
7839      "table": "`t1`",
7840      "range_analysis": {
7841        "table_scan": {
7842          "rows": 3,
7843          "cost": 4.7154
7844        } /* table_scan */
7845      } /* range_analysis */
7846    }
7847  ] /* steps */
7848}	0	0
7849select sum(data) into ret from t1	{
7850  "steps": [
7851    {
7852      "join_preparation": {
7853        "select#": 1,
7854        "steps": [
7855          {
7856            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
7857          }
7858        ] /* steps */
7859      } /* join_preparation */
7860    },
7861    {
7862      "join_optimization": {
7863        "select#": 1,
7864        "steps": [
7865          {
7866            "table_dependencies": [
7867              {
7868                "table": "`t1`",
7869                "row_may_be_null": false,
7870                "map_bit": 0,
7871                "depends_on_map_bits": [
7872                ] /* depends_on_map_bits */
7873              }
7874            ] /* table_dependencies */
7875          },
7876          {
7877            "rows_estimation": [
7878              {
7879                "table": "`t1`",
7880                "table_scan": {
7881                  "rows": 2,
7882                  "cost": 2
7883                } /* table_scan */
7884              }
7885            ] /* rows_estimation */
7886          },
7887          {
7888            "considered_execution_plans": [
7889              {
7890                "plan_prefix": [
7891                ] /* plan_prefix */,
7892                "table": "`t1`",
7893                "best_access_path": {
7894                  "considered_access_paths": [
7895                    {
7896                      "rows_to_scan": 2,
7897                      "access_type": "scan",
7898                      "resulting_rows": 2,
7899                      "cost": 2.4154,
7900                      "chosen": true
7901                    }
7902                  ] /* considered_access_paths */
7903                } /* best_access_path */,
7904                "condition_filtering_pct": 100,
7905                "rows_for_plan": 2,
7906                "cost_for_plan": 2.4154,
7907                "chosen": true
7908              }
7909            ] /* considered_execution_plans */
7910          },
7911          {
7912            "attaching_conditions_to_tables": {
7913              "original_condition": null,
7914              "attached_conditions_computation": [
7915              ] /* attached_conditions_computation */,
7916              "attached_conditions_summary": [
7917                {
7918                  "table": "`t1`",
7919                  "attached": null
7920                }
7921              ] /* attached_conditions_summary */
7922            } /* attaching_conditions_to_tables */
7923          },
7924          {
7925            "refine_plan": [
7926              {
7927                "table": "`t1`"
7928              }
7929            ] /* refine_plan */
7930          }
7931        ] /* steps */
7932      } /* join_optimization */
7933    },
7934    {
7935      "join_execution": {
7936        "select#": 1,
7937        "steps": [
7938        ] /* steps */
7939      } /* join_execution */
7940    }
7941  ] /* steps */
7942}	0	0
7943freturn 3 ret@0	{
7944  "steps": [
7945  ] /* steps */
7946}	0	0
7947set ret@0 NULL	{
7948  "steps": [
7949  ] /* steps */
7950}	0	0
7951insert into t1 values("z",0)	{
7952  "steps": [
7953  ] /* steps */
7954}	0	0
7955delete from t1 where id="z"	{
7956  "steps": [
7957    {
7958      "substitute_generated_columns": {
7959      } /* substitute_generated_columns */
7960    },
7961    {
7962      "condition_processing": {
7963        "condition": "WHERE",
7964        "original_condition": "(`t1`.`id` = 'z')",
7965        "steps": [
7966          {
7967            "transformation": "equality_propagation",
7968            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7969          },
7970          {
7971            "transformation": "constant_propagation",
7972            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7973          },
7974          {
7975            "transformation": "trivial_condition_removal",
7976            "resulting_condition": "multiple equal('z', `t1`.`id`)"
7977          }
7978        ] /* steps */
7979      } /* condition_processing */
7980    },
7981    {
7982      "table": "`t1`",
7983      "range_analysis": {
7984        "table_scan": {
7985          "rows": 3,
7986          "cost": 4.7154
7987        } /* table_scan */
7988      } /* range_analysis */
7989    }
7990  ] /* steps */
7991}	0	0
7992select sum(data) into ret from t1	{
7993  "steps": [
7994    {
7995      "join_preparation": {
7996        "select#": 1,
7997        "steps": [
7998          {
7999            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
8000          }
8001        ] /* steps */
8002      } /* join_preparation */
8003    },
8004    {
8005      "join_optimization": {
8006        "select#": 1,
8007        "steps": [
8008          {
8009            "table_dependencies": [
8010              {
8011                "table": "`t1`",
8012                "row_may_be_null": false,
8013                "map_bit": 0,
8014                "depends_on_map_bits": [
8015                ] /* depends_on_map_bits */
8016              }
8017            ] /* table_dependencies */
8018          },
8019          {
8020            "rows_estimation": [
8021              {
8022                "table": "`t1`",
8023                "table_scan": {
8024                  "rows": 2,
8025                  "cost": 2
8026                } /* table_scan */
8027              }
8028            ] /* rows_estimation */
8029          },
8030          {
8031            "considered_execution_plans": [
8032              {
8033                "plan_prefix": [
8034                ] /* plan_prefix */,
8035                "table": "`t1`",
8036                "best_access_path": {
8037                  "considered_access_paths": [
8038                    {
8039                      "rows_to_scan": 2,
8040                      "access_type": "scan",
8041                      "resulting_rows": 2,
8042                      "cost": 2.4154,
8043                      "chosen": true
8044                    }
8045                  ] /* considered_access_paths */
8046                } /* best_access_path */,
8047                "condition_filtering_pct": 100,
8048                "rows_for_plan": 2,
8049                "cost_for_plan": 2.4154,
8050                "chosen": true
8051              }
8052            ] /* considered_execution_plans */
8053          },
8054          {
8055            "attaching_conditions_to_tables": {
8056              "original_condition": null,
8057              "attached_conditions_computation": [
8058              ] /* attached_conditions_computation */,
8059              "attached_conditions_summary": [
8060                {
8061                  "table": "`t1`",
8062                  "attached": null
8063                }
8064              ] /* attached_conditions_summary */
8065            } /* attaching_conditions_to_tables */
8066          },
8067          {
8068            "refine_plan": [
8069              {
8070                "table": "`t1`"
8071              }
8072            ] /* refine_plan */
8073          }
8074        ] /* steps */
8075      } /* join_optimization */
8076    },
8077    {
8078      "join_execution": {
8079        "select#": 1,
8080        "steps": [
8081        ] /* steps */
8082      } /* join_execution */
8083    }
8084  ] /* steps */
8085}	0	0
8086freturn 3 ret@0	{
8087  "steps": [
8088  ] /* steps */
8089}	0	0
8090set ret@0 NULL	{
8091  "steps": [
8092  ] /* steps */
8093}	0	0
8094insert into t1 values("z",0)	{
8095  "steps": [
8096  ] /* steps */
8097}	0	0
8098delete from t1 where id="z"	{
8099  "steps": [
8100    {
8101      "substitute_generated_columns": {
8102      } /* substitute_generated_columns */
8103    },
8104    {
8105      "condition_processing": {
8106        "condition": "WHERE",
8107        "original_condition": "(`t1`.`id` = 'z')",
8108        "steps": [
8109          {
8110            "transformation": "equality_propagation",
8111            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8112          },
8113          {
8114            "transformation": "constant_propagation",
8115            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8116          },
8117          {
8118            "transformation": "trivial_condition_removal",
8119            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8120          }
8121        ] /* steps */
8122      } /* condition_processing */
8123    },
8124    {
8125      "table": "`t1`",
8126      "range_analysis": {
8127        "table_scan": {
8128          "rows": 3,
8129          "cost": 4.7154
8130        } /* table_scan */
8131      } /* range_analysis */
8132    }
8133  ] /* steps */
8134}	0	0
8135select sum(data) into ret from t1	{
8136  "steps": [
8137    {
8138      "join_preparation": {
8139        "select#": 1,
8140        "steps": [
8141          {
8142            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
8143          }
8144        ] /* steps */
8145      } /* join_preparation */
8146    },
8147    {
8148      "join_optimization": {
8149        "select#": 1,
8150        "steps": [
8151          {
8152            "table_dependencies": [
8153              {
8154                "table": "`t1`",
8155                "row_may_be_null": false,
8156                "map_bit": 0,
8157                "depends_on_map_bits": [
8158                ] /* depends_on_map_bits */
8159              }
8160            ] /* table_dependencies */
8161          },
8162          {
8163            "rows_estimation": [
8164              {
8165                "table": "`t1`",
8166                "table_scan": {
8167                  "rows": 2,
8168                  "cost": 2
8169                } /* table_scan */
8170              }
8171            ] /* rows_estimation */
8172          },
8173          {
8174            "considered_execution_plans": [
8175              {
8176                "plan_prefix": [
8177                ] /* plan_prefix */,
8178                "table": "`t1`",
8179                "best_access_path": {
8180                  "considered_access_paths": [
8181                    {
8182                      "rows_to_scan": 2,
8183                      "access_type": "scan",
8184                      "resulting_rows": 2,
8185                      "cost": 2.4154,
8186                      "chosen": true
8187                    }
8188                  ] /* considered_access_paths */
8189                } /* best_access_path */,
8190                "condition_filtering_pct": 100,
8191                "rows_for_plan": 2,
8192                "cost_for_plan": 2.4154,
8193                "chosen": true
8194              }
8195            ] /* considered_execution_plans */
8196          },
8197          {
8198            "attaching_conditions_to_tables": {
8199              "original_condition": null,
8200              "attached_conditions_computation": [
8201              ] /* attached_conditions_computation */,
8202              "attached_conditions_summary": [
8203                {
8204                  "table": "`t1`",
8205                  "attached": null
8206                }
8207              ] /* attached_conditions_summary */
8208            } /* attaching_conditions_to_tables */
8209          },
8210          {
8211            "refine_plan": [
8212              {
8213                "table": "`t1`"
8214              }
8215            ] /* refine_plan */
8216          }
8217        ] /* steps */
8218      } /* join_optimization */
8219    },
8220    {
8221      "join_execution": {
8222        "select#": 1,
8223        "steps": [
8224        ] /* steps */
8225      } /* join_execution */
8226    }
8227  ] /* steps */
8228}	0	0
8229freturn 3 ret@0	{
8230  "steps": [
8231  ] /* steps */
8232}	0	0
8233select count(*) from information_schema.OPTIMIZER_TRACE|
8234count(*)
823521
8236set optimizer_trace_offset=3, optimizer_trace_limit=1|
8237select * from t6 where d in (select f1() from t2 where s="c")|
8238d
8239select * from information_schema.OPTIMIZER_TRACE|
8240QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
8241delete from t1 where id="z"	{
8242  "steps": [
8243    {
8244      "substitute_generated_columns": {
8245      } /* substitute_generated_columns */
8246    },
8247    {
8248      "condition_processing": {
8249        "condition": "WHERE",
8250        "original_condition": "(`t1`.`id` = 'z')",
8251        "steps": [
8252          {
8253            "transformation": "equality_propagation",
8254            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8255          },
8256          {
8257            "transformation": "constant_propagation",
8258            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8259          },
8260          {
8261            "transformation": "trivial_condition_removal",
8262            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8263          }
8264        ] /* steps */
8265      } /* condition_processing */
8266    },
8267    {
8268      "table": "`t1`",
8269      "range_analysis": {
8270        "table_scan": {
8271          "rows": 3,
8272          "cost": 4.7154
8273        } /* table_scan */
8274      } /* range_analysis */
8275    }
8276  ] /* steps */
8277}	0	0
8278set @@optimizer_switch=@old_opt_switch;
8279# Stored procedures
8280create procedure p1(arg char(1))
8281begin
8282declare res int;
8283select d into res from t6 where d in (select f1() from t2 where s=arg);
8284select d+1 into res from t6 where d=res+1;
8285end|
8286set @old_opt_switch=@@optimizer_switch;
8287# Test was created when sj-mat-scan could not handle this query...
8288set optimizer_switch="materialization=off";
8289set optimizer_trace_offset=0, optimizer_trace_limit=100;
8290call p1("c")|
8291Warnings:
8292Warning	1329	No data - zero rows fetched, selected, or processed
8293select * from information_schema.OPTIMIZER_TRACE|
8294QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
8295call p1("c")	{
8296  "steps": [
8297  ] /* steps */
8298}	0	0
8299set res@1 NULL	{
8300  "steps": [
8301  ] /* steps */
8302}	0	0
8303select d into res from t6 where d in (select f1() from t2 where s=arg)	{
8304  "steps": [
8305    {
8306      "join_preparation": {
8307        "select#": 1,
8308        "steps": [
8309          {
8310            "join_preparation": {
8311              "select#": 2,
8312              "steps": [
8313                {
8314                  "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
8315                },
8316                {
8317                  "transformation": {
8318                    "select#": 2,
8319                    "from": "IN (SELECT)",
8320                    "to": "semijoin",
8321                    "chosen": false
8322                  } /* transformation */
8323                },
8324                {
8325                  "transformation": {
8326                    "select#": 2,
8327                    "from": "IN (SELECT)",
8328                    "to": "EXISTS (CORRELATED SELECT)",
8329                    "chosen": true,
8330                    "evaluating_constant_where_conditions": [
8331                    ] /* evaluating_constant_where_conditions */
8332                  } /* transformation */
8333                }
8334              ] /* steps */
8335            } /* join_preparation */
8336          },
8337          {
8338            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where <in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
8339          }
8340        ] /* steps */
8341      } /* join_preparation */
8342    },
8343    {
8344      "join_optimization": {
8345        "select#": 1,
8346        "steps": [
8347          {
8348            "condition_processing": {
8349              "condition": "WHERE",
8350              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))",
8351              "steps": [
8352                {
8353                  "transformation": "equality_propagation",
8354                  "subselect_evaluation": [
8355                  ] /* subselect_evaluation */,
8356                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
8357                },
8358                {
8359                  "transformation": "constant_propagation",
8360                  "subselect_evaluation": [
8361                  ] /* subselect_evaluation */,
8362                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
8363                },
8364                {
8365                  "transformation": "trivial_condition_removal",
8366                  "subselect_evaluation": [
8367                  ] /* subselect_evaluation */,
8368                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
8369                }
8370              ] /* steps */
8371            } /* condition_processing */
8372          },
8373          {
8374            "substitute_generated_columns": {
8375            } /* substitute_generated_columns */
8376          },
8377          {
8378            "table_dependencies": [
8379              {
8380                "table": "`t6`",
8381                "row_may_be_null": false,
8382                "map_bit": 0,
8383                "depends_on_map_bits": [
8384                ] /* depends_on_map_bits */
8385              }
8386            ] /* table_dependencies */
8387          },
8388          {
8389            "ref_optimizer_key_uses": [
8390            ] /* ref_optimizer_key_uses */
8391          },
8392          {
8393            "rows_estimation": [
8394              {
8395                "table": "`t6`",
8396                "table_scan": {
8397                  "rows": 4,
8398                  "cost": 2
8399                } /* table_scan */
8400              }
8401            ] /* rows_estimation */
8402          },
8403          {
8404            "considered_execution_plans": [
8405              {
8406                "plan_prefix": [
8407                ] /* plan_prefix */,
8408                "table": "`t6`",
8409                "best_access_path": {
8410                  "considered_access_paths": [
8411                    {
8412                      "rows_to_scan": 4,
8413                      "access_type": "scan",
8414                      "resulting_rows": 4,
8415                      "cost": 2.8068,
8416                      "chosen": true
8417                    }
8418                  ] /* considered_access_paths */
8419                } /* best_access_path */,
8420                "condition_filtering_pct": 100,
8421                "rows_for_plan": 4,
8422                "cost_for_plan": 2.8068,
8423                "chosen": true
8424              }
8425            ] /* considered_execution_plans */
8426          },
8427          {
8428            "attaching_conditions_to_tables": {
8429              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))",
8430              "attached_conditions_computation": [
8431              ] /* attached_conditions_computation */,
8432              "attached_conditions_summary": [
8433                {
8434                  "table": "`t6`",
8435                  "attached": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
8436                }
8437              ] /* attached_conditions_summary */
8438            } /* attaching_conditions_to_tables */
8439          },
8440          {
8441            "refine_plan": [
8442              {
8443                "table": "`t6`"
8444              }
8445            ] /* refine_plan */
8446          }
8447        ] /* steps */
8448      } /* join_optimization */
8449    },
8450    {
8451      "join_optimization": {
8452        "select#": 2,
8453        "steps": [
8454          {
8455            "condition_processing": {
8456              "condition": "WHERE",
8457              "original_condition": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))",
8458              "steps": [
8459                {
8460                  "transformation": "equality_propagation",
8461                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8462                },
8463                {
8464                  "transformation": "constant_propagation",
8465                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8466                },
8467                {
8468                  "transformation": "trivial_condition_removal",
8469                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8470                }
8471              ] /* steps */
8472            } /* condition_processing */
8473          },
8474          {
8475            "substitute_generated_columns": {
8476            } /* substitute_generated_columns */
8477          },
8478          {
8479            "table_dependencies": [
8480              {
8481                "table": "`t2`",
8482                "row_may_be_null": false,
8483                "map_bit": 0,
8484                "depends_on_map_bits": [
8485                ] /* depends_on_map_bits */
8486              }
8487            ] /* table_dependencies */
8488          },
8489          {
8490            "ref_optimizer_key_uses": [
8491            ] /* ref_optimizer_key_uses */
8492          },
8493          {
8494            "rows_estimation": [
8495              {
8496                "table": "`t2`",
8497                "table_scan": {
8498                  "rows": 4,
8499                  "cost": 2
8500                } /* table_scan */
8501              }
8502            ] /* rows_estimation */
8503          },
8504          {
8505            "considered_execution_plans": [
8506              {
8507                "plan_prefix": [
8508                ] /* plan_prefix */,
8509                "table": "`t2`",
8510                "best_access_path": {
8511                  "considered_access_paths": [
8512                    {
8513                      "rows_to_scan": 4,
8514                      "access_type": "scan",
8515                      "resulting_rows": 1,
8516                      "cost": 2.8283,
8517                      "chosen": true
8518                    }
8519                  ] /* considered_access_paths */
8520                } /* best_access_path */,
8521                "condition_filtering_pct": 100,
8522                "rows_for_plan": 1,
8523                "cost_for_plan": 2.8283,
8524                "chosen": true
8525              }
8526            ] /* considered_execution_plans */
8527          },
8528          {
8529            "attaching_conditions_to_tables": {
8530              "original_condition": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))",
8531              "attached_conditions_computation": [
8532              ] /* attached_conditions_computation */,
8533              "attached_conditions_summary": [
8534                {
8535                  "table": "`t2`",
8536                  "attached": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))"
8537                }
8538              ] /* attached_conditions_summary */
8539            } /* attaching_conditions_to_tables */
8540          },
8541          {
8542            "refine_plan": [
8543              {
8544                "table": "`t2`"
8545              }
8546            ] /* refine_plan */
8547          }
8548        ] /* steps */
8549      } /* join_optimization */
8550    },
8551    {
8552      "join_execution": {
8553        "select#": 1,
8554        "steps": [
8555          {
8556            "subselect_execution": {
8557              "select#": 2,
8558              "steps": [
8559                {
8560                  "join_execution": {
8561                    "select#": 2,
8562                    "steps": [
8563                    ] /* steps */
8564                  } /* join_execution */
8565                }
8566              ] /* steps */
8567            } /* subselect_execution */
8568          },
8569          {
8570            "subselect_execution": {
8571              "select#": 2,
8572              "steps": [
8573                {
8574                  "join_execution": {
8575                    "select#": 2,
8576                    "steps": [
8577                    ] /* steps */
8578                  } /* join_execution */
8579                }
8580              ] /* steps */
8581            } /* subselect_execution */
8582          },
8583          {
8584            "subselect_execution": {
8585              "select#": 2,
8586              "steps": [
8587                {
8588                  "join_execution": {
8589                    "select#": 2,
8590                    "steps": [
8591                    ] /* steps */
8592                  } /* join_execution */
8593                }
8594              ] /* steps */
8595            } /* subselect_execution */
8596          },
8597          {
8598            "subselect_execution": {
8599              "select#": 2,
8600              "steps": [
8601                {
8602                  "join_execution": {
8603                    "select#": 2,
8604                    "steps": [
8605                    ] /* steps */
8606                  } /* join_execution */
8607                }
8608              ] /* steps */
8609            } /* subselect_execution */
8610          }
8611        ] /* steps */
8612      } /* join_execution */
8613    }
8614  ] /* steps */
8615}	0	0
8616set ret@0 NULL	{
8617  "steps": [
8618  ] /* steps */
8619}	0	0
8620insert into t1 values("z",0)	{
8621  "steps": [
8622  ] /* steps */
8623}	0	0
8624delete from t1 where id="z"	{
8625  "steps": [
8626    {
8627      "substitute_generated_columns": {
8628      } /* substitute_generated_columns */
8629    },
8630    {
8631      "condition_processing": {
8632        "condition": "WHERE",
8633        "original_condition": "(`t1`.`id` = 'z')",
8634        "steps": [
8635          {
8636            "transformation": "equality_propagation",
8637            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8638          },
8639          {
8640            "transformation": "constant_propagation",
8641            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8642          },
8643          {
8644            "transformation": "trivial_condition_removal",
8645            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8646          }
8647        ] /* steps */
8648      } /* condition_processing */
8649    },
8650    {
8651      "table": "`t1`",
8652      "range_analysis": {
8653        "table_scan": {
8654          "rows": 3,
8655          "cost": 4.7154
8656        } /* table_scan */
8657      } /* range_analysis */
8658    }
8659  ] /* steps */
8660}	0	0
8661select sum(data) into ret from t1	{
8662  "steps": [
8663    {
8664      "join_preparation": {
8665        "select#": 1,
8666        "steps": [
8667          {
8668            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
8669          }
8670        ] /* steps */
8671      } /* join_preparation */
8672    },
8673    {
8674      "join_optimization": {
8675        "select#": 1,
8676        "steps": [
8677          {
8678            "table_dependencies": [
8679              {
8680                "table": "`t1`",
8681                "row_may_be_null": false,
8682                "map_bit": 0,
8683                "depends_on_map_bits": [
8684                ] /* depends_on_map_bits */
8685              }
8686            ] /* table_dependencies */
8687          },
8688          {
8689            "rows_estimation": [
8690              {
8691                "table": "`t1`",
8692                "table_scan": {
8693                  "rows": 2,
8694                  "cost": 2
8695                } /* table_scan */
8696              }
8697            ] /* rows_estimation */
8698          },
8699          {
8700            "considered_execution_plans": [
8701              {
8702                "plan_prefix": [
8703                ] /* plan_prefix */,
8704                "table": "`t1`",
8705                "best_access_path": {
8706                  "considered_access_paths": [
8707                    {
8708                      "rows_to_scan": 2,
8709                      "access_type": "scan",
8710                      "resulting_rows": 2,
8711                      "cost": 2.4154,
8712                      "chosen": true
8713                    }
8714                  ] /* considered_access_paths */
8715                } /* best_access_path */,
8716                "condition_filtering_pct": 100,
8717                "rows_for_plan": 2,
8718                "cost_for_plan": 2.4154,
8719                "chosen": true
8720              }
8721            ] /* considered_execution_plans */
8722          },
8723          {
8724            "attaching_conditions_to_tables": {
8725              "original_condition": null,
8726              "attached_conditions_computation": [
8727              ] /* attached_conditions_computation */,
8728              "attached_conditions_summary": [
8729                {
8730                  "table": "`t1`",
8731                  "attached": null
8732                }
8733              ] /* attached_conditions_summary */
8734            } /* attaching_conditions_to_tables */
8735          },
8736          {
8737            "refine_plan": [
8738              {
8739                "table": "`t1`"
8740              }
8741            ] /* refine_plan */
8742          }
8743        ] /* steps */
8744      } /* join_optimization */
8745    },
8746    {
8747      "join_execution": {
8748        "select#": 1,
8749        "steps": [
8750        ] /* steps */
8751      } /* join_execution */
8752    }
8753  ] /* steps */
8754}	0	0
8755freturn 3 ret@0	{
8756  "steps": [
8757  ] /* steps */
8758}	0	0
8759set ret@0 NULL	{
8760  "steps": [
8761  ] /* steps */
8762}	0	0
8763insert into t1 values("z",0)	{
8764  "steps": [
8765  ] /* steps */
8766}	0	0
8767delete from t1 where id="z"	{
8768  "steps": [
8769    {
8770      "substitute_generated_columns": {
8771      } /* substitute_generated_columns */
8772    },
8773    {
8774      "condition_processing": {
8775        "condition": "WHERE",
8776        "original_condition": "(`t1`.`id` = 'z')",
8777        "steps": [
8778          {
8779            "transformation": "equality_propagation",
8780            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8781          },
8782          {
8783            "transformation": "constant_propagation",
8784            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8785          },
8786          {
8787            "transformation": "trivial_condition_removal",
8788            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8789          }
8790        ] /* steps */
8791      } /* condition_processing */
8792    },
8793    {
8794      "table": "`t1`",
8795      "range_analysis": {
8796        "table_scan": {
8797          "rows": 3,
8798          "cost": 4.7154
8799        } /* table_scan */
8800      } /* range_analysis */
8801    }
8802  ] /* steps */
8803}	0	0
8804select sum(data) into ret from t1	{
8805  "steps": [
8806    {
8807      "join_preparation": {
8808        "select#": 1,
8809        "steps": [
8810          {
8811            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
8812          }
8813        ] /* steps */
8814      } /* join_preparation */
8815    },
8816    {
8817      "join_optimization": {
8818        "select#": 1,
8819        "steps": [
8820          {
8821            "table_dependencies": [
8822              {
8823                "table": "`t1`",
8824                "row_may_be_null": false,
8825                "map_bit": 0,
8826                "depends_on_map_bits": [
8827                ] /* depends_on_map_bits */
8828              }
8829            ] /* table_dependencies */
8830          },
8831          {
8832            "rows_estimation": [
8833              {
8834                "table": "`t1`",
8835                "table_scan": {
8836                  "rows": 2,
8837                  "cost": 2
8838                } /* table_scan */
8839              }
8840            ] /* rows_estimation */
8841          },
8842          {
8843            "considered_execution_plans": [
8844              {
8845                "plan_prefix": [
8846                ] /* plan_prefix */,
8847                "table": "`t1`",
8848                "best_access_path": {
8849                  "considered_access_paths": [
8850                    {
8851                      "rows_to_scan": 2,
8852                      "access_type": "scan",
8853                      "resulting_rows": 2,
8854                      "cost": 2.4154,
8855                      "chosen": true
8856                    }
8857                  ] /* considered_access_paths */
8858                } /* best_access_path */,
8859                "condition_filtering_pct": 100,
8860                "rows_for_plan": 2,
8861                "cost_for_plan": 2.4154,
8862                "chosen": true
8863              }
8864            ] /* considered_execution_plans */
8865          },
8866          {
8867            "attaching_conditions_to_tables": {
8868              "original_condition": null,
8869              "attached_conditions_computation": [
8870              ] /* attached_conditions_computation */,
8871              "attached_conditions_summary": [
8872                {
8873                  "table": "`t1`",
8874                  "attached": null
8875                }
8876              ] /* attached_conditions_summary */
8877            } /* attaching_conditions_to_tables */
8878          },
8879          {
8880            "refine_plan": [
8881              {
8882                "table": "`t1`"
8883              }
8884            ] /* refine_plan */
8885          }
8886        ] /* steps */
8887      } /* join_optimization */
8888    },
8889    {
8890      "join_execution": {
8891        "select#": 1,
8892        "steps": [
8893        ] /* steps */
8894      } /* join_execution */
8895    }
8896  ] /* steps */
8897}	0	0
8898freturn 3 ret@0	{
8899  "steps": [
8900  ] /* steps */
8901}	0	0
8902set ret@0 NULL	{
8903  "steps": [
8904  ] /* steps */
8905}	0	0
8906insert into t1 values("z",0)	{
8907  "steps": [
8908  ] /* steps */
8909}	0	0
8910delete from t1 where id="z"	{
8911  "steps": [
8912    {
8913      "substitute_generated_columns": {
8914      } /* substitute_generated_columns */
8915    },
8916    {
8917      "condition_processing": {
8918        "condition": "WHERE",
8919        "original_condition": "(`t1`.`id` = 'z')",
8920        "steps": [
8921          {
8922            "transformation": "equality_propagation",
8923            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8924          },
8925          {
8926            "transformation": "constant_propagation",
8927            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8928          },
8929          {
8930            "transformation": "trivial_condition_removal",
8931            "resulting_condition": "multiple equal('z', `t1`.`id`)"
8932          }
8933        ] /* steps */
8934      } /* condition_processing */
8935    },
8936    {
8937      "table": "`t1`",
8938      "range_analysis": {
8939        "table_scan": {
8940          "rows": 3,
8941          "cost": 4.7154
8942        } /* table_scan */
8943      } /* range_analysis */
8944    }
8945  ] /* steps */
8946}	0	0
8947select sum(data) into ret from t1	{
8948  "steps": [
8949    {
8950      "join_preparation": {
8951        "select#": 1,
8952        "steps": [
8953          {
8954            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
8955          }
8956        ] /* steps */
8957      } /* join_preparation */
8958    },
8959    {
8960      "join_optimization": {
8961        "select#": 1,
8962        "steps": [
8963          {
8964            "table_dependencies": [
8965              {
8966                "table": "`t1`",
8967                "row_may_be_null": false,
8968                "map_bit": 0,
8969                "depends_on_map_bits": [
8970                ] /* depends_on_map_bits */
8971              }
8972            ] /* table_dependencies */
8973          },
8974          {
8975            "rows_estimation": [
8976              {
8977                "table": "`t1`",
8978                "table_scan": {
8979                  "rows": 2,
8980                  "cost": 2
8981                } /* table_scan */
8982              }
8983            ] /* rows_estimation */
8984          },
8985          {
8986            "considered_execution_plans": [
8987              {
8988                "plan_prefix": [
8989                ] /* plan_prefix */,
8990                "table": "`t1`",
8991                "best_access_path": {
8992                  "considered_access_paths": [
8993                    {
8994                      "rows_to_scan": 2,
8995                      "access_type": "scan",
8996                      "resulting_rows": 2,
8997                      "cost": 2.4154,
8998                      "chosen": true
8999                    }
9000                  ] /* considered_access_paths */
9001                } /* best_access_path */,
9002                "condition_filtering_pct": 100,
9003                "rows_for_plan": 2,
9004                "cost_for_plan": 2.4154,
9005                "chosen": true
9006              }
9007            ] /* considered_execution_plans */
9008          },
9009          {
9010            "attaching_conditions_to_tables": {
9011              "original_condition": null,
9012              "attached_conditions_computation": [
9013              ] /* attached_conditions_computation */,
9014              "attached_conditions_summary": [
9015                {
9016                  "table": "`t1`",
9017                  "attached": null
9018                }
9019              ] /* attached_conditions_summary */
9020            } /* attaching_conditions_to_tables */
9021          },
9022          {
9023            "refine_plan": [
9024              {
9025                "table": "`t1`"
9026              }
9027            ] /* refine_plan */
9028          }
9029        ] /* steps */
9030      } /* join_optimization */
9031    },
9032    {
9033      "join_execution": {
9034        "select#": 1,
9035        "steps": [
9036        ] /* steps */
9037      } /* join_execution */
9038    }
9039  ] /* steps */
9040}	0	0
9041freturn 3 ret@0	{
9042  "steps": [
9043  ] /* steps */
9044}	0	0
9045set ret@0 NULL	{
9046  "steps": [
9047  ] /* steps */
9048}	0	0
9049insert into t1 values("z",0)	{
9050  "steps": [
9051  ] /* steps */
9052}	0	0
9053delete from t1 where id="z"	{
9054  "steps": [
9055    {
9056      "substitute_generated_columns": {
9057      } /* substitute_generated_columns */
9058    },
9059    {
9060      "condition_processing": {
9061        "condition": "WHERE",
9062        "original_condition": "(`t1`.`id` = 'z')",
9063        "steps": [
9064          {
9065            "transformation": "equality_propagation",
9066            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9067          },
9068          {
9069            "transformation": "constant_propagation",
9070            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9071          },
9072          {
9073            "transformation": "trivial_condition_removal",
9074            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9075          }
9076        ] /* steps */
9077      } /* condition_processing */
9078    },
9079    {
9080      "table": "`t1`",
9081      "range_analysis": {
9082        "table_scan": {
9083          "rows": 3,
9084          "cost": 4.7154
9085        } /* table_scan */
9086      } /* range_analysis */
9087    }
9088  ] /* steps */
9089}	0	0
9090select sum(data) into ret from t1	{
9091  "steps": [
9092    {
9093      "join_preparation": {
9094        "select#": 1,
9095        "steps": [
9096          {
9097            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9098          }
9099        ] /* steps */
9100      } /* join_preparation */
9101    },
9102    {
9103      "join_optimization": {
9104        "select#": 1,
9105        "steps": [
9106          {
9107            "table_dependencies": [
9108              {
9109                "table": "`t1`",
9110                "row_may_be_null": false,
9111                "map_bit": 0,
9112                "depends_on_map_bits": [
9113                ] /* depends_on_map_bits */
9114              }
9115            ] /* table_dependencies */
9116          },
9117          {
9118            "rows_estimation": [
9119              {
9120                "table": "`t1`",
9121                "table_scan": {
9122                  "rows": 2,
9123                  "cost": 2
9124                } /* table_scan */
9125              }
9126            ] /* rows_estimation */
9127          },
9128          {
9129            "considered_execution_plans": [
9130              {
9131                "plan_prefix": [
9132                ] /* plan_prefix */,
9133                "table": "`t1`",
9134                "best_access_path": {
9135                  "considered_access_paths": [
9136                    {
9137                      "rows_to_scan": 2,
9138                      "access_type": "scan",
9139                      "resulting_rows": 2,
9140                      "cost": 2.4154,
9141                      "chosen": true
9142                    }
9143                  ] /* considered_access_paths */
9144                } /* best_access_path */,
9145                "condition_filtering_pct": 100,
9146                "rows_for_plan": 2,
9147                "cost_for_plan": 2.4154,
9148                "chosen": true
9149              }
9150            ] /* considered_execution_plans */
9151          },
9152          {
9153            "attaching_conditions_to_tables": {
9154              "original_condition": null,
9155              "attached_conditions_computation": [
9156              ] /* attached_conditions_computation */,
9157              "attached_conditions_summary": [
9158                {
9159                  "table": "`t1`",
9160                  "attached": null
9161                }
9162              ] /* attached_conditions_summary */
9163            } /* attaching_conditions_to_tables */
9164          },
9165          {
9166            "refine_plan": [
9167              {
9168                "table": "`t1`"
9169              }
9170            ] /* refine_plan */
9171          }
9172        ] /* steps */
9173      } /* join_optimization */
9174    },
9175    {
9176      "join_execution": {
9177        "select#": 1,
9178        "steps": [
9179        ] /* steps */
9180      } /* join_execution */
9181    }
9182  ] /* steps */
9183}	0	0
9184freturn 3 ret@0	{
9185  "steps": [
9186  ] /* steps */
9187}	0	0
9188select d+1 into res from t6 where d=res+1	{
9189  "steps": [
9190    {
9191      "join_preparation": {
9192        "select#": 1,
9193        "steps": [
9194          {
9195            "expanded_query": "/* select#1 */ select (`t6`.`d` + 1) AS `d+1` from `t6` where (`t6`.`d` = (res@1 + 1))"
9196          }
9197        ] /* steps */
9198      } /* join_preparation */
9199    },
9200    {
9201      "join_optimization": {
9202        "select#": 1,
9203        "steps": [
9204          {
9205            "condition_processing": {
9206              "condition": "WHERE",
9207              "original_condition": "(`t6`.`d` = (res@1 + 1))",
9208              "steps": [
9209                {
9210                  "transformation": "equality_propagation",
9211                  "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9212                },
9213                {
9214                  "transformation": "constant_propagation",
9215                  "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9216                },
9217                {
9218                  "transformation": "trivial_condition_removal",
9219                  "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9220                }
9221              ] /* steps */
9222            } /* condition_processing */
9223          },
9224          {
9225            "substitute_generated_columns": {
9226            } /* substitute_generated_columns */
9227          },
9228          {
9229            "table_dependencies": [
9230              {
9231                "table": "`t6`",
9232                "row_may_be_null": false,
9233                "map_bit": 0,
9234                "depends_on_map_bits": [
9235                ] /* depends_on_map_bits */
9236              }
9237            ] /* table_dependencies */
9238          },
9239          {
9240            "ref_optimizer_key_uses": [
9241              {
9242                "table": "`t6`",
9243                "field": "d",
9244                "equals": "(res@1 + 1)",
9245                "null_rejecting": false
9246              }
9247            ] /* ref_optimizer_key_uses */
9248          },
9249          {
9250            "rows_estimation": [
9251              {
9252                "table": "`t6`",
9253                "range_analysis": {
9254                  "table_scan": {
9255                    "rows": 4,
9256                    "cost": 4.9068
9257                  } /* table_scan */,
9258                  "potential_range_indexes": [
9259                    {
9260                      "index": "d",
9261                      "usable": true,
9262                      "key_parts": [
9263                        "d"
9264                      ] /* key_parts */
9265                    }
9266                  ] /* potential_range_indexes */,
9267                  "best_covering_index_scan": {
9268                    "index": "d",
9269                    "cost": 1.8698,
9270                    "chosen": true
9271                  } /* best_covering_index_scan */,
9272                  "setup_range_conditions": [
9273                    {
9274                      "impossible_condition": {
9275                        "cause": "comparison_with_null_always_false"
9276                      } /* impossible_condition */
9277                    }
9278                  ] /* setup_range_conditions */,
9279                  "impossible_range": true
9280                } /* range_analysis */,
9281                "rows": 0,
9282                "cause": "impossible_where_condition"
9283              }
9284            ] /* rows_estimation */
9285          }
9286        ] /* steps */,
9287        "empty_result": {
9288          "cause": "no matching row in const table"
9289        } /* empty_result */
9290      } /* join_optimization */
9291    },
9292    {
9293      "join_execution": {
9294        "select#": 1,
9295        "steps": [
9296        ] /* steps */
9297      } /* join_execution */
9298    }
9299  ] /* steps */
9300}	0	0
9301set @@optimizer_switch=@old_opt_switch;
9302# Triggers
9303create trigger trg1 before insert on t2 for each row
9304begin
9305set new.s=f1();
9306end|
9307set optimizer_trace_offset=0, optimizer_trace_limit=100|
9308insert into t2 select d,100,200 from t6 where d is not null|
9309select * from information_schema.OPTIMIZER_TRACE|
9310QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
9311insert into t2 select d,100,200 from t6 where d is not null	{
9312  "steps": [
9313    {
9314      "join_preparation": {
9315        "select#": 1,
9316        "steps": [
9317          {
9318            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d`,100 AS `100`,200 AS `200` from `t6` where (`t6`.`d` is not null)"
9319          }
9320        ] /* steps */
9321      } /* join_preparation */
9322    },
9323    {
9324      "join_optimization": {
9325        "select#": 1,
9326        "steps": [
9327          {
9328            "condition_processing": {
9329              "condition": "WHERE",
9330              "original_condition": "(`t6`.`d` is not null)",
9331              "steps": [
9332                {
9333                  "transformation": "equality_propagation",
9334                  "resulting_condition": "(`t6`.`d` is not null)"
9335                },
9336                {
9337                  "transformation": "constant_propagation",
9338                  "resulting_condition": "(`t6`.`d` is not null)"
9339                },
9340                {
9341                  "transformation": "trivial_condition_removal",
9342                  "resulting_condition": "(`t6`.`d` is not null)"
9343                }
9344              ] /* steps */
9345            } /* condition_processing */
9346          },
9347          {
9348            "substitute_generated_columns": {
9349            } /* substitute_generated_columns */
9350          },
9351          {
9352            "table_dependencies": [
9353              {
9354                "table": "`t6`",
9355                "row_may_be_null": false,
9356                "map_bit": 0,
9357                "depends_on_map_bits": [
9358                ] /* depends_on_map_bits */
9359              }
9360            ] /* table_dependencies */
9361          },
9362          {
9363            "ref_optimizer_key_uses": [
9364            ] /* ref_optimizer_key_uses */
9365          },
9366          {
9367            "rows_estimation": [
9368              {
9369                "table": "`t6`",
9370                "range_analysis": {
9371                  "table_scan": {
9372                    "rows": 4,
9373                    "cost": 4.9068
9374                  } /* table_scan */,
9375                  "potential_range_indexes": [
9376                    {
9377                      "index": "d",
9378                      "usable": true,
9379                      "key_parts": [
9380                        "d"
9381                      ] /* key_parts */
9382                    }
9383                  ] /* potential_range_indexes */,
9384                  "best_covering_index_scan": {
9385                    "index": "d",
9386                    "cost": 1.8698,
9387                    "chosen": true
9388                  } /* best_covering_index_scan */,
9389                  "setup_range_conditions": [
9390                  ] /* setup_range_conditions */,
9391                  "group_index_range": {
9392                    "chosen": false,
9393                    "cause": "not_group_by_or_distinct"
9394                  } /* group_index_range */,
9395                  "analyzing_range_alternatives": {
9396                    "range_scan_alternatives": [
9397                      {
9398                        "index": "d",
9399                        "ranges": [
9400                          "NULL < d"
9401                        ] /* ranges */,
9402                        "index_dives_for_eq_ranges": true,
9403                        "rowid_ordered": false,
9404                        "using_mrr": false,
9405                        "index_only": true,
9406                        "rows": 4,
9407                        "cost": 1.8798,
9408                        "chosen": false,
9409                        "cause": "cost"
9410                      }
9411                    ] /* range_scan_alternatives */,
9412                    "analyzing_roworder_intersect": {
9413                      "usable": false,
9414                      "cause": "too_few_roworder_scans"
9415                    } /* analyzing_roworder_intersect */
9416                  } /* analyzing_range_alternatives */
9417                } /* range_analysis */
9418              }
9419            ] /* rows_estimation */
9420          },
9421          {
9422            "considered_execution_plans": [
9423              {
9424                "plan_prefix": [
9425                ] /* plan_prefix */,
9426                "table": "`t6`",
9427                "best_access_path": {
9428                  "considered_access_paths": [
9429                    {
9430                      "rows_to_scan": 4,
9431                      "access_type": "scan",
9432                      "resulting_rows": 4,
9433                      "cost": 2.8068,
9434                      "chosen": true
9435                    }
9436                  ] /* considered_access_paths */
9437                } /* best_access_path */,
9438                "condition_filtering_pct": 100,
9439                "rows_for_plan": 4,
9440                "cost_for_plan": 2.8068,
9441                "chosen": true
9442              }
9443            ] /* considered_execution_plans */
9444          },
9445          {
9446            "attaching_conditions_to_tables": {
9447              "original_condition": "(`t6`.`d` is not null)",
9448              "attached_conditions_computation": [
9449              ] /* attached_conditions_computation */,
9450              "attached_conditions_summary": [
9451                {
9452                  "table": "`t6`",
9453                  "attached": "(`t6`.`d` is not null)"
9454                }
9455              ] /* attached_conditions_summary */
9456            } /* attaching_conditions_to_tables */
9457          },
9458          {
9459            "refine_plan": [
9460              {
9461                "table": "`t6`"
9462              }
9463            ] /* refine_plan */
9464          }
9465        ] /* steps */
9466      } /* join_optimization */
9467    },
9468    {
9469      "join_execution": {
9470        "select#": 1,
9471        "steps": [
9472        ] /* steps */
9473      } /* join_execution */
9474    }
9475  ] /* steps */
9476}	0	0
9477set_trigger_field NEW.s:=`f1`()	{
9478  "steps": [
9479  ] /* steps */
9480}	0	0
9481set ret@0 NULL	{
9482  "steps": [
9483  ] /* steps */
9484}	0	0
9485insert into t1 values("z",0)	{
9486  "steps": [
9487  ] /* steps */
9488}	0	0
9489delete from t1 where id="z"	{
9490  "steps": [
9491    {
9492      "substitute_generated_columns": {
9493      } /* substitute_generated_columns */
9494    },
9495    {
9496      "condition_processing": {
9497        "condition": "WHERE",
9498        "original_condition": "(`t1`.`id` = 'z')",
9499        "steps": [
9500          {
9501            "transformation": "equality_propagation",
9502            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9503          },
9504          {
9505            "transformation": "constant_propagation",
9506            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9507          },
9508          {
9509            "transformation": "trivial_condition_removal",
9510            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9511          }
9512        ] /* steps */
9513      } /* condition_processing */
9514    },
9515    {
9516      "table": "`t1`",
9517      "range_analysis": {
9518        "table_scan": {
9519          "rows": 3,
9520          "cost": 4.7154
9521        } /* table_scan */
9522      } /* range_analysis */
9523    }
9524  ] /* steps */
9525}	0	0
9526select sum(data) into ret from t1	{
9527  "steps": [
9528    {
9529      "join_preparation": {
9530        "select#": 1,
9531        "steps": [
9532          {
9533            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9534          }
9535        ] /* steps */
9536      } /* join_preparation */
9537    },
9538    {
9539      "join_optimization": {
9540        "select#": 1,
9541        "steps": [
9542          {
9543            "table_dependencies": [
9544              {
9545                "table": "`t1`",
9546                "row_may_be_null": false,
9547                "map_bit": 0,
9548                "depends_on_map_bits": [
9549                ] /* depends_on_map_bits */
9550              }
9551            ] /* table_dependencies */
9552          },
9553          {
9554            "rows_estimation": [
9555              {
9556                "table": "`t1`",
9557                "table_scan": {
9558                  "rows": 2,
9559                  "cost": 2
9560                } /* table_scan */
9561              }
9562            ] /* rows_estimation */
9563          },
9564          {
9565            "considered_execution_plans": [
9566              {
9567                "plan_prefix": [
9568                ] /* plan_prefix */,
9569                "table": "`t1`",
9570                "best_access_path": {
9571                  "considered_access_paths": [
9572                    {
9573                      "rows_to_scan": 2,
9574                      "access_type": "scan",
9575                      "resulting_rows": 2,
9576                      "cost": 2.4154,
9577                      "chosen": true
9578                    }
9579                  ] /* considered_access_paths */
9580                } /* best_access_path */,
9581                "condition_filtering_pct": 100,
9582                "rows_for_plan": 2,
9583                "cost_for_plan": 2.4154,
9584                "chosen": true
9585              }
9586            ] /* considered_execution_plans */
9587          },
9588          {
9589            "attaching_conditions_to_tables": {
9590              "original_condition": null,
9591              "attached_conditions_computation": [
9592              ] /* attached_conditions_computation */,
9593              "attached_conditions_summary": [
9594                {
9595                  "table": "`t1`",
9596                  "attached": null
9597                }
9598              ] /* attached_conditions_summary */
9599            } /* attaching_conditions_to_tables */
9600          },
9601          {
9602            "refine_plan": [
9603              {
9604                "table": "`t1`"
9605              }
9606            ] /* refine_plan */
9607          }
9608        ] /* steps */
9609      } /* join_optimization */
9610    },
9611    {
9612      "join_execution": {
9613        "select#": 1,
9614        "steps": [
9615        ] /* steps */
9616      } /* join_execution */
9617    }
9618  ] /* steps */
9619}	0	0
9620freturn 3 ret@0	{
9621  "steps": [
9622  ] /* steps */
9623}	0	0
9624set_trigger_field NEW.s:=`f1`()	{
9625  "steps": [
9626  ] /* steps */
9627}	0	0
9628set ret@0 NULL	{
9629  "steps": [
9630  ] /* steps */
9631}	0	0
9632insert into t1 values("z",0)	{
9633  "steps": [
9634  ] /* steps */
9635}	0	0
9636delete from t1 where id="z"	{
9637  "steps": [
9638    {
9639      "substitute_generated_columns": {
9640      } /* substitute_generated_columns */
9641    },
9642    {
9643      "condition_processing": {
9644        "condition": "WHERE",
9645        "original_condition": "(`t1`.`id` = 'z')",
9646        "steps": [
9647          {
9648            "transformation": "equality_propagation",
9649            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9650          },
9651          {
9652            "transformation": "constant_propagation",
9653            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9654          },
9655          {
9656            "transformation": "trivial_condition_removal",
9657            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9658          }
9659        ] /* steps */
9660      } /* condition_processing */
9661    },
9662    {
9663      "table": "`t1`",
9664      "range_analysis": {
9665        "table_scan": {
9666          "rows": 3,
9667          "cost": 4.7154
9668        } /* table_scan */
9669      } /* range_analysis */
9670    }
9671  ] /* steps */
9672}	0	0
9673select sum(data) into ret from t1	{
9674  "steps": [
9675    {
9676      "join_preparation": {
9677        "select#": 1,
9678        "steps": [
9679          {
9680            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9681          }
9682        ] /* steps */
9683      } /* join_preparation */
9684    },
9685    {
9686      "join_optimization": {
9687        "select#": 1,
9688        "steps": [
9689          {
9690            "table_dependencies": [
9691              {
9692                "table": "`t1`",
9693                "row_may_be_null": false,
9694                "map_bit": 0,
9695                "depends_on_map_bits": [
9696                ] /* depends_on_map_bits */
9697              }
9698            ] /* table_dependencies */
9699          },
9700          {
9701            "rows_estimation": [
9702              {
9703                "table": "`t1`",
9704                "table_scan": {
9705                  "rows": 2,
9706                  "cost": 2
9707                } /* table_scan */
9708              }
9709            ] /* rows_estimation */
9710          },
9711          {
9712            "considered_execution_plans": [
9713              {
9714                "plan_prefix": [
9715                ] /* plan_prefix */,
9716                "table": "`t1`",
9717                "best_access_path": {
9718                  "considered_access_paths": [
9719                    {
9720                      "rows_to_scan": 2,
9721                      "access_type": "scan",
9722                      "resulting_rows": 2,
9723                      "cost": 2.4154,
9724                      "chosen": true
9725                    }
9726                  ] /* considered_access_paths */
9727                } /* best_access_path */,
9728                "condition_filtering_pct": 100,
9729                "rows_for_plan": 2,
9730                "cost_for_plan": 2.4154,
9731                "chosen": true
9732              }
9733            ] /* considered_execution_plans */
9734          },
9735          {
9736            "attaching_conditions_to_tables": {
9737              "original_condition": null,
9738              "attached_conditions_computation": [
9739              ] /* attached_conditions_computation */,
9740              "attached_conditions_summary": [
9741                {
9742                  "table": "`t1`",
9743                  "attached": null
9744                }
9745              ] /* attached_conditions_summary */
9746            } /* attaching_conditions_to_tables */
9747          },
9748          {
9749            "refine_plan": [
9750              {
9751                "table": "`t1`"
9752              }
9753            ] /* refine_plan */
9754          }
9755        ] /* steps */
9756      } /* join_optimization */
9757    },
9758    {
9759      "join_execution": {
9760        "select#": 1,
9761        "steps": [
9762        ] /* steps */
9763      } /* join_execution */
9764    }
9765  ] /* steps */
9766}	0	0
9767freturn 3 ret@0	{
9768  "steps": [
9769  ] /* steps */
9770}	0	0
9771set_trigger_field NEW.s:=`f1`()	{
9772  "steps": [
9773  ] /* steps */
9774}	0	0
9775set ret@0 NULL	{
9776  "steps": [
9777  ] /* steps */
9778}	0	0
9779insert into t1 values("z",0)	{
9780  "steps": [
9781  ] /* steps */
9782}	0	0
9783delete from t1 where id="z"	{
9784  "steps": [
9785    {
9786      "substitute_generated_columns": {
9787      } /* substitute_generated_columns */
9788    },
9789    {
9790      "condition_processing": {
9791        "condition": "WHERE",
9792        "original_condition": "(`t1`.`id` = 'z')",
9793        "steps": [
9794          {
9795            "transformation": "equality_propagation",
9796            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9797          },
9798          {
9799            "transformation": "constant_propagation",
9800            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9801          },
9802          {
9803            "transformation": "trivial_condition_removal",
9804            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9805          }
9806        ] /* steps */
9807      } /* condition_processing */
9808    },
9809    {
9810      "table": "`t1`",
9811      "range_analysis": {
9812        "table_scan": {
9813          "rows": 3,
9814          "cost": 4.7154
9815        } /* table_scan */
9816      } /* range_analysis */
9817    }
9818  ] /* steps */
9819}	0	0
9820select sum(data) into ret from t1	{
9821  "steps": [
9822    {
9823      "join_preparation": {
9824        "select#": 1,
9825        "steps": [
9826          {
9827            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9828          }
9829        ] /* steps */
9830      } /* join_preparation */
9831    },
9832    {
9833      "join_optimization": {
9834        "select#": 1,
9835        "steps": [
9836          {
9837            "table_dependencies": [
9838              {
9839                "table": "`t1`",
9840                "row_may_be_null": false,
9841                "map_bit": 0,
9842                "depends_on_map_bits": [
9843                ] /* depends_on_map_bits */
9844              }
9845            ] /* table_dependencies */
9846          },
9847          {
9848            "rows_estimation": [
9849              {
9850                "table": "`t1`",
9851                "table_scan": {
9852                  "rows": 2,
9853                  "cost": 2
9854                } /* table_scan */
9855              }
9856            ] /* rows_estimation */
9857          },
9858          {
9859            "considered_execution_plans": [
9860              {
9861                "plan_prefix": [
9862                ] /* plan_prefix */,
9863                "table": "`t1`",
9864                "best_access_path": {
9865                  "considered_access_paths": [
9866                    {
9867                      "rows_to_scan": 2,
9868                      "access_type": "scan",
9869                      "resulting_rows": 2,
9870                      "cost": 2.4154,
9871                      "chosen": true
9872                    }
9873                  ] /* considered_access_paths */
9874                } /* best_access_path */,
9875                "condition_filtering_pct": 100,
9876                "rows_for_plan": 2,
9877                "cost_for_plan": 2.4154,
9878                "chosen": true
9879              }
9880            ] /* considered_execution_plans */
9881          },
9882          {
9883            "attaching_conditions_to_tables": {
9884              "original_condition": null,
9885              "attached_conditions_computation": [
9886              ] /* attached_conditions_computation */,
9887              "attached_conditions_summary": [
9888                {
9889                  "table": "`t1`",
9890                  "attached": null
9891                }
9892              ] /* attached_conditions_summary */
9893            } /* attaching_conditions_to_tables */
9894          },
9895          {
9896            "refine_plan": [
9897              {
9898                "table": "`t1`"
9899              }
9900            ] /* refine_plan */
9901          }
9902        ] /* steps */
9903      } /* join_optimization */
9904    },
9905    {
9906      "join_execution": {
9907        "select#": 1,
9908        "steps": [
9909        ] /* steps */
9910      } /* join_execution */
9911    }
9912  ] /* steps */
9913}	0	0
9914freturn 3 ret@0	{
9915  "steps": [
9916  ] /* steps */
9917}	0	0
9918set_trigger_field NEW.s:=`f1`()	{
9919  "steps": [
9920  ] /* steps */
9921}	0	0
9922set ret@0 NULL	{
9923  "steps": [
9924  ] /* steps */
9925}	0	0
9926insert into t1 values("z",0)	{
9927  "steps": [
9928  ] /* steps */
9929}	0	0
9930delete from t1 where id="z"	{
9931  "steps": [
9932    {
9933      "substitute_generated_columns": {
9934      } /* substitute_generated_columns */
9935    },
9936    {
9937      "condition_processing": {
9938        "condition": "WHERE",
9939        "original_condition": "(`t1`.`id` = 'z')",
9940        "steps": [
9941          {
9942            "transformation": "equality_propagation",
9943            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9944          },
9945          {
9946            "transformation": "constant_propagation",
9947            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9948          },
9949          {
9950            "transformation": "trivial_condition_removal",
9951            "resulting_condition": "multiple equal('z', `t1`.`id`)"
9952          }
9953        ] /* steps */
9954      } /* condition_processing */
9955    },
9956    {
9957      "table": "`t1`",
9958      "range_analysis": {
9959        "table_scan": {
9960          "rows": 3,
9961          "cost": 4.7154
9962        } /* table_scan */
9963      } /* range_analysis */
9964    }
9965  ] /* steps */
9966}	0	0
9967select sum(data) into ret from t1	{
9968  "steps": [
9969    {
9970      "join_preparation": {
9971        "select#": 1,
9972        "steps": [
9973          {
9974            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9975          }
9976        ] /* steps */
9977      } /* join_preparation */
9978    },
9979    {
9980      "join_optimization": {
9981        "select#": 1,
9982        "steps": [
9983          {
9984            "table_dependencies": [
9985              {
9986                "table": "`t1`",
9987                "row_may_be_null": false,
9988                "map_bit": 0,
9989                "depends_on_map_bits": [
9990                ] /* depends_on_map_bits */
9991              }
9992            ] /* table_dependencies */
9993          },
9994          {
9995            "rows_estimation": [
9996              {
9997                "table": "`t1`",
9998                "table_scan": {
9999                  "rows": 2,
10000                  "cost": 2
10001                } /* table_scan */
10002              }
10003            ] /* rows_estimation */
10004          },
10005          {
10006            "considered_execution_plans": [
10007              {
10008                "plan_prefix": [
10009                ] /* plan_prefix */,
10010                "table": "`t1`",
10011                "best_access_path": {
10012                  "considered_access_paths": [
10013                    {
10014                      "rows_to_scan": 2,
10015                      "access_type": "scan",
10016                      "resulting_rows": 2,
10017                      "cost": 2.4154,
10018                      "chosen": true
10019                    }
10020                  ] /* considered_access_paths */
10021                } /* best_access_path */,
10022                "condition_filtering_pct": 100,
10023                "rows_for_plan": 2,
10024                "cost_for_plan": 2.4154,
10025                "chosen": true
10026              }
10027            ] /* considered_execution_plans */
10028          },
10029          {
10030            "attaching_conditions_to_tables": {
10031              "original_condition": null,
10032              "attached_conditions_computation": [
10033              ] /* attached_conditions_computation */,
10034              "attached_conditions_summary": [
10035                {
10036                  "table": "`t1`",
10037                  "attached": null
10038                }
10039              ] /* attached_conditions_summary */
10040            } /* attaching_conditions_to_tables */
10041          },
10042          {
10043            "refine_plan": [
10044              {
10045                "table": "`t1`"
10046              }
10047            ] /* refine_plan */
10048          }
10049        ] /* steps */
10050      } /* join_optimization */
10051    },
10052    {
10053      "join_execution": {
10054        "select#": 1,
10055        "steps": [
10056        ] /* steps */
10057      } /* join_execution */
10058    }
10059  ] /* steps */
10060}	0	0
10061freturn 3 ret@0	{
10062  "steps": [
10063  ] /* steps */
10064}	0	0
10065select * from t2|
10066s	i	d
10067a	1	1
10068b	2	2
10069c	3	3
10070d	4	4
100713	100	200
100723	100	200
100733	100	200
100743	100	200
10075prepare stmt from 'select count(*) from t1 where t1.data=?';
10076set @param="c";
10077set optimizer_trace_offset=0, optimizer_trace_limit=100;
10078execute stmt using @param;
10079count(*)
100800
10081select count(*) from information_schema.OPTIMIZER_TRACE;
10082count(*)
100831
10084select TRACE into @trace from information_schema.OPTIMIZER_TRACE;
10085select @trace;
10086@trace
10087{
10088  "steps": [
10089    {
10090      "join_preparation": {
10091        "select#": 1,
10092        "steps": [
10093          {
10094            "expanded_query": "/* select#1 */ select count(0) AS `count(*)` from `t1` where (`t1`.`data` = 'c')"
10095          }
10096        ] /* steps */
10097      } /* join_preparation */
10098    },
10099    {
10100      "join_optimization": {
10101        "select#": 1,
10102        "steps": [
10103          {
10104            "condition_processing": {
10105              "condition": "WHERE",
10106              "original_condition": "(`t1`.`data` = 'c')",
10107              "steps": [
10108                {
10109                  "transformation": "equality_propagation",
10110                  "resulting_condition": "(`t1`.`data` = 'c')"
10111                },
10112                {
10113                  "transformation": "constant_propagation",
10114                  "resulting_condition": "(`t1`.`data` = 'c')"
10115                },
10116                {
10117                  "transformation": "trivial_condition_removal",
10118                  "resulting_condition": "(`t1`.`data` = 'c')"
10119                }
10120              ] /* steps */
10121            } /* condition_processing */
10122          },
10123          {
10124            "substitute_generated_columns": {
10125            } /* substitute_generated_columns */
10126          },
10127          {
10128            "table_dependencies": [
10129              {
10130                "table": "`t1`",
10131                "row_may_be_null": false,
10132                "map_bit": 0,
10133                "depends_on_map_bits": [
10134                ] /* depends_on_map_bits */
10135              }
10136            ] /* table_dependencies */
10137          },
10138          {
10139            "ref_optimizer_key_uses": [
10140            ] /* ref_optimizer_key_uses */
10141          },
10142          {
10143            "rows_estimation": [
10144              {
10145                "table": "`t1`",
10146                "table_scan": {
10147                  "rows": 2,
10148                  "cost": 2
10149                } /* table_scan */
10150              }
10151            ] /* rows_estimation */
10152          },
10153          {
10154            "considered_execution_plans": [
10155              {
10156                "plan_prefix": [
10157                ] /* plan_prefix */,
10158                "table": "`t1`",
10159                "best_access_path": {
10160                  "considered_access_paths": [
10161                    {
10162                      "rows_to_scan": 2,
10163                      "access_type": "scan",
10164                      "resulting_rows": 2,
10165                      "cost": 2.4154,
10166                      "chosen": true
10167                    }
10168                  ] /* considered_access_paths */
10169                } /* best_access_path */,
10170                "condition_filtering_pct": 100,
10171                "rows_for_plan": 2,
10172                "cost_for_plan": 2.4154,
10173                "chosen": true
10174              }
10175            ] /* considered_execution_plans */
10176          },
10177          {
10178            "attaching_conditions_to_tables": {
10179              "original_condition": "(`t1`.`data` = 'c')",
10180              "attached_conditions_computation": [
10181              ] /* attached_conditions_computation */,
10182              "attached_conditions_summary": [
10183                {
10184                  "table": "`t1`",
10185                  "attached": "(`t1`.`data` = 'c')"
10186                }
10187              ] /* attached_conditions_summary */
10188            } /* attaching_conditions_to_tables */
10189          },
10190          {
10191            "refine_plan": [
10192              {
10193                "table": "`t1`"
10194              }
10195            ] /* refine_plan */
10196          }
10197        ] /* steps */
10198      } /* join_optimization */
10199    },
10200    {
10201      "join_execution": {
10202        "select#": 1,
10203        "steps": [
10204        ] /* steps */
10205      } /* join_execution */
10206    }
10207  ] /* steps */
10208}
10209set optimizer_trace_offset=0, optimizer_trace_limit=100;
10210execute stmt using @param;
10211count(*)
102120
10213select count(*) from information_schema.OPTIMIZER_TRACE;
10214count(*)
102151
10216select TRACE into @trace2 from information_schema.OPTIMIZER_TRACE;
10217select @trace=@trace2;
10218@trace=@trace2
102191
10220drop procedure p1;
10221create temporary table optt like information_schema.OPTIMIZER_TRACE;
10222create procedure p1(arg char(1))
10223begin
10224declare res int;
10225set optimizer_trace="enabled=off";
10226# want to see all of SELECT below
10227set optimizer_trace_offset=0, optimizer_trace_limit=100;
10228set optimizer_trace="enabled=on";
10229select d into res from t6 where d in (select f1() from t2 where s=arg);
10230set optimizer_trace="enabled=off"; # and not more
10231insert into optt select * from information_schema.OPTIMIZER_TRACE;
10232set optimizer_trace_offset=default, optimizer_trace_limit=default;
10233select d+1 into res from t6 where d=res+1;
10234end|
10235call  p1("c")|
10236Warnings:
10237Warning	1329	No data - zero rows fetched, selected, or processed
10238select * from optt|
10239QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
10240select d into res from t6 where d in (select f1() from t2 where s=arg)	{
10241  "steps": [
10242    {
10243      "join_preparation": {
10244        "select#": 1,
10245        "steps": [
10246          {
10247            "join_preparation": {
10248              "select#": 2,
10249              "steps": [
10250                {
10251                  "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
10252                },
10253                {
10254                  "transformation": {
10255                    "select#": 2,
10256                    "from": "IN (SELECT)",
10257                    "to": "semijoin",
10258                    "chosen": false
10259                  } /* transformation */
10260                },
10261                {
10262                  "transformation": {
10263                    "select#": 2,
10264                    "from": "IN (SELECT)",
10265                    "to": "EXISTS (CORRELATED SELECT)",
10266                    "chosen": true,
10267                    "evaluating_constant_where_conditions": [
10268                    ] /* evaluating_constant_where_conditions */
10269                  } /* transformation */
10270                }
10271              ] /* steps */
10272            } /* join_preparation */
10273          },
10274          {
10275            "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where <in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
10276          }
10277        ] /* steps */
10278      } /* join_preparation */
10279    },
10280    {
10281      "join_optimization": {
10282        "select#": 1,
10283        "steps": [
10284          {
10285            "condition_processing": {
10286              "condition": "WHERE",
10287              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))",
10288              "steps": [
10289                {
10290                  "transformation": "equality_propagation",
10291                  "subselect_evaluation": [
10292                  ] /* subselect_evaluation */,
10293                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
10294                },
10295                {
10296                  "transformation": "constant_propagation",
10297                  "subselect_evaluation": [
10298                  ] /* subselect_evaluation */,
10299                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
10300                },
10301                {
10302                  "transformation": "trivial_condition_removal",
10303                  "subselect_evaluation": [
10304                  ] /* subselect_evaluation */,
10305                  "resulting_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
10306                }
10307              ] /* steps */
10308            } /* condition_processing */
10309          },
10310          {
10311            "substitute_generated_columns": {
10312            } /* substitute_generated_columns */
10313          },
10314          {
10315            "table_dependencies": [
10316              {
10317                "table": "`t6`",
10318                "row_may_be_null": false,
10319                "map_bit": 0,
10320                "depends_on_map_bits": [
10321                ] /* depends_on_map_bits */
10322              }
10323            ] /* table_dependencies */
10324          },
10325          {
10326            "ref_optimizer_key_uses": [
10327            ] /* ref_optimizer_key_uses */
10328          },
10329          {
10330            "rows_estimation": [
10331              {
10332                "table": "`t6`",
10333                "table_scan": {
10334                  "rows": 4,
10335                  "cost": 2
10336                } /* table_scan */
10337              }
10338            ] /* rows_estimation */
10339          },
10340          {
10341            "considered_execution_plans": [
10342              {
10343                "plan_prefix": [
10344                ] /* plan_prefix */,
10345                "table": "`t6`",
10346                "best_access_path": {
10347                  "considered_access_paths": [
10348                    {
10349                      "rows_to_scan": 4,
10350                      "access_type": "scan",
10351                      "resulting_rows": 4,
10352                      "cost": 2.8068,
10353                      "chosen": true
10354                    }
10355                  ] /* considered_access_paths */
10356                } /* best_access_path */,
10357                "condition_filtering_pct": 100,
10358                "rows_for_plan": 4,
10359                "cost_for_plan": 2.8068,
10360                "chosen": true
10361              }
10362            ] /* considered_execution_plans */
10363          },
10364          {
10365            "attaching_conditions_to_tables": {
10366              "original_condition": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))",
10367              "attached_conditions_computation": [
10368              ] /* attached_conditions_computation */,
10369              "attached_conditions_summary": [
10370                {
10371                  "table": "`t6`",
10372                  "attached": "<in_optimizer>(`t6`.`d`,<exists>(/* select#2 */ select `f1`() from `t2` where ((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))))"
10373                }
10374              ] /* attached_conditions_summary */
10375            } /* attaching_conditions_to_tables */
10376          },
10377          {
10378            "refine_plan": [
10379              {
10380                "table": "`t6`"
10381              }
10382            ] /* refine_plan */
10383          }
10384        ] /* steps */
10385      } /* join_optimization */
10386    },
10387    {
10388      "join_optimization": {
10389        "select#": 2,
10390        "steps": [
10391          {
10392            "condition_processing": {
10393              "condition": "WHERE",
10394              "original_condition": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))",
10395              "steps": [
10396                {
10397                  "transformation": "equality_propagation",
10398                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10399                },
10400                {
10401                  "transformation": "constant_propagation",
10402                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10403                },
10404                {
10405                  "transformation": "trivial_condition_removal",
10406                  "resulting_condition": "((<cache>(`t6`.`d`) = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10407                }
10408              ] /* steps */
10409            } /* condition_processing */
10410          },
10411          {
10412            "substitute_generated_columns": {
10413            } /* substitute_generated_columns */
10414          },
10415          {
10416            "table_dependencies": [
10417              {
10418                "table": "`t2`",
10419                "row_may_be_null": false,
10420                "map_bit": 0,
10421                "depends_on_map_bits": [
10422                ] /* depends_on_map_bits */
10423              }
10424            ] /* table_dependencies */
10425          },
10426          {
10427            "ref_optimizer_key_uses": [
10428            ] /* ref_optimizer_key_uses */
10429          },
10430          {
10431            "rows_estimation": [
10432              {
10433                "table": "`t2`",
10434                "table_scan": {
10435                  "rows": 8,
10436                  "cost": 2
10437                } /* table_scan */
10438              }
10439            ] /* rows_estimation */
10440          },
10441          {
10442            "considered_execution_plans": [
10443              {
10444                "plan_prefix": [
10445                ] /* plan_prefix */,
10446                "table": "`t2`",
10447                "best_access_path": {
10448                  "considered_access_paths": [
10449                    {
10450                      "rows_to_scan": 8,
10451                      "access_type": "scan",
10452                      "resulting_rows": 1,
10453                      "cost": 3.6566,
10454                      "chosen": true
10455                    }
10456                  ] /* considered_access_paths */
10457                } /* best_access_path */,
10458                "condition_filtering_pct": 100,
10459                "rows_for_plan": 1,
10460                "cost_for_plan": 3.6566,
10461                "chosen": true
10462              }
10463            ] /* considered_execution_plans */
10464          },
10465          {
10466            "attaching_conditions_to_tables": {
10467              "original_condition": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))",
10468              "attached_conditions_computation": [
10469              ] /* attached_conditions_computation */,
10470              "attached_conditions_summary": [
10471                {
10472                  "table": "`t2`",
10473                  "attached": "((`t2`.`s` = arg@0) and (<cache>(`t6`.`d`) = `f1`()))"
10474                }
10475              ] /* attached_conditions_summary */
10476            } /* attaching_conditions_to_tables */
10477          },
10478          {
10479            "refine_plan": [
10480              {
10481                "table": "`t2`"
10482              }
10483            ] /* refine_plan */
10484          }
10485        ] /* steps */
10486      } /* join_optimization */
10487    },
10488    {
10489      "join_execution": {
10490        "select#": 1,
10491        "steps": [
10492          {
10493            "subselect_execution": {
10494              "select#": 2,
10495              "steps": [
10496                {
10497                  "join_execution": {
10498                    "select#": 2,
10499                    "steps": [
10500                    ] /* steps */
10501                  } /* join_execution */
10502                }
10503              ] /* steps */
10504            } /* subselect_execution */
10505          },
10506          {
10507            "subselect_execution": {
10508              "select#": 2,
10509              "steps": [
10510                {
10511                  "join_execution": {
10512                    "select#": 2,
10513                    "steps": [
10514                    ] /* steps */
10515                  } /* join_execution */
10516                }
10517              ] /* steps */
10518            } /* subselect_execution */
10519          },
10520          {
10521            "subselect_execution": {
10522              "select#": 2,
10523              "steps": [
10524                {
10525                  "join_execution": {
10526                    "select#": 2,
10527                    "steps": [
10528                    ] /* steps */
10529                  } /* join_execution */
10530                }
10531              ] /* steps */
10532            } /* subselect_execution */
10533          },
10534          {
10535            "subselect_execution": {
10536              "select#": 2,
10537              "steps": [
10538                {
10539                  "join_execution": {
10540                    "select#": 2,
10541                    "steps": [
10542                    ] /* steps */
10543                  } /* join_execution */
10544                }
10545              ] /* steps */
10546            } /* subselect_execution */
10547          }
10548        ] /* steps */
10549      } /* join_execution */
10550    }
10551  ] /* steps */
10552}	0	0
10553set ret@0 NULL	{
10554  "steps": [
10555  ] /* steps */
10556}	0	0
10557insert into t1 values("z",0)	{
10558  "steps": [
10559  ] /* steps */
10560}	0	0
10561delete from t1 where id="z"	{
10562  "steps": [
10563    {
10564      "substitute_generated_columns": {
10565      } /* substitute_generated_columns */
10566    },
10567    {
10568      "condition_processing": {
10569        "condition": "WHERE",
10570        "original_condition": "(`t1`.`id` = 'z')",
10571        "steps": [
10572          {
10573            "transformation": "equality_propagation",
10574            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10575          },
10576          {
10577            "transformation": "constant_propagation",
10578            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10579          },
10580          {
10581            "transformation": "trivial_condition_removal",
10582            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10583          }
10584        ] /* steps */
10585      } /* condition_processing */
10586    },
10587    {
10588      "table": "`t1`",
10589      "range_analysis": {
10590        "table_scan": {
10591          "rows": 3,
10592          "cost": 4.7154
10593        } /* table_scan */
10594      } /* range_analysis */
10595    }
10596  ] /* steps */
10597}	0	0
10598select sum(data) into ret from t1	{
10599  "steps": [
10600    {
10601      "join_preparation": {
10602        "select#": 1,
10603        "steps": [
10604          {
10605            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
10606          }
10607        ] /* steps */
10608      } /* join_preparation */
10609    },
10610    {
10611      "join_optimization": {
10612        "select#": 1,
10613        "steps": [
10614          {
10615            "table_dependencies": [
10616              {
10617                "table": "`t1`",
10618                "row_may_be_null": false,
10619                "map_bit": 0,
10620                "depends_on_map_bits": [
10621                ] /* depends_on_map_bits */
10622              }
10623            ] /* table_dependencies */
10624          },
10625          {
10626            "rows_estimation": [
10627              {
10628                "table": "`t1`",
10629                "table_scan": {
10630                  "rows": 2,
10631                  "cost": 2
10632                } /* table_scan */
10633              }
10634            ] /* rows_estimation */
10635          },
10636          {
10637            "considered_execution_plans": [
10638              {
10639                "plan_prefix": [
10640                ] /* plan_prefix */,
10641                "table": "`t1`",
10642                "best_access_path": {
10643                  "considered_access_paths": [
10644                    {
10645                      "rows_to_scan": 2,
10646                      "access_type": "scan",
10647                      "resulting_rows": 2,
10648                      "cost": 2.4154,
10649                      "chosen": true
10650                    }
10651                  ] /* considered_access_paths */
10652                } /* best_access_path */,
10653                "condition_filtering_pct": 100,
10654                "rows_for_plan": 2,
10655                "cost_for_plan": 2.4154,
10656                "chosen": true
10657              }
10658            ] /* considered_execution_plans */
10659          },
10660          {
10661            "attaching_conditions_to_tables": {
10662              "original_condition": null,
10663              "attached_conditions_computation": [
10664              ] /* attached_conditions_computation */,
10665              "attached_conditions_summary": [
10666                {
10667                  "table": "`t1`",
10668                  "attached": null
10669                }
10670              ] /* attached_conditions_summary */
10671            } /* attaching_conditions_to_tables */
10672          },
10673          {
10674            "refine_plan": [
10675              {
10676                "table": "`t1`"
10677              }
10678            ] /* refine_plan */
10679          }
10680        ] /* steps */
10681      } /* join_optimization */
10682    },
10683    {
10684      "join_execution": {
10685        "select#": 1,
10686        "steps": [
10687        ] /* steps */
10688      } /* join_execution */
10689    }
10690  ] /* steps */
10691}	0	0
10692freturn 3 ret@0	{
10693  "steps": [
10694  ] /* steps */
10695}	0	0
10696set ret@0 NULL	{
10697  "steps": [
10698  ] /* steps */
10699}	0	0
10700insert into t1 values("z",0)	{
10701  "steps": [
10702  ] /* steps */
10703}	0	0
10704delete from t1 where id="z"	{
10705  "steps": [
10706    {
10707      "substitute_generated_columns": {
10708      } /* substitute_generated_columns */
10709    },
10710    {
10711      "condition_processing": {
10712        "condition": "WHERE",
10713        "original_condition": "(`t1`.`id` = 'z')",
10714        "steps": [
10715          {
10716            "transformation": "equality_propagation",
10717            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10718          },
10719          {
10720            "transformation": "constant_propagation",
10721            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10722          },
10723          {
10724            "transformation": "trivial_condition_removal",
10725            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10726          }
10727        ] /* steps */
10728      } /* condition_processing */
10729    },
10730    {
10731      "table": "`t1`",
10732      "range_analysis": {
10733        "table_scan": {
10734          "rows": 3,
10735          "cost": 4.7154
10736        } /* table_scan */
10737      } /* range_analysis */
10738    }
10739  ] /* steps */
10740}	0	0
10741select sum(data) into ret from t1	{
10742  "steps": [
10743    {
10744      "join_preparation": {
10745        "select#": 1,
10746        "steps": [
10747          {
10748            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
10749          }
10750        ] /* steps */
10751      } /* join_preparation */
10752    },
10753    {
10754      "join_optimization": {
10755        "select#": 1,
10756        "steps": [
10757          {
10758            "table_dependencies": [
10759              {
10760                "table": "`t1`",
10761                "row_may_be_null": false,
10762                "map_bit": 0,
10763                "depends_on_map_bits": [
10764                ] /* depends_on_map_bits */
10765              }
10766            ] /* table_dependencies */
10767          },
10768          {
10769            "rows_estimation": [
10770              {
10771                "table": "`t1`",
10772                "table_scan": {
10773                  "rows": 2,
10774                  "cost": 2
10775                } /* table_scan */
10776              }
10777            ] /* rows_estimation */
10778          },
10779          {
10780            "considered_execution_plans": [
10781              {
10782                "plan_prefix": [
10783                ] /* plan_prefix */,
10784                "table": "`t1`",
10785                "best_access_path": {
10786                  "considered_access_paths": [
10787                    {
10788                      "rows_to_scan": 2,
10789                      "access_type": "scan",
10790                      "resulting_rows": 2,
10791                      "cost": 2.4154,
10792                      "chosen": true
10793                    }
10794                  ] /* considered_access_paths */
10795                } /* best_access_path */,
10796                "condition_filtering_pct": 100,
10797                "rows_for_plan": 2,
10798                "cost_for_plan": 2.4154,
10799                "chosen": true
10800              }
10801            ] /* considered_execution_plans */
10802          },
10803          {
10804            "attaching_conditions_to_tables": {
10805              "original_condition": null,
10806              "attached_conditions_computation": [
10807              ] /* attached_conditions_computation */,
10808              "attached_conditions_summary": [
10809                {
10810                  "table": "`t1`",
10811                  "attached": null
10812                }
10813              ] /* attached_conditions_summary */
10814            } /* attaching_conditions_to_tables */
10815          },
10816          {
10817            "refine_plan": [
10818              {
10819                "table": "`t1`"
10820              }
10821            ] /* refine_plan */
10822          }
10823        ] /* steps */
10824      } /* join_optimization */
10825    },
10826    {
10827      "join_execution": {
10828        "select#": 1,
10829        "steps": [
10830        ] /* steps */
10831      } /* join_execution */
10832    }
10833  ] /* steps */
10834}	0	0
10835freturn 3 ret@0	{
10836  "steps": [
10837  ] /* steps */
10838}	0	0
10839set ret@0 NULL	{
10840  "steps": [
10841  ] /* steps */
10842}	0	0
10843insert into t1 values("z",0)	{
10844  "steps": [
10845  ] /* steps */
10846}	0	0
10847delete from t1 where id="z"	{
10848  "steps": [
10849    {
10850      "substitute_generated_columns": {
10851      } /* substitute_generated_columns */
10852    },
10853    {
10854      "condition_processing": {
10855        "condition": "WHERE",
10856        "original_condition": "(`t1`.`id` = 'z')",
10857        "steps": [
10858          {
10859            "transformation": "equality_propagation",
10860            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10861          },
10862          {
10863            "transformation": "constant_propagation",
10864            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10865          },
10866          {
10867            "transformation": "trivial_condition_removal",
10868            "resulting_condition": "multiple equal('z', `t1`.`id`)"
10869          }
10870        ] /* steps */
10871      } /* condition_processing */
10872    },
10873    {
10874      "table": "`t1`",
10875      "range_analysis": {
10876        "table_scan": {
10877          "rows": 3,
10878          "cost": 4.7154
10879        } /* table_scan */
10880      } /* range_analysis */
10881    }
10882  ] /* steps */
10883}	0	0
10884select sum(data) into ret from t1	{
10885  "steps": [
10886    {
10887      "join_preparation": {
10888        "select#": 1,
10889        "steps": [
10890          {
10891            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
10892          }
10893        ] /* steps */
10894      } /* join_preparation */
10895    },
10896    {
10897      "join_optimization": {
10898        "select#": 1,
10899        "steps": [
10900          {
10901            "table_dependencies": [
10902              {
10903                "table": "`t1`",
10904                "row_may_be_null": false,
10905                "map_bit": 0,
10906                "depends_on_map_bits": [
10907                ] /* depends_on_map_bits */
10908              }
10909            ] /* table_dependencies */
10910          },
10911          {
10912            "rows_estimation": [
10913              {
10914                "table": "`t1`",
10915                "table_scan": {
10916                  "rows": 2,
10917                  "cost": 2
10918                } /* table_scan */
10919              }
10920            ] /* rows_estimation */
10921          },
10922          {
10923            "considered_execution_plans": [
10924              {
10925                "plan_prefix": [
10926                ] /* plan_prefix */,
10927                "table": "`t1`",
10928                "best_access_path": {
10929                  "considered_access_paths": [
10930                    {
10931                      "rows_to_scan": 2,
10932                      "access_type": "scan",
10933                      "resulting_rows": 2,
10934                      "cost": 2.4154,
10935                      "chosen": true
10936                    }
10937                  ] /* considered_access_paths */
10938                } /* best_access_path */,
10939                "condition_filtering_pct": 100,
10940                "rows_for_plan": 2,
10941                "cost_for_plan": 2.4154,
10942                "chosen": true
10943              }
10944            ] /* considered_execution_plans */
10945          },
10946          {
10947            "attaching_conditions_to_tables": {
10948              "original_condition": null,
10949              "attached_conditions_computation": [
10950              ] /* attached_conditions_computation */,
10951              "attached_conditions_summary": [
10952                {
10953                  "table": "`t1`",
10954                  "attached": null
10955                }
10956              ] /* attached_conditions_summary */
10957            } /* attaching_conditions_to_tables */
10958          },
10959          {
10960            "refine_plan": [
10961              {
10962                "table": "`t1`"
10963              }
10964            ] /* refine_plan */
10965          }
10966        ] /* steps */
10967      } /* join_optimization */
10968    },
10969    {
10970      "join_execution": {
10971        "select#": 1,
10972        "steps": [
10973        ] /* steps */
10974      } /* join_execution */
10975    }
10976  ] /* steps */
10977}	0	0
10978freturn 3 ret@0	{
10979  "steps": [
10980  ] /* steps */
10981}	0	0
10982set ret@0 NULL	{
10983  "steps": [
10984  ] /* steps */
10985}	0	0
10986insert into t1 values("z",0)	{
10987  "steps": [
10988  ] /* steps */
10989}	0	0
10990delete from t1 where id="z"	{
10991  "steps": [
10992    {
10993      "substitute_generated_columns": {
10994      } /* substitute_generated_columns */
10995    },
10996    {
10997      "condition_processing": {
10998        "condition": "WHERE",
10999        "original_condition": "(`t1`.`id` = 'z')",
11000        "steps": [
11001          {
11002            "transformation": "equality_propagation",
11003            "resulting_condition": "multiple equal('z', `t1`.`id`)"
11004          },
11005          {
11006            "transformation": "constant_propagation",
11007            "resulting_condition": "multiple equal('z', `t1`.`id`)"
11008          },
11009          {
11010            "transformation": "trivial_condition_removal",
11011            "resulting_condition": "multiple equal('z', `t1`.`id`)"
11012          }
11013        ] /* steps */
11014      } /* condition_processing */
11015    },
11016    {
11017      "table": "`t1`",
11018      "range_analysis": {
11019        "table_scan": {
11020          "rows": 3,
11021          "cost": 4.7154
11022        } /* table_scan */
11023      } /* range_analysis */
11024    }
11025  ] /* steps */
11026}	0	0
11027select sum(data) into ret from t1	{
11028  "steps": [
11029    {
11030      "join_preparation": {
11031        "select#": 1,
11032        "steps": [
11033          {
11034            "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
11035          }
11036        ] /* steps */
11037      } /* join_preparation */
11038    },
11039    {
11040      "join_optimization": {
11041        "select#": 1,
11042        "steps": [
11043          {
11044            "table_dependencies": [
11045              {
11046                "table": "`t1`",
11047                "row_may_be_null": false,
11048                "map_bit": 0,
11049                "depends_on_map_bits": [
11050                ] /* depends_on_map_bits */
11051              }
11052            ] /* table_dependencies */
11053          },
11054          {
11055            "rows_estimation": [
11056              {
11057                "table": "`t1`",
11058                "table_scan": {
11059                  "rows": 2,
11060                  "cost": 2
11061                } /* table_scan */
11062              }
11063            ] /* rows_estimation */
11064          },
11065          {
11066            "considered_execution_plans": [
11067              {
11068                "plan_prefix": [
11069                ] /* plan_prefix */,
11070                "table": "`t1`",
11071                "best_access_path": {
11072                  "considered_access_paths": [
11073                    {
11074                      "rows_to_scan": 2,
11075                      "access_type": "scan",
11076                      "resulting_rows": 2,
11077                      "cost": 2.4154,
11078                      "chosen": true
11079                    }
11080                  ] /* considered_access_paths */
11081                } /* best_access_path */,
11082                "condition_filtering_pct": 100,
11083                "rows_for_plan": 2,
11084                "cost_for_plan": 2.4154,
11085                "chosen": true
11086              }
11087            ] /* considered_execution_plans */
11088          },
11089          {
11090            "attaching_conditions_to_tables": {
11091              "original_condition": null,
11092              "attached_conditions_computation": [
11093              ] /* attached_conditions_computation */,
11094              "attached_conditions_summary": [
11095                {
11096                  "table": "`t1`",
11097                  "attached": null
11098                }
11099              ] /* attached_conditions_summary */
11100            } /* attaching_conditions_to_tables */
11101          },
11102          {
11103            "refine_plan": [
11104              {
11105                "table": "`t1`"
11106              }
11107            ] /* refine_plan */
11108          }
11109        ] /* steps */
11110      } /* join_optimization */
11111    },
11112    {
11113      "join_execution": {
11114        "select#": 1,
11115        "steps": [
11116        ] /* steps */
11117      } /* join_execution */
11118    }
11119  ] /* steps */
11120}	0	0
11121freturn 3 ret@0	{
11122  "steps": [
11123  ] /* steps */
11124}	0	0
11125select @@optimizer_trace|
11126@@optimizer_trace
11127enabled=off,one_line=off
11128set optimizer_trace="enabled=on";
11129drop temporary table optt;
11130drop function f1;
11131drop procedure p1;
11132drop trigger trg1;
11133create view v1 as select * from t1 where id < "c";
11134explain select * from v1 where id="b";
11135id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
111361	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where
11137Warnings:
11138Note	1003	/* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`data` AS `data` from `test`.`t1` where (`test`.`t1`.`id` = 'b')
11139select * from information_schema.OPTIMIZER_TRACE;
11140QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11141explain select * from v1 where id="b"	{
11142  "steps": [
11143    {
11144      "join_preparation": {
11145        "select#": 1,
11146        "steps": [
11147          {
11148            "join_preparation": {
11149              "select#": 2,
11150              "steps": [
11151                {
11152                  "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
11153                }
11154              ] /* steps */
11155            } /* join_preparation */
11156          },
11157          {
11158            "view": {
11159              "table": "`v1`",
11160              "select#": 2,
11161              "merged": true
11162            } /* view */
11163          },
11164          {
11165            "expanded_query": "/* select#1 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from (`t1`) where (`t1`.`id` = 'b')"
11166          },
11167          {
11168            "transformations_to_nested_joins": {
11169              "transformations": [
11170                "JOIN_condition_to_WHERE",
11171                "parenthesis_removal"
11172              ] /* transformations */,
11173              "expanded_query": "/* select#1 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where ((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))"
11174            } /* transformations_to_nested_joins */
11175          }
11176        ] /* steps */
11177      } /* join_preparation */
11178    },
11179    {
11180      "join_optimization": {
11181        "select#": 1,
11182        "steps": [
11183          {
11184            "condition_processing": {
11185              "condition": "WHERE",
11186              "original_condition": "((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))",
11187              "steps": [
11188                {
11189                  "transformation": "equality_propagation",
11190                  "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
11191                },
11192                {
11193                  "transformation": "constant_propagation",
11194                  "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
11195                },
11196                {
11197                  "transformation": "trivial_condition_removal",
11198                  "resulting_condition": "multiple equal('b', `t1`.`id`)"
11199                }
11200              ] /* steps */
11201            } /* condition_processing */
11202          },
11203          {
11204            "substitute_generated_columns": {
11205            } /* substitute_generated_columns */
11206          },
11207          {
11208            "table_dependencies": [
11209              {
11210                "table": "`t1`",
11211                "row_may_be_null": false,
11212                "map_bit": 0,
11213                "depends_on_map_bits": [
11214                ] /* depends_on_map_bits */
11215              }
11216            ] /* table_dependencies */
11217          },
11218          {
11219            "ref_optimizer_key_uses": [
11220            ] /* ref_optimizer_key_uses */
11221          },
11222          {
11223            "rows_estimation": [
11224              {
11225                "table": "`t1`",
11226                "table_scan": {
11227                  "rows": 2,
11228                  "cost": 2
11229                } /* table_scan */
11230              }
11231            ] /* rows_estimation */
11232          },
11233          {
11234            "considered_execution_plans": [
11235              {
11236                "plan_prefix": [
11237                ] /* plan_prefix */,
11238                "table": "`t1`",
11239                "best_access_path": {
11240                  "considered_access_paths": [
11241                    {
11242                      "rows_to_scan": 2,
11243                      "access_type": "scan",
11244                      "resulting_rows": 1,
11245                      "cost": 2.4154,
11246                      "chosen": true
11247                    }
11248                  ] /* considered_access_paths */
11249                } /* best_access_path */,
11250                "condition_filtering_pct": 100,
11251                "rows_for_plan": 1,
11252                "cost_for_plan": 2.4154,
11253                "chosen": true
11254              }
11255            ] /* considered_execution_plans */
11256          },
11257          {
11258            "attaching_conditions_to_tables": {
11259              "original_condition": "(`t1`.`id` = 'b')",
11260              "attached_conditions_computation": [
11261              ] /* attached_conditions_computation */,
11262              "attached_conditions_summary": [
11263                {
11264                  "table": "`t1`",
11265                  "attached": "(`t1`.`id` = 'b')"
11266                }
11267              ] /* attached_conditions_summary */
11268            } /* attaching_conditions_to_tables */
11269          },
11270          {
11271            "refine_plan": [
11272              {
11273                "table": "`t1`"
11274              }
11275            ] /* refine_plan */
11276          }
11277        ] /* steps */
11278      } /* join_optimization */
11279    },
11280    {
11281      "join_explain": {
11282        "select#": 1,
11283        "steps": [
11284        ] /* steps */
11285      } /* join_explain */
11286    }
11287  ] /* steps */
11288}	0	0
11289insert into v1 values("z", 100);
11290select * from information_schema.OPTIMIZER_TRACE;
11291QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11292insert into v1 values("z", 100)	{
11293  "steps": [
11294    {
11295      "join_preparation": {
11296        "select#": 2,
11297        "steps": [
11298          {
11299            "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
11300          }
11301        ] /* steps */
11302      } /* join_preparation */
11303    },
11304    {
11305      "view": {
11306        "table": "`v1`",
11307        "select#": 2,
11308        "merged": true
11309      } /* view */
11310    }
11311  ] /* steps */
11312}	0	0
11313delete from v1 where data=100;
11314select * from information_schema.OPTIMIZER_TRACE;
11315QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11316delete from v1 where data=100	{
11317  "steps": [
11318    {
11319      "join_preparation": {
11320        "select#": 2,
11321        "steps": [
11322          {
11323            "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
11324          }
11325        ] /* steps */
11326      } /* join_preparation */
11327    },
11328    {
11329      "view": {
11330        "table": "`v1`",
11331        "select#": 2,
11332        "merged": true
11333      } /* view */
11334    },
11335    {
11336      "transformations_to_nested_joins": {
11337        "transformations": [
11338          "JOIN_condition_to_WHERE",
11339          "parenthesis_removal"
11340        ] /* transformations */,
11341        "expanded_query": "/* select#1 */ select  from `t1` where ((`t1`.`data` = 100) and (`t1`.`id` < 'c'))"
11342      } /* transformations_to_nested_joins */
11343    },
11344    {
11345      "substitute_generated_columns": {
11346      } /* substitute_generated_columns */
11347    },
11348    {
11349      "condition_processing": {
11350        "condition": "WHERE",
11351        "original_condition": "((`t1`.`data` = 100) and (`t1`.`id` < 'c'))",
11352        "steps": [
11353          {
11354            "transformation": "equality_propagation",
11355            "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
11356          },
11357          {
11358            "transformation": "constant_propagation",
11359            "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
11360          },
11361          {
11362            "transformation": "trivial_condition_removal",
11363            "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
11364          }
11365        ] /* steps */
11366      } /* condition_processing */
11367    },
11368    {
11369      "table": "`t1`",
11370      "range_analysis": {
11371        "table_scan": {
11372          "rows": 3,
11373          "cost": 4.7154
11374        } /* table_scan */
11375      } /* range_analysis */
11376    }
11377  ] /* steps */
11378}	0	0
11379drop view v1;
11380create view v1 as select * from t1 where id < "c" limit 2;
11381explain select * from v1 where id="b";
11382id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
113831	PRIMARY	<derived2>	NULL	ref	<auto_key0>	<auto_key0>	16	const	1	100.00	NULL
113842	DERIVED	t1	NULL	ALL	NULL	NULL	NULL	NULL	3	33.33	Using where
11385Warnings:
11386Note	1003	/* select#1 */ select `v1`.`id` AS `id`,`v1`.`data` AS `data` from `test`.`v1` where (`v1`.`id` = 'b')
11387select * from information_schema.OPTIMIZER_TRACE;
11388QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11389explain select * from v1 where id="b"	{
11390  "steps": [
11391    {
11392      "join_preparation": {
11393        "select#": 1,
11394        "steps": [
11395          {
11396            "join_preparation": {
11397              "select#": 2,
11398              "steps": [
11399                {
11400                  "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c') limit 2"
11401                }
11402              ] /* steps */
11403            } /* join_preparation */
11404          },
11405          {
11406            "view": {
11407              "table": "`v1`",
11408              "select#": 2,
11409              "materialized": true
11410            } /* view */
11411          },
11412          {
11413            "expanded_query": "/* select#1 */ select `v1`.`id` AS `id`,`v1`.`data` AS `data` from `v1` where (`v1`.`id` = 'b')"
11414          }
11415        ] /* steps */
11416      } /* join_preparation */
11417    },
11418    {
11419      "join_optimization": {
11420        "select#": 1,
11421        "steps": [
11422          {
11423            "join_optimization": {
11424              "select#": 2,
11425              "steps": [
11426                {
11427                  "condition_processing": {
11428                    "condition": "WHERE",
11429                    "original_condition": "(`t1`.`id` < 'c')",
11430                    "steps": [
11431                      {
11432                        "transformation": "equality_propagation",
11433                        "resulting_condition": "(`t1`.`id` < 'c')"
11434                      },
11435                      {
11436                        "transformation": "constant_propagation",
11437                        "resulting_condition": "(`t1`.`id` < 'c')"
11438                      },
11439                      {
11440                        "transformation": "trivial_condition_removal",
11441                        "resulting_condition": "(`t1`.`id` < 'c')"
11442                      }
11443                    ] /* steps */
11444                  } /* condition_processing */
11445                },
11446                {
11447                  "substitute_generated_columns": {
11448                  } /* substitute_generated_columns */
11449                },
11450                {
11451                  "table_dependencies": [
11452                    {
11453                      "table": "`t1`",
11454                      "row_may_be_null": false,
11455                      "map_bit": 0,
11456                      "depends_on_map_bits": [
11457                      ] /* depends_on_map_bits */
11458                    }
11459                  ] /* table_dependencies */
11460                },
11461                {
11462                  "ref_optimizer_key_uses": [
11463                  ] /* ref_optimizer_key_uses */
11464                },
11465                {
11466                  "rows_estimation": [
11467                    {
11468                      "table": "`t1`",
11469                      "table_scan": {
11470                        "rows": 3,
11471                        "cost": 2
11472                      } /* table_scan */
11473                    }
11474                  ] /* rows_estimation */
11475                },
11476                {
11477                  "considered_execution_plans": [
11478                    {
11479                      "plan_prefix": [
11480                      ] /* plan_prefix */,
11481                      "table": "`t1`",
11482                      "best_access_path": {
11483                        "considered_access_paths": [
11484                          {
11485                            "rows_to_scan": 3,
11486                            "access_type": "scan",
11487                            "resulting_rows": 1,
11488                            "cost": 2.6154,
11489                            "chosen": true
11490                          }
11491                        ] /* considered_access_paths */
11492                      } /* best_access_path */,
11493                      "condition_filtering_pct": 100,
11494                      "rows_for_plan": 1,
11495                      "cost_for_plan": 2.6154,
11496                      "chosen": true
11497                    }
11498                  ] /* considered_execution_plans */
11499                },
11500                {
11501                  "attaching_conditions_to_tables": {
11502                    "original_condition": "(`t1`.`id` < 'c')",
11503                    "attached_conditions_computation": [
11504                    ] /* attached_conditions_computation */,
11505                    "attached_conditions_summary": [
11506                      {
11507                        "table": "`t1`",
11508                        "attached": "(`t1`.`id` < 'c')"
11509                      }
11510                    ] /* attached_conditions_summary */
11511                  } /* attaching_conditions_to_tables */
11512                },
11513                {
11514                  "refine_plan": [
11515                    {
11516                      "table": "`t1`"
11517                    }
11518                  ] /* refine_plan */
11519                }
11520              ] /* steps */
11521            } /* join_optimization */
11522          },
11523          {
11524            "condition_processing": {
11525              "condition": "WHERE",
11526              "original_condition": "(`v1`.`id` = 'b')",
11527              "steps": [
11528                {
11529                  "transformation": "equality_propagation",
11530                  "resulting_condition": "multiple equal('b', `v1`.`id`)"
11531                },
11532                {
11533                  "transformation": "constant_propagation",
11534                  "resulting_condition": "multiple equal('b', `v1`.`id`)"
11535                },
11536                {
11537                  "transformation": "trivial_condition_removal",
11538                  "resulting_condition": "multiple equal('b', `v1`.`id`)"
11539                }
11540              ] /* steps */
11541            } /* condition_processing */
11542          },
11543          {
11544            "substitute_generated_columns": {
11545            } /* substitute_generated_columns */
11546          },
11547          {
11548            "table_dependencies": [
11549              {
11550                "table": "`v1`",
11551                "row_may_be_null": false,
11552                "map_bit": 0,
11553                "depends_on_map_bits": [
11554                ] /* depends_on_map_bits */
11555              }
11556            ] /* table_dependencies */
11557          },
11558          {
11559            "ref_optimizer_key_uses": [
11560              {
11561                "table": "`v1`",
11562                "field": "id",
11563                "equals": "'b'",
11564                "null_rejecting": false
11565              }
11566            ] /* ref_optimizer_key_uses */
11567          },
11568          {
11569            "rows_estimation": [
11570              {
11571                "table": "`v1`"
11572              }
11573            ] /* rows_estimation */
11574          },
11575          {
11576            "considered_execution_plans": [
11577              {
11578                "plan_prefix": [
11579                ] /* plan_prefix */,
11580                "table": "`v1`",
11581                "best_access_path": {
11582                  "considered_access_paths": [
11583                    {
11584                      "access_type": "ref",
11585                      "index": "<auto_key0>",
11586                      "rows": 1,
11587                      "cost": 1.2,
11588                      "chosen": true
11589                    },
11590                    {
11591                      "access_type": "scan",
11592                      "cost": 10.4,
11593                      "rows": 2,
11594                      "chosen": false,
11595                      "cause": "cost"
11596                    }
11597                  ] /* considered_access_paths */
11598                } /* best_access_path */,
11599                "condition_filtering_pct": 100,
11600                "rows_for_plan": 1,
11601                "cost_for_plan": 1.2,
11602                "chosen": true
11603              }
11604            ] /* considered_execution_plans */
11605          },
11606          {
11607            "attaching_conditions_to_tables": {
11608              "original_condition": "(`v1`.`id` = 'b')",
11609              "attached_conditions_computation": [
11610              ] /* attached_conditions_computation */,
11611              "attached_conditions_summary": [
11612                {
11613                  "table": "`v1`",
11614                  "attached": null
11615                }
11616              ] /* attached_conditions_summary */
11617            } /* attaching_conditions_to_tables */
11618          },
11619          {
11620            "refine_plan": [
11621              {
11622                "table": "`v1`"
11623              }
11624            ] /* refine_plan */
11625          }
11626        ] /* steps */
11627      } /* join_optimization */
11628    },
11629    {
11630      "join_explain": {
11631        "select#": 1,
11632        "steps": [
11633          {
11634            "creating_tmp_table": {
11635              "tmp_table_info": {
11636                "table": "`v1`",
11637                "row_length": 21,
11638                "key_length": 16,
11639                "unique_constraint": false,
11640                "location": "memory (heap)",
11641                "row_limit_estimate": 49932
11642              } /* tmp_table_info */
11643            } /* creating_tmp_table */
11644          },
11645          {
11646            "join_explain": {
11647              "select#": 2,
11648              "steps": [
11649              ] /* steps */
11650            } /* join_explain */
11651          }
11652        ] /* steps */
11653      } /* join_explain */
11654    }
11655  ] /* steps */
11656}	0	0
11657drop view v1;
11658select * from information_schema.session_variables where
11659VARIABLE_NAME="optimizer_trace";
11660VARIABLE_NAME	VARIABLE_VALUE
11661OPTIMIZER_TRACE	enabled=on,one_line=off
11662select * from information_schema.OPTIMIZER_TRACE;
11663QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11664select * from information_schema.session_variables where
11665VARIABLE_NAME="optimizer_trace"	{
11666  "steps": [
11667    {
11668      "creating_tmp_table": {
11669        "tmp_table_info": {
11670          "row_length": 3268,
11671          "key_length": 0,
11672          "unique_constraint": false,
11673          "location": "memory (heap)",
11674          "row_limit_estimate": 320
11675        } /* tmp_table_info */
11676      } /* creating_tmp_table */
11677    },
11678    {
11679      "join_preparation": {
11680        "select#": 1,
11681        "steps": [
11682          {
11683            "expanded_query": "/* select#1 */ select `information_schema`.`session_variables`.`VARIABLE_NAME` AS `VARIABLE_NAME`,`information_schema`.`session_variables`.`VARIABLE_VALUE` AS `VARIABLE_VALUE` from `information_schema`.`session_variables` where (`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')"
11684          }
11685        ] /* steps */
11686      } /* join_preparation */
11687    },
11688    {
11689      "join_optimization": {
11690        "select#": 1,
11691        "steps": [
11692          {
11693            "condition_processing": {
11694              "condition": "WHERE",
11695              "original_condition": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')",
11696              "steps": [
11697                {
11698                  "transformation": "equality_propagation",
11699                  "resulting_condition": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')"
11700                },
11701                {
11702                  "transformation": "constant_propagation",
11703                  "resulting_condition": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')"
11704                },
11705                {
11706                  "transformation": "trivial_condition_removal",
11707                  "resulting_condition": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')"
11708                }
11709              ] /* steps */
11710            } /* condition_processing */
11711          },
11712          {
11713            "substitute_generated_columns": {
11714            } /* substitute_generated_columns */
11715          },
11716          {
11717            "table_dependencies": [
11718              {
11719                "table": "`information_schema`.`session_variables`",
11720                "row_may_be_null": false,
11721                "map_bit": 0,
11722                "depends_on_map_bits": [
11723                ] /* depends_on_map_bits */
11724              }
11725            ] /* table_dependencies */
11726          },
11727          {
11728            "ref_optimizer_key_uses": [
11729            ] /* ref_optimizer_key_uses */
11730          },
11731          {
11732            "rows_estimation": [
11733              {
11734                "table": "`information_schema`.`session_variables`",
11735                "table_scan": {
11736                  "rows": 2,
11737                  "cost": 10
11738                } /* table_scan */
11739              }
11740            ] /* rows_estimation */
11741          },
11742          {
11743            "considered_execution_plans": [
11744              {
11745                "plan_prefix": [
11746                ] /* plan_prefix */,
11747                "table": "`information_schema`.`session_variables`",
11748                "best_access_path": {
11749                  "considered_access_paths": [
11750                    {
11751                      "rows_to_scan": 2,
11752                      "access_type": "scan",
11753                      "resulting_rows": 2,
11754                      "cost": 10.5,
11755                      "chosen": true
11756                    }
11757                  ] /* considered_access_paths */
11758                } /* best_access_path */,
11759                "condition_filtering_pct": 100,
11760                "rows_for_plan": 2,
11761                "cost_for_plan": 10.5,
11762                "chosen": true
11763              }
11764            ] /* considered_execution_plans */
11765          },
11766          {
11767            "attaching_conditions_to_tables": {
11768              "original_condition": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')",
11769              "attached_conditions_computation": [
11770              ] /* attached_conditions_computation */,
11771              "attached_conditions_summary": [
11772                {
11773                  "table": "`information_schema`.`session_variables`",
11774                  "attached": "(`information_schema`.`session_variables`.`VARIABLE_NAME` = 'optimizer_trace')"
11775                }
11776              ] /* attached_conditions_summary */
11777            } /* attaching_conditions_to_tables */
11778          },
11779          {
11780            "refine_plan": [
11781              {
11782                "table": "`information_schema`.`session_variables`"
11783              }
11784            ] /* refine_plan */
11785          }
11786        ] /* steps */
11787      } /* join_optimization */
11788    },
11789    {
11790      "join_execution": {
11791        "select#": 1,
11792        "steps": [
11793        ] /* steps */
11794      } /* join_execution */
11795    }
11796  ] /* steps */
11797}	0	0
11798set end_markers_in_json=off;
11799select 1 union select 2;
118001
118011
118022
11803select TRACE into dumpfile 'MYSQLTEST_VARDIR/tmp/optimizer_trace.txt' from information_schema.OPTIMIZER_TRACE;;
11804{
11805  "steps": [
11806    {
11807      "join_preparation": {
11808        "select#": 1,
11809        "steps": [
11810          {
11811            "expanded_query": "/* select#1 */ select 1 AS `1`"
11812          }
11813        ]
11814      }
11815    },
11816    {
11817      "join_preparation": {
11818        "select#": 2,
11819        "steps": [
11820          {
11821            "expanded_query": "/* select#2 */ select 2 AS `2`"
11822          }
11823        ]
11824      }
11825    },
11826    {
11827      "creating_tmp_table": {
11828        "tmp_table_info": {
11829          "table": "intermediate_tmp_table",
11830          "row_length": 9,
11831          "key_length": 8,
11832          "unique_constraint": false,
11833          "location": "memory (heap)",
11834          "row_limit_estimate": 116508
11835        }
11836      }
11837    },
11838    {
11839      "join_preparation": {
11840        "select#": "fake",
11841        "steps": [
11842          {
11843            "expanded_query": "/* select#fake */ select `1` AS `1` from dual"
11844          }
11845        ]
11846      }
11847    },
11848    {
11849      "join_optimization": {
11850        "select#": 1,
11851        "steps": [
11852        ]
11853      }
11854    },
11855    {
11856      "join_optimization": {
11857        "select#": 2,
11858        "steps": [
11859        ]
11860      }
11861    },
11862    {
11863      "join_optimization": {
11864        "select#": "fake",
11865        "steps": [
11866          {
11867            "table_dependencies": [
11868              {
11869                "table": "``.``",
11870                "row_may_be_null": false,
11871                "map_bit": 0,
11872                "depends_on_map_bits": [
11873                ]
11874              }
11875            ]
11876          },
11877          {
11878            "rows_estimation": [
11879              {
11880                "table": "``.``",
11881                "table_scan": {
11882                  "rows": 0,
11883                  "cost": 10
11884                }
11885              }
11886            ]
11887          },
11888          {
11889            "considered_execution_plans": [
11890              {
11891                "plan_prefix": [
11892                ],
11893                "table": "``.``",
11894                "best_access_path": {
11895                  "considered_access_paths": [
11896                    {
11897                      "rows_to_scan": 0,
11898                      "access_type": "scan",
11899                      "resulting_rows": 0,
11900                      "cost": 10,
11901                      "chosen": true
11902                    }
11903                  ]
11904                },
11905                "condition_filtering_pct": 100,
11906                "rows_for_plan": 0,
11907                "cost_for_plan": 10,
11908                "chosen": true
11909              }
11910            ]
11911          },
11912          {
11913            "attaching_conditions_to_tables": {
11914              "original_condition": null,
11915              "attached_conditions_computation": [
11916              ],
11917              "attached_conditions_summary": [
11918                {
11919                  "table": "``.``",
11920                  "attached": null
11921                }
11922              ]
11923            }
11924          },
11925          {
11926            "refine_plan": [
11927              {
11928                "table": "``.``"
11929              }
11930            ]
11931          }
11932        ]
11933      }
11934    },
11935    {
11936      "join_execution": {
11937        "select#": 1,
11938        "steps": [
11939        ]
11940      }
11941    },
11942    {
11943      "join_execution": {
11944        "select#": 2,
11945        "steps": [
11946        ]
11947      }
11948    },
11949    {
11950      "join_execution": {
11951        "select#": "fake",
11952        "steps": [
11953        ]
11954      }
11955    }
11956  ]
11957}set optimizer_switch='default,index_merge=on,index_merge=off,default';
11958ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off,default'
11959select @@optimizer_switch=@old_opt_switch;
11960@@optimizer_switch=@old_opt_switch
119611
11962select * from information_schema.OPTIMIZER_TRACE;
11963QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
11964select "abc1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111def" as col	{
11965  "steps": [
11966    {
11967      "join_preparation": {
11968        "select#": 1,
11969        "steps": [
11970          {
11971            "expanded_query": "/* select#1 */ select 'abc1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111def' AS `col`"
11972          }
11973        ]
11974      }
11975    },
11976    {
11977      "join_optimization": {
11978        "select#": 1,
11979        "steps": [
11980        ]
11981      }
11982    },
11983    {
11984      "join_execution": {
11985        "select#": 1,
11986        "steps": [
11987        ]
11988      }
11989    }
11990  ]
11991}	0	0
11992drop table t1,t2;
11993DROP TABLE t5,t6;
11994set optimizer_trace=default;
11995