1SET optimizer_trace_max_mem_size=1048576;
2SET @@session.optimizer_trace="enabled=on";
3#
4# BUG#18195373: OPTIMIZER TRACE SHOULD PRINT NAME OF
5#               INDEX FOR RANGE ACCESS
6CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
7INSERT INTO t1 VALUES('Testing how', 'full-text search'),
8('is printed to the', 'optimizer trace.'),
9('We need test coverage','of that too');
10SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("coverage");
11a	b
12We need test coverage	of that too
13SELECT * FROM information_schema.OPTIMIZER_TRACE;
14QUERY	TRACE	MISSING_BYTES_BEYOND_MAX_MEM_SIZE	INSUFFICIENT_PRIVILEGES
15SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("coverage")	{
16  "steps": [
17    {
18      "join_preparation": {
19        "select#": 1,
20        "steps": [
21          {
22            "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where (match `t1`.`a`,`t1`.`b` against ('coverage'))"
23          }
24        ]
25      }
26    },
27    {
28      "join_optimization": {
29        "select#": 1,
30        "steps": [
31          {
32            "condition_processing": {
33              "condition": "WHERE",
34              "original_condition": "(match `t1`.`a`,`t1`.`b` against ('coverage'))",
35              "steps": [
36                {
37                  "transformation": "equality_propagation",
38                  "resulting_condition": "(match `t1`.`a`,`t1`.`b` against ('coverage'))"
39                },
40                {
41                  "transformation": "constant_propagation",
42                  "resulting_condition": "(match `t1`.`a`,`t1`.`b` against ('coverage'))"
43                },
44                {
45                  "transformation": "trivial_condition_removal",
46                  "resulting_condition": "(match `t1`.`a`,`t1`.`b` against ('coverage'))"
47                }
48              ]
49            }
50          },
51          {
52            "substitute_generated_columns": {
53            }
54          },
55          {
56            "table_dependencies": [
57              {
58                "table": "`t1`",
59                "row_may_be_null": false,
60                "map_bit": 0,
61                "depends_on_map_bits": [
62                ]
63              }
64            ]
65          },
66          {
67            "ref_optimizer_key_uses": [
68              {
69                "table": "`t1`",
70                "field": "<fulltext>",
71                "equals": "(match `t1`.`a`,`t1`.`b` against ('coverage'))",
72                "null_rejecting": false
73              }
74            ]
75          },
76          {
77            "rows_estimation": [
78              {
79                "table": "`t1`",
80                "table_scan": {
81                  "rows": 3,
82                  "cost": 2
83                }
84              }
85            ]
86          },
87          {
88            "considered_execution_plans": [
89              {
90                "plan_prefix": [
91                ],
92                "table": "`t1`",
93                "best_access_path": {
94                  "considered_access_paths": [
95                    {
96                      "access_type": "fulltext",
97                      "index": "a",
98                      "rows": 1,
99                      "cost": 1.2,
100                      "chosen": true
101                    },
102                    {
103                      "access_type": "scan",
104                      "cost": 2.6,
105                      "rows": 3,
106                      "chosen": false,
107                      "cause": "cost"
108                    }
109                  ]
110                },
111                "condition_filtering_pct": 100,
112                "rows_for_plan": 1,
113                "cost_for_plan": 1.2,
114                "chosen": true
115              }
116            ]
117          },
118          {
119            "attaching_conditions_to_tables": {
120              "original_condition": "(match `t1`.`a`,`t1`.`b` against ('coverage'))",
121              "attached_conditions_computation": [
122              ],
123              "attached_conditions_summary": [
124                {
125                  "table": "`t1`",
126                  "attached": "(match `t1`.`a`,`t1`.`b` against ('coverage'))"
127                }
128              ]
129            }
130          },
131          {
132            "refine_plan": [
133              {
134                "table": "`t1`"
135              }
136            ]
137          }
138        ]
139      }
140    },
141    {
142      "join_execution": {
143        "select#": 1,
144        "steps": [
145        ]
146      }
147    }
148  ]
149}	0	0
150DROP TABLE t1;
151