| 37 | */ |
| 38 | |
| 39 | int Pushdown_query::execute(JOIN *join) |
| 40 | { |
| 41 | int err; |
| 42 | ha_rows max_limit; |
| 43 | bool reset_limit= FALSE; |
| 44 | Item **reset_item= 0; |
| 45 | THD *thd= handler->thd; |
| 46 | TABLE *table= handler->table; |
| 47 | DBUG_ENTER("Pushdown_query::execute"); |
| 48 | |
| 49 | if ((err= handler->init_scan())) |
| 50 | goto error; |
| 51 | |
| 52 | if (store_data_in_temp_table) |
| 53 | { |
| 54 | max_limit= join->tmp_table_param.end_write_records; |
| 55 | reset_limit= TRUE; |
| 56 | } |
| 57 | else |
| 58 | { |
| 59 | max_limit= join->unit->lim.get_select_limit(); |
| 60 | if (join->unit->fake_select_lex) |
| 61 | reset_item= &join->unit->fake_select_lex->limit_params.select_limit; |
| 62 | } |
| 63 | |
| 64 | while (!(err= handler->next_row())) |
| 65 | { |
| 66 | if (unlikely(thd->check_killed())) |
| 67 | { |
| 68 | handler->end_scan(); |
| 69 | DBUG_RETURN(-1); |
| 70 | } |
| 71 | |
| 72 | /* Check if we can accept the row */ |
| 73 | if (!having || having->val_bool()) |
| 74 | { |
| 75 | if (store_data_in_temp_table) |
| 76 | { |
| 77 | if ((err= table->file->ha_write_tmp_row(table->record[0]))) |
| 78 | { |
| 79 | bool is_duplicate; |
| 80 | if (likely(!table->file->is_fatal_error(err, HA_CHECK_DUP))) |
| 81 | continue; // Distinct elimination |
| 82 | |
| 83 | if (create_internal_tmp_table_from_heap(thd, table, |
| 84 | join->tmp_table_param. |
| 85 | start_recinfo, |
| 86 | &join->tmp_table_param. |
| 87 | recinfo, |
| 88 | err, 1, &is_duplicate)) |
| 89 | DBUG_RETURN(1); |
| 90 | if (is_duplicate) |
| 91 | continue; |
| 92 | } |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | if (join->do_send_rows) |
nothing calls this directly
no test coverage detected