Commit 3e4126e9 authored by Alexey Botchkov's avatar Alexey Botchkov

Merge branch '10.1' of github.com:MariaDB/server into 10.1

parents fb3e3120 9b57b214
...@@ -107,7 +107,7 @@ and (end_event_id <= @marker_end) ...@@ -107,7 +107,7 @@ and (end_event_id <= @marker_end)
) all_events ) all_events
order by relative_event_id asc; order by relative_event_id asc;
relative_event_id relative_end_event_id event_name comment nesting_event_type relative_nesting_event_id relative_event_id relative_end_event_id event_name comment nesting_event_type relative_nesting_event_id
0 19 statement/sql/select select "MARKER_BEGIN" as marker NULL NULL 0 18 statement/sql/select select "MARKER_BEGIN" as marker NULL NULL
1 4 stage/sql/init (stage) STATEMENT 0 1 4 stage/sql/init (stage) STATEMENT 0
2 2 wait/io/socket/sql/client_connection recv STAGE 1 2 2 wait/io/socket/sql/client_connection recv STAGE 1
3 3 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 1 3 3 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 1
...@@ -124,125 +124,118 @@ relative_event_id relative_end_event_id event_name comment nesting_event_type re ...@@ -124,125 +124,118 @@ relative_event_id relative_end_event_id event_name comment nesting_event_type re
14 14 stage/sql/freeing items (stage) STATEMENT 0 14 14 stage/sql/freeing items (stage) STATEMENT 0
15 15 wait/io/socket/sql/client_connection send STATEMENT 0 15 15 wait/io/socket/sql/client_connection send STATEMENT 0
16 16 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 0 16 16 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 0
17 17 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 0 17 18 stage/sql/cleaning up (stage) STATEMENT 0
18 19 stage/sql/cleaning up (stage) STATEMENT 0 18 18 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 17
19 19 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 18 19 19 idle idle NULL NULL
20 20 idle idle NULL NULL 20 38 statement/sql/select select "This is simple statement one" as payload NULL NULL
21 40 statement/sql/select select "This is simple statement one" as payload NULL NULL 21 24 stage/sql/init (stage) STATEMENT 20
22 25 stage/sql/init (stage) STATEMENT 21 22 22 wait/io/socket/sql/client_connection recv STAGE 21
23 23 wait/io/socket/sql/client_connection recv STAGE 22 23 23 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 21
24 24 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 22 24 24 wait/io/file/sql/query_log write STAGE 21
25 25 wait/io/file/sql/query_log write STAGE 22 25 25 stage/sql/checking permissions (stage) STATEMENT 20
26 26 stage/sql/checking permissions (stage) STATEMENT 21 26 26 stage/sql/Opening tables (stage) STATEMENT 20
27 27 stage/sql/Opening tables (stage) STATEMENT 21 27 27 stage/sql/After opening tables (stage) STATEMENT 20
28 28 stage/sql/After opening tables (stage) STATEMENT 21 28 28 stage/sql/init (stage) STATEMENT 20
29 29 stage/sql/init (stage) STATEMENT 21 29 29 stage/sql/optimizing (stage) STATEMENT 20
30 30 stage/sql/optimizing (stage) STATEMENT 21 30 30 stage/sql/executing (stage) STATEMENT 20
31 31 stage/sql/executing (stage) STATEMENT 21 31 31 stage/sql/end (stage) STATEMENT 20
32 32 stage/sql/end (stage) STATEMENT 21 32 32 stage/sql/query end (stage) STATEMENT 20
33 33 stage/sql/query end (stage) STATEMENT 21 33 33 stage/sql/closing tables (stage) STATEMENT 20
34 34 stage/sql/closing tables (stage) STATEMENT 21 34 34 stage/sql/freeing items (stage) STATEMENT 20
35 35 stage/sql/freeing items (stage) STATEMENT 21 35 35 wait/io/socket/sql/client_connection send STATEMENT 20
36 36 wait/io/socket/sql/client_connection send STATEMENT 21 36 36 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 20
37 37 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 21 37 38 stage/sql/cleaning up (stage) STATEMENT 20
38 38 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 21 38 38 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 37
39 40 stage/sql/cleaning up (stage) STATEMENT 21 39 39 idle idle NULL NULL
40 40 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 39 40 58 statement/sql/select select "This is simple statement two" as payload NULL NULL
41 41 idle idle NULL NULL 41 44 stage/sql/init (stage) STATEMENT 40
42 61 statement/sql/select select "This is simple statement two" as payload NULL NULL 42 42 wait/io/socket/sql/client_connection recv STAGE 41
43 46 stage/sql/init (stage) STATEMENT 42 43 43 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 41
44 44 wait/io/socket/sql/client_connection recv STAGE 43 44 44 wait/io/file/sql/query_log write STAGE 41
45 45 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 43 45 45 stage/sql/checking permissions (stage) STATEMENT 40
46 46 wait/io/file/sql/query_log write STAGE 43 46 46 stage/sql/Opening tables (stage) STATEMENT 40
47 47 stage/sql/checking permissions (stage) STATEMENT 42 47 47 stage/sql/After opening tables (stage) STATEMENT 40
48 48 stage/sql/Opening tables (stage) STATEMENT 42 48 48 stage/sql/init (stage) STATEMENT 40
49 49 stage/sql/After opening tables (stage) STATEMENT 42 49 49 stage/sql/optimizing (stage) STATEMENT 40
50 50 stage/sql/init (stage) STATEMENT 42 50 50 stage/sql/executing (stage) STATEMENT 40
51 51 stage/sql/optimizing (stage) STATEMENT 42 51 51 stage/sql/end (stage) STATEMENT 40
52 52 stage/sql/executing (stage) STATEMENT 42 52 52 stage/sql/query end (stage) STATEMENT 40
53 53 stage/sql/end (stage) STATEMENT 42 53 53 stage/sql/closing tables (stage) STATEMENT 40
54 54 stage/sql/query end (stage) STATEMENT 42 54 54 stage/sql/freeing items (stage) STATEMENT 40
55 55 stage/sql/closing tables (stage) STATEMENT 42 55 55 wait/io/socket/sql/client_connection send STATEMENT 40
56 56 stage/sql/freeing items (stage) STATEMENT 42 56 56 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 40
57 57 wait/io/socket/sql/client_connection send STATEMENT 42 57 58 stage/sql/cleaning up (stage) STATEMENT 40
58 58 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 42 58 58 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 57
59 59 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 42 59 59 idle idle NULL NULL
60 61 stage/sql/cleaning up (stage) STATEMENT 42 60 76 statement/sql/select select "This is the first part of a multi query" as payload;
61 61 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 60
62 62 idle idle NULL NULL
63 80 statement/sql/select select "This is the first part of a multi query" as payload;
select "And this is the second part of a multi query" as payload; select "And this is the second part of a multi query" as payload;
select "With a third part to make things complete" as payload NULL NULL select "With a third part to make things complete" as payload NULL NULL
64 67 stage/sql/init (stage) STATEMENT 63 61 64 stage/sql/init (stage) STATEMENT 60
65 65 wait/io/socket/sql/client_connection recv STAGE 64 62 62 wait/io/socket/sql/client_connection recv STAGE 61
66 66 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 64 63 63 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 61
67 67 wait/io/file/sql/query_log write STAGE 64 64 64 wait/io/file/sql/query_log write STAGE 61
68 68 stage/sql/checking permissions (stage) STATEMENT 63 65 65 stage/sql/checking permissions (stage) STATEMENT 60
69 69 stage/sql/Opening tables (stage) STATEMENT 63 66 66 stage/sql/Opening tables (stage) STATEMENT 60
70 70 stage/sql/After opening tables (stage) STATEMENT 63 67 67 stage/sql/After opening tables (stage) STATEMENT 60
71 71 stage/sql/init (stage) STATEMENT 63 68 68 stage/sql/init (stage) STATEMENT 60
72 72 stage/sql/optimizing (stage) STATEMENT 63 69 69 stage/sql/optimizing (stage) STATEMENT 60
73 73 stage/sql/executing (stage) STATEMENT 63 70 70 stage/sql/executing (stage) STATEMENT 60
74 74 stage/sql/end (stage) STATEMENT 63 71 71 stage/sql/end (stage) STATEMENT 60
75 75 stage/sql/query end (stage) STATEMENT 63 72 72 stage/sql/query end (stage) STATEMENT 60
76 76 stage/sql/closing tables (stage) STATEMENT 63 73 73 stage/sql/closing tables (stage) STATEMENT 60
77 80 stage/sql/freeing items (stage) STATEMENT 63 74 76 stage/sql/freeing items (stage) STATEMENT 60
78 78 wait/io/socket/sql/client_connection send STAGE 77 75 75 wait/io/socket/sql/client_connection send STAGE 74
79 79 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 77 76 76 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 74
80 80 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 77 77 91 statement/sql/select select "And this is the second part of a multi query" as payload;
81 96 statement/sql/select select "And this is the second part of a multi query" as payload;
select "With a third part to make things complete" as payload NULL NULL select "With a third part to make things complete" as payload NULL NULL
82 83 stage/sql/init (stage) STATEMENT 81 78 79 stage/sql/init (stage) STATEMENT 77
83 83 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 82 79 79 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 78
84 84 stage/sql/checking permissions (stage) STATEMENT 81 80 80 stage/sql/checking permissions (stage) STATEMENT 77
85 85 stage/sql/Opening tables (stage) STATEMENT 81 81 81 stage/sql/Opening tables (stage) STATEMENT 77
86 86 stage/sql/After opening tables (stage) STATEMENT 81 82 82 stage/sql/After opening tables (stage) STATEMENT 77
87 87 stage/sql/init (stage) STATEMENT 81 83 83 stage/sql/init (stage) STATEMENT 77
88 88 stage/sql/optimizing (stage) STATEMENT 81 84 84 stage/sql/optimizing (stage) STATEMENT 77
89 89 stage/sql/executing (stage) STATEMENT 81 85 85 stage/sql/executing (stage) STATEMENT 77
90 90 stage/sql/end (stage) STATEMENT 81 86 86 stage/sql/end (stage) STATEMENT 77
91 91 stage/sql/query end (stage) STATEMENT 81 87 87 stage/sql/query end (stage) STATEMENT 77
92 92 stage/sql/closing tables (stage) STATEMENT 81 88 88 stage/sql/closing tables (stage) STATEMENT 77
93 96 stage/sql/freeing items (stage) STATEMENT 81 89 91 stage/sql/freeing items (stage) STATEMENT 77
94 94 wait/io/socket/sql/client_connection send STAGE 93 90 90 wait/io/socket/sql/client_connection send STAGE 89
95 95 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 93 91 91 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 89
96 96 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 93 92 108 statement/sql/select select "With a third part to make things complete" as payload NULL NULL
97 114 statement/sql/select select "With a third part to make things complete" as payload NULL NULL 93 94 stage/sql/init (stage) STATEMENT 92
98 99 stage/sql/init (stage) STATEMENT 97 94 94 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 93
99 99 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 98 95 95 stage/sql/checking permissions (stage) STATEMENT 92
100 100 stage/sql/checking permissions (stage) STATEMENT 97 96 96 stage/sql/Opening tables (stage) STATEMENT 92
101 101 stage/sql/Opening tables (stage) STATEMENT 97 97 97 stage/sql/After opening tables (stage) STATEMENT 92
102 102 stage/sql/After opening tables (stage) STATEMENT 97 98 98 stage/sql/init (stage) STATEMENT 92
103 103 stage/sql/init (stage) STATEMENT 97 99 99 stage/sql/optimizing (stage) STATEMENT 92
104 104 stage/sql/optimizing (stage) STATEMENT 97 100 100 stage/sql/executing (stage) STATEMENT 92
105 105 stage/sql/executing (stage) STATEMENT 97 101 101 stage/sql/end (stage) STATEMENT 92
106 106 stage/sql/end (stage) STATEMENT 97 102 102 stage/sql/query end (stage) STATEMENT 92
107 107 stage/sql/query end (stage) STATEMENT 97 103 103 stage/sql/closing tables (stage) STATEMENT 92
108 108 stage/sql/closing tables (stage) STATEMENT 97 104 104 stage/sql/freeing items (stage) STATEMENT 92
109 109 stage/sql/freeing items (stage) STATEMENT 97 105 105 wait/io/socket/sql/client_connection send STATEMENT 92
110 110 wait/io/socket/sql/client_connection send STATEMENT 97 106 106 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 92
111 111 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 97 107 108 stage/sql/cleaning up (stage) STATEMENT 92
112 112 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 97 108 108 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 107
113 114 stage/sql/cleaning up (stage) STATEMENT 97 109 109 idle idle NULL NULL
114 114 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 113 110 128 statement/sql/select select "MARKER_END" as marker NULL NULL
115 115 idle idle NULL NULL 111 114 stage/sql/init (stage) STATEMENT 110
116 135 statement/sql/select select "MARKER_END" as marker NULL NULL 112 112 wait/io/socket/sql/client_connection recv STAGE 111
117 120 stage/sql/init (stage) STATEMENT 116 113 113 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 111
118 118 wait/io/socket/sql/client_connection recv STAGE 117 114 114 wait/io/file/sql/query_log write STAGE 111
119 119 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 117 115 115 stage/sql/checking permissions (stage) STATEMENT 110
120 120 wait/io/file/sql/query_log write STAGE 117 116 116 stage/sql/Opening tables (stage) STATEMENT 110
121 121 stage/sql/checking permissions (stage) STATEMENT 116 117 117 stage/sql/After opening tables (stage) STATEMENT 110
122 122 stage/sql/Opening tables (stage) STATEMENT 116 118 118 stage/sql/init (stage) STATEMENT 110
123 123 stage/sql/After opening tables (stage) STATEMENT 116 119 119 stage/sql/optimizing (stage) STATEMENT 110
124 124 stage/sql/init (stage) STATEMENT 116 120 120 stage/sql/executing (stage) STATEMENT 110
125 125 stage/sql/optimizing (stage) STATEMENT 116 121 121 stage/sql/end (stage) STATEMENT 110
126 126 stage/sql/executing (stage) STATEMENT 116 122 122 stage/sql/query end (stage) STATEMENT 110
127 127 stage/sql/end (stage) STATEMENT 116 123 123 stage/sql/closing tables (stage) STATEMENT 110
128 128 stage/sql/query end (stage) STATEMENT 116 124 124 stage/sql/freeing items (stage) STATEMENT 110
129 129 stage/sql/closing tables (stage) STATEMENT 116 125 125 wait/io/socket/sql/client_connection send STATEMENT 110
130 130 stage/sql/freeing items (stage) STATEMENT 116 126 126 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 110
131 131 wait/io/socket/sql/client_connection send STATEMENT 116 127 128 stage/sql/cleaning up (stage) STATEMENT 110
132 132 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 116 128 128 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 127
133 133 wait/synch/mutex/sql/THD::LOCK_thd_data lock STATEMENT 116
134 135 stage/sql/cleaning up (stage) STATEMENT 116
135 135 wait/synch/mutex/sql/THD::LOCK_thd_data lock STAGE 134
...@@ -41,45 +41,6 @@ void Apc_target::init(mysql_mutex_t *target_mutex) ...@@ -41,45 +41,6 @@ void Apc_target::init(mysql_mutex_t *target_mutex)
} }
/*
Destroy the target. The target must be disabled when this call is made.
*/
void Apc_target::destroy()
{
DBUG_ASSERT(!enabled);
}
/*
Enter ther state where the target is available for serving APC requests
*/
void Apc_target::enable()
{
/* Ok to do without getting/releasing the mutex: */
enabled++;
}
/*
Make the target unavailable for serving APC requests.
@note
This call will serve all requests that were already enqueued
*/
void Apc_target::disable()
{
bool process= FALSE;
DBUG_ASSERT(enabled);
mysql_mutex_lock(LOCK_thd_data_ptr);
if (!(--enabled))
process= TRUE;
mysql_mutex_unlock(LOCK_thd_data_ptr);
if (process)
process_apc_requests();
}
/* [internal] Put request qe into the request list */ /* [internal] Put request qe into the request list */
void Apc_target::enqueue_request(Call_request *qe) void Apc_target::enqueue_request(Call_request *qe)
......
...@@ -50,10 +50,29 @@ public: ...@@ -50,10 +50,29 @@ public:
~Apc_target() { DBUG_ASSERT(!enabled && !apc_calls);} ~Apc_target() { DBUG_ASSERT(!enabled && !apc_calls);}
void init(mysql_mutex_t *target_mutex); void init(mysql_mutex_t *target_mutex);
void destroy();
void enable(); /* Destroy the target. The target must be disabled when this call is made. */
void disable(); void destroy() { DBUG_ASSERT(!enabled); }
/* Enter ther state where the target is available for serving APC requests */
void enable() { enabled++; }
/*
Make the target unavailable for serving APC requests.
@note
This call will serve all requests that were already enqueued
*/
void disable()
{
DBUG_ASSERT(enabled);
mysql_mutex_lock(LOCK_thd_data_ptr);
bool process= !--enabled && have_apc_requests();
mysql_mutex_unlock(LOCK_thd_data_ptr);
if (unlikely(process))
process_apc_requests();
}
void process_apc_requests(); void process_apc_requests();
/* /*
A lightweight function, intended to be used in frequent checks like this: A lightweight function, intended to be used in frequent checks like this:
......
...@@ -276,10 +276,8 @@ Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field, ...@@ -276,10 +276,8 @@ Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field,
JOIN_TAB *first_depth_first_tab(JOIN* join); JOIN_TAB *first_depth_first_tab(JOIN* join);
JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab); JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab);
enum enum_exec_or_opt {WALK_OPTIMIZATION_TABS , WALK_EXECUTION_TABS}; static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab,
JOIN_TAB *first_breadth_first_tab(JOIN *join, enum enum_exec_or_opt tabs_kind); uint n_top_tabs_count, JOIN_TAB *tab);
JOIN_TAB *next_breadth_first_tab(JOIN *join, enum enum_exec_or_opt tabs_kind,
JOIN_TAB *tab);
static double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, static double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
table_map rem_tables); table_map rem_tables);
...@@ -7202,12 +7200,13 @@ double JOIN::get_examined_rows() ...@@ -7202,12 +7200,13 @@ double JOIN::get_examined_rows()
{ {
double examined_rows; double examined_rows;
double prev_fanout= 1; double prev_fanout= 1;
JOIN_TAB *tab= first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS); JOIN_TAB *tab= first_breadth_first_optimization_tab();
JOIN_TAB *prev_tab= tab; JOIN_TAB *prev_tab= tab;
examined_rows= tab->get_examined_rows(); examined_rows= tab->get_examined_rows();
while ((tab= next_breadth_first_tab(this, WALK_OPTIMIZATION_TABS, tab))) while ((tab= next_breadth_first_tab(first_breadth_first_optimization_tab(),
top_table_access_tabs_count, tab)))
{ {
prev_fanout *= prev_tab->records_read; prev_fanout *= prev_tab->records_read;
examined_rows+= tab->get_examined_rows() * prev_fanout; examined_rows+= tab->get_examined_rows() * prev_fanout;
...@@ -8201,21 +8200,9 @@ prev_record_reads(POSITION *positions, uint idx, table_map found_ref) ...@@ -8201,21 +8200,9 @@ prev_record_reads(POSITION *positions, uint idx, table_map found_ref)
Enumerate join tabs in breadth-first fashion, including const tables. Enumerate join tabs in breadth-first fashion, including const tables.
*/ */
JOIN_TAB *first_breadth_first_tab(JOIN *join, enum enum_exec_or_opt tabs_kind) static JOIN_TAB *next_breadth_first_tab(JOIN_TAB *first_top_tab,
uint n_top_tabs_count, JOIN_TAB *tab)
{ {
/* There's always one (i.e. first) table */
return (tabs_kind == WALK_EXECUTION_TABS)? join->join_tab:
join->table_access_tabs;
}
JOIN_TAB *next_breadth_first_tab(JOIN *join, enum enum_exec_or_opt tabs_kind,
JOIN_TAB *tab)
{
JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, tabs_kind);
const uint n_top_tabs_count= (tabs_kind == WALK_EXECUTION_TABS)?
join->top_join_tab_count:
join->top_table_access_tabs_count;
if (!tab->bush_root_tab) if (!tab->bush_root_tab)
{ {
/* We're at top level. Get the next top-level tab */ /* We're at top level. Get the next top-level tab */
...@@ -8307,7 +8294,8 @@ JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables const_tbls ...@@ -8307,7 +8294,8 @@ JOIN_TAB *first_top_level_tab(JOIN *join, enum enum_with_const_tables const_tbls
JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab) JOIN_TAB *next_top_level_tab(JOIN *join, JOIN_TAB *tab)
{ {
tab= next_breadth_first_tab(join, WALK_EXECUTION_TABS, tab); tab= next_breadth_first_tab(join->first_breadth_first_execution_tab(),
join->top_join_tab_count, tab);
if (tab && tab->bush_root_tab) if (tab && tab->bush_root_tab)
tab= NULL; tab= NULL;
return tab; return tab;
...@@ -11800,27 +11788,21 @@ void JOIN::cleanup(bool full) ...@@ -11800,27 +11788,21 @@ void JOIN::cleanup(bool full)
w/o tables: they don't have some members initialized and w/o tables: they don't have some members initialized and
WALK_OPTIMIZATION_TABS may not work correctly for them. WALK_OPTIMIZATION_TABS may not work correctly for them.
*/ */
enum enum_exec_or_opt tabs_kind;
if (first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS))
tabs_kind= WALK_OPTIMIZATION_TABS;
else
tabs_kind= WALK_EXECUTION_TABS;
if (table_count) if (table_count)
{ {
for (tab= first_breadth_first_tab(this, tabs_kind); tab; for (tab= first_breadth_first_optimization_tab(); tab;
tab= next_breadth_first_tab(this, tabs_kind, tab)) tab= next_breadth_first_tab(first_breadth_first_optimization_tab(),
{ top_table_access_tabs_count, tab))
tab->cleanup(); tab->cleanup();
}
if (tabs_kind == WALK_OPTIMIZATION_TABS && /* We've walked optimization tabs, do execution ones too. */
first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS) != if (first_breadth_first_execution_tab() !=
first_breadth_first_tab(this, WALK_EXECUTION_TABS)) first_breadth_first_optimization_tab())
{ {
JOIN_TAB *jt= first_breadth_first_tab(this, WALK_EXECUTION_TABS); for (tab= first_breadth_first_execution_tab(); tab;
/* We've walked optimization tabs. do execution ones too */ tab= next_breadth_first_tab(first_breadth_first_execution_tab(),
if (jt) top_join_tab_count, tab))
jt->cleanup(); tab->cleanup();
} }
} }
cleaned= true; cleaned= true;
...@@ -23556,13 +23538,13 @@ int append_possible_keys(MEM_ROOT *alloc, String_list &list, TABLE *table, ...@@ -23556,13 +23538,13 @@ int append_possible_keys(MEM_ROOT *alloc, String_list &list, TABLE *table,
void JOIN_TAB::update_explain_data(uint idx) void JOIN_TAB::update_explain_data(uint idx)
{ {
if (this == first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS) + join->const_tables && if (this == join->first_breadth_first_optimization_tab() + join->const_tables &&
join->select_lex->select_number != INT_MAX && join->select_lex->select_number != INT_MAX &&
join->select_lex->select_number != UINT_MAX) join->select_lex->select_number != UINT_MAX)
{ {
Explain_table_access *eta= new (join->thd->mem_root) Explain_table_access(join->thd->mem_root); Explain_table_access *eta= new (join->thd->mem_root) Explain_table_access(join->thd->mem_root);
JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS); save_explain_data(eta, join->const_table_map, join->select_distinct,
save_explain_data(eta, join->const_table_map, join->select_distinct, first_top_tab); join->first_breadth_first_optimization_tab());
Explain_select *sel= join->thd->lex->explain->get_select(join->select_lex->select_number); Explain_select *sel= join->thd->lex->explain->get_select(join->select_lex->select_number);
idx -= my_count_bits(join->eliminated_tables); idx -= my_count_bits(join->eliminated_tables);
...@@ -24059,7 +24041,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table, ...@@ -24059,7 +24041,7 @@ int JOIN::save_explain_data_intern(Explain_query *output, bool need_tmp_table,
xpl_sel->exec_const_cond= exec_const_cond; xpl_sel->exec_const_cond= exec_const_cond;
JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS); JOIN_TAB* const first_top_tab= join->first_breadth_first_optimization_tab();
JOIN_TAB* prev_bush_root_tab= NULL; JOIN_TAB* prev_bush_root_tab= NULL;
Explain_basic_join *cur_parent= xpl_sel; Explain_basic_join *cur_parent= xpl_sel;
......
...@@ -1531,6 +1531,8 @@ public: ...@@ -1531,6 +1531,8 @@ public:
int save_explain_data_intern(Explain_query *output, bool need_tmp_table, int save_explain_data_intern(Explain_query *output, bool need_tmp_table,
bool need_order, bool distinct, bool need_order, bool distinct,
const char *message); const char *message);
JOIN_TAB *first_breadth_first_optimization_tab() { return table_access_tabs; }
JOIN_TAB *first_breadth_first_execution_tab() { return join_tab; }
private: private:
/** /**
TRUE if the query contains an aggregate function but has no GROUP TRUE if the query contains an aggregate function but has no GROUP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment