| 25717 | |
| 25718 | |
| 25719 | int join_init_read_record(JOIN_TAB *tab) |
| 25720 | { |
| 25721 | bool need_unpacking= FALSE; |
| 25722 | JOIN *join= tab->join; |
| 25723 | /* |
| 25724 | Note: the query plan tree for the below operations is constructed in |
| 25725 | save_agg_explain_data. |
| 25726 | */ |
| 25727 | if (tab->distinct && tab->remove_duplicates()) // Remove duplicates. |
| 25728 | return 1; |
| 25729 | |
| 25730 | if (join->top_join_tab_count != join->const_tables) |
| 25731 | { |
| 25732 | TABLE_LIST *tbl= tab->table->pos_in_table_list; |
| 25733 | need_unpacking= tbl ? tbl->is_sjm_scan_table() : FALSE; |
| 25734 | } |
| 25735 | |
| 25736 | if (tab->need_to_build_rowid_filter) |
| 25737 | { |
| 25738 | if (tab->build_range_rowid_filter()) |
| 25739 | return 1; /* Fatal error */ |
| 25740 | } |
| 25741 | |
| 25742 | if (tab->filesort && tab->sort_table()) // Sort table. |
| 25743 | return 1; |
| 25744 | |
| 25745 | DBUG_EXECUTE_IF("kill_join_init_read_record", |
| 25746 | tab->join->thd->set_killed(KILL_QUERY);); |
| 25747 | |
| 25748 | |
| 25749 | if (!tab->preread_init_done && tab->preread_init()) |
| 25750 | return 1; |
| 25751 | |
| 25752 | if (tab->select && tab->select->quick && tab->select->quick->reset()) |
| 25753 | { |
| 25754 | /* Ensures error status is propagated back to client */ |
| 25755 | report_error(tab->table, |
| 25756 | tab->join->thd->killed ? HA_ERR_QUERY_INTERRUPTED : HA_ERR_OUT_OF_MEM); |
| 25757 | return 1; |
| 25758 | } |
| 25759 | /* make sure we won't get ER_QUERY_INTERRUPTED from any code below */ |
| 25760 | DBUG_EXECUTE_IF("kill_join_init_read_record", |
| 25761 | tab->join->thd->reset_killed();); |
| 25762 | |
| 25763 | Copy_field *save_copy, *save_copy_end; |
| 25764 | |
| 25765 | /* |
| 25766 | init_read_record resets all elements of tab->read_record(). |
| 25767 | Remember things that we don't want to have reset. |
| 25768 | */ |
| 25769 | save_copy= tab->read_record.copy_field; |
| 25770 | save_copy_end= tab->read_record.copy_field_end; |
| 25771 | |
| 25772 | /* |
| 25773 | JT_NEXT means that we should use an index scan on index 'tab->index' |
| 25774 | However if filesort is set, the table was already sorted above |
| 25775 | and now have to retrieve the rows from the tmp file or by rnd_pos() |
| 25776 | If !(tab->select && tab->select->quick)) it means that we are |
no test coverage detected