| 24097 | */ |
| 24098 | |
| 24099 | static int |
| 24100 | do_select(JOIN *join, Procedure *procedure) |
| 24101 | { |
| 24102 | int rc= 0; |
| 24103 | enum_nested_loop_state error= NESTED_LOOP_OK; |
| 24104 | uint top_level_tables= join->exec_join_tab_cnt(); |
| 24105 | DBUG_ENTER("do_select"); |
| 24106 | |
| 24107 | if (join->pushdown_query) |
| 24108 | { |
| 24109 | /* Select fields are in the temporary table */ |
| 24110 | join->fields= &join->tmp_fields_list1; |
| 24111 | /* Setup HAVING to work with fields in temporary table */ |
| 24112 | join->set_items_ref_array(join->items1); |
| 24113 | /* The storage engine will take care of the group by query result */ |
| 24114 | int res= join->pushdown_query->execute(join); |
| 24115 | |
| 24116 | if (res) |
| 24117 | DBUG_RETURN(res); |
| 24118 | |
| 24119 | if (join->pushdown_query->store_data_in_temp_table) |
| 24120 | { |
| 24121 | JOIN_TAB *last_tab= join->join_tab + top_level_tables; |
| 24122 | last_tab->next_select= end_send; |
| 24123 | last_tab->cached_pfs_batch_update= last_tab->pfs_batch_update(); |
| 24124 | |
| 24125 | enum_nested_loop_state state= last_tab->aggr->end_send(); |
| 24126 | if (state >= NESTED_LOOP_OK) |
| 24127 | state= sub_select(join, last_tab, true); |
| 24128 | |
| 24129 | if (state < NESTED_LOOP_OK) |
| 24130 | res= 1; |
| 24131 | |
| 24132 | if (join->result->send_eof()) |
| 24133 | res= 1; |
| 24134 | } |
| 24135 | DBUG_RETURN(res); |
| 24136 | } |
| 24137 | |
| 24138 | join->procedure= procedure; |
| 24139 | join->duplicate_rows= join->send_records=0; |
| 24140 | |
| 24141 | if (join->only_const_tables() && !join->need_tmp) |
| 24142 | { |
| 24143 | Next_select_func end_select= setup_end_select_func(join); |
| 24144 | |
| 24145 | /* |
| 24146 | HAVING will be checked after processing aggregate functions, |
| 24147 | But WHERE should checked here (we alredy have read tables). |
| 24148 | Notice that make_join_select() splits all conditions in this case |
| 24149 | into two groups exec_const_cond and outer_ref_cond. |
| 24150 | If join->table_count == join->const_tables then it is |
| 24151 | sufficient to check only the condition pseudo_bits_cond. |
| 24152 | */ |
| 24153 | DBUG_ASSERT(join->outer_ref_cond == NULL); |
| 24154 | if (!join->pseudo_bits_cond || join->pseudo_bits_cond->val_bool()) |
| 24155 | { |
| 24156 | // HAVING will be checked by end_select |
no test coverage detected